diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2007-06-22 11:50:48 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2007-06-22 11:50:48 +0000 |
commit | 0bc991544790227ea04309acd3f094ee2dddf48f (patch) | |
tree | 1e3b4abdb97b0e115a960192fe5763c2e3d2ceb1 | |
parent | 42a85cc5b90cd0909b7f429f002d702f5ab2a688 (diff) | |
download | javassist-0bc991544790227ea04309acd3f094ee2dddf48f.tar.gz javassist-0bc991544790227ea04309acd3f094ee2dddf48f.zip |
fixed a bug of CtClassType#releaseClassFiles()
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@391 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/expr/Cast.java | 1 | ||||
-rw-r--r-- | src/main/javassist/expr/Expr.java | 5 | ||||
-rw-r--r-- | src/main/javassist/expr/FieldAccess.java | 1 | ||||
-rw-r--r-- | src/main/javassist/expr/Instanceof.java | 1 | ||||
-rw-r--r-- | src/main/javassist/expr/MethodCall.java | 1 | ||||
-rw-r--r-- | src/main/javassist/expr/NewArray.java | 1 | ||||
-rw-r--r-- | src/main/javassist/expr/NewExpr.java | 2 |
7 files changed, 12 insertions, 0 deletions
diff --git a/src/main/javassist/expr/Cast.java b/src/main/javassist/expr/Cast.java index bcce724a..effa8010 100644 --- a/src/main/javassist/expr/Cast.java +++ b/src/main/javassist/expr/Cast.java @@ -87,6 +87,7 @@ public class Cast extends Expr { * @param statement a Java statement. */ public void replace(String statement) throws CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). ConstPool constPool = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); diff --git a/src/main/javassist/expr/Expr.java b/src/main/javassist/expr/Expr.java index 6d9566f9..e21d148d 100644 --- a/src/main/javassist/expr/Expr.java +++ b/src/main/javassist/expr/Expr.java @@ -247,6 +247,11 @@ public abstract class Expr implements Opcode { } } + // The implementation of replace() should call thisClass.checkModify() + // so that isModify() will return true. Otherwise, thisClass.classfile + // might be released during compilation and the compiler might generate + // bytecode with a wrong copy of ConstPool. + /** * Replaces this expression with the bytecode derived from * the given source text. diff --git a/src/main/javassist/expr/FieldAccess.java b/src/main/javassist/expr/FieldAccess.java index 63d2b458..97f3ce14 100644 --- a/src/main/javassist/expr/FieldAccess.java +++ b/src/main/javassist/expr/FieldAccess.java @@ -147,6 +147,7 @@ public class FieldAccess extends Expr { * @param statement a Java statement. */ public void replace(String statement) throws CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). ConstPool constPool = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); diff --git a/src/main/javassist/expr/Instanceof.java b/src/main/javassist/expr/Instanceof.java index cdc9ce93..b5de1b97 100644 --- a/src/main/javassist/expr/Instanceof.java +++ b/src/main/javassist/expr/Instanceof.java @@ -90,6 +90,7 @@ public class Instanceof extends Expr { * @param statement a Java statement. */ public void replace(String statement) throws CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). ConstPool constPool = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); diff --git a/src/main/javassist/expr/MethodCall.java b/src/main/javassist/expr/MethodCall.java index 2a9a891a..63a5bf9a 100644 --- a/src/main/javassist/expr/MethodCall.java +++ b/src/main/javassist/expr/MethodCall.java @@ -176,6 +176,7 @@ public class MethodCall extends Expr { * @param statement a Java statement. */ public void replace(String statement) throws CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). ConstPool constPool = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); diff --git a/src/main/javassist/expr/NewArray.java b/src/main/javassist/expr/NewArray.java index 44ba80f9..48ebc9f6 100644 --- a/src/main/javassist/expr/NewArray.java +++ b/src/main/javassist/expr/NewArray.java @@ -170,6 +170,7 @@ public class NewArray extends Expr { throws CompileError, NotFoundException, BadBytecode, CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). ConstPool constPool = getConstPool(); int pos = currentPos; CtClass retType; diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java index c37a021a..0552ba9e 100644 --- a/src/main/javassist/expr/NewExpr.java +++ b/src/main/javassist/expr/NewExpr.java @@ -160,6 +160,8 @@ public class NewExpr extends Expr { * @param statement a Java statement. */ public void replace(String statement) throws CannotCompileException { + thisClass.getClassFile(); // to call checkModify(). + final int bytecodeSize = 3; int pos = newPos; |