-
Small programming tips
A quickpost inspired by issues I encountered recently. How to concatenate (aggregate) strings with PostgreSQL? In MySQL you can write: SELECT concat(name) FROM test_table Because concat also works as an aggregate function (like MIN, MAX, SUM, COUNT, etc). To get the equivalent result in PostgreSQL, you can use the following query (based on ideas from…
-
Repetitive testcases with jUnit
-
Random Java blogging
-
Watch out for long running tasks with Java Timer
The problem? Write a code which will execute every N seconds. The solution? Using a Timer with scheduleAtFixedRate. Now you got two problems :-), unless you’ve carefully read the documentation which states (emphasis added): If an execution is delayed for any reason (such as garbage collection or other background activity), two or more executions will…
-
Java numerical calculation benchmark
Update: it seems that the JITting process has improved quite a bit these last years (which is to be expected), and the differences are much smaller (and in some cases in favor of Java). Also, the discussion below is to be understood in the context of trigonometric functions rather than floating point operations in general.…
-
Privacy risks of signed Java applets
-
Negative zero – what is it?
Computers have two ways of representing numbers: One is called sign and magnitude – usually you have one bit specifying the sign (again, most of time you have 0 for positive and 1 for negative) and the rest of the bits specify the absolute value (“magnitude”) of the number. The other is ordering the numbers…
-
If you have problems using SVN with Eclipse…
make sure that you’ve installed the JavaHL Adapter. Otherwise you will get messages saying: Unable to load default SVN Client JavaHL seems to be the actual bingding to the Subversion, so it is really a mystery to me why it isn’t marked as a dependency for subeclipse… Related blogposts which pointed me in the right…
-
Curious Eclipse (Java?) bug…
It seems that watchpoints are not triggered if the field is changed using reflection. A simple test program to demonstrate this: import java.lang.reflect.*; public class ReflectMe { public static int foo = 1; //*1 public void test() throws Exception { foo = 2; //*2 Class c = Class.forName(“ReflectMe”); Field f = c.getField(“foo”); f.setInt(this, 10); //*3…
-
The big java regex shoutout
I discovered recently that the built-in java regex library has problems with some expressions, so I set out to find alternatives. Searching for regex benchmarks, I found the following page: Java Regular expression library benchmarks (it also has an older version). The original IBM article also contains a benchmark. However both of these resources are…