How to test for the implementation of toString()

Update: This entry has been crossposted to the transylvania-jug blog.

Problem statement: you have some value objects for which you implemented toString() (for debugging purposes) and now you would like to test using a unit test that these implementations exist.

Possible solutions:

  1. Use reflection to detect the existence of the ...

more ...

Comparative book review

Below is a a short comparative review of tow books about Java concurrency which I’ve read in the last couple of months. Disclaier: the Amazon links are affiliate ones.

Java Concurrency in Practice is an interesting book, which should be a must-read for anyone doing concurrent programming in Java ...

more ...


Java Date objects can mutate, even when read

Ran into this problem a couple of months ago, when we saw some strange dates in production. So I dug into the Java library sources (thank you Sun for providing those!) and found that Date objects aren’t always “normalized”. Rather, sometimes a “denormalized” value is stored which is later ...

more ...

Putting the eval into Java

2254800793_185ccbdfa1_b “eval” (short for evaluate) is usually the name given to the method in dynamic languages which makes it possible for the programmer to access the compiler / runtime. Here are a few links to the documentation for the function in different languages:

They are usually ...

more ...

Performance optimization techniques for Java code

Yesterday I gave a presentation at the Transylvania JUG about using profilers and different techniques which you can use to work around the discovered performance problems. Below you can find the embedded presentation.

**http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=java-perf-201003-100326052203-phpapp02&rel=0&stripped\_title=performance-optimization-techniques-for-java-code**

If you are ...

more ...

String.intern() – there are better ways

4349787041_f31a40baf4_o I don’t want to write a “considered harmful” article (because they are harmful), but after experimenting with different solutions I do have a strong opinion that there almost no reason to use String.intern() in Java. But let us proceed step-by-step.

First of all, what does String.intern() do ...

more ...

Java import statement gotcha

190774444_2687512fb9_o There is a lot of debate on the intertubes if one should or shouldn’t use wildcard imports. I’m mostly indifferent to the discussion (mainly because all the package references are resolved compile time – so there is no performance overhead – and because today’s IDE’s contain a lot ...

more ...

Splitting hairs^H^H^H^H^H strings with Java

[![Split Personality](http://farm3.static.flickr.com/2097/2225546021_4864c2bc72.jpg)](http://www.flickr.com/photos/nickwheeleroz/2225546021/ “Split Personality by nickwheeleroz, on Flickr”)

Offtopic: where does \^H come from? (since I too found it only recently) - from the source of all wisdom - Wikipedia :-p

Pressing the backspace key on a ...

more ...

Choosing a Java profiler

Recently I’ve been looking around for a Java profiler (since the two things you need for a successful performance tuning session are good data and clear targets). I’ll share the notes about my findings in the hope that they might be useful for someone. Quick disclaimer: don’t ...

more ...