Replies: 3 comments 3 replies
-
Thanks for the suggestion -- implemented, see 04457b9. Works for me, but YMMV -- I don't know under which circumstances the line numbers are stripped from classfiles, but they are not required to be there. The methods you want are Also, I don't see any similar line number info for fields (unfortunately)... Released in 4.8.149. |
Beta Was this translation helpful? Give feedback.
-
Glad it's (mostly) working for you! Where do you see the line number in the bytecode for fields? |
Beta Was this translation helpful? Give feedback.
-
Oh, if the line numbers are in the bytecode, then there's no way for ClassGraph to get those numbers. ClassGraph will never parse bytecode, only class metadata. |
Beta Was this translation helpful? Give feedback.
-
Hi,
About the use case
As I am developing a rather reflection-heavy framework, I often need to throw exceptions in case the user didn't declare a method correctly, or if they used an incorrect annotation for example.
When making these errors, even if I put the faulty method's signature in the exception, it still takes some time for the user, including myself, to find back the faulty class.
The use case solution
The solution would be to print a text similar to when an exception happens, it is formatted in such a way that IDEs recognize them and make an hyperlink to the method declaration. (such as
System.err.println("MyCommand.declare(MyCommand.kt:63)")
)Unfortunately I could not find a practical way that would let me get the line at which a method is declared, I could only find the JVM specification about it
As it is a rather specific suggestion, it is fine if its not implemented, but I would appreciate having better exceptions thanks to this feature.
Beta Was this translation helpful? Give feedback.
All reactions