aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Readme.html6
-rw-r--r--javassist.jarbin674459 -> 675068 bytes
-rw-r--r--src/main/javassist/CtClass.java2
-rw-r--r--src/main/javassist/bytecode/stackmap/BasicBlock.java20
-rw-r--r--src/main/javassist/bytecode/stackmap/MapMaker.java22
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java2
-rw-r--r--src/test/javassist/bytecode/StackMapTest.java31
7 files changed, 70 insertions, 13 deletions
diff --git a/Readme.html b/Readme.html
index 1afde361..bdc46af1 100644
--- a/Readme.html
+++ b/Readme.html
@@ -281,6 +281,12 @@ see javassist.Dump.
<h2>Changes</h2>
+<p>-version 3.17.1
+<ul>
+ <li>JIRA JASSIST-177
+</ul>
+
+
<p>-version 3.17 on November 8, 2012
<ul>
<li>OSGi bundle info is now included in the jar file.
diff --git a/javassist.jar b/javassist.jar
index fa0ece44..42b02760 100644
--- a/javassist.jar
+++ b/javassist.jar
Binary files differ
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index bcf61e41..8a3d6b2d 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -69,7 +69,7 @@ public abstract class CtClass {
/**
* The version number of this release.
*/
- public static final String version = "3.17.0-GA";
+ public static final String version = "3.17.1-snapshot";
/**
* Prints the version number and the copyright notice.
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;
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index d5c61bd2..3ea68eb1 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -590,7 +590,7 @@ public class MemberCodeGen extends CodeGen {
if (mname.equals(MethodInfo.nameInit)) {
isSpecial = true;
if (declClass != targetClass)
- throw new CompileError("no such constructor");
+ throw new CompileError("no such constructor: " + targetClass.getName());
if (declClass != thisClass && AccessFlag.isPrivate(acc)) {
desc = getAccessibleConstructor(desc, declClass, minfo);
diff --git a/src/test/javassist/bytecode/StackMapTest.java b/src/test/javassist/bytecode/StackMapTest.java
index c3be2231..1004b29c 100644
--- a/src/test/javassist/bytecode/StackMapTest.java
+++ b/src/test/javassist/bytecode/StackMapTest.java
@@ -13,6 +13,7 @@ import javassist.ClassPool;
import javassist.CodeConverter;
import javassist.CtClass;
import javassist.CtMethod;
+import javassist.CtNewConstructor;
import javassist.CtNewMethod;
import javassist.JvstTest;
import javassist.Loader;
@@ -779,6 +780,36 @@ public class StackMapTest extends TestCase {
assertTrue(two.subtypeOf(objarray));
}
+ public void testJsr() throws Exception {
+ CtClass cc = loader.makeClass("javassist.bytecode.StackMapTestJsrTest");
+ ClassFile cf = cc.getClassFile();
+ cf.setMajorVersion(ClassFile.JAVA_6);
+ ConstPool cp = cf.getConstPool();
+ MethodInfo mi = new MethodInfo(cp, "test", "()I");
+ mi.setAccessFlags(AccessFlag.PUBLIC);
+ Bytecode code = new Bytecode(cp, 1, 3);
+ code.addIconst(3);
+ code.addIstore(1);
+ code.add(Opcode.JSR);
+ code.addIndex(5);
+ code.addIload(1);
+ code.add(Opcode.IRETURN);
+ code.addAstore(2);
+ code.addRet(2);
+ CodeAttribute ca = code.toCodeAttribute();
+ mi.addAttribute(ca);
+ mi.rebuildStackMap(loader);
+ cf.addMethod(mi);
+ cc.addConstructor(CtNewConstructor.make("public StackMapTestJsrTest() {}", cc));
+ cc.addMethod(CtMethod.make("public static void main(String[] args) {"
+ + "new javassist.bytecode.StackMapTestJsrTest().test();"
+ + "}",
+ cc));
+ cc.writeFile();
+ // Object t1 = make(cc.getName());
+ // assertEquals(3, invoke(t1, "test"));
+ }
+
public void tstCtClassType() throws Exception {
ClassPool cp = ClassPool.getDefault();
CtClass cc = cp.get("javassist.CtClassType");