How to force use of StringBuffer instead of StringBuilder by default in javac?

1.1k Views Asked by At

I am trying to compile the CLDC with kvm on linux, I get an error

cannot access java.lang.StringBuilder class file for java.lang.StringBuilder not found

at the statement:

return getClass().getName() + "@" + Integer.toHexString(hashCode());

I think that is because this uses its own bootclasspath which contains StringBuffer but not StringBuilder. Now, how do I force javac to use StringBuffer instead of default StringBuilder?

My dev environment is: Ubuntu 10.04.2 LTS + javac 1.6.0_24 (sun-java6-jdk)

2

There are 2 best solutions below

0
On BEST ANSWER

After googling around a bit more, I found that one can set the target jsr specification with '-target' option to javac. To fix my problem , I had to go back to jsr14 to emit StringBuffer instead of StringBuilder.

javac -target jsr14 *.java

More about this here: http://twit88.com/blog/2008/08/26/java-understanding-jsr14/

1
On

You could try setting the source and object levels to 1.3 or whatever versin was the last one without StringBuilder.