]> source.dussan.org Git - javassist.git/commitdiff
the default major version of newly-created class files is either JDK 1.3 or 1.5,...
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 13 Aug 2007 09:06:31 +0000 (09:06 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 13 Aug 2007 09:06:31 +0000 (09:06 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@402 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/bytecode/ClassFile.java
src/main/javassist/bytecode/LocalVariableAttribute.java

index 4720d289d02ccff9e5b0ad71796956f0b86d8ff5..c087073c325dad217a197318a3bda8d2d039647a 100644 (file)
@@ -65,9 +65,18 @@ public final class ClassFile {
 
     /**
      * The major version number of class files created
-     * from scratch.  The value is 47 (JDK 1.3).
+     * from scratch.  The default value is 47 (JDK 1.3)
+     * or 49 (JDK 1.5) if the JVM supports <code>java.lang.StringBuilder</code>.
      */
-    public static final int MAJOR_VERSION = JAVA_3;
+    public static int MAJOR_VERSION = JAVA_3;
+
+    static {
+        try {
+            Class.forName("java.lang.StringBuilder");
+            MAJOR_VERSION = JAVA_5;
+        }
+        catch (Throwable t) {}
+    }
 
     /**
      * Constructs a class file from a byte stream.
index f1eb203c8474f19f196de9594156af9de383668b..549291374beb6e68f2c3c87b76003d0d7e1afe42 100644 (file)
@@ -260,8 +260,11 @@ public class LocalVariableAttribute extends AttributeInfo {
 
             ByteArray.write16bit(name, dest, j + 4);
 
-            if (type != 0)
-                type = cp.copy(type, newCp, null);
+            if (type != 0)  {
+                String sig = cp.getUtf8Info(type);
+                sig = Descriptor.rename(sig, classnames);
+                type = newCp.addUtf8Info(sig);
+            }
 
             ByteArray.write16bit(type, dest, j + 6);
             ByteArray.write16bit(index, dest, j + 8);