I followed the instructions in Create and install de-lomboked source jar in maven for delomboking my source code and including it in the jar. So now, in another project, I can access the delomboked source. The problem is that IntelliJ uses this source to display when I click on a stack trace and the line numbers are wrong. IntelliJ is using the line numbers from the compiled source and it doesn't match up exactly with the actual source.
Is there around this? If not, I'll have to go back to using the regular source code, instead of de-lomboked
Related
I've just downloaded apache commons-lang3-3.2.1 source and binary because I want to try out their Fraction class.
My first question is how to find the relevant file to add to the build path in Eclipse?
My second question is whether to use binary or source?
I've tried looking in both but I can only see executable JARs and JAVA files and I seem to remember they aren't what I need from past experience.
You need to decide to add source or binary to your eclipse buildpath, but i would always add just the complete binary to eclipse build path and if i need to see how the method internally really works we can any way have a look in the api source code without adding it to the buildpath.
I am new to both java and eclipse, I have been trying to debug an android app on a device. It is a small project with a jar file reference. I read similar questions but they didn't help.
What I need is to be able to debug the source codes of the jar file so I attached the source codes ( which I obtained using a decompiler ) and I am able to go into source codes of the library so I thought I did that correctly. But I can not succeed in debugging into these source codes; in debug mode it skipps breakpoints (only the ones in the source files which are attached to jar file) and when I try to 'step into code' it goes to random lines skips lines when debugging.
I am using the latest versions of eclipse, android sdk and jdk. I don't know what causes this problem and I'd like to know.
Thanks in advance, I hope I explained sufficiently.
The problem is, that you can't decompile the class files to debug it. Because the lines of the decompiled files will differ to the original Java source code lines (imagine: the real source code has some comments and other things which will not be compiled into class files)!
So, if your Eclipse shows you the current debug line 42, then it only tells you, that the debugger will present you the 42th line of code in the class file. This won't match your decompiled java source file.
However, you could decompile the class files with the option add line numbers as comments. These line numbers in comments you can compare to the actual stacktrace line numbers. This could help you a little bit to imagine the issue.
edit: as Laurent B recommended, you will be able to realign the code with JD-Eclipse, see: http://mchr3k.github.io/jdeclipse-realign/
+1 for the comment! :)
edit2: You won't be able to decompile with line numbers if the class files are compiled with the flag -g:none:
-g:none
Do not generate any debugging information.
So if this is the case: try to find the original source code of your jar file!
Its shows that the source file and Jar is not same. Try to get the right version of Source.
A decompiler will not get the exact source code but will try to recreate it from the generated bytecode.
This is an entropic process so Decompile(Compile(Source)) will not output Source (you loose information) such as line number. That is why you will need the original source code. If you don't have it, you will have to use your immagination to be able to follow the code :)
EDIT : apparently some decompiler tools can do that for you as stated by bobbel.
see jdeclipse plugin.
Try debugging your code line by line by pressing F6
Decompiled source code sometimes acts like that. Unfortunately, the only solution for you is to stop debugging the jar and search the web for the source code and add it to your project.
I'm tracing into eclipse LTK plugin. I could set a breakpoint in some of the readonly java source for LTK. (for example ProcessorBasedRefactoring.java)
However, I couldn't set a breakpoint in some source files. (for example JavaRenameProcessor).
When I tried to set a method breakpoint, I got "Cannot create method breakpoint, method signature not available." error message.
What might be wrong? Why I can't set a breakpoint in some of the (binary) Java source file?
ADDED:
For a simple workaround to this issue, I just set a breakpoint wherever possible, and then open the java source to click a line. Then, I can use command-R so that eclipse executes up to the line that I point to.
ADDED2:
The breakpoint was there, but eclipse doesn't show it.
The other thing that I noticed was that the java file, just disappears from the IDE when I restart the debugger. And even when I reopen it in eclipse.
I got this error message - "zip file closed".
And then I can see the source code only when I trace into the method that the java source contains.
I believe that the class is compiled without debug information and/or the byte code is obfuscated.
Download java source code from open source website, the file's form is XXX.zip, not XXX.jar.
Build path -->c onfigure build path, enter the page, choose libraries, and open a jar file, find "Source attachment", and choose it, you can find a button is named "Edit" on the right, click it, and type the xxx.zip what you downloaded path into it.
back to your debug page, continue your work
Good luck! I hope my answer can help you.
I am using eclipse for java. When I debug, 'source not found' came out, is it because of javadoc? Where can i find javadoc in my desktop?
It appears your debugger stepped into a library class, and Eclipse cannot find the source for said library class.
You must tell Eclipse where the source files are located.
This is not related to javadoc
When you debug and when you go to inside of a method to debug and if you call that method through a jar file you will get this "source not found". If you can use source codes instead of that jar you will not get that and it will direct you to required source line in that method.
Eclipse telling you that source is not found has nothing to do with javadoc, but with the actual java files.
Most probably you do not have your project configured has a java project with source folders configured. To configure your project source folders do the following:
Right click on your project's name in the navigator view
Select properties
Go to Java Build Path -> Source
Make sure all your source folders are there.
After making sure that all source folders are correctly configured, you should move on to your debug view, and while debugging:
Right click in the attached process
Select Edit Source Lookup
Make sure your project is in the list, otherwise add it.
It can also happen that Eclipse is trying to display you a source file which is not from your project but rather from some other jar you're using or from the actual Java Runtime.
If that's the case and you still want to debug that source too you have to download the source (the correct version you're using) and use the previous 3 steps in the debug view to add that source to your debug environment.
One of the problems I'm running into is that my jar files and my source files don't match.
I'd like to:
Be Notified when when source and binary don't match (I think Visual Studio can do something like this...)
Set break points not by line, but by function. For example, set a break point at the entry of function foo().
I use eclipse mainly; so Solutions for eclipse would be most appreciated, but any IDE (or command line debugger) will do.
Thanks!
When developing just use and link to .class files that are saved by your IDE.
If your project starts to grow to a point where it's really useful to link to a .jar you're better off treating the jar's as separate projects.
Go to Project tab in Eclipse and then
click clean: Project->Clean…
click build automatically: Project->Build automatically
Use method breakpoints instead of line breakpoints. They can be set to halt on entering/exiting a method. You get them by double clicking the left editor side in a line containing a method declaration.
The debug information is limited to line numbers in the source file... I do agree that having a warning that the lines are wrong would be nice, but that would require more meta data in the jar than I think is available...
You might want to consider addressing the challenge with a change in your build process. This isn't exactly answering your question, but hopefully it will give you a strategy that will address the underlying problem.
When you generate the jar for deployment, also generate a jar with the binary AND source. For investigating the source code of a stack trace on the live server, set up a separate project in eclipse and have the binary+source jar be on the classpath. You may have to explicitly set the source code location back to the same jar (though I think Eclipse will just do this automatically).
Then you just have to add copying of the binary+source jar into the appropriate location in your workspace as you do your deployments (preferably with a deployment script).
If it's your server, you may want to even consider deploying the binary+source jar to the live server - that way you will always be able to get at the source.