Reflection – Java 8 – invalid constant type
I have a problem with the reflections library
Dependency and in POM Build in XML
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
No exclusion is the same effect
Code:
URL jarUrl = jarFile.toURI().toURL();
urlclassloader child = new urlclassloader(new URL[]{jarUrl},this.getClass().getClassLoader());
ConfigurationBuilder builder = new ConfigurationBuilder()
.addClassLoader(child)
.addUrls(jarUrl)
.setScanners(new SubTypesScanner());
Reflections r = new Reflections(builder);
return r.getSubTypesOf(cls);
How to load classes using lambda expressions?
Sorry, English:)
Solution
If you see this table, you will see that "constant type: 18" refers to the constant with the tag value of 18_ Invokedynamic property
So the library you use has a class parser that is not Java 8 compatible In fact, this class parser is not even Java 7 compatible because the constant value is specified from Java 7 Since normal java code does not use this feature in Java 7, it has disappeared But when with different JVM programming languages, it may even fail with Java 7
An item in the Bug Tracker of reflections describes your problem At the bottom, you will find a notification:
