Give me some GC stats...

While analysing application memory usage and inspecting allocation/garbage creation patterns, we generally need to know garbage collection count, time, rate etc. Although most of the profilers give this information out-of-the-box or JVM already has builtin flags to enable GC logging in many details, sometimes we want to access GC information programmatically.

Fortunately, there’s a formal/public API in JDK to gather some useful information: java.lang.management.GarbageCollectorMXBean.

More >>>

How many bytes can I store here, sir?

Every operating system has its own special procedure to access memory information and statistics. In Linux one can read /proc filesystem, in nearly every OS one can fork a subprocess to execute a system command to find out memory information or call a system dependent API.

But since Java has the motto of write once run everywhere, how can one access memory information in Java?

More >>>

Spurious wakeups are real!

Most probably you heard spurious wakeup term many times, you read it in many API docs. But have you actually seen it in the wild? Is it real?

Here is wikipedia definition:

Spurious wakeup describes a complication in the use of condition variables as provided by certain multithreading APIs such as POSIX Threads and the Windows API.

Even after a condition variable appears to have been signaled from a waiting thread’s point of view, the condition that was awaited may still be false.

More >>>

Using AspectJ in Ecplipse RCP

If you try to export an AspectJ enabled Eclipse RCP 3.6, you will notice that none of your pretty aspects is compiled. Before Eclipse 3.6 there was an export option as “Export Product with AspectJ”.

But since version 3.6 you will not see that option. Instead you should just add AspectJ compiler adapter into your build.properties file:

compilerAdapter = org.eclipse.ajdt.core.ant.AJDT_AjcCompilerAdapter
sourceFileExtensions = *.java, *.aj

Migrated from old blog: using-aspectj-in-eclipse-rcp

JFreeChart in Eclipse RCP & SWT

To use JFreeChart in a Eclipse RCP project or simply embed in an SWT composite, you have two applicable choices: org.jfree.experimental.chart.swt.ChartComposite from JFreeChart SWT experimental project, which I can not say works seamless.

SWT_AWT bridge, hmm, not perfect but plays its role better.

More >>>