[jboss-cvs] javassist/src/main/javassist/compiler ...
Shigeru Chiba
chiba at is.titech.ac.jp
Tue May 29 05:22:02 EDT 2007
User: chiba
Date: 07/05/29 05:22:02
Modified: src/main/javassist/compiler MemberCodeGen.java
Log:
changed the compiler so that .class will be compiled into ldc.
Revision Changes Path
1.28 +15 -5 javassist/src/main/javassist/compiler/MemberCodeGen.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MemberCodeGen.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/compiler/MemberCodeGen.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- MemberCodeGen.java 12 May 2007 14:45:10 -0000 1.27
+++ MemberCodeGen.java 29 May 2007 09:22:01 -0000 1.28
@@ -24,13 +24,13 @@
/* 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 @@
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 @@
}
protected void atClassObject2(String cname) throws CompileError {
+ if (getMajorVersion() < JAVA5_VER)
super.atClassObject2(cname);
+ else
+ bytecode.addLdc(bytecode.getConstPool().addClassInfo(cname));
}
protected void atFieldPlusPlus(int token, boolean isPost,
More information about the jboss-cvs-commits
mailing list