You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by Claudio Corsi <cc...@progress.com> on 2003/08/07 17:44:43 UTC
Question: what version of jdk is bcel 5.1 expected to be run with?
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!
That is why I am wondering which jdk is bcel 5.1 suppose to work with.
thanks,
--Claudio
Re: Question: what version of jdk is bcel 5.1 expected to be run with?
Posted by Claudio Corsi <cc...@progress.com>.
Thomas Hawtin wrote:
> 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
>
Tom,
The code in question is LineNumberTable toString method here is the code:
public final String toString() {
StringBuffer buf = new StringBuffer();
StringBuffer line = new StringBuffer();
for(int i=0; i < line_number_table_length; i++) {
line.append(line_number_table[i].toString());
if(i < line_number_table_length - 1)
line.append(", ");
if(line.length() > 72) {
line.append('\n');
buf.append(line); <-------
line.setLength(0);
}
}
buf.append(line);
return buf.toString();
}
The shows use that we are appending a StringBuffer and StringBuffer does
not contain such a method within jdk 1.3. It has been introduced in jdk 1.4.
This will compile with jdk 1.4 and jdk 1.3. I have not javap the code
but I would assume that the jdk 1.3 compiler would call the passed
StringBuffer toString method to allow this to work.
--Claudio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-dev-help@jakarta.apache.org
>
Re: Question: what version of jdk is bcel 5.1 expected to be run
with?
Posted by Thomas Hawtin <th...@tackline.demon.co.uk>.
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