Java - Is it possible to output the stacktrace with method signatures?
Asked Answered
D

2

6

Is it possible to output the current stacktrace with method signatures? I'm trying to debug some obfuscated code that has a ton of methods with the same name that just differ in arguments and return type.

Some things that will not work:

Thread.currentThread().getStackTrace();
new Throwable().getStackTrace();
// etc..
Dredi answered 4/11, 2011 at 21:24 Comment(6)
If it's obfuscated and you're debugging it, then either it's your code, and you should have an unobfuscated version somewhere, or it isn't, and you shouldn't be debugging it.Hostility
That's somewhat subjective, don't you think?Dredi
@JBNizet Meh, there are legitimate reasons to figure out issues in libraries that you don't have source for, obfuscated or not.Lassalle
Obfuscating code is normally a way to make sure it's unreadable. So it's done to prevent anyone from reading it.Hostility
Open source code is usually not obfuscated. And non-open source, obfuscated code is generally forbidden by the license agreement to even decompile. But do whatever you want.Hostility
@JB Nizet: Obfuscating also allows to shrink the size. This used to be both very important and very common on the old J2ME apps for cellphones and some fully open libs were obfuscated just for the code size reduction. Some people probably still do it just for the code size reduction even though nowadays cellphones are much more powerful than when I used to work with them : )Purgation
L
3

Nope, but you could instrument with AspectJ while troubleshooting to get more complete info without adding logging.

Depending on the nature of what you're trying to debug and how much you know about any data involved you might be able to target more or less precisely.

Lassalle answered 4/11, 2011 at 21:30 Comment(0)
G
1

Not possible. The stacktrace does't contain that info.

Greenhaw answered 4/11, 2011 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.