Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class resolution incorrect when accessing static fields -- ClassNotFoundExceptions #158

Open
BenTels opened this issue May 4, 2018 · 0 comments

Comments

@BenTels
Copy link

BenTels commented May 4, 2018

When a resource class has static fields, the reflective resolution of the containing class seems to be incorrect, leading to java.lang.ClassNotFoundExceptions being thrown.

Example from my project, standalone run:

  • Command: java -jar jaxrs-analyzer.jar -b plaintext target/classes -cp $CPATH -X
  • Result: Lots and lots of errors like this:

Could not access static property, reason: nl.promoir.roomer.pms2.resources.roomtypegroups.RoomTypeRatePlanDefaultsSubResource
java.lang.ClassNotFoundException: nl.promoir.roomer.pms2.resources.roomtypegroups.RoomTypeRatePlanDefaultsSubResource
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.collection.InstructionBuilder.getStaticValue(InstructionBuilder.java:293)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.collection.InstructionBuilder.buildFieldInstruction(InstructionBuilder.java:35)
at com.sebastian_daschner.jaxrs_analyzer.analysis.classes.ProjectMethodVisitor.visitFieldInsn(ProjectMethodVisitor.java:111)
at org.objectweb.asm.ClassReader.a(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzer.analyzeClass(ProjectAnalyzer.java:134)
at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzer.analyze(ProjectAnalyzer.java:105)
at com.sebastian_daschner.jaxrs_analyzer.JAXRSAnalyzer.analyze(JAXRSAnalyzer.java:69)
at com.sebastian_daschner.jaxrs_analyzer.Main.main(Main.java:94)

The CPATH environment variable contains all the jars in the lib dir of the exploded WAR that has been built, plus target/classes just for good measure (and trying to solve the problem).

Just to be clear, the classes that are reportedly not found, do exist:

$> echo nl.promoir.roomer.pms2.resources.roomtypegroups.RoomTypeRatePlanDefaultsSubResource | sed -e 's/\./\//g' | xargs -I{} ls target/classes/{}.class

target/classes/nl/promoir/roomer/pms2/resources/roomtypegroups/RoomTypeRatePlanDefaultsSubResource.class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant