aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/test4
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-08-31 10:29:34 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-08-31 10:29:34 +0000
commitd72870bfb6b09927e10944bdd129ce18dfcf7366 (patch)
tree27f56e4d1523a8cecc8976df60155e6b8429e504 /src/test/test4
parent76a1cba9c433e8242bb6648e72b3ed43c7a4995a (diff)
downloadjavassist-d72870bfb6b09927e10944bdd129ce18dfcf7366.tar.gz
javassist-d72870bfb6b09927e10944bdd129ce18dfcf7366.zip
JvstTest test case.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@589 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/test/test4')
-rw-r--r--src/test/test4/Anno.java6
-rw-r--r--src/test/test4/Anno1.java5
-rw-r--r--src/test/test4/CodeConv.java19
-rw-r--r--src/test/test4/CodeConv2.java39
-rw-r--r--src/test/test4/CtArrayTest.java4
-rw-r--r--src/test/test4/GapSwitch.java83
-rw-r--r--src/test/test4/GetAllRef.java33
-rw-r--r--src/test/test4/GetAllRefAnno2.java6
-rw-r--r--src/test/test4/GetAllRefEnum2.java3
-rw-r--r--src/test/test4/GetAllRefInnerTest.java26
-rw-r--r--src/test/test4/GetFieldDesc.java11
-rw-r--r--src/test/test4/ImportPac.java4
-rw-r--r--src/test/test4/JIRA93.java5
-rw-r--r--src/test/test4/LocalVars.java60
-rw-r--r--src/test/test4/MakeMethod.java7
-rw-r--r--src/test/test4/NestedClass.java29
-rw-r--r--src/test/test4/NewImportPac.java4
-rw-r--r--src/test/test4/NewRemover.java30
-rw-r--r--src/test/test4/Rename.java24
-rw-r--r--src/test/test4/Signature.java16
-rw-r--r--src/test/test4/VarArgs.java15
-rw-r--r--src/test/test4/length.java5
22 files changed, 434 insertions, 0 deletions
diff --git a/src/test/test4/Anno.java b/src/test/test4/Anno.java
new file mode 100644
index 00000000..336d4e6f
--- /dev/null
+++ b/src/test/test4/Anno.java
@@ -0,0 +1,6 @@
+package test4;
+
+@Anno1 public class Anno {
+ @Anno1 public int value;
+ @Anno1 public int foo() { return 0; }
+}
diff --git a/src/test/test4/Anno1.java b/src/test/test4/Anno1.java
new file mode 100644
index 00000000..d368ecc1
--- /dev/null
+++ b/src/test/test4/Anno1.java
@@ -0,0 +1,5 @@
+package test4;
+
+public @interface Anno1 {
+ String value() default "empty";
+}
diff --git a/src/test/test4/CodeConv.java b/src/test/test4/CodeConv.java
new file mode 100644
index 00000000..548c1d2c
--- /dev/null
+++ b/src/test/test4/CodeConv.java
@@ -0,0 +1,19 @@
+package test4;
+
+public class CodeConv {
+ int k = 1;
+ public int m1() {
+ return k + 10;
+ }
+ public int m2() {
+ return k + 100;
+ }
+ public static void m3(CodeConv cc) {
+ cc.k++;
+ }
+
+ public int run() {
+ int i = m1() * 1000 + m2();
+ return k + i * 10;
+ }
+}
diff --git a/src/test/test4/CodeConv2.java b/src/test/test4/CodeConv2.java
new file mode 100644
index 00000000..3a4ce036
--- /dev/null
+++ b/src/test/test4/CodeConv2.java
@@ -0,0 +1,39 @@
+package test4;
+
+public class CodeConv2 {
+ int field = 3;
+ static int sf = 1;
+
+ public int run() {
+ field = 7;
+ sf = 8;
+ switch (field) {
+ case 0:
+ field = 1;
+ break;
+ default:
+ }
+ int r = field * 10000 + sf;
+ switch (field) {
+ case 0:
+ field = 1;
+ break;
+ default:
+ }
+ return r;
+ }
+
+ public static void write(Object target, int value) {
+ if (target == null)
+ sf = value * 2;
+ else
+ ((CodeConv2)target).field = value * 2;
+ }
+
+ public static int read(Object target) {
+ if (target == null)
+ return sf * 100;
+ else
+ return ((CodeConv2)target).field * 100;
+ }
+}
diff --git a/src/test/test4/CtArrayTest.java b/src/test/test4/CtArrayTest.java
new file mode 100644
index 00000000..3967d4bd
--- /dev/null
+++ b/src/test/test4/CtArrayTest.java
@@ -0,0 +1,4 @@
+package test4;
+
+public abstract class CtArrayTest {
+}
diff --git a/src/test/test4/GapSwitch.java b/src/test/test4/GapSwitch.java
new file mode 100644
index 00000000..126bbdf9
--- /dev/null
+++ b/src/test/test4/GapSwitch.java
@@ -0,0 +1,83 @@
+package test4;
+
+public class GapSwitch {
+ public int value;
+ public int foo(int i) { return i + 1; }
+ public int run() {
+ value = 0;
+ int k = 0;
+ k = foo(k);
+ switch (value) {
+ case 0:
+ k++;
+ break;
+ case 1:
+ k *= 10;
+ break;
+ default:
+ k *= 100;
+ break;
+ }
+
+ return k + value * 1000;
+ }
+
+ public int run2() {
+ value = 0;
+ int k = 0;
+ k = foo(k);
+ switch (value) {
+ case 10:
+ k++;
+ break;
+ case 1300:
+ k *= 10;
+ break;
+ default:
+ k *= 100;
+ break;
+ }
+
+ return k + value * 1000;
+ }
+
+ public int run3() {
+ value = 1;
+ int k = 0;
+ for (int i = 0; i < 2; i++) {
+ k = foo(k);
+ switch (value) {
+ case 10:
+ k++;
+ k = foo(k);
+ break;
+ case 1300:
+ k *= 100;
+ k = foo(k);
+ break;
+ default:
+ k *= 10;
+ k = foo(k);
+ break;
+ }
+
+ k = foo(k);
+ switch (value) {
+ case 10:
+ k++;
+ k = foo(k);
+ break;
+ case 13:
+ k *= 100;
+ k = foo(k);
+ break;
+ default:
+ k *= 10;
+ k = foo(k);
+ break;
+ }
+ }
+
+ return k + value;
+ }
+}
diff --git a/src/test/test4/GetAllRef.java b/src/test/test4/GetAllRef.java
new file mode 100644
index 00000000..c19bfabd
--- /dev/null
+++ b/src/test/test4/GetAllRef.java
@@ -0,0 +1,33 @@
+package test4;
+
+enum GetAllRefEnum { A, B };
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface GetAllRefAnno {
+ GetAllRefEnum getA();
+ Class getC();
+}
+
+@interface GetAllRefAnnoC {}
+
+@interface GetAllRefAnnoC2 {}
+
+@interface GetAllRefAnnoC3 {}
+
+@interface GetAllRefAnnoC4 {}
+
+@GetAllRefAnno(getA = GetAllRefEnum.A, getC = String.class)
+public class GetAllRef {
+}
+
+@GetAllRefAnno(getA = GetAllRefEnum.A, getC = String.class)
+class GetAllRefB {
+}
+
+@GetAllRefAnno(getA = GetAllRefEnum.A, getC = String.class)
+class GetAllRefC {
+ void bar(@GetAllRefAnnoC3 int i, int j,
+ @GetAllRefAnnoC2 @GetAllRefAnnoC4 boolean b) {}
+ @GetAllRefAnnoC void foo() {}
+ @GetAllRefAnnoC2 int value;
+}
diff --git a/src/test/test4/GetAllRefAnno2.java b/src/test/test4/GetAllRefAnno2.java
new file mode 100644
index 00000000..dcb0956b
--- /dev/null
+++ b/src/test/test4/GetAllRefAnno2.java
@@ -0,0 +1,6 @@
+package test4;
+
+public @interface GetAllRefAnno2 {
+ GetAllRefEnum2 getA();
+ Class getC();
+}
diff --git a/src/test/test4/GetAllRefEnum2.java b/src/test/test4/GetAllRefEnum2.java
new file mode 100644
index 00000000..d6cf6292
--- /dev/null
+++ b/src/test/test4/GetAllRefEnum2.java
@@ -0,0 +1,3 @@
+package test4;
+
+public enum GetAllRefEnum2 { A, B }
diff --git a/src/test/test4/GetAllRefInnerTest.java b/src/test/test4/GetAllRefInnerTest.java
new file mode 100644
index 00000000..352b3252
--- /dev/null
+++ b/src/test/test4/GetAllRefInnerTest.java
@@ -0,0 +1,26 @@
+package test4;
+
+class GetAllRefInnerTest2<T> {
+ Class clazz;
+ T value;
+ void foo(T t) { value = t; }
+ Object poi(T t) {
+ return new Object() {
+ public String toString(T t) { return this.getClass().toString(); }
+ };
+ }
+}
+
+public class GetAllRefInnerTest<T> {
+ public T bar(T b) {
+ Object obj = new GetAllRefInnerTest2<java.util.HashMap>() {
+ void foo(java.util.HashMap a) { value = null; String s = clazz.toString() + a.toString(); }
+ };
+ return b;
+ }
+ public Object foo() {
+ return new java.util.HashSet<String>() {
+ public String toString() { return this.getClass().toString(); }
+ };
+ }
+}
diff --git a/src/test/test4/GetFieldDesc.java b/src/test/test4/GetFieldDesc.java
new file mode 100644
index 00000000..605e2ad1
--- /dev/null
+++ b/src/test/test4/GetFieldDesc.java
@@ -0,0 +1,11 @@
+package test4;
+
+public class GetFieldDesc {
+ public int f;
+ public String s;
+}
+
+class GetFieldDescSub extends GetFieldDesc {
+ public int f;
+ public int s;
+}
diff --git a/src/test/test4/ImportPac.java b/src/test/test4/ImportPac.java
new file mode 100644
index 00000000..c6127c9c
--- /dev/null
+++ b/src/test/test4/ImportPac.java
@@ -0,0 +1,4 @@
+package test4;
+
+public class ImportPac {
+}
diff --git a/src/test/test4/JIRA93.java b/src/test/test4/JIRA93.java
new file mode 100644
index 00000000..2d94710f
--- /dev/null
+++ b/src/test/test4/JIRA93.java
@@ -0,0 +1,5 @@
+package test4;
+
+public class JIRA93 {
+ public void foo() {}
+}
diff --git a/src/test/test4/LocalVars.java b/src/test/test4/LocalVars.java
new file mode 100644
index 00000000..17ab6cd1
--- /dev/null
+++ b/src/test/test4/LocalVars.java
@@ -0,0 +1,60 @@
+package test4;
+
+public class LocalVars {
+ public int run() {
+ int i = 0;
+ int p = i;
+ int q = p;
+ int r = q;
+ for (int k = 1; k < 3; ++k)
+ p += k;
+
+ for (int k = 3; k > 0; --k)
+ try {
+ foo(k);
+ p++;
+ }
+ finally {
+ p++;
+ }
+
+ switch (p) {
+ case 1:
+ p = 100;
+ break;
+ default :
+ ++p;
+ }
+ return p + r;
+ }
+
+ public int run2() {
+ int i = 0;
+ int p = i;
+ int q = p;
+ int r = q;
+ for (int k = 1; k < 3; ++k)
+ p += k;
+
+ for (int k = 3; k > 0; --k)
+ try {
+ foo(k);
+ p++;
+ }
+ finally {
+ p++;
+ }
+
+ switch (p) {
+ case 1:
+ p = 100;
+ break;
+ default :
+ ++p;
+ }
+
+ return p + r;
+ }
+
+ public int foo(int i) { return i; }
+}
diff --git a/src/test/test4/MakeMethod.java b/src/test/test4/MakeMethod.java
new file mode 100644
index 00000000..4b9bb24c
--- /dev/null
+++ b/src/test/test4/MakeMethod.java
@@ -0,0 +1,7 @@
+package test4;
+
+public class MakeMethod {
+ public static final String foo() {
+ return "foo";
+ }
+}
diff --git a/src/test/test4/NestedClass.java b/src/test/test4/NestedClass.java
new file mode 100644
index 00000000..3e18f7a3
--- /dev/null
+++ b/src/test/test4/NestedClass.java
@@ -0,0 +1,29 @@
+package test4;
+
+public class NestedClass {
+ public S.S2 s2;
+ public class N {
+ public String toString() { return "N"; }
+ }
+ public static class S {
+ public String toString() { return "S"; }
+ public static class S2 {
+ public String toString() { return "S2"; }
+ }
+ }
+ public Object foo() {
+ class In {
+ public String toString() { return "S"; }
+ public String toString2() { return new S().toString(); }
+ }
+ return new Object() {
+ public String toString() {
+ return new Object() {
+ public String toString() {
+ return "ok";
+ }
+ }.toString();
+ }
+ };
+ }
+}
diff --git a/src/test/test4/NewImportPac.java b/src/test/test4/NewImportPac.java
new file mode 100644
index 00000000..fa9f4ac3
--- /dev/null
+++ b/src/test/test4/NewImportPac.java
@@ -0,0 +1,4 @@
+package test4;
+
+public class NewImportPac {
+}
diff --git a/src/test/test4/NewRemover.java b/src/test/test4/NewRemover.java
new file mode 100644
index 00000000..ff57ce2d
--- /dev/null
+++ b/src/test/test4/NewRemover.java
@@ -0,0 +1,30 @@
+package test4;
+
+public class NewRemover {
+ static NewRemover obj = new NewRemover(7);
+ int value;
+ static int value2 = 5;
+
+ public NewRemover() {
+ this(3);
+ }
+
+ public NewRemover(int k) {
+ value = k;
+ }
+
+ public int run() {
+ return make();
+ }
+
+ public int make() {
+ NewRemover nr = new NewRemover(value2 > 0 ? 3 : 0);
+ return nr.value;
+ }
+
+ public static NewRemover make2(int z) {
+ System.out.println("make2 " + z);
+ obj.value += z;
+ return obj;
+ }
+}
diff --git a/src/test/test4/Rename.java b/src/test/test4/Rename.java
new file mode 100644
index 00000000..1ded1f69
--- /dev/null
+++ b/src/test/test4/Rename.java
@@ -0,0 +1,24 @@
+package test4;
+
+interface IRename {
+ Rename foo(Rename r);
+}
+
+public class Rename implements IRename {
+ int value = 3;
+ Rename next = null;
+
+ public Rename foo(Rename r) {
+ Rename k = r;
+ if (k == null)
+ return null;
+ else
+ return k.next;
+ }
+
+ public int run() {
+ next = new Rename();
+ next.value = 4;
+ return foo(this).value;
+ }
+}
diff --git a/src/test/test4/Signature.java b/src/test/test4/Signature.java
new file mode 100644
index 00000000..aa9de28b
--- /dev/null
+++ b/src/test/test4/Signature.java
@@ -0,0 +1,16 @@
+package test4;
+
+public class Signature<T> {
+ public static class Foo {
+ int value;
+ }
+
+ public int run() {
+ Signature<String> s = new Signature<String>();
+ return s.foo(new Integer(3), "foo", s, null).length();
+ }
+
+ <S> T foo(S s, T t, Signature<T> signature, Signature<Signature<String>> v) {
+ return t;
+ }
+}
diff --git a/src/test/test4/VarArgs.java b/src/test/test4/VarArgs.java
new file mode 100644
index 00000000..53c04072
--- /dev/null
+++ b/src/test/test4/VarArgs.java
@@ -0,0 +1,15 @@
+package test4;
+
+public class VarArgs {
+ public int test() {
+ return goo(1, 2, 3) + goo(1, "a", "b", "c");
+ }
+
+ public int goo(int i, int... k) {
+ return k.length;
+ }
+
+ public int goo(int i, String... k) {
+ return k.length;
+ }
+}
diff --git a/src/test/test4/length.java b/src/test/test4/length.java
new file mode 100644
index 00000000..8158f4c1
--- /dev/null
+++ b/src/test/test4/length.java
@@ -0,0 +1,5 @@
+package test4;
+
+public class length {
+ public static int m() { return 7; }
+}