InitializationError java.lang.IllegalStateException: Failed to transform class with name Processor.java. Reason: java.io.IOException: invalid constant type: 18

When we upgraded our application to jdk-8 , I was getting the below error during my gradle test task.

initializationError java.lang.IllegalStateException: Failed to transform class with name Processor.java. Reason: java.io.IOException: invalid constant type: 18

The issue was one of my class was using javasssit library which is not compatible with java-8. So we have upgraded javassist to the latest version.

 

compile(group: ‘org.javassist’, name: ‘javassist’, version: ‘3.20.0-GA’)

Reference:

https://github.com/brettwooldridge/HikariCP/issues/83

https://github.com/bitronix/btm/issues/38

 

 

 

steps to upgrade jdk-8 & gradle-2.11

Upgrading java using update-alternatives


  1. Download the latest java-8 binary zip from official oracle downloads
  2. Create a new folder  under /opt
     mkdir -p /opt/jdk-8
  3. Extract the gzip file to the /opt/jdk-8 directory
     tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk-8
  4. Setting Oracle JDK as the default JVM
    update-alternatives --install /usr/bin/java java  /opt/jdk-8/jdk1.8.0_74/bin/java 2000
    update-alternatives --install /usr/bin/javac  javac /opt/jdk-8/jdk1.8.0_74/bin/javac 2000
  5. Configure java if more than one java version is available already.
     update-alternatives --config java

    choose the correct number if prompted .

  6.  Verify the installation
     java –version

Upgrading gradle manually.


  1. Download the latest gradle binary file from gradle-2.11-all.zip
  2. Create a new folder  under /opt
     mkdir -p /opt/gradle-2.11
  3. Extract the gzip file to the /opt/gradle-2.11 directory
     tar -zxf gradle-2.11.all.zip -C /opt/gradle-2.11
  4. Create a symbolic link to the original file.
     ln -s /opt/gradle-2.11/bin/gradle /usr/local/bin/gradle
  5. Verify the installation
     gradle –version

Note:
gradle –version -> may still use the older version of java  if  JAVA_HOME is not  points to the latest jdk-8 directory.

 export JAVA_HOME=/opt/jdk-8/jdk1.8.0_74
 export PATH=$PATH:$JAVA_HOME/bin

reference:
https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps