aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/stackmap
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2012-11-15 15:06:33 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2012-11-15 15:06:33 +0000
commit226a8f53e5d26d8a4a5aefcfd09340bbc9caf7ce (patch)
treecc37a3cbb8524ff7cee6acb4fcf366c78bb4bdc8 /src/main/javassist/bytecode/stackmap
parentc135586d0914166b9ec51eef0e5dea07be8c7e95 (diff)
downloadjavassist-226a8f53e5d26d8a4a5aefcfd09340bbc9caf7ce.tar.gz
javassist-226a8f53e5d26d8a4a5aefcfd09340bbc9caf7ce.zip
fixed JASSIST-177
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@686 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/stackmap')
-rw-r--r--src/main/javassist/bytecode/stackmap/BasicBlock.java20
-rw-r--r--src/main/javassist/bytecode/stackmap/MapMaker.java22
2 files changed, 31 insertions, 11 deletions
diff --git a/src/main/javassist/bytecode/stackmap/BasicBlock.java b/src/main/javassist/bytecode/stackmap/BasicBlock.java
index 9afe1a3a..6213e22a 100644
--- a/src/main/javassist/bytecode/stackmap/BasicBlock.java
+++ b/src/main/javassist/bytecode/stackmap/BasicBlock.java
@@ -23,10 +23,14 @@ import java.util.ArrayList;
/**
* A basic block is a sequence of bytecode that does not contain jump/branch
* instructions except at the last bytecode.
- * Since Java6 or later does not allow JSR, this class deals with JSR as a
- * non-branch instruction.
+ * Since Java7 or later does not allow JSR, this class throws an exception when
+ * it finds JSR.
*/
public class BasicBlock {
+ static class JsrBytecode extends BadBytecode {
+ JsrBytecode() { super("JSR"); }
+ }
+
protected int position, length;
protected int incoming; // the number of incoming branches.
protected BasicBlock[] exit; // null if the block is a leaf.
@@ -294,16 +298,18 @@ public class BasicBlock {
makeMark(marks, pos, jumps, size, true);
}
- /**
- * We ignore JSR since Java 6 or later does not allow it.
- */
- protected void makeJsr(HashMap marks, int pos, int target, int size) {
/*
+ * We could ignore JSR since Java 7 or later does not allow it.
+ * See The JVM Spec. Sec. 4.10.2.5.
+ */
+ protected void makeJsr(HashMap marks, int pos, int target, int size) throws BadBytecode {
+ /*
Mark to = makeMark(marks, target);
Mark next = makeMark(marks, pos + size);
BasicBlock[] jumps = makeArray(to.block, next.block);
makeMark(marks, pos, jumps, size, false);
- */
+ */
+ throw new JsrBytecode();
}
private BasicBlock[] makeBlocks(HashMap markTable) {
diff --git a/src/main/javassist/bytecode/stackmap/MapMaker.java b/src/main/javassist/bytecode/stackmap/MapMaker.java
index 3c96a36a..9777ca20 100644
--- a/src/main/javassist/bytecode/stackmap/MapMaker.java
+++ b/src/main/javassist/bytecode/stackmap/MapMaker.java
@@ -82,7 +82,7 @@ public class MapMaker extends Tracer {
/**
* Computes the stack map table of the given method and returns it.
* It returns null if the given method does not have to have a
- * stack map table.
+ * stack map table or it includes JSR.
*/
public static StackMapTable make(ClassPool classes, MethodInfo minfo)
throws BadBytecode
@@ -91,7 +91,14 @@ public class MapMaker extends Tracer {
if (ca == null)
return null;
- TypedBlock[] blocks = TypedBlock.makeBlocks(minfo, ca, true);
+ TypedBlock[] blocks;
+ try {
+ blocks = TypedBlock.makeBlocks(minfo, ca, true);
+ }
+ catch (BasicBlock.JsrBytecode e) {
+ return null;
+ }
+
if (blocks == null)
return null;
@@ -109,7 +116,7 @@ public class MapMaker extends Tracer {
/**
* Computes the stack map table for J2ME.
* It returns null if the given method does not have to have a
- * stack map table.
+ * stack map table or it includes JSR.
*/
public static StackMap make2(ClassPool classes, MethodInfo minfo)
throws BadBytecode
@@ -118,7 +125,14 @@ public class MapMaker extends Tracer {
if (ca == null)
return null;
- TypedBlock[] blocks = TypedBlock.makeBlocks(minfo, ca, true);
+ TypedBlock[] blocks;
+ try {
+ blocks = TypedBlock.makeBlocks(minfo, ca, true);
+ }
+ catch (BasicBlock.JsrBytecode e) {
+ return null;
+ }
+
if (blocks == null)
return null;