Bad Habits Die Hard – How to Prepare Java Apps for Full Speed Debugging

Deutsche Fassung bei Debuggen von Java Anwendungen – auf der Überholspur! 

When instrumenting your Java application for remote debugging, a commonly used set of VM parameters brings your application to a crawl, as it disables just-in-time compiliation and enforces interpeter-only mode, e.g.:

-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
-Djava.compiler=NONE 

Starting with Java 1.4, it is neither required nor advisable to disable the Java just-in-time compiler,

so just remove the -Djava.compiler=NONE:

-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

Thus, you are able to prepare your application (e.g. JBoss) for debugging, and there will be no perceivable overhead unless you actually connect your debugger to the debuggee (using remote debugging). And even while debugging, the Java just-in-time compiler will speed up your application. That may be handy for test (or even production) environments that are supposed to both deliver full speed and still supply a back door for debugging once the need arises.

Even recent posts still promote the -Djava.compiler=NONE  antipattern, as in See how maven works inside – remote debugging plugins or Debugging your Maven Project in Eclipse.

And the bad -Djava.compiler=NONE habit may still be hidden within numerous configuration files or tools, as it even made its way into Sun’s Java 6 itself.  See -Djava.compiler=NONE and -Xdebug anachronisms unanachronistically disable full-speed debugging at Sun’s Bug Database.

Unknown's avatar

About Reiner

Born 1954 in Ratisbon (Bavaria, Germany), in 1976 punched cards at Berlin Technical University, caught hacking one of its mainframes by Horst Zuse (son of Konrad Zuse), started studying computer science and soon was offered a job whithin their computer department doing systems programming for IBM VM/370. While studying, jobbed around Germany at various places doing all sorts of things, then returned to Berlin to work at SRZ (computer aided typesetting). Never finished my master degree, but chose to take up self-employed work (which didn't turn me rich nor famous). Now working for a mid-sized software company within a very promising department as head of server software development.
This entry was posted in Computers, English. Bookmark the permalink.

1 Response to Bad Habits Die Hard – How to Prepare Java Apps for Full Speed Debugging

  1. ensiklopedia's avatar ensiklopedia says:

    I was curious if you ever thought of changing the page layout of your website?
    Its very well written; I love what youve got to say. But maybe
    you could a little more in the way of content so people could connect with it
    better. Youve got an awful lot of text for only having 1 or two pictures.
    Maybe you could space it out better?

    Like

Leave a comment