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
Invalid classfile: Unknown constant pool tag 17 (element size unknown, cannot continue reading class) #527
Comments
Hi @haoyuf, Thanks for the bug report. It looks like what happened is that constant pool tag numbers 1-20 were added up to JDK 9, but then in JDK 11, for some weird reason they went back and used an unused tag number 17. The reason why ClassGraph can't keep scanning with an unknown tag number is that it doesn't know how big the corresponding constant pool entry is, which throws off reading of the rest of the classfile, because the classfile format was not well designed to support forwards compatibility by just skipping over unknown information. (I argued long and hard with the JVM team to fix this, and they pushed back by saying that if a library couldn't understand 100% of the classfile format, it had no business trying to parse the classfile, and that no assumptions could be made about future format changes, so every library that reads classfiles must be prepared to carefully check and conform to spec changes with the new 6-monthly release cadence, and push out a release at least every 6 months to keep up. I think their stance is ridiculous, but that's what they ruled!) Tag 17 is used to "represent a dynamically-computed constant, an arbitrary value that is produced by invocation of a bootstrap method in the course of an ldc instruction, among others". I don't know what language feature(s) or what JVM language(s) would make use of that. I fixed this by skipping over constant pool records corresponding to tag 17, since there's no useful information for ClassGraph in those records. This is released in 4.8.108. Thank you / 谢谢! |
PS with this change, ClassGraph's support for constant pool tags is updated up to the most recent release, JDK 16. Hopefully adding a new constant pool tag is a rare occurrence. |
Thanks a lot, this is really quick reply! I would like to try version 4.8.108! |
I try to turn around bugfixes quickly, because almost no other open source project ever does! :-) This should fix the problem, but let me know if you run into further issues. Thanks for the report! |
Hey, Luke. Just FYI. Your commit fixed the issue! |
Great, thank you for confirming! |
Java version: JDK 11.0.11
ClassGraph version: 4.8.47
Hey, I found a really tricky issue in our team code when we tried to upgrade from JDK8 to JDK11.
The error as in the title happened when we tried to scan the classes under certain package prefix.
Below is the code we run and the error logs.
The tricky thing is, it only happened when we tried to use JDK11 and scan cross Jars. It works totally fine if we are using JDK8 or if we only scan inside the same jar which ClassGraph sits. Wondering do you have any clue? If it requires to upgrade ClassGraph, we need to talk to other teams to do it. Anything we can try out before that? Thanks!
Best
The text was updated successfully, but these errors were encountered: