Menu

#75 Incorrect decompilation of String.append(char[])

open
nobody
decompiler (49)
5
2005-03-27
2005-03-27
Anonymous
No

JODE successfully decompiles the following code (no runtime
errors). However the decompiled code is not equivalent to the original
code (running the decompiled code prints different results than
running the original code).

ORIGINAL CODE:
public class ConcatenateCharArray {
public static void main(String[] args) {
char[] abc = new char[] {'a', 'b', 'c'};
System.out.println(
new StringBuffer().
append("char array: ").
append((Object) abc).
toString());
System.out.println(
new StringBuffer().
append("char array: ").
append((char[]) abc). // char[] cast important
toString());
}
}

JODE CODE:
public class ConcatenateCharArray
{
public static void main(String[] strings) {
char[] cs = { 'a', 'b', 'c' };
System.out.println("char array: " + (Object) cs); // correct;
cast is unnecessary, however
System.out.println("char array: " + cs); // INCORRECT
}
}

CONTACT E-MAIL:
"davidfstr at earthlink dot net" (to confuse spam bots - hopefully)

Discussion


Log in to post a comment.