jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Hawtin <thaw...@tackline.demon.co.uk>
Subject Re: Question: what version of jdk is bcel 5.1 expected to be run with?
Date Thu, 07 Aug 2003 22:01:58 GMT
Claudio Corsi wrote:
> 
> I have been using this tool to create a byte-code enhancement of created 
> class files and I kept getting a NoSuchMethodError.
> 
> The reason that I get this is because I am running my application with 
> jdk 1.3 and the method that causes this exception is the 
> StringBuffer.append(StringBuffer) method.
> 
> This method does not exist within jdk 1.3 but it is part of the 
> distribution of jdk 1.4.
> 
> The interesting thing about this is that I was able to build the bcel 
> 5.1 source using jdk 1.3!

For any program with code like:

     String s;
     StringBuffer b;
     ...
     b.append(s);

Then using the 1.4 libraries it will compile to using 
StringBuffer.append(String), while 1.3 will use 
StringBuffer.append(Object) (neither of which have very nice threading 
properties, but that's rarely significant). The standard solution is to 
use the 1.3 libraries as the bootclasspath to javac. An easy way to do 
that is to use JDK 1.3, but I'd suggest using 1.4 with -bootclasspath. 
If that's out of your control you can always explicitly choose the other 
append method:

     b.append((Object)s);

Tom Hawtin



Mime
View raw message