aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2007-05-29 09:22:02 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2007-05-29 09:22:02 +0000
commit33ce6656c3b8c08be8d9b9d7fdc4b70e7f290ecc (patch)
tree6e6a022872d11fa48a9dc3e88a8b942c2f8c49c5 /src/main
parent2cecffb9c750eeb468700e90a00710821ad534c3 (diff)
downloadjavassist-33ce6656c3b8c08be8d9b9d7fdc4b70e7f290ecc.tar.gz
javassist-33ce6656c3b8c08be8d9b9d7fdc4b70e7f290ecc.zip
changed the compiler so that .class will be compiled into ldc.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@376 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main')
-rw-r--r--src/main/javassist/bytecode/stackmap/TypeData.java2
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java20
2 files changed, 16 insertions, 6 deletions
diff --git a/src/main/javassist/bytecode/stackmap/TypeData.java b/src/main/javassist/bytecode/stackmap/TypeData.java
index 6c073702..ee2f296a 100644
--- a/src/main/javassist/bytecode/stackmap/TypeData.java
+++ b/src/main/javassist/bytecode/stackmap/TypeData.java
@@ -113,7 +113,7 @@ public abstract class TypeData {
}
protected void setType(String s, ClassPool cp) throws BadBytecode {
- throw new BadBytecode("conflict:" + name + " and " + s);
+ throw new BadBytecode("conflict: " + name + " and " + s);
}
public String toString() { return name; }
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index 225844f9..bd77b878 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -24,13 +24,13 @@ import java.util.ArrayList;
/* Code generator methods depending on javassist.* classes.
*/
public class MemberCodeGen extends CodeGen {
+ public static final int JAVA1_VER = 45;
public static final int JAVA5_VER = 49;
public static final int JAVA6_VER = 50;
protected MemberResolver resolver;
protected CtClass thisClass;
protected MethodInfo thisMethod;
- protected int version; // the major version of a class file.
protected boolean resultStatic;
@@ -39,11 +39,18 @@ public class MemberCodeGen extends CodeGen {
resolver = new MemberResolver(cp);
thisClass = cc;
thisMethod = null;
- ClassFile cf = cc.getClassFile2();
+ }
+
+ /**
+ * Returns the major version of the class file
+ * targeted by this compilation.
+ */
+ public int getMajorVersion() {
+ ClassFile cf = thisClass.getClassFile2();
if (cf == null)
- version = 0;
+ return JAVA1_VER;
else
- version = cf.getMajorVersion();
+ return cf.getMajorVersion();
}
/**
@@ -918,7 +925,10 @@ public class MemberCodeGen extends CodeGen {
}
protected void atClassObject2(String cname) throws CompileError {
- super.atClassObject2(cname);
+ if (getMajorVersion() < JAVA5_VER)
+ super.atClassObject2(cname);
+ else
+ bytecode.addLdc(bytecode.getConstPool().addClassInfo(cname));
}
protected void atFieldPlusPlus(int token, boolean isPost,