Without any testing, just seeing that it compiles, following code snippet should allow embedding periodic thread time usage analysis into application. [code lang=”java”] import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** * Thread time usage analyzer */ final class Analyzer extends Thread { /** * Accuraracy of measurement; coarse timing is enough,…
Read moreAnalyzing Byte Cote
So lets see how we can test for ”param is valid type”. Bar [code lang=”java”] public class Bar { } [/code] Test [code lang=”java”] public class Test { private static final Class CLS = Bar.class; public static void test1(Object a) { if (a instanceof Bar) { int x = 0; } } public static void…
Read moreHidden cost of initialization
Trick question: What is difference between these: Sample Code 1 [code lang=”java”] class FooBar { private int x = 0; [/code] Sample Code 2 [code lang=”java”] class FooBar { private int x; [/code] Q: What is difference? I.e. aren’t those pieces of code by definition exactly same, thus it doesn’t matter what you write. A:…
Read moreReal UML
My interest (after trying lots of different tools, Objecteering, ArgoUML, BoUML) into real UML tools was arised with this one: UMLet UMLet allow nice user friendly concept of editing properties of elements direcly as plain text, instead of clumsy dialogs like every other tools what I’d tried so far. However, appetite grows, and this sounds…
Read moreDuh, Don’t, now keep going on…
Seemingly there is eeny-weeny little things what could be optimized in Log4J. Re: Proposed synchronization changes log4j-dev Re: log4j multithreading performance Proposed synchronization changes By quickly looking, changes make sense, only one detail strikes me as potential problem: new logic is causing re-allocation of StringBuffer iin PatternLayout, everytime when formatting of layout is done (==…
Read moreDriving java with handbreak on
Do you driver your car with handbreak on? Doesn’t it feel a bit cumbersome? Well, concurrent programming with java can easily turn into equivalent situation, simply due to fact that some synchronization is required between threads. And sad fact is that there isn’t actually clear workaround for this since correctness of program requires usage of…
Read moreThere is no magic bullets
ORM mapping sounds easy and neat way of managing DB persistency in java. However, in reality it’s not dance with roses. Primarily problem comes from the fact that ORM attempts to hide details, which in reality are crusical for performant and scalable application. People are still writing straight JDBC Code? The Vietnam of Computer Science
Read moreCache locality in java
Not new, but still quite interesting to read: Caching and the Java Virtual Machine References: Thread scheduling implications in Java Use stack variables whenever possible Java bytecode: Understanding bytecode makes you a better programmer The Final Word On the final Keyword Premature Optimization Java theory and practice: Managing volatility How fast is Java Volatile? or…
Read moreMysteries of Nimbus
About defaults in Nimbus: Nimbus Defaults (originates from: Nimbus UIManager UIDefaults) Misc Textarea background issue Update: 10.7.2010 Skinning a Slider with Nimbus
Read moreBeware of Antipatterns
Instead of having ”this proper way”, anti patterns tend to be even more useful by pointing out issues which are problematic. Java Anti-Patterns
Read more