Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsSource not found in debugger
https://www.eclipse.org/forums/index.php/mv/msg/441084/989150/#msg_989150
I am stumbled on a source not found problem in debug mode and could not figure out the reason. I have simplified and compared the problem as below:
Problem:
1. Project "A" with class "com.a.Test" with public static method "test()", put a break point within the test() method. Project A is built as jar "a.jar" using Maven (mvn package)
2. Project "B" (not a maven managed project) with class "com.b.TestDriver" with main() method that calls the com.a.Test.test(). Project B uses the a.jar
3. When I debug on com.b.TestDriver.main(), the Debugger halts correctly at the Test.test() line and the editor has only a single red line saying "Source not found" and right below a button to "Edit Source Lookup Path..."
4. Click the "Edit Source Lookup Path...", Add the Java Project "A" in the source lookup. But the editor stills shows "Source not found"
In order to narrow down the problem, I modified the flow a little bit and source lookup work as intended:
1. Everything is the same for project A. But instead of using "mvn package" to build the jar, I exported it as a jar directly from eclipse using "Export...> Java > JAR file"
3. When I debug on com.b.TestDriver.main(), the Debugger halts correctly at Test.test() line and the editor has black line saying "Source not found" but with more information about the method signature and so on". It also has button "Attach Source..." instead of "Edit Source Lookup Path..."
4. Click the "Attach Source...", add the java Project A from workspace and the editor locates the source code correctly.
The thing that I cannot figure out is that why the jar built by "mvn package" triggers a different "source not found" behavior on eclipse? In both test cases eclipse managed to halt at the correct break-point and prompt for source but prompts are different and the source lookup for the mvn packaged one did not work.
Can someone please kindly help me with this or give me some pointers?
Zillion thanks in advance!
]]>Patson Luk2012-12-04T20:33:52-00:00Re: Source not found in debugger
https://www.eclipse.org/forums/index.php/mv/msg/441084/989158/#msg_989158
David Wegener2012-12-04T22:24:59-00:00Re: Source not found in debugger
https://www.eclipse.org/forums/index.php/mv/msg/441084/989159/#msg_989159
Upon further investigation, it turns out that the Maven build process uses Proguard plugin with obfuscate set to TRUE. Therefore the generated bytecode included in the jar was modified which triggered debugger failure on eclipse side.
The debugger did manage to lookup the correct line number but it showed [local variables unavailable] next to the stack trace. I bet the obfuscation hinders the debugger from correctly linking the bytecode with the provided source therefore the failure of using lookup source.
To me it is expected that debugger would not work on obfuscated bytecode. The source showed up just fine once I set the obfuscate option to false in the maven build process.
Thanks all again!
]]>Patson Luk2012-12-04T22:26:05-00:00