summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2012-10-06 14:47:31 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2012-10-06 14:47:31 +0000
commit3ab8b841312f792dc64016800193cb1b0368a9f9 (patch)
tree981c95a6f1657ea8289be88ef2cc7cc7877fa916
parenteffbfdc89cd7cb85127319b5951871dbefec5ea3 (diff)
downloadjavassist-3ab8b841312f792dc64016800193cb1b0368a9f9.tar.gz
javassist-3ab8b841312f792dc64016800193cb1b0368a9f9.zip
fixed JASSIST-160
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@672 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--Readme.html2
-rw-r--r--javassist.jarbin698321 -> 698340 bytes
-rw-r--r--src/main/javassist/bytecode/CodeIterator.java6
-rw-r--r--src/main/javassist/bytecode/stackmap/Tracer.java9
-rw-r--r--src/main/javassist/bytecode/stackmap/TypeData.java4
-rw-r--r--src/test/javassist/bytecode/StackMapTest.java34
-rw-r--r--src/test/test4/InvokeDyn.java14
7 files changed, 62 insertions, 7 deletions
diff --git a/Readme.html b/Readme.html
index 353cb4b2..72933367 100644
--- a/Readme.html
+++ b/Readme.html
@@ -7,7 +7,7 @@
<h1>Javassist version 3</h1>
-<h3>Copyright (C) 1999-2011 by Shigeru Chiba, All rights reserved.</h3>
+<h3>Copyright (C) 1999-2012 by Shigeru Chiba, All rights reserved.</h3>
<p><br></p>
diff --git a/javassist.jar b/javassist.jar
index 719a322e..ec0b29a9 100644
--- a/javassist.jar
+++ b/javassist.jar
Binary files differ
diff --git a/src/main/javassist/bytecode/CodeIterator.java b/src/main/javassist/bytecode/CodeIterator.java
index 0c5db6ff..a1d882e0 100644
--- a/src/main/javassist/bytecode/CodeIterator.java
+++ b/src/main/javassist/bytecode/CodeIterator.java
@@ -27,10 +27,14 @@ import java.util.ArrayList;
* the following code substitutes the <code>NOP</code> instruction for the first
* instruction of the method:
*
- * <pre>CodeAttribute ca = method.getMethodInfo().getCodeAttribute();
+ * <pre>
+ * CodeAttribute ca = method.getMethodInfo().getCodeAttribute();
* CodeIterator ci = ca.iterator();
* ci.writeByte(Opcode.NOP, 0);</pre>
*
+ * <p>To visit every instruction, call {@link #next()} on a <code>CodeIterator</code>.
+ * It returns the index of the first byte of the next instruction.
+ *
* <p>If there are multiple <code>CodeIterator</code>s referring to the
* same <code>Code_attribute</code>, then inserting a gap by one
* <code>CodeIterator</code> will break the other
diff --git a/src/main/javassist/bytecode/stackmap/Tracer.java b/src/main/javassist/bytecode/stackmap/Tracer.java
index 1bacd09c..e5216165 100644
--- a/src/main/javassist/bytecode/stackmap/Tracer.java
+++ b/src/main/javassist/bytecode/stackmap/Tracer.java
@@ -803,7 +803,9 @@ public abstract class Tracer implements TypeTag {
String className = cpool.getMethodrefClassName(i);
TypeData target = stackTypes[--stackTop];
if (target instanceof TypeData.UninitTypeVar && target.isUninit())
- constructorCalled((TypeData.UninitTypeVar)target);
+ constructorCalled(target, ((TypeData.UninitTypeVar)target).offset());
+ else if (target instanceof TypeData.UninitData)
+ constructorCalled(target, ((TypeData.UninitData)target).offset());
target.setType(className, classPool);
}
@@ -814,9 +816,10 @@ public abstract class Tracer implements TypeTag {
/* This is a constructor call on an uninitialized object.
* Sets flags of other references to that object.
+ *
+ * @param offset the offset where the object has been created.
*/
- private void constructorCalled(TypeData.UninitTypeVar target) {
- int offset = target.offset();
+ private void constructorCalled(TypeData target, int offset) {
target.constructorCalled(offset);
for (int i = 0; i < stackTop; i++)
stackTypes[i].constructorCalled(offset);
diff --git a/src/main/javassist/bytecode/stackmap/TypeData.java b/src/main/javassist/bytecode/stackmap/TypeData.java
index d77f6a55..6428335d 100644
--- a/src/main/javassist/bytecode/stackmap/TypeData.java
+++ b/src/main/javassist/bytecode/stackmap/TypeData.java
@@ -745,11 +745,13 @@ public abstract class TypeData {
public void setType(String typeName, ClassPool cp) throws BadBytecode {
super.setType(typeName, cp);
- initialized = true;
+ // initialized = true;
}
public String toString() { return "uninit:" + getName() + "@" + offset; }
+ public int offset() { return offset; }
+
public void constructorCalled(int offset) {
if (offset == this.offset)
initialized = true;
diff --git a/src/test/javassist/bytecode/StackMapTest.java b/src/test/javassist/bytecode/StackMapTest.java
index 4b9339d7..4714f7aa 100644
--- a/src/test/javassist/bytecode/StackMapTest.java
+++ b/src/test/javassist/bytecode/StackMapTest.java
@@ -529,6 +529,7 @@ public class StackMapTest extends TestCase {
public static class T8dd {
java.util.List foo(String s) { return new java.util.ArrayList(); }
}
+
public static class T8d {
static T8dd helper() { return new T8dd(); }
int integer() { return 9; }
@@ -588,6 +589,39 @@ public class StackMapTest extends TestCase {
}
}
+ public void testInnerClass() throws Exception {
+ CtClass cc = loader.get("javassist.bytecode.StackMapTest$T9");
+ CtClass par = loader.get("javassist.bytecode.StackMapTest$T9$Parent");
+ CtClass in = loader.get("javassist.bytecode.StackMapTest$T9$In");
+ rebuildStackMaps2(cc);
+ rebuildStackMaps2(par);
+ rebuildStackMaps2(in);
+ cc.writeFile();
+ in.writeFile();
+ par.writeFile();
+ Object t1 = make(cc.getName());
+ assertEquals(19, invoke(t1, "test"));
+ }
+
+ public static class T9 {
+ class Parent {
+ int f;
+ Parent(int i) { f = i; }
+ }
+ class In extends Parent {
+ int value;
+ public In(int i) {
+ super(i > 0 ? 10 : 20);
+ value = i;
+ }
+ }
+
+ public int test() {
+ In in = new In(9);
+ return in.value + in.f;
+ }
+ }
+
public void tstCtClassType() throws Exception {
ClassPool cp = ClassPool.getDefault();
CtClass cc = cp.get("javassist.CtClassType");
diff --git a/src/test/test4/InvokeDyn.java b/src/test/test4/InvokeDyn.java
index 5e5f0c01..fbcba64d 100644
--- a/src/test/test4/InvokeDyn.java
+++ b/src/test/test4/InvokeDyn.java
@@ -4,11 +4,23 @@ import java.lang.invoke.*;
public class InvokeDyn {
public static int test9(int i, String s) { return 9; }
+ public int test8(int i, String s) { return 8; }
- public static CallSite boot(MethodHandles.Lookup caller, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ public static CallSite boot(MethodHandles.Lookup caller, String name, MethodType type)
+ throws NoSuchMethodException, IllegalAccessException
+ {
MethodHandles.Lookup lookup = MethodHandles.lookup();
Class thisClass = lookup.lookupClass();
MethodHandle method = lookup.findStatic(thisClass, "test9", MethodType.methodType(int.class, int.class, String.class));
return new ConstantCallSite(method);
}
+
+ public CallSite boot2(MethodHandles.Lookup caller, String name, MethodType type)
+ throws NoSuchMethodException, IllegalAccessException
+ {
+ MethodHandles.Lookup lookup = MethodHandles.lookup();
+ Class thisClass = lookup.lookupClass();
+ MethodHandle method = lookup.findVirtual(thisClass, "test8", MethodType.methodType(int.class, int.class, String.class));
+ return new ConstantCallSite(method.asType(MethodType.methodType(int.class, Object.class, int.class, String.class)));
+ }
}