-
Notifications
You must be signed in to change notification settings - Fork 34
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
ClassNotFoundException and other unexpected errors should come with a trail allowing the user to figure out where they came from #142
Comments
Hi, |
Looks like this is not an annotation. So I am working on improving the error message... |
It looks like this is not easy to solve... The calls to class lookups are often very deep inside other calls which are recursive. I think the easiest is to record some "current method/state" on the top level class scanner and when you get a CNFE, we can add the state to the message. Not sure yet how this works, but it's hard - unfortunately. |
I think just having it on the class scanner would be a good step forwards, because it would at least narrow down the manual search to one I was able to capture a full stack:
ClassScanner.java:183 is checking arguments for a method, and then ClassScanner.java:153 is checking the superclasses/interfaces of the class. So I know that there is something which implements the interface which is causing the problem, which then appears as a parameter in a method somewhere. :) A full solution seems like it would really want a context object passed around where you'd push/pop the current thing being looked at, and then when an error occurs, it would report the whole contents of the context stack which would point directly at the issue. So this context would have to be created somewhere around |
Hi, the state for pushing popping was my idea, too. We don't need to pass that through the whole method calls, it can be a field on ClassScanner. |
You could totally make a system where the context object does get passed from method to method and pushing onto it actually creates a new immutable context, which would avoid ever having to pop, but would also create an immense amount of garbage which may or may not slow down the processing. |
I have a plan already, it's not too much work. There is not much push/pop required, as you don't need to go deep inside. It's enough to push/pop on every field and method declaration. You would also get the line number inside methods. At least you don't need to really push its enough to have a "shared" state object that gets modified - very easy. Its currently done like that for the lambdas, it just needs to be extended. I will work on that! |
I did not implement a whole state machine, but in the next version this will be fixed like this:
|
I have a problem where I am getting
ClassNotFoundException
from forbidden-apis where it is trying to find up a class which was apparently referred to from some other class.Problem is, there are no references to that class in the module where the error occurred. So it's referred to be some class in another module which is then indirectly referred to from the module I'm building, and the project is way too big to figure out where it might be.
It would be nice if the error would be caught and rethrown with additional context about which class/method/parameter is being processed when it occurs. That would point directly at the problem.
The text was updated successfully, but these errors were encountered: