aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-09-09 17:27:32 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-09-09 17:27:32 +0000
commite639e4cf386625a0714d8bb9686b91f943713357 (patch)
treef9c5226819f0ba3c045c68e04a383e759e4109fe
parent6ff64121db30642bcfe4e6dbe3236873d52e8f6f (diff)
downloadjavassist-e639e4cf386625a0714d8bb9686b91f943713357.tar.gz
javassist-e639e4cf386625a0714d8bb9686b91f943713357.zip
fixed JASSIST-132
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@572 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--src/main/javassist/bytecode/stackmap/Tracer.java25
-rw-r--r--src/main/javassist/expr/Cast.java2
-rw-r--r--src/main/javassist/expr/Expr.java4
-rw-r--r--src/main/javassist/expr/FieldAccess.java2
-rw-r--r--src/main/javassist/expr/Handler.java2
-rw-r--r--src/main/javassist/expr/Instanceof.java2
-rw-r--r--src/main/javassist/expr/MethodCall.java2
-rw-r--r--src/main/javassist/expr/NewArray.java2
-rw-r--r--src/main/javassist/expr/NewExpr.java2
-rw-r--r--tutorial/tutorial2.html2
10 files changed, 25 insertions, 20 deletions
diff --git a/src/main/javassist/bytecode/stackmap/Tracer.java b/src/main/javassist/bytecode/stackmap/Tracer.java
index 837257bc..89e788d7 100644
--- a/src/main/javassist/bytecode/stackmap/Tracer.java
+++ b/src/main/javassist/bytecode/stackmap/Tracer.java
@@ -88,17 +88,22 @@ public abstract class Tracer implements TypeTag {
* @return the size of the instruction at POS.
*/
protected int doOpcode(int pos, byte[] code) throws BadBytecode {
- int op = code[pos] & 0xff;
- if (op < 96)
- if (op < 54)
- return doOpcode0_53(pos, code, op);
- else
- return doOpcode54_95(pos, code, op);
- else
- if (op < 148)
- return doOpcode96_147(pos, code, op);
+ try {
+ int op = code[pos] & 0xff;
+ if (op < 96)
+ if (op < 54)
+ return doOpcode0_53(pos, code, op);
+ else
+ return doOpcode54_95(pos, code, op);
else
- return doOpcode148_201(pos, code, op);
+ if (op < 148)
+ return doOpcode96_147(pos, code, op);
+ else
+ return doOpcode148_201(pos, code, op);
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ throw new BadBytecode("inconsistent stack height " + e.getMessage());
+ }
}
protected void visitBranch(int pos, byte[] code, int offset) throws BadBytecode {}
diff --git a/src/main/javassist/expr/Cast.java b/src/main/javassist/expr/Cast.java
index c70df21d..1ef87be2 100644
--- a/src/main/javassist/expr/Cast.java
+++ b/src/main/javassist/expr/Cast.java
@@ -84,7 +84,7 @@ public class Cast extends Expr {
*
* <p>$0 is available but the value is <code>null</code>.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
thisClass.getClassFile(); // to call checkModify().
diff --git a/src/main/javassist/expr/Expr.java b/src/main/javassist/expr/Expr.java
index 56d9edd3..75de54a8 100644
--- a/src/main/javassist/expr/Expr.java
+++ b/src/main/javassist/expr/Expr.java
@@ -264,7 +264,7 @@ public abstract class Expr implements Opcode {
* Replaces this expression with the bytecode derived from
* the given source text.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public abstract void replace(String statement) throws CannotCompileException;
@@ -272,7 +272,7 @@ public abstract class Expr implements Opcode {
* Replaces this expression with the bytecode derived from
* the given source text and <code>ExprEditor</code>.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
* @param recursive if not null, the substituted bytecode
* is recursively processed by the given
* <code>ExprEditor</code>.
diff --git a/src/main/javassist/expr/FieldAccess.java b/src/main/javassist/expr/FieldAccess.java
index 97f3ce14..56ead160 100644
--- a/src/main/javassist/expr/FieldAccess.java
+++ b/src/main/javassist/expr/FieldAccess.java
@@ -144,7 +144,7 @@ public class FieldAccess extends Expr {
* If the field access is writing, $_ is available but the value
* of $_ is ignored.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
thisClass.getClassFile(); // to call checkModify().
diff --git a/src/main/javassist/expr/Handler.java b/src/main/javassist/expr/Handler.java
index 5bed0924..dd7e53f2 100644
--- a/src/main/javassist/expr/Handler.java
+++ b/src/main/javassist/expr/Handler.java
@@ -92,7 +92,7 @@ public class Handler extends Expr {
/**
* This method has not been implemented yet.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
throw new RuntimeException("not implemented yet");
diff --git a/src/main/javassist/expr/Instanceof.java b/src/main/javassist/expr/Instanceof.java
index f85357cf..1ceed134 100644
--- a/src/main/javassist/expr/Instanceof.java
+++ b/src/main/javassist/expr/Instanceof.java
@@ -87,7 +87,7 @@ public class Instanceof extends Expr {
*
* <p>$0 is available but the value is <code>null</code>.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
thisClass.getClassFile(); // to call checkModify().
diff --git a/src/main/javassist/expr/MethodCall.java b/src/main/javassist/expr/MethodCall.java
index 63a5bf9a..9e9d1db5 100644
--- a/src/main/javassist/expr/MethodCall.java
+++ b/src/main/javassist/expr/MethodCall.java
@@ -173,7 +173,7 @@ public class MethodCall extends Expr {
*
* <p>$0 is available even if the called method is static.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
thisClass.getClassFile(); // to call checkModify().
diff --git a/src/main/javassist/expr/NewArray.java b/src/main/javassist/expr/NewArray.java
index 48ebc9f6..c5ac41e6 100644
--- a/src/main/javassist/expr/NewArray.java
+++ b/src/main/javassist/expr/NewArray.java
@@ -153,7 +153,7 @@ public class NewArray extends Expr {
* If the field access is writing, $_ is available but the value
* of $_ is ignored.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
try {
diff --git a/src/main/javassist/expr/NewExpr.java b/src/main/javassist/expr/NewExpr.java
index 353e32cd..c2ab0443 100644
--- a/src/main/javassist/expr/NewExpr.java
+++ b/src/main/javassist/expr/NewExpr.java
@@ -156,7 +156,7 @@ public class NewExpr extends Expr {
*
* <p>$0 is available but the value is null.
*
- * @param statement a Java statement.
+ * @param statement a Java statement except try-catch.
*/
public void replace(String statement) throws CannotCompileException {
thisClass.getClassFile(); // to call checkModify().
diff --git a/tutorial/tutorial2.html b/tutorial/tutorial2.html
index 65be0311..445fc90b 100644
--- a/tutorial/tutorial2.html
+++ b/tutorial/tutorial2.html
@@ -664,7 +664,7 @@ with a block:
<p>so that the first parameter to <code>move()</code> is always 0.
Note that the substituted code is not an expression but
-a statement or a block.
+a statement or a block. It cannot be or contain a try-catch statement.
<p>The method <code>instrument()</code> searches a method body.
If it finds an expression such as a method call, field access, and object