Skip to content

Need a way to gracefully handle attempts to TASTy-Inspect Java classes #8215

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

Closed
gzoller opened this issue Feb 5, 2020 · 0 comments · Fixed by #8220
Closed

Need a way to gracefully handle attempts to TASTy-Inspect Java classes #8215

gzoller opened this issue Feb 5, 2020 · 0 comments · Fixed by #8220

Comments

@gzoller
Copy link
Contributor

gzoller commented Feb 5, 2020

Today

If I TASTy-inspect a Java class I see a warning on the screen, then nothing happens, which isn't very useful.

(As an aside, I get an alreadyLoaded() warning. I would have expected a cannotUnpickle(s"its class file does not have a TASTY attribute") for a Java class.)

While this behavior is somewhat expected, as there is obviously no .tasty file for Java classes, it would be valuable to know that I encountered a Java file in my top-level TastyInspector implementation, not just "nothing" (empty root tree). As we live on the JVM, I categorize this request as a "friendly-failure", as it could surely happen in the wild.

I seek a way to know if a compilation unit was in fact a Java class from within TastyInspector.

expectation

I'm working on a PR for this, attempting to do as minimal surgery as possible.

My thought is to add a marker class, JavaCompilationUnit, that can be returned from ReadTasty. Then I can add a getJavaClass():Option[String] method on Reflection.Context, which internally will check the CompilationUnit to see if it's a JavaCompilationUnit and return the class name if so. This information I can access from within my TastyInspector and do whatever I need to from there. Those who don't care about Java classes will experience the current behavior minus the warning.

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

Successfully merging a pull request may close this issue.

2 participants