Skip to content
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

Improved No such method : traces #924

Closed
nbrugger-tgm opened this issue Jun 1, 2023 · 3 comments
Closed

Improved No such method : traces #924

nbrugger-tgm opened this issue Jun 1, 2023 · 3 comments

Comments

@nbrugger-tgm
Copy link
Contributor

When the parser cant resolve a method, an exception is throw that ends the process and shows the information: No such method : <method signature>

Proposed improvements:

  • Format better
    • currently: java/lang/Enum.getDeclaringClass()Ljava/lang/Class
    • proposal: Class Enum.getDeclaredClass() (or fully qualified if it's worth the clutter)
  • Dump the path that reached the unfindable method
    • proposal
 No such method : Class Enum.getDeclaringClass()
     calledFrom EnumSet.of(Enum[])
     calledFrom Set.of(Object[])
     calledFrom MyJava20Software.init() (MyJavaSoftware.java:123)

TeaVm does something similar to this

Why?

For maintainers

When a user submits a report such as add Enum.getDeclaringClass() support it is very likely that he does not call Enum.declaringValue directly and doesn't actually needs it. But maintainers cannot know which component (EnumSet.of() in this example above) they need to "substitute" to actually fix the users behaviour. But if he pastes a stack as shown above one can see : "Oh we need EnumSet support" and easily implement it instead of doing a complicated flow analysis "who calls Enum.getDeclaringClass"

For users

When users do not have the time to wait for official support they probably just want to replace their call with a new one. (In this example using new HashSet<>() instead of Set.of()` because it fixes the problem and they can go on. But currently finding out that "Set.of()" is the problem is quite hard -

  1. you have to set a debug point in the maven plugin (which is a chalange of itself)
  2. Debug the maven plugin at compile time (which doesn't work to well in all IDEs)
  3. Walk up the call stack and try to figure out where in your code the origin lies.
    This process is hard or impossible depening on your skill and available tools (ide, maven, gradle, OS) and could be drasticaly improved
@nbrugger-tgm nbrugger-tgm changed the title Maintainer enhancment: dump call/parse graph on No such method : Improved No such method : traces Jun 1, 2023
@nbrugger-tgm
Copy link
Contributor Author

The first proposal should be a separate PR/issue since its a more "global" issue in ResolvedMethod that would have a broader and possibly breaking impact on core

mirkosertic pushed a commit that referenced this issue Jun 15, 2023
mirkosertic added a commit that referenced this issue Jun 15, 2023
- Added proper exception handling to Maven mojo.
mirkosertic added a commit that referenced this issue Jun 15, 2023
- Added proper exception handling to Maven mojo.
mirkosertic added a commit that referenced this issue Jun 15, 2023
- Added proper exception handling to Maven mojo.
@mirkosertic
Copy link
Owner

@mirkosertic
Copy link
Owner

You can see the new implementation in action, as of #1012. I'll close this ticket for now. Thank you for reporting!

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

No branches or pull requests

2 participants