Detecting from where code is called

Detect if current piece of code is called by own classes: [code lang=”java”] /** * @return True if current execution points originates from own classes */ public static boolean isOwn() { StackTraceElement[] stack = Thread.currentThread().getStackTrace(); int len = stack.length; for (int i = 2; i < len; i++) { if (stack[i].getClassName().startsWith("org.kari.")) { return true; }...

Read more

Calculating JTextComponent -height

Problem: Let’s assume that we know the available width and we should determine what is the required height for JTextComponent within that limitation. This problem arises immediately, at least in three cases in java: Variable row height table cells Tooltip size Message dialog size In all of these cases, it is necessary sometimes to know…

Read more

Eclipse 3.3 is crappy slow

After all it turns out that crap factor has overcome over the usability factor. Basically Eclipse 3.3 contains some improvements to speed things up. However, in reality it’s just slower then 3.2.x. Reason for this strangeness is the fact that Eclipse 3.2, made big speed improvement by starting to use jar packaged plugins. This reduced…

Read more

RMI over zipped stream

If large amounts of compressable data is transferred over RMI, then valid question to ask is if compression would make any benefit there. However, before going into compression of the outputstream, first thing is to do algorithmic changes to reduce traffic. I.e. no compresion can match algorithm which avoids reduntant traffic completely. Also compression adds…

Read more

Pimp the Performance

For Java … Java Tuning White Paper Java Performance Tuning Highlight for today: -XX:+UseBiasedLocking – An object is ”biased” toward the thread which first acquires its monitor via a monitorenter bytecode or synchronized method invocation; subsequent monitor-related operations performed by that thread are relatively much faster on multiprocessor machines. Some applications with significant amounts of…

Read more