ParseException while scanning Scala jar dependency
See original GitHub issueHi,
I am trying to use ClassGraph to analyze our Scala project. Sadly while scanning the project with
new ClassGraph().verbose().enableInterClassDependencies().scan();
I get a ParseException:
2021-01-21T12:34:24.353+0100 ClassGraph Uncaught exception during scan
2021-01-21T12:34:24.353+0100 ClassGraph -- java.lang.IllegalArgumentException: nonapi.io.github.classgraph.types.ParseException: Expected ':'; got '$' (before: "<K$"; after: ":Ljava/lang/Object;V$:Ljava/lang/Object;>(Lscala/$less$colon$less<TA;Lscala/Tupl"; position: 3; token: "")
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.MethodInfo.getTypeSignature(MethodInfo.java:251)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.MethodInfo.findReferencedClassInfo(MethodInfo.java:759)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.MethodInfoList.findReferencedClassInfo(MethodInfoList.java:95)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.ClassInfo.findReferencedClassInfo(ClassInfo.java:2930)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.ScanResultObject.findReferencedClassInfo(ScanResultObject.java:68)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.ScanResult.indexResourcesAndClassInfo(ScanResult.java:315)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.ScanResult.<init>(ScanResult.java:262)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.Scanner.performScan(Scanner.java:1013)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.Scanner.openClasspathElementsThenScan(Scanner.java:1112)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.Scanner.call(Scanner.java:1146)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.Scanner.call(Scanner.java:83)
2021-01-21T12:34:24.353+0100 ClassGraph -- at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
2021-01-21T12:34:24.353+0100 ClassGraph -- at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
2021-01-21T12:34:24.353+0100 ClassGraph -- at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
2021-01-21T12:34:24.353+0100 ClassGraph -- at java.base/java.lang.Thread.run(Thread.java:834)
2021-01-21T12:34:24.353+0100 ClassGraph -- Caused by: nonapi.io.github.classgraph.types.ParseException: Expected ':'; got '$' (before: "<K$"; after: ":Ljava/lang/Object;V$:Ljava/lang/Object;>(Lscala/$less$colon$less<TA;Lscala/Tupl"; position: 3; token: "")
2021-01-21T12:34:24.353+0100 ClassGraph -- at nonapi.io.github.classgraph.types.Parser.expect(Parser.java:130)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.ReferenceTypeSignature.parseClassBound(ReferenceTypeSignature.java:85)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.TypeParameter.parseList(TypeParameter.java:138)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.MethodTypeSignature.parse(MethodTypeSignature.java:333)
2021-01-21T12:34:24.353+0100 ClassGraph -- at io.github.classgraph.MethodInfo.getTypeSignature(MethodInfo.java:243)
2021-01-21T12:34:24.353+0100 ClassGraph -- ... 14 more
The verbose.log
s and a minimal Maven Java project (create by IntelliJ) are attached. I get a very similar but different exception when calling:
new ClassGraph().verbose().enableAllInfo().enableInterClassDependencies().scan();
Without the call to .enableInterClassDependencies()
the errors do not appear.
I am using ClassGraph 4.8.98 and the project is configured for Java 11. The minimal example is a Java project for simplicity. Our real project is setup for Scala 2.13.
As far as I can see one of the parsers isn’t able to handle the names or types containing $
created by the scala compiler.
Another thing that worries me about the logs is that there are statements like the following:
2021-01-21T12:34:23.366+0100 ClassGraph -- Scanning jarfile classpath element C:/Users/jbr/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.5.23/akka-testkit_2.13-2.5.23.jar (took 0.019827 sec)
2021-01-21T12:34:23.368+0100 ClassGraph ---- Found resource within subpackage of accepted package: META-INF/MANIFEST.MF
2021-01-21T12:34:23.368+0100 ClassGraph ---- Found classfile within subpackage of accepted package: akka/testkit/CachingPartialFunction.class
2021-01-21T12:34:23.567+0100 ClassGraph ------ Parsing classfile (took 0.014931 sec)
2021-01-21T12:34:23.582+0100 ClassGraph -------- Invalid classfile: Could not parse type signature: Lakka/japi/JavaPartialFunction$NoMatch$;
2021-01-21T12:34:23.368+0100 ClassGraph ---- Found classfile within subpackage of accepted package: akka/testkit/CallingThreadDispatcher$.class
2021-01-21T12:34:23.568+0100 ClassGraph ------ Parsing classfile (took 0.014226 sec)
2021-01-21T12:34:23.582+0100 ClassGraph -------- Invalid classfile: Could not parse type signature: Lakka/testkit/CallingThreadDispatcher$;
2021-01-21T12:34:23.368+0100 ClassGraph ---- Found classfile within subpackage of accepted package: akka/testkit/CallingThreadDispatcher.class
2021-01-21T12:34:23.568+0100 ClassGraph ------ Parsing classfile (took 0.014104 sec)
2021-01-21T12:34:23.582+0100 ClassGraph -------- Invalid classfile: Could not parse type signature: Lakka/testkit/CallingThreadDispatcher$;
These suggest to me that the class file scanner is lacking somewhere, since these are clearly valid class files that are being used and executed in our project. Though I suspect these messages may be connected with the exceptions I mentioned above.
ClassGraphMinimalExample.zip verbose-with-enableAllInfo.log verbose-without-enableAllInfo.log
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:30 (16 by maintainers)
Top GitHub Comments
You’re welcome! I appreciate the responsiveness too.
Thank you for your quick support and bug fixing!