summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2020-07-13 09:02:22 +0900
committerchibash <chiba@javassist.org>2020-07-13 09:02:22 +0900
commitda043b46bc20f3a186bd0434dad617f7a71b98de (patch)
treef2c087faea0e08d6dca9d929853b4e5adaa50e39 /src
parent5e3b6a8f64a291ac98f1b50cb82da4cc1cff8f90 (diff)
downloadjavassist-da043b46bc20f3a186bd0434dad617f7a71b98de.tar.gz
javassist-da043b46bc20f3a186bd0434dad617f7a71b98de.zip
fixes a bug of javassist.bytecode.stackmap, which was reported as Issue #328.
Diffstat (limited to 'src')
-rw-r--r--src/main/javassist/bytecode/stackmap/TypeData.java14
-rw-r--r--src/test/javassist/bytecode/StackMapTest.java18
2 files changed, 30 insertions, 2 deletions
diff --git a/src/main/javassist/bytecode/stackmap/TypeData.java b/src/main/javassist/bytecode/stackmap/TypeData.java
index 9bc837d3..4762eb85 100644
--- a/src/main/javassist/bytecode/stackmap/TypeData.java
+++ b/src/main/javassist/bytecode/stackmap/TypeData.java
@@ -206,7 +206,12 @@ public abstract class TypeData {
}
@Override
- public boolean eq(TypeData d) { return getName().equals(d.getName()); }
+ public boolean eq(TypeData d) {
+ if (d.isUninit())
+ return d.eq(this);
+ else
+ return getName().equals(d.getName());
+ }
}
/* a type variable representing a class type or a basic type.
@@ -853,7 +858,12 @@ public abstract class TypeData {
}
@Override
- public boolean eq(TypeData d) { return name.equals(d.getName()); }
+ public boolean eq(TypeData d) {
+ if (d.isUninit())
+ return d.eq(this);
+ else
+ return name.equals(d.getName());
+ }
@Override
public void setType(String typeName, ClassPool cp) throws BadBytecode {}
diff --git a/src/test/javassist/bytecode/StackMapTest.java b/src/test/javassist/bytecode/StackMapTest.java
index 153f75ac..07ee50be 100644
--- a/src/test/javassist/bytecode/StackMapTest.java
+++ b/src/test/javassist/bytecode/StackMapTest.java
@@ -12,6 +12,7 @@ import java.lang.reflect.Method;
import javassist.ClassPool;
import javassist.CodeConverter;
import javassist.CtClass;
+import javassist.CtConstructor;
import javassist.CtMethod;
import javassist.CtNewConstructor;
import javassist.CtNewMethod;
@@ -830,4 +831,21 @@ public class StackMapTest extends TestCase {
return null;
}
+
+ public static class C7 {
+ public int value;
+ public static int value2;
+ public C7() { this(3); }
+ public C7(int i) {
+ value = i;
+ }
+ }
+
+ public void testIssue328() throws Exception {
+ CtClass cc = loader.get("javassist.bytecode.StackMapTest$C7");
+ CtConstructor cons = cc.getDeclaredConstructor(new CtClass[] { CtClass.intType });
+ cons.insertBefore("if ($1 < 0) { super(); if (value2 > 0) { value2++; } return; }");
+ cc.writeFile();
+ Object t1 = make(cc.getName());
+ }
}