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
Error when creating ScanResult from JSON #682
Comments
Hi @thibaultmeyer, thanks for the bug report. I solved the issue of an exception being thrown in this case, however the fix is a bit simplistic. What is going on here is that type signatures are only parsed lazily as they are requested by the user after the scan is complete (to speed up scanning). Type annotations are added to type signatures only when the type signature is parsed, using "decorator" lambdas. These decorators were added recently (with type annotation support), and they were not marked as Type annotations are only rarely used, and the built-in JSON serialization functionality is used even more rarely, so I assume that in practice this won't cause a problem for many people. The solution would be to have the serializer run the decorators on every type signature in the I'm actually going to remove the JSON serializer in ClassGraph 5.0, because it has been a source of some bugs in the past, and almost nobody uses it. Also almost nobody needs the entire The above "fix" is released in ClassGraph 4.8.147. (I put fix in quotes because of the caveat that type annotation information will be lost during serialization.) |
Hi @lukehutch, Thank you for your answer. |
@thibaultmeyer The fields in However one of the reasons why I wrote a custom serializer for What I was talking about when I said to try custom-serializing to disk just the information you need is simply that you can think about the exact queries you need to run, then run those queries (potentially at build time), and come up with your own way of serializing just those results. For example, if you need to know which classes have a certain class annotation, run the query and then write out to a file just the names of the classes that have that annotation. You can repeat this process for each query type whose results you care about. The result will be dramatically smaller (and therefore faster to read at runtime) than using the full JSON file generated by ClassGraph's built-in serializer. Also, you should be able to use the built-in serializer again as of ClassGraph-4.8.147, and the 4.x series will continue to work (albeit not receiving further bugfixes) after I release ClassGraph-5.x. Anyway ClassGraph-5.x is not likely to be released before the end of the year, I have too much else going on... |
Hello,
I get an error when I try to restore a ScanResult from JSON.
Environment
ClassGraph version : 4.8.146
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
Creating JSON
Loading JSON
Error
The text was updated successfully, but these errors were encountered: