This looks to be a problem in javassist rather jboss-retro
The following test class
| public class Test
| {
| public static void main(String[] args) throws Exception
| {
| final StringBuilder s = new StringBuilder("hello");
| System.out.println(s.toString());
| }
| }
|
When run through the following simple javassist program to change the class names
| import java.io.DataInputStream;
| import java.io.DataOutputStream;
| import java.io.FileInputStream;
| import java.io.FileOutputStream;
| import javassist.bytecode.ClassFile;
|
| public class Rename
| {
| public static void main(String[] args) throws Exception
| {
| DataInputStream dis = new DataInputStream(new
FileInputStream("Test.class"));
| ClassFile cf = new ClassFile(dis);
| cf.renameClass("Test", "Test1");
| cf.renameClass("java/lang/StringBuilder",
"test/StringBuilder");
| DataOutputStream dos = new DataOutputStream(new
FileOutputStream("Test1.class"));
| cf.write(dos);
| }
| }
|
Isn't renaming the literal used by the local variable table
I think because it is marked as type "Asciz" rather than "class"?
BEFORE
| $ javap -c -verbose Test
| Compiled from "Test.java"
| public class Test extends java.lang.Object
| SourceFile: "Test.java"
| minor version: 0
| major version: 49
| Constant pool:
| const #1 = Method #9.#20; // java/lang/Object."<init>":()V
| const #2 = class #21; // java/lang/StringBuilder
| const #3 = String #22; // hello
| const #4 = Method #2.#23; //
java/lang/StringBuilder."<init>":(Ljava/lang/String;)V
| const #5 = Field #24.#25; //
java/lang/System.out:Ljava/io/PrintStream;
| const #6 = Method #2.#26; //
java/lang/StringBuilder.toString:()Ljava/lang/String;
| const #7 = Method #27.#28; //
java/io/PrintStream.println:(Ljava/lang/String;)V
| const #8 = class #29; // Test
| const #9 = class #30; // java/lang/Object
| const #10 = Asciz <init>;
| const #11 = Asciz ()V;
| const #12 = Asciz Code;
| const #13 = Asciz LineNumberTable;
| const #14 = Asciz main;
| const #15 = Asciz ([Ljava/lang/String;)V;
| const #16 = Asciz Exceptions;
| const #17 = class #31; // java/lang/Exception
| const #18 = Asciz SourceFile;
| const #19 = Asciz Test.java;
| const #20 = NameAndType #10:#11;// "<init>":()V
| const #21 = Asciz java/lang/StringBuilder;
| const #22 = Asciz hello;
| const #23 = NameAndType #10:#32;// "<init>":(Ljava/lang/String;)V
| const #24 = class #33; // java/lang/System
| const #25 = NameAndType #34:#35;// out:Ljava/io/PrintStream;
| const #26 = NameAndType #36:#37;// toString:()Ljava/lang/String;
| const #27 = class #38; // java/io/PrintStream
| const #28 = NameAndType #39:#32;// println:(Ljava/lang/String;)V
| const #29 = Asciz Test;
| const #30 = Asciz java/lang/Object;
| const #31 = Asciz java/lang/Exception;
| const #32 = Asciz (Ljava/lang/String;)V;
| const #33 = Asciz java/lang/System;
| const #34 = Asciz out;
| const #35 = Asciz Ljava/io/PrintStream;;
| const #36 = Asciz toString;
| const #37 = Asciz ()Ljava/lang/String;;
| const #38 = Asciz java/io/PrintStream;
| const #39 = Asciz println;
|
| {
| public Test();
| Code:
| Stack=1, Locals=1, Args_size=1
| 0: aload_0
| 1: invokespecial #1; //Method java/lang/Object."<init>":()V
| 4: return
| LineNumberTable:
| line 1: 0
|
| public static void main(java.lang.String[]) throws java.lang.Exception;
| Code:
| Stack=3, Locals=2, Args_size=1
| 0: new #2; //class java/lang/StringBuilder
| 3: dup
| 4: ldc #3; //String hello
| 6: invokespecial #4; //Method
java/lang/StringBuilder."<init>":(Ljava/lang/String;)V
| 9: astore_1
| 10: getstatic #5; //Field java/lang/System.out:Ljava/io/PrintStream;
| 13: aload_1
| 14: invokevirtual #6; //Method
java/lang/StringBuilder.toString:()Ljava/lang/String;
| 17: invokevirtual #7; //Method
java/io/PrintStream.println:(Ljava/lang/String;)V
| 20: return
| LineNumberTable:
| line 5: 0
| line 6: 10
| line 7: 20
| Exceptions:
| throws java.lang.Exception
| }
|
AFTER
| [ejort@warjort final-test]$ javap -c -verbose Test1
| Compiled from "Test.java"
| public class Test1 extends java.lang.Object
| SourceFile: "Test.java"
| minor version: 0
| major version: 49
| Constant pool:
| const #1 = Method #9.#20; // java/lang/Object."<init>":()V
| const #2 = class #41; // test/StringBuilder
| const #3 = String #22; // hello
| const #4 = Method #2.#23; //
test/StringBuilder."<init>":(Ljava/lang/String;)V
| const #5 = Field #24.#25; //
java/lang/System.out:Ljava/io/PrintStream;
| const #6 = Method #2.#26; // test/StringBuilder.toString:()Ljava/lang/String;
| const #7 = Method #27.#28; //
java/io/PrintStream.println:(Ljava/lang/String;)V
| const #8 = class #40; // Test1
| const #9 = class #30; // java/lang/Object
| const #10 = Asciz <init>;
| const #11 = Asciz ()V;
| const #12 = Asciz Code;
| const #13 = Asciz LineNumberTable;
| const #14 = Asciz main;
| const #15 = Asciz ([Ljava/lang/String;)V;
| const #16 = Asciz Exceptions;
| const #17 = class #31; // java/lang/Exception
| const #18 = Asciz SourceFile;
| const #19 = Asciz Test.java;
| const #20 = NameAndType #10:#11;// "<init>":()V
| const #21 = Asciz java/lang/StringBuilder;
| const #22 = Asciz hello;
| const #23 = NameAndType #10:#32;// "<init>":(Ljava/lang/String;)V
| const #24 = class #33; // java/lang/System
| const #25 = NameAndType #34:#35;// out:Ljava/io/PrintStream;
| const #26 = NameAndType #36:#37;// toString:()Ljava/lang/String;
| const #27 = class #38; // java/io/PrintStream
| const #28 = NameAndType #39:#32;// println:(Ljava/lang/String;)V
| const #29 = Asciz Test;
| const #30 = Asciz java/lang/Object;
| const #31 = Asciz java/lang/Exception;
| const #32 = Asciz (Ljava/lang/String;)V;
| const #33 = Asciz java/lang/System;
| const #34 = Asciz out;
| const #35 = Asciz Ljava/io/PrintStream;;
| const #36 = Asciz toString;
| const #37 = Asciz ()Ljava/lang/String;;
| const #38 = Asciz java/io/PrintStream;
| const #39 = Asciz println;
| const #40 = Asciz Test1;
| const #41 = Asciz test/StringBuilder;
|
| {
| public Test1();
| Code:
| Stack=1, Locals=1, Args_size=1
| 0: aload_0
| 1: invokespecial #1; //Method java/lang/Object."<init>":()V
| 4: return
| LineNumberTable:
| line 1: 0
|
| public static void main(java.lang.String[]) throws java.lang.Exception;
| Code:
| Stack=3, Locals=2, Args_size=1
| 0: new #2; //class test/StringBuilder
| 3: dup
| 4: ldc #3; //String hello
| 6: invokespecial #4; //Method
test/StringBuilder."<init>":(Ljava/lang/String;)V
| 9: astore_1
| 10: getstatic #5; //Field java/lang/System.out:Ljava/io/PrintStream;
| 13: aload_1
| 14: invokevirtual #6; //Method test/StringBuilder.toString:()Ljava/lang/String;
| 17: invokevirtual #7; //Method
java/io/PrintStream.println:(Ljava/lang/String;)V
| 20: return
| LineNumberTable:
| line 5: 0
| line 6: 10
| line 7: 20
| Exceptions:
| throws java.lang.Exception
| }
|
See the in both:
const #21 = Asciz java/lang/StringBuilder;
So this needs to be raised as a bug in javassist rather than jboss-retro
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4222661#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...