aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2016-10-05 00:51:28 +0900
committerchibash <chiba@javassist.org>2016-10-05 00:51:28 +0900
commitfd1b5fa8cdf07a6b153bbc606fe1ab78c2be6c26 (patch)
tree4bd332eaa9935a9962e517f18beb5cda27eb2f77 /src/test/javassist
parent35fb5b39f86ef92661a0f672780bb000692fc580 (diff)
parent5ea5b6695cf3ecb9896b9e9ce02f089b893101a4 (diff)
downloadjavassist-fd1b5fa8cdf07a6b153bbc606fe1ab78c2be6c26.tar.gz
javassist-fd1b5fa8cdf07a6b153bbc606fe1ab78c2be6c26.zip
Merge branch 'test/java9-jigsaw'
Diffstat (limited to 'src/test/javassist')
-rw-r--r--src/test/javassist/JvstTest.java2
-rw-r--r--src/test/javassist/JvstTest2.java12
-rw-r--r--src/test/javassist/JvstTest3.java8
-rw-r--r--src/test/javassist/JvstTest4.java15
-rw-r--r--src/test/javassist/JvstTest5.java11
-rw-r--r--src/test/javassist/JvstTestRoot.java4
-rw-r--r--src/test/javassist/SetterTest.java10
-rw-r--r--src/test/javassist/bytecode/BytecodeTest.java2
-rw-r--r--src/test/javassist/bytecode/InsertGap0.java4
-rw-r--r--src/test/javassist/bytecode/StackMapTest.java8
-rw-r--r--src/test/javassist/proxyfactory/ProxyFactoryTest.java10
-rw-r--r--src/test/javassist/proxyfactory/Tester.java2
12 files changed, 51 insertions, 37 deletions
diff --git a/src/test/javassist/JvstTest.java b/src/test/javassist/JvstTest.java
index 9a671de6..eb57a643 100644
--- a/src/test/javassist/JvstTest.java
+++ b/src/test/javassist/JvstTest.java
@@ -1041,7 +1041,7 @@ public class JvstTest extends JvstTestRoot {
}
public void testPackage() throws Exception {
- Object obj = new Loader().loadClass("test1.Pac").newInstance();
+ Object obj = new Loader().loadClass("test1.Pac").getConstructor().newInstance();
assertEquals(1, invoke(obj, "run"));
}
diff --git a/src/test/javassist/JvstTest2.java b/src/test/javassist/JvstTest2.java
index 4ff84784..10d5d3e3 100644
--- a/src/test/javassist/JvstTest2.java
+++ b/src/test/javassist/JvstTest2.java
@@ -1423,32 +1423,32 @@ public class JvstTest2 extends JvstTestRoot {
CtField f = new CtField(CtClass.intType, "sff1", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "5");
- assertEquals(new Integer(5), f.getConstantValue());
+ assertEquals(Integer.valueOf(5), f.getConstantValue());
f = new CtField(CtClass.longType, "sff2", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "6");
- assertEquals(new Long(6), f.getConstantValue());
+ assertEquals(Long.valueOf(6), f.getConstantValue());
f = new CtField(CtClass.floatType, "sff3", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "7");
- assertEquals(new Float(7.0F), f.getConstantValue());
+ assertEquals(Float.valueOf(7.0F), f.getConstantValue());
f = new CtField(CtClass.floatType, "sff4", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "8.0");
- assertEquals(new Float(8.0F), f.getConstantValue());
+ assertEquals(Float.valueOf(8.0F), f.getConstantValue());
f = new CtField(CtClass.doubleType, "sff5", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "9");
- assertEquals(new Double(9.0), f.getConstantValue());
+ assertEquals(Double.valueOf(9.0), f.getConstantValue());
f = new CtField(CtClass.doubleType, "sff6", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
cc.addField(f, "10.0");
- assertEquals(new Double(10.0), f.getConstantValue());
+ assertEquals(Double.valueOf(10.0), f.getConstantValue());
f = new CtField(sloader.get("java.lang.String"), "sff7", cc);
f.setModifiers(Modifier.STATIC | Modifier.FINAL);
diff --git a/src/test/javassist/JvstTest3.java b/src/test/javassist/JvstTest3.java
index 427479d1..056df5c2 100644
--- a/src/test/javassist/JvstTest3.java
+++ b/src/test/javassist/JvstTest3.java
@@ -852,7 +852,7 @@ public class JvstTest3 extends JvstTestRoot {
{
java.lang.reflect.Method m =
target.getClass().getMethod(method, new Class[] { long.class, int.class });
- Object res = m.invoke(target, new Object[] { new Long(arg1), new Integer(arg2)});
+ Object res = m.invoke(target, new Object[] { Long.valueOf(arg1), Integer.valueOf(arg2)});
return ((Integer)res).intValue();
}
@@ -861,7 +861,7 @@ public class JvstTest3 extends JvstTestRoot {
{
java.lang.reflect.Method m =
target.getClass().getMethod(method, new Class[] { int.class, double.class });
- Object res = m.invoke(target, new Object[] { new Integer(arg1), new Double(arg2)});
+ Object res = m.invoke(target, new Object[] { Integer.valueOf(arg1), Double.valueOf(arg2)});
return ((Integer)res).intValue();
}
@@ -870,7 +870,7 @@ public class JvstTest3 extends JvstTestRoot {
{
java.lang.reflect.Method m =
target.getClass().getMethod(method, new Class[] { int.class, String.class, Object.class });
- Object res = m.invoke(target, new Object[] { new Integer(arg1), arg2, arg3});
+ Object res = m.invoke(target, new Object[] { Integer.valueOf(arg1), arg2, arg3});
return ((Integer)res).intValue();
}
@@ -1107,7 +1107,7 @@ public class JvstTest3 extends JvstTestRoot {
sb.append("}");
ctc.addMethod(CtNewMethod.make(sb.toString(), ctc));
ctc.debugWriteFile();
- ctc.toClass().newInstance();
+ ctc.toClass().getConstructor().newInstance();
}
// JIRA-83
diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java
index ac4c1e3b..1fdec977 100644
--- a/src/test/javassist/JvstTest4.java
+++ b/src/test/javassist/JvstTest4.java
@@ -606,7 +606,7 @@ public class JvstTest4 extends JvstTestRoot {
pool.makePackage(pool.getClassLoader(), packageName);
CtClass ctcl = pool.makeClass("test4.pack.Clazz");
Class cl = ctcl.toClass();
- Object obj = cl.newInstance();
+ Object obj = cl.getConstructor().newInstance();
assertEquals(packageName, obj.getClass().getPackage().getName());
}
@@ -872,10 +872,17 @@ public class JvstTest4 extends JvstTestRoot {
CtClass cc = sloader.get("test4.JIRA181");
CtField field = cc.getField("aField");
String s = field.getAnnotation(test4.JIRA181.Condition.class).toString();
- assertEquals("@test4.JIRA181$Condition(condition=test4.JIRA181<T>.B.class)", s);
+ if (ClassFile.MAJOR_VERSION < ClassFile.JAVA_9)
+ assertEquals("@test4.JIRA181$Condition(condition=test4.JIRA181<T>.B.class)", s);
+ else
+ assertEquals("@test4.JIRA181$Condition(condition=test4.JIRA181.B.class)", s);
+
CtField field2 = cc.getField("aField2");
String s2 = field2.getAnnotation(test4.JIRA181.Condition2.class).toString();
- assertEquals("@test4.JIRA181$Condition2(condition=test4.JIRA181<T>.B[].class)", s2);
+ if (ClassFile.MAJOR_VERSION < ClassFile.JAVA_9)
+ assertEquals("@test4.JIRA181$Condition2(condition=test4.JIRA181<T>.B[].class)", s2);
+ else
+ assertEquals("@test4.JIRA181$Condition2(condition=test4.JIRA181.B[].class)", s2);
}
public void testJIRA195() throws Exception {
@@ -1022,7 +1029,7 @@ public class JvstTest4 extends JvstTestRoot {
newClass.debugWriteFile();
Class<?> cClass = newClass.toClass();
- Object o = cClass.newInstance();
+ Object o = cClass.getConstructor().newInstance();
java.lang.reflect.Method m = cClass.getMethod("evaluate");
m.invoke(o);
m = cClass.getMethod("evaluate2");
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java
index c20a85f2..26474bb7 100644
--- a/src/test/javassist/JvstTest5.java
+++ b/src/test/javassist/JvstTest5.java
@@ -77,7 +77,7 @@ public class JvstTest5 extends JvstTestRoot {
}
public void testJIRA242() throws Exception {
- Boolean ss = new Boolean(2 > 3);
+ Boolean ss = Boolean.valueOf(2 > 3);
ClassPool cp = ClassPool.getDefault();
CtClass cc = cp.get("test5.JIRA242$Hello");
CtMethod m = cc.getDeclaredMethod("say");
@@ -219,7 +219,7 @@ public class JvstTest5 extends JvstTestRoot {
System.out.println(src);
badClass.addMethod(CtMethod.make(src, badClass));
Class clazzz = badClass.toClass();
- Object obj = clazzz.newInstance(); // <-- falls here
+ Object obj = clazzz.getConstructor().newInstance(); // <-- falls here
}
public void test83StackmapWithArrayType() throws Exception {
@@ -237,6 +237,13 @@ public class JvstTest5 extends JvstTestRoot {
assertEquals(1, invoke(obj, "run"));
}
+ public void testLoaderClassPath() throws Exception {
+ ClassPool cp = new ClassPool();
+ cp.appendClassPath(new LoaderClassPath(new Loader()));
+ assertNotNull(cp.get(Object.class.getName()));
+ assertNotNull(cp.get(this.getClass().getName()));
+ }
+
public void testAddDefaultMethod() throws Exception {
CtClass cc = sloader.makeInterface("test5.AddDefaultMethod");
cc.addMethod(CtNewMethod.make("static int foo() { return 1; }", cc));
diff --git a/src/test/javassist/JvstTestRoot.java b/src/test/javassist/JvstTestRoot.java
index f2dccda3..118e8511 100644
--- a/src/test/javassist/JvstTestRoot.java
+++ b/src/test/javassist/JvstTestRoot.java
@@ -34,7 +34,7 @@ public class JvstTestRoot extends TestCase {
}
protected Object make(String name) throws Exception {
- return cloader.loadClass(name).newInstance();
+ return cloader.loadClass(name).getConstructor().newInstance();
}
protected int invoke(Object target, String method) throws Exception {
@@ -47,7 +47,7 @@ public class JvstTestRoot extends TestCase {
throws Exception {
Method m =
target.getClass().getMethod(method, new Class[] { int.class });
- Object res = m.invoke(target, new Object[] { new Integer(arg)});
+ Object res = m.invoke(target, new Object[] { Integer.valueOf(arg)});
return ((Integer) res).intValue();
}
}
diff --git a/src/test/javassist/SetterTest.java b/src/test/javassist/SetterTest.java
index f11429ad..a989d39a 100644
--- a/src/test/javassist/SetterTest.java
+++ b/src/test/javassist/SetterTest.java
@@ -29,7 +29,7 @@ public class SetterTest extends TestCase {
clazz.addMethod(CtNewMethod.getter("isBroken", field));
Class _class = clazz.toClass();
- Object object = _class.newInstance();
+ Object object = _class.getConstructor().newInstance();
check(_class, object, true);
}
@@ -47,7 +47,7 @@ public class SetterTest extends TestCase {
clazz.addMethod(CtNewMethod.setter("setBroken", field));
Class _class = clazz.toClass();
- Object object = _class.newInstance();
+ Object object = _class.getConstructor().newInstance();
set(_class, object, false);
check(_class, object, false);
@@ -67,7 +67,7 @@ public class SetterTest extends TestCase {
clazz.addMethod(CtNewMethod.getter("isBroken", field));
Class _class = clazz.toClass();
- Object object = _class.newInstance();
+ Object object = _class.getConstructor().newInstance();
check(_class, object, true);
}
@@ -86,7 +86,7 @@ public class SetterTest extends TestCase {
clazz.addMethod(CtNewMethod.setter("setBroken", field));
Class _class = clazz.toClass();
- Object object = _class.newInstance();
+ Object object = _class.getConstructor().newInstance();
set(_class, object, false);
check(_class, object, false);
@@ -106,6 +106,6 @@ public class SetterTest extends TestCase {
{
Method method = _class.getMethod("setBroken",
new Class[] {Boolean.TYPE});
- method.invoke(object, new Object[] {new Boolean(willBe)});
+ method.invoke(object, new Object[] { Boolean.valueOf(willBe)});
}
}
diff --git a/src/test/javassist/bytecode/BytecodeTest.java b/src/test/javassist/bytecode/BytecodeTest.java
index b918750f..a859f248 100644
--- a/src/test/javassist/bytecode/BytecodeTest.java
+++ b/src/test/javassist/bytecode/BytecodeTest.java
@@ -29,7 +29,7 @@ public class BytecodeTest extends TestCase {
}
protected Object make(String name) throws Exception {
- return cloader.loadClass(name).newInstance();
+ return cloader.loadClass(name).getConstructor().newInstance();
}
protected int invoke(Object target, String method) throws Exception {
diff --git a/src/test/javassist/bytecode/InsertGap0.java b/src/test/javassist/bytecode/InsertGap0.java
index 31fec3aa..6a034141 100644
--- a/src/test/javassist/bytecode/InsertGap0.java
+++ b/src/test/javassist/bytecode/InsertGap0.java
@@ -175,7 +175,7 @@ public final class InsertGap0 extends JvstTestRoot {
Class c = cc.toClass();
cc.stopPruning(p);
- Object obj = c.newInstance();
+ Object obj = c.getConstructor().newInstance();
assertEquals(2, invoke(obj, "run", 0));
}
@@ -194,7 +194,7 @@ public final class InsertGap0 extends JvstTestRoot {
Class c = cc.toClass();
cc.stopPruning(p);
- Object obj = c.newInstance();
+ Object obj = c.getConstructor().newInstance();
assertEquals(0, invoke(obj, "run2", 0));
}
diff --git a/src/test/javassist/bytecode/StackMapTest.java b/src/test/javassist/bytecode/StackMapTest.java
index fc54c592..77d827be 100644
--- a/src/test/javassist/bytecode/StackMapTest.java
+++ b/src/test/javassist/bytecode/StackMapTest.java
@@ -37,7 +37,7 @@ public class StackMapTest extends TestCase {
}
protected Object make(String name) throws Exception {
- return cloader.loadClass(name).newInstance();
+ return cloader.loadClass(name).getConstructor().newInstance();
}
protected int invoke(Object target, String method) throws Exception {
@@ -143,7 +143,7 @@ public class StackMapTest extends TestCase {
CtClass cc = loader.get("javassist.bytecode.StackMapTest$T1");
rebuildStackMaps2(cc);
//Class c = cc.toClass();
- //Object t1 = c.newInstance();
+ //Object t1 = c.getConstructor().newInstance();
cc.writeFile();
Object t1 = make(cc.getName());
assertEquals(3, invoke(t1, "test"));
@@ -582,9 +582,9 @@ public class StackMapTest extends TestCase {
if (v5) // 246:
this.print2(s);
if (v5)
- this.log(ldcw(), v7, s, Long.valueOf(new Integer(i).longValue()), k, null);
+ this.log(ldcw(), v7, s, Long.valueOf(Integer.valueOf(i).longValue()), k, null);
else // 290:
- this.log(ldcw(), v7, s, Long.valueOf(new Integer(i).longValue()), k, null);
+ this.log(ldcw(), v7, s, Long.valueOf(Integer.valueOf(i).longValue()), k, null);
return v5;
}
diff --git a/src/test/javassist/proxyfactory/ProxyFactoryTest.java b/src/test/javassist/proxyfactory/ProxyFactoryTest.java
index 5b1bb2ef..2b41af7a 100644
--- a/src/test/javassist/proxyfactory/ProxyFactoryTest.java
+++ b/src/test/javassist/proxyfactory/ProxyFactoryTest.java
@@ -21,7 +21,7 @@ public class ProxyFactoryTest extends TestCase {
MyMethodHandler myHandler = new MyMethodHandler();
myHandler.setX(4711);
- MyCls myCls = (MyCls) proxyClass.newInstance();
+ MyCls myCls = (MyCls) proxyClass.getConstructor().newInstance();
((ProxyObject) myCls).setHandler(myHandler);
MethodHandler h2 = ((ProxyObject) myCls).getHandler();
@@ -38,7 +38,7 @@ public class ProxyFactoryTest extends TestCase {
MyMethodHandler myHandler = new MyMethodHandler();
myHandler.setX(4711);
- MyCls myCls = (MyCls) proxyClass.newInstance();
+ MyCls myCls = (MyCls) proxyClass.getConstructor().newInstance();
((ProxyObject) myCls).setHandler(myHandler);
@@ -93,21 +93,21 @@ public class ProxyFactoryTest extends TestCase {
//proxyFactory.writeDirectory = "./dump";
proxyFactory.setInterfaces(new Class[]{ TestDefaultI.class });
Class intf = proxyFactory.createClass();
- TestDefaultI obj = (TestDefaultI)intf.newInstance();
+ TestDefaultI obj = (TestDefaultI)intf.getConstructor().newInstance();
obj.foo();
ProxyFactory proxyFactory2 = new ProxyFactory();
//proxyFactory2.writeDirectory = "./dump";
proxyFactory2.setSuperclass(TestDefaultC.class);
Class clazz2 = proxyFactory2.createClass();
- TestDefaultC obj2 = (TestDefaultC)clazz2.newInstance();
+ TestDefaultC obj2 = (TestDefaultC)clazz2.getConstructor().newInstance();
obj2.foo();
obj2.bar();
ProxyFactory proxyFactory3 = new ProxyFactory();
proxyFactory3.setSuperclass(TestDefaultC2.class);
Class clazz3 = proxyFactory3.createClass();
- TestDefaultC2 obj3 = (TestDefaultC2)clazz3.newInstance();
+ TestDefaultC2 obj3 = (TestDefaultC2)clazz3.getConstructor().newInstance();
obj3.foo();
obj3.bar();
obj3.baz();
diff --git a/src/test/javassist/proxyfactory/Tester.java b/src/test/javassist/proxyfactory/Tester.java
index 39033885..601076da 100644
--- a/src/test/javassist/proxyfactory/Tester.java
+++ b/src/test/javassist/proxyfactory/Tester.java
@@ -27,7 +27,7 @@ public class Tester extends TestCase {
ProxyFactory f = new ProxyFactory();
f.setSuperclass(Hand.class);
Class c = f.createClass();
- Hand foo = (Hand)c.newInstance();
+ Hand foo = (Hand)c.getConstructor().newInstance();
((Proxy)foo).setHandler(mi);
assertTrue(ProxyFactory.isProxyClass(c));
assertEquals(3, foo.getHandler());