question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ParseException while scanning Scala jar dependency

See original GitHub issue

Hi,

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.logs 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:30 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
lukehutchcommented, Jan 27, 2021

You’re welcome! I appreciate the responsiveness too.

0reactions
jbrackercommented, Jan 27, 2021

Thank you for your quick support and bug fixing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fat jar from scala project throws error when run - Stack Overflow
I created Scala project using Maven as build tools. I try to build fat jar that later I will be able to run...
Read more >
Failed to execute goal net.alchim31.maven:scala ... - GitHub
I just created a new scala project using archtype and tried compiling it. I am getting below error while maven install- [INFO] Scanning...
Read more >
Minimal executable jar based on Scala code packed with Maven
Hi folks,. I would like to make a minimal example packed with Maven based on Scala code (like a hello world) and run...
Read more >
Maven Resolve Missing Artifact Error Example
Maven throws “Missing artifact error” when a dependency is not recognized or a dependency artifact cannot be found either in the local ...
Read more >
Scala Application Packaging - Veracode Docs
For a successful scan, you cannot obfuscate Scala applications. You must compile and submit Scala applications as JAR files. You can do this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found