Specification-Title: Javassist
Specification-Vendor: Shigeru Chiba, www.javassist.org
-Specification-Version: 3.20.0-GA
+Specification-Version: 3.21.0-GA
Main-Class: javassist.CtClass
Object[] args;
if (domain == null) {
method = defineClass1;
- args = new Object[] { ct.getName(), b, new Integer(0),
- new Integer(b.length)};
+ args = new Object[] { ct.getName(), b, Integer.valueOf(0),
+ Integer.valueOf(b.length)};
}
else {
method = defineClass2;
- args = new Object[] { ct.getName(), b, new Integer(0),
- new Integer(b.length), domain};
+ args = new Object[] { ct.getName(), b, Integer.valueOf(0),
+ Integer.valueOf(b.length), domain};
}
return (Class)toClass2(method, loader, args);
/**
* The version number of this release.
*/
- public static final String version = "3.20.0-GA";
+ public static final String version = "3.21.0-GA";
/**
* Prints the version number and the copyright notice.
*/
public static void main(String[] args) {
System.out.println("Javassist version " + CtClass.version);
- System.out.println("Copyright (C) 1999-2015 Shigeru Chiba."
+ System.out.println("Copyright (C) 1999-2016 Shigeru Chiba."
+ " All Rights Reserved.");
}
ConstPool cp = fieldInfo.getConstPool();
switch (cp.getTag(index)) {
case ConstPool.CONST_Long :
- return new Long(cp.getLongInfo(index));
+ return Long.valueOf(cp.getLongInfo(index));
case ConstPool.CONST_Float :
- return new Float(cp.getFloatInfo(index));
+ return Float.valueOf(cp.getFloatInfo(index));
case ConstPool.CONST_Double :
- return new Double(cp.getDoubleInfo(index));
+ return Double.valueOf(cp.getDoubleInfo(index));
case ConstPool.CONST_Integer :
int value = cp.getIntegerInfo(index);
// "Z" means boolean type.
if ("Z".equals(fieldInfo.getDescriptor()))
- return new Boolean(value != 0);
+ return Boolean.valueOf(value != 0);
else
- return new Integer(value);
+ return Integer.valueOf(value);
case ConstPool.CONST_String :
return cp.getStringInfo(index);
default :
if (constInfo instanceof StringInfo)
value = this.getStringInfo(index);
else if (constInfo instanceof FloatInfo)
- value = new Float(getFloatInfo(index));
+ value = Float.valueOf(getFloatInfo(index));
else if (constInfo instanceof IntegerInfo)
- value = new Integer(getIntegerInfo(index));
+ value = Integer.valueOf(getIntegerInfo(index));
else if (constInfo instanceof LongInfo)
- value = new Long(getLongInfo(index));
+ value = Long.valueOf(getLongInfo(index));
else if (constInfo instanceof DoubleInfo)
- value = new Double(getDoubleInfo(index));
+ value = Double.valueOf(getDoubleInfo(index));
else
value = null;
public Subroutine(int start, int caller) {
this.start = start;
- callers.add(new Integer(caller));
+ callers.add(Integer.valueOf(caller));
}
public void addCaller(int caller) {
- callers.add(new Integer(caller));
+ callers.add(Integer.valueOf(caller));
}
public int start() {
}
public void access(int index) {
- access.add(new Integer(index));
+ access.add(Integer.valueOf(index));
}
public boolean isAccessed(int index) {
- return access.contains(new Integer(index));
+ return access.contains(Integer.valueOf(index));
}
public Collection accessed() {
private void scan(int pos, CodeIterator iter, Subroutine sub) throws BadBytecode {
// Skip already processed blocks
- if (done.contains(new Integer(pos)))
+ if (done.contains(Integer.valueOf(pos)))
return;
- done.add(new Integer(pos));
+ done.add(Integer.valueOf(pos));
int old = iter.lookAhead();
iter.move(pos);
if (Util.isJumpInstruction(opcode)) {
int target = Util.getJumpTarget(pos, iter);
if (opcode == JSR || opcode == JSR_W) {
- Subroutine s = (Subroutine) subTable.get(new Integer(target));
+ Subroutine s = (Subroutine) subTable.get(Integer.valueOf(target));
if (s == null) {
s = new Subroutine(target, pos);
- subTable.put(new Integer(target), s);
+ subTable.put(Integer.valueOf(target), s);
scan(target, iter, s);
} else {
s.addCaller(pos);
if (Object.class == method.getDeclaringClass()) {
if ("equals".equals(name)) {
Object obj = args[0];
- return new Boolean(checkEquals(obj));
+ return Boolean.valueOf(checkEquals(obj));
}
else if ("toString".equals(name))
return annotation.toString();
else if ("hashCode".equals(name))
- return new Integer(hashCode());
+ return Integer.valueOf(hashCode());
}
else if ("annotationType".equals(name)
&& method.getParameterTypes().length == 0)
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Boolean(getValue());
+ return Boolean.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Byte(getValue());
+ return Byte.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Character(getValue());
+ return Character.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Double(getValue());
+ return Double.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Float(getValue());
+ return Float.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Integer(getValue());
+ return Integer.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Long(getValue());
+ return Long.valueOf(getValue());
}
Class getType(ClassLoader cl) {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Short(getValue());
+ return Short.valueOf(getValue());
}
Class getType(ClassLoader cl) {
private Mark makeMark0(HashMap table, int pos,
boolean isBlockBegin, boolean isTarget) {
- Integer p = new Integer(pos);
+ Integer p = Integer.valueOf(pos);
Mark m = (Mark)table.get(p);
if (m == null) {
m = new Mark(pos);
"sorry, not support labeled break or continue");
bytecode.addOpcode(Opcode.GOTO);
- Integer pc = new Integer(bytecode.currentPc());
+ Integer pc = Integer.valueOf(bytecode.currentPc());
bytecode.addIndex(0);
if (notCont)
breakList.add(pc);
}
public void append(String name, int t) {
- put(name, new Integer(t));
+ put(name, Integer.valueOf(t));
}
}
boolean tryNotReturn = !hasReturned;
if (tryNotReturn) {
bc.addOpcode(Opcode.GOTO);
- gotoList.add(new Integer(bc.currentPc()));
+ gotoList.add(Integer.valueOf(bc.currentPc()));
bc.addIndex(0); // correct later
}
if (!hasReturned) {
bc.addOpcode(Opcode.GOTO);
- gotoList.add(new Integer(bc.currentPc()));
+ gotoList.add(Integer.valueOf(bc.currentPc()));
bc.addIndex(0); // correct later
tryNotReturn = true;
}
private Object createProxy(int oid, String classname) throws Exception {
Class c = Class.forName(classname);
Constructor cons = c.getConstructor(proxyConstructorParamTypes);
- return cons.newInstance(new Object[] { this, new Integer(oid) });
+ return cons.newInstance(new Object[] { this, Integer.valueOf(oid) });
}
/**
Object[] args;
if (domain == null) {
method = defineClass1;
- args = new Object[] { cf.getName(), b, new Integer(0),
- new Integer(b.length) };
+ args = new Object[] { cf.getName(), b, Integer.valueOf(0),
+ Integer.valueOf(b.length) };
}
else {
method = defineClass2;
- args = new Object[] { cf.getName(), b, new Integer(0),
- new Integer(b.length), domain };
+ args = new Object[] { cf.getName(), b, Integer.valueOf(0),
+ Integer.valueOf(b.length), domain };
}
return toClass2(method, loader, args);
package javassist.util.proxy;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
import java.io.ObjectStreamException;
import java.security.AccessController;
import java.security.PrivilegedActionException;
ProxyFactory f = new ProxyFactory();
f.setSuperclass(loadClass(superClass));
f.setInterfaces(infs);
- Proxy proxy = (Proxy)f.createClass(filterSignature).newInstance();
+ Proxy proxy = (Proxy)f.createClass(filterSignature).getConstructor().newInstance();
proxy.setHandler(handler);
return proxy;
}
+ catch (NoSuchMethodException e) {
+ throw new java.io.InvalidClassException(e.getMessage());
+ }
+ catch (InvocationTargetException e) {
+ throw new java.io.InvalidClassException(e.getMessage());
+ }
catch (ClassNotFoundException e) {
throw new java.io.InvalidClassException(e.getMessage());
}
ctClass.debugWriteFile();
Class<?> cc = ctClass.toClass();
System.out.println(cc.getName());
- InvalidStackMapFrame obj = (InvalidStackMapFrame)cc.newInstance();
+ InvalidStackMapFrame obj = (InvalidStackMapFrame)cc.getDeclaredConstructor().newInstance();
obj.bytecodeVerifyError();
}
}
}
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"));
}
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);
{
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();
}
{
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();
}
{
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();
}
sb.append("}");
ctc.addMethod(CtNewMethod.make(sb.toString(), ctc));
ctc.debugWriteFile();
- ctc.toClass().newInstance();
+ ctc.toClass().getConstructor().newInstance();
}
// JIRA-83
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());
}
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");
}
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");
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 {
}
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 {
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();
}
}
clazz.addMethod(CtNewMethod.getter("isBroken", field));\r
Class _class = clazz.toClass();\r
\r
- Object object = _class.newInstance();\r
+ Object object = _class.getConstructor().newInstance();\r
check(_class, object, true);\r
}\r
\r
clazz.addMethod(CtNewMethod.setter("setBroken", field));\r
Class _class = clazz.toClass();\r
\r
- Object object = _class.newInstance();\r
+ Object object = _class.getConstructor().newInstance();\r
\r
set(_class, object, false);\r
check(_class, object, false);\r
clazz.addMethod(CtNewMethod.getter("isBroken", field));\r
Class _class = clazz.toClass();\r
\r
- Object object = _class.newInstance();\r
+ Object object = _class.getConstructor().newInstance();\r
check(_class, object, true);\r
}\r
\r
clazz.addMethod(CtNewMethod.setter("setBroken", field));\r
Class _class = clazz.toClass();\r
\r
- Object object = _class.newInstance();\r
+ Object object = _class.getConstructor().newInstance();\r
\r
set(_class, object, false);\r
check(_class, object, false);\r
{\r
Method method = _class.getMethod("setBroken",\r
new Class[] {Boolean.TYPE});\r
- method.invoke(object, new Object[] {new Boolean(willBe)});\r
+ method.invoke(object, new Object[] { Boolean.valueOf(willBe)});\r
}\r
}\r
}
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 {
Class c = cc.toClass();
cc.stopPruning(p);
- Object obj = c.newInstance();
+ Object obj = c.getConstructor().newInstance();
assertEquals(2, invoke(obj, "run", 0));
}
Class c = cc.toClass();
cc.stopPruning(p);
- Object obj = c.newInstance();
+ Object obj = c.getConstructor().newInstance();
assertEquals(0, invoke(obj, "run2", 0));
}
}
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 {
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"));
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;
}
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();
MyMethodHandler myHandler = new MyMethodHandler();
myHandler.setX(4711);
- MyCls myCls = (MyCls) proxyClass.newInstance();
+ MyCls myCls = (MyCls) proxyClass.getConstructor().newInstance();
((ProxyObject) myCls).setHandler(myHandler);
//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();
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());
assertNotNull(sub);
assertEquals(sub.start(), start);
for (int i = 0; i < callers.length; i++)
- assertTrue(sub.callers().contains(new Integer(callers[i])));
+ assertTrue(sub.callers().contains(Integer.valueOf(callers[i])));
}
private static void generate(ClassPool pool) throws CannotCompileException, IOException, NotFoundException {
converter.replaceArrayAccess(echoClass, new CodeConverter.DefaultArrayAccessReplacementMethodNames());
simpleClass.instrument(converter);
//simpleClass.writeFile("/tmp");
- simple = (SimpleInterface) simpleClass.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).newInstance();
+ simple = (SimpleInterface) simpleClass.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).getConstructor().newInstance();
}
public void testComplex() throws Exception {
CodeConverter converter = new CodeConverter();
converter.replaceArrayAccess(clazz, new CodeConverter.DefaultArrayAccessReplacementMethodNames());
clazz.instrument(converter);
- ComplexInterface instance = (ComplexInterface) clazz.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).newInstance();
- assertEquals(new Integer(5), instance.complexRead(4));
+ ComplexInterface instance = (ComplexInterface) clazz.toClass(new URLClassLoader(new URL[0], getClass().getClassLoader()), Class.class.getProtectionDomain()).getConstructor().newInstance();
+ assertEquals(Integer.valueOf(5), instance.complexRead(4));
}
public void testBoolean() throws Exception {
public void testObject() throws Exception {
for (int i = 0; i < 100; i++) {
- simple.setObject(i, new Integer(i));
+ simple.setObject(i, Integer.valueOf(i));
}
for (int i = 0; i < 100; i++) {
- assertEquals(new Integer(i), simple.getObject(i));
+ assertEquals(Integer.valueOf(i), simple.getObject(i));
}
}
public static Map shortMap = new HashMap();
public static Object arrayReadObject(Object array, int index) {
- return objectMap.get(new Integer(index));
+ return objectMap.get(Integer.valueOf(index));
}
public static void arrayWriteObject(Object array, int index, Object element) {
- objectMap.put(new Integer(index), element);
+ objectMap.put(Integer.valueOf(index), element);
}
public static byte arrayReadByteOrBoolean(Object array, int index) {
- return ((Byte)byteMap.get(new Integer(index))).byteValue();
+ return ((Byte)byteMap.get(Integer.valueOf(index))).byteValue();
}
public static void arrayWriteByteOrBoolean(Object array, int index, byte element) {
- byteMap.put(new Integer(index), new Byte(element));
+ byteMap.put(Integer.valueOf(index), Byte.valueOf(element));
}
public static char arrayReadChar(Object array, int index) {
- return ((Character)charMap.get(new Integer(index))).charValue();
+ return ((Character)charMap.get(Integer.valueOf(index))).charValue();
}
public static void arrayWriteChar(Object array, int index, char element) {
- charMap.put(new Integer(index), new Character(element));
+ charMap.put(Integer.valueOf(index), Character.valueOf(element));
}
public static double arrayReadDouble(Object array, int index) {
- return ((Double)doubleMap.get(new Integer(index))).doubleValue();
+ return ((Double)doubleMap.get(Integer.valueOf(index))).doubleValue();
}
public static void arrayWriteDouble(Object array, int index, double element) {
- doubleMap.put(new Integer(index), new Double(element));
+ doubleMap.put(Integer.valueOf(index), Double.valueOf(element));
}
public static float arrayReadFloat(Object array, int index) {
- return ((Float)floatMap.get(new Integer(index))).floatValue();
+ return ((Float)floatMap.get(Integer.valueOf(index))).floatValue();
}
public static void arrayWriteFloat(Object array, int index, float element) {
- floatMap.put(new Integer(index), new Float(element));
+ floatMap.put(Integer.valueOf(index), Float.valueOf(element));
}
public static int arrayReadInt(Object array, int index) {
- return ((Integer)intMap.get(new Integer(index))).intValue();
+ return ((Integer)intMap.get(Integer.valueOf(index))).intValue();
}
public static void arrayWriteInt(Object array, int index, int element) {
- intMap.put(new Integer(index), new Integer(element));
+ intMap.put(Integer.valueOf(index), Integer.valueOf(element));
}
public static long arrayReadLong(Object array, int index) {
- return ((Long)longMap.get(new Integer(index))).longValue();
+ return ((Long)longMap.get(Integer.valueOf(index))).longValue();
}
public static void arrayWriteLong(Object array, int index, long element) {
- longMap.put(new Integer(index), new Long(element));
+ longMap.put(Integer.valueOf(index), Long.valueOf(element));
}
public static short arrayReadShort(Object array, int index) {
- return ((Short)shortMap.get(new Integer(index))).shortValue();
+ return ((Short)shortMap.get(Integer.valueOf(index))).shortValue();
}
public static void arrayWriteShort(Object array, int index, short element) {
- shortMap.put(new Integer(index), new Short(element));
+ shortMap.put(Integer.valueOf(index), Short.valueOf(element));
}
}
private static Integer justRead;
public static Object arrayReadObject(Object array, int offset) {
- return new Integer(justRead.intValue() + offset);
+ return Integer.valueOf(justRead.intValue() + offset);
}
public static void arrayWriteObject(Object array, int offset, Object element) {
}
public Object getInteger(int i) {
- return (Object) new Integer(i);
+ return (Object) Integer.valueOf(i);
}
public Number complexRead(int x) {
// method.
}
};
- Foo foo = (Foo)c.newInstance();
+ Foo foo = (Foo)c.getConstructor().newInstance();
try {
((ProxyObject)foo).setHandler(mi);
fail("foo is a ProxyObject!");
// method.
}
};
- Foo2 foo = (Foo2)c.newInstance();
+ Foo2 foo = (Foo2)c.getConstructor().newInstance();
try {
((ProxyObject)foo).setHandler(mi);
fail("foo is a ProxyObject!");
Class javaHandlerClass = classPool.toClass(ctHandlerClass);
Class javaFilterClass = classPool.toClass(ctFilterClass);
- MethodHandler handler= (MethodHandler)javaHandlerClass.newInstance();
- MethodFilter filter = (MethodFilter)javaFilterClass.newInstance();
+ MethodHandler handler= (MethodHandler)javaHandlerClass.getConstructor().newInstance();
+ MethodFilter filter = (MethodFilter)javaFilterClass.getConstructor().newInstance();
// ok, now create a factory and a proxy class and proxy from that factory
factory.setFilter(filter);
// factory.setSuperclass(Object.class);
Class proxyClass = factory.createClass();
- Object target = proxyClass.newInstance();
+ Object target = proxyClass.getConstructor().newInstance();
((ProxyObject)target).setHandler(handler);
} catch (Exception e) {
e.printStackTrace();
// create the same class twice and check that it is reused
Class proxyClass1 = factory.createClass();
System.out.println("created first class " + proxyClass1.getName());
- TestClass proxy1 = (TestClass)proxyClass1.newInstance();
+ TestClass proxy1 = (TestClass)proxyClass1.getConstructor().newInstance();
((ProxyObject) proxy1).setHandler(handler);
proxy1.testMethod();
assertTrue(proxy1.isTestCalled());
Class proxyClass2 = factory.createClass();
System.out.println("created second class " + proxyClass2.getName());
- TestClass proxy2 = (TestClass)proxyClass2.newInstance();
+ TestClass proxy2 = (TestClass)proxyClass2.getConstructor().newInstance();
((ProxyObject) proxy2).setHandler(handler);
proxy2.testMethod();
assertTrue(proxy2.isTestCalled());
// create the same class twice and check that it is reused
Class proxyClass3 = factory.createClass();
System.out.println("created third class " + proxyClass3.getName());
- TestClass proxy3 = (TestClass)proxyClass3.newInstance();
+ TestClass proxy3 = (TestClass)proxyClass3.getConstructor().newInstance();
((Proxy)proxy3).setHandler(handler);
proxy3.testMethod();
assertTrue(proxy3.isTestCalled());
Class proxyClass4 = factory.createClass();
System.out.println("created fourth class " + proxyClass4.getName());
- TestClass proxy4 = (TestClass)proxyClass4.newInstance();
+ TestClass proxy4 = (TestClass)proxyClass4.getConstructor().newInstance();
((Proxy)proxy4).setHandler(handler);
proxy4.testMethod();
assertTrue(proxy4.isTestCalled());
return proceed.invoke(self, args); // execute the original method.
}
};
- Foo foo = (Foo)c.newInstance();
+ Foo foo = (Foo)c.getConstructor().newInstance();
((Proxy)foo).setHandler(mi);
testResult = "";
foo.foo(1);
};
ProxyFactory pf = new ProxyFactory();
pf.setSuperclass(ReadWriteData.class);
- Object data = pf.createClass().newInstance();
+ Object data = pf.createClass().getConstructor().newInstance();
// Object data = new ReadWriteData();
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName));
oos.writeObject(data);
public void testWriteReplace() throws Exception {
ProxyFactory pf = new ProxyFactory();
pf.setSuperclass(WriteReplace.class);
- Object data = pf.createClass().newInstance();
+ Object data = pf.createClass().getConstructor().newInstance();
assertEquals(data, ((WriteReplace)data).writeReplace());
ProxyFactory pf2 = new ProxyFactory();
pf2.setSuperclass(WriteReplace2.class);
- Object data2 = pf2.createClass().newInstance();
+ Object data2 = pf2.createClass().getConstructor().newInstance();
Method meth = data2.getClass().getDeclaredMethod("writeReplace", new Class[0]);
assertEquals("javassist.util.proxy.SerializedProxy",
meth.invoke(data2, new Object[0]).getClass().getName());
}
public static class WriteReplace2 implements Serializable {
- public Object writeReplace(int i) { return new Integer(i); }
+ public Object writeReplace(int i) { return Integer.valueOf(i); }
}
String value244;
return proceed.invoke(self, args); // execute the original method.
}
};
- Default3 foo = (Default3)c.newInstance();
+ Default3 foo = (Default3)c.getConstructor().newInstance();
((Proxy)foo).setHandler(mi);
foo.foo();
foo.bar();
return proceed.invoke(self, args); // execute the original method.
}
};
- Default2 foo = (Default2)c.newInstance();
+ Default2 foo = (Default2)c.getConstructor().newInstance();
((Proxy)foo).setHandler(mi);
foo.foo();
foo.bar();
public static final double d = 9.0;\r
public static final String s = "const";\r
public static final Object obj = null;\r
- public static final Integer integer = new Integer(4);\r
+ public static final Integer integer = Integer.valueOf(4);\r
public static int k = 2;\r
}\r
}
});
Class c = e.createClass();
- EnhanceTest obj = (EnhanceTest)c.newInstance();
+ EnhanceTest obj = (EnhanceTest)c.getConstructor().newInstance();
obj.foo("test");
}
public int run() {
Signature<String> s = new Signature<String>();
- return s.foo(new Integer(3), "foo", s, null).length();
+ return s.foo(Integer.valueOf(3), "foo", s, null).length();
}
<S> T foo(S s, T t, Signature<T> signature, Signature<Signature<String>> v) {
error = null;\r
Thread[] threads = new Thread[MAX_THREADS];\r
for (int i = 0; i < threads.length; ++i) {\r
- threads[i] = (Thread)cl.newInstance();\r
+ threads[i] = (Thread)cl.getDeclaredConstructor().newInstance();\r
}\r
long time = System.currentTimeMillis();\r
for (int i = 0; i < threads.length; ++i) {\r
f.setFilter(finalizeRemover);\r
f.writeDirectory = ".";\r
Class c = f.createClass();\r
- Target obj = (Target)c.newInstance();\r
+ Target obj = (Target)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor);\r
obj.m();\r
assertEquals(true, obj.m(true));\r
// f.setHandler(interceptor);\r
f.setFilter(finalizeRemover);\r
Class c = f.createClass();\r
- Target1 obj = (Target1)c.newInstance();\r
+ Target1 obj = (Target1)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor);\r
assertEquals(null, obj.m(null));\r
assertEquals(1, interceptor.counter);\r
// f.setHandler(interceptor);\r
f.setFilter(finalizeRemover);\r
Class c = f.createClass();\r
- Object obj = (Object)c.newInstance();\r
+ Object obj = (Object)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor);\r
System.out.println(obj.toString());\r
assertEquals(2, interceptor.counter);\r
// f.setHandler(interceptor);\r
f.setFilter(finalizeRemover);\r
Class c = f.createClass();\r
- Object obj = (Object)c.newInstance();\r
+ Object obj = (Object)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor);\r
System.out.println("setter1: " + obj.toString());\r
((ProxyObject)obj).setHandler(new MethodHandler() {\r
f.setFilter(finalizeRemover);\r
f.setInterfaces(new Class[] { Target3.class });\r
Class c = f.createClass();\r
- Target3 obj = (Target3)c.newInstance();\r
+ Target3 obj = (Target3)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor2);\r
assertEquals("OK", obj.m());\r
System.out.println(obj.toString());\r
f.setFilter(finalizeRemover);\r
f.setInterfaces(new Class[] { Target3.class, Target4.class });\r
Class c = f.createClass();\r
- Target3 obj = (Target3)c.newInstance();\r
+ Target3 obj = (Target3)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor2);\r
assertEquals("OK", obj.m());\r
System.out.println(obj.toString());\r
assertEquals(3, interceptor2.counter);\r
\r
interceptor2.counter = 0;\r
- Target4 obj4 = (Target4)c.newInstance();\r
+ Target4 obj4 = (Target4)c.getConstructor().newInstance();\r
((Proxy)obj4).setHandler(interceptor2);\r
assertEquals(3, obj4.bar4());\r
assertEquals(3, obj4.foo4());\r
}\r
});\r
Class c = f.createClass();\r
- Target3 obj = (Target3)c.newInstance();\r
+ Target3 obj = (Target3)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor2);\r
assertEquals("OK", obj.m());\r
System.out.println(obj.toString());\r
Class c = f.createClass();\r
assertTrue(testInitFlag); // since 3.12. Before then, this line was assertFalse(testInitFlag);\r
System.out.println("testInit createClass(): " + testInitFlag);\r
- TargetInit obj = (TargetInit)c.newInstance();\r
+ TargetInit obj = (TargetInit)c.getConstructor().newInstance();\r
assertTrue(testInitFlag);\r
System.out.println("testInit newInstance(): " + testInitFlag);\r
((ProxyObject)obj).setHandler(handler);\r
// f.setHandler(interceptor);\r
f.setFilter(finalizeRemover);\r
Class c = f.createClass();\r
- BridgeMethod obj = (BridgeMethod)c.newInstance();\r
+ BridgeMethod obj = (BridgeMethod)c.getConstructor().newInstance();\r
((Proxy)obj).setHandler(interceptor);\r
Integer value = obj.m1();\r
assertEquals(7, value.intValue());\r
};\r
ProxyFactory pf = new ProxyFactory();\r
pf.setSuperclass(ReadWriteData.class);\r
- Object data = pf.createClass().newInstance();\r
+ Object data = pf.createClass().getConstructor().newInstance();\r
// Object data = new ReadWriteData();\r
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName));\r
oos.writeObject(data);\r
public void testWriteReplace() throws Exception {\r
ProxyFactory pf = new ProxyFactory();\r
pf.setSuperclass(WriteReplace.class);\r
- Object data = pf.createClass().newInstance();\r
+ Object data = pf.createClass().getConstructor().newInstance();\r
assertEquals(data, ((WriteReplace)data).writeReplace());\r
\r
ProxyFactory pf2 = new ProxyFactory();\r
pf2.setSuperclass(WriteReplace2.class);\r
- Object data2 = pf2.createClass().newInstance();\r
+ Object data2 = pf2.createClass().getConstructor().newInstance();\r
Method meth = data2.getClass().getDeclaredMethod("writeReplace", new Class[0]);\r
assertEquals("javassist.util.proxy.SerializedProxy",\r
meth.invoke(data2, new Object[0]).getClass().getName());\r
}\r
\r
public static class WriteReplace2 implements Serializable {\r
- public Object writeReplace(int i) { return new Integer(i); }\r
+ public Object writeReplace(int i) { return Integer.valueOf(i); }\r
}\r
\r
public static void testJIRA189() throws Exception {\r
factory.setSuperclass(persistentClass);\r
factory.setInterfaces(new Class[] { Target189.TestProxy.class });\r
Class cl = factory.createClass();\r
- Target189.TestProxy proxy = (Target189.TestProxy)cl.newInstance();\r
+ Target189.TestProxy proxy = (Target189.TestProxy)cl.getConstructor().newInstance();\r
Target189.TestMethodHandler methodHandler = new Target189.TestMethodHandler();\r
((ProxyObject)proxy).setHandler(methodHandler);\r
((Target189.Article)proxy).getIssue();\r