Plugin for better debugging in Eclipse IDE - java

I am new to this project and it's code doesn't have any logger statement. It is tedious and time consuming to follow any flow.Because of the application's exception handling framework all the exception fall into a common exception block and it is pretty cumbersome to track back from there.
Is there any Eclipse plugin which can help me to debug the issues? I am kind of looking for similar to XCode's debug feature where it stops the flow at the line which is causing exception. You can track back on that.
Updated my question.
Note: I am using Eclipse Juno and in the middle of developing AspectJ logging utility to help me with debug statements.

Himanshu, Eclipse has a full-fledged debugger which has withstood the test of time. You will need to give it a bit more time and explore it to realize it's full potential.
For instance, the feature that you miss from XCode has a counterpart in Eclipse in the form of Exception Breakpoints.
Setting them up (as Ajay George points out) is detailed in this question :
Break when exception is thrown
I am very interested in knowing the other things that you are looking for in the Eclipse Debugger.
Edit : The following might not be of great help to you if you already have experience with Eclipse but I shall leave them here for posterity :
This is a comprehensive tutorial on debugging with Eclipse.
Also, if you prefer watching and doing instead of reading then this is a good place to start ( OR directly checkout/download the videos from here )

Eclipse has an inbuilt debugger to debug java programs (http://www.ibm.com/developerworks/library/os-ecbug/), are you looking for something other than this?

Related

Running debug session for lwpd.xsp.core source

Assuming I have a decompiled source of lwpd.xsp.core library, is there any way to run it through Domino Designer Java debug session? I want to fully understand what happens behind the scenes, but IBM actually lacks any good documentation except apidoc that doesn't help too much. I think running the full request/response cycle from debugger would be the fastest and most effective way to clear things up, than browsing the code through IDE. On the other hand, I can put sout pritln-s where I need or insert some custom logging statements, but debugger is still preferred.
I guess maybe I have to remove lwpd.xsp.core.jar from Plug-in Dependencies of my XPages application and attach it as an external library instead, but I don't have a clue how to do it. If it is possible at all, I'll make a research on the topic.
You can decompile the code during runtime with the JD GUI Eclipse Plugin. Just download the update site and import it into DDE.
No Source code needed.
And please donate for the project (I am not the author of JD GUI or have any benefits from a donation).
By the way: the most interesting parts of the XPages engine are stored in the files
lwpd.xsp.core.jar
lwpd.xsp.extsn.jar
lwpd.xsp.domino.jar
lwpd.xsp.designer

IDEA - Custom Errors

While working on my code I was reminded of just how much IDEA does for me. This gave me the idea, what if I could add some custom compile time processing. In which, if my code is invalid it will prompt me with an error. Say for example I left a return type as a null when it should never be null. Basically framework and API checks to reduce production errors.
The problem is I have no clue where to start on doing this. I assume I need to develop a plugin but am having issues finding documentation. If someone would be so kind as to help me get started. As well maybe even provide links to example projects or existing projects (github if possible).
As well I plan to release this plugin as part of a few APIs I develop. So helping me will help others in the long run :)
You can create an intellij plugin that implements custom inspections.
Example here:
https://confluence.jetbrains.com/display/IDEADEV/Inspection+of+Code+Source
The inspections that you create can highlight code red, allow the user to disable them, and also prompt for fixes. Please see intellij plugin development API's for more details.
You can use standard java assertions for this:
https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html

How to log every executed line of code in Java for debug purposes

I am using a third party open source library for authentication in my web app. Its logging is lacking to say the least. I do have the code (its on github) and can find choice locations in the code to log but I was wondering if there is a quick way to alter the byte-code to log each line of code? Similar to Jacoco or Clover, except its for logging and not code coverage. I assumed there would have been a top search result for this on Google or Stackoverflow but maybe I am not using the right search query.
So far I took the code from github and created an uber jar of it using Shades Maven plugin. So all the code byte code, and its dependencies are in one jar file.
EDIT: To answer the question of why I would want to do this. The library has a lot of classes. Essentially its very time consuming to find where the problem could be. And while I am wasting time typing this question and can be finding the best places to log, I want the answer because if I come across this in the future I would like to use this same approach. If I add the logging manually, I would have to compile, and deploy, then when I see that I logged the wrong lines or now need to log more lines, then I would rinse/repeat till I hunt down the culprit. This is more than just solving this immediate problem, this is something that should be doable within Java's various tools and I want to know how to do it, so please keep answers related to solving my question and not providing workarounds.

way to debug java frameworks on console

I am a C++ dev, working in java technology for about a year. Forgive my ignorance, but I have tried to search for following two questions.
What is the best way to debug in console for a java application (ala gdb in good ol' C++).
It seems jdb is below par.
Eclipse is the way to go for its IDE. But Eclipse is a GUI and I do develop in console on unix servers.
What is the best way to tame huge jave open-source frameworks. eg, camel, hibernate, spring, logback, blah, blah
I do most of my debugging in the console.
I have found that for the majority of bugs, Java stack traces are sufficient to identify the bug and develop a fix. This of course means that it's critical to allow stack traces to be seen on the console. For most applications, I've found that it's best to allow unchecked exceptions to propagate until they terminate the thread, with a stack trace showing up in the console; unchecked exceptions should normally indicate programming errors or uncontrollable conditions where the thread should be terminated anyway.
In cases where the stack trace is not sufficient, I've found that using System.out.println() during the debugging process is actually more effective than using an interactive debugger. Having a full log of a run is for me more useful than running a debugger where I may easily step past an issue that later turns out to be important.
Wat is the problem in setting up the project in eclipse IDE, you can always get the source code and set up your workspace??
Using sysout is great for small java programs but as the code grows or for big application (according to my understanding you plan to debug something big :P) it would really be a headache placing all those sysout and then removing them once you are done with the debugging.
I would suggest you to set up your own workspace by choosing 'import existing project in workspace' option of IDE, though it would be tiring first but will help you in long run.
I would say that there is no need for such a tool, because Java supports remote debugging.
You need to start your (server) JVM with remote debugging enabled - this will work for newer JDKs:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
After that you connect to it from the IDE, and set breakpoints or conditional breakpoints wherever you like.
See this question for more details
Also, this is a personal preference, but I would say that IntelliJ IDEA is the way to go as far as Java IDEs go.

Eclipse Debugging Method Calls

I have two versions of a project that are intended to accomplish the same effect. One is an older implementation, while the second is an updated, modified, and (hopefully) enhanced version. The issue is that they are not giving identical outputs. Is there an option to have Eclipse print out a list of everything a program is doing such that I can compare them (with some sort of merge/diff tool) and find out where they diverge?
This is in Java, using JBuilder 2008, which is more or less identical to Eclipse.
I am not familiar with JBuilder. In Eclipse you can right click on a project and click debug to launch the debugger. You can then set your breakpoints on where you want to start debugging from and step through. Is this a web app or a standalone app? If it's a web app running on a server then you may have to do remote debugging.
Here is one link and another link to a tutorial on debugging set up in Eclipse.
The easiest way to do this is probably to use AOP (Aspect Oriented Programming) which allows you to add code in a non-linear way. See this question about logging which I would expect to be very close to what you need, and how simple the AOP approach is.
Traditional logging vs AOP logging
#After("execution(* *.doSomething())")
public void logAfter(JoinPoint jp){
logger.debug("...");
}

Categories

Resources