Skip to content

Commit

Permalink
fixes calls to a deprecated method in Java 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
chibash committed Aug 1, 2016
1 parent 4ed22b0 commit 0ebd27d
Show file tree
Hide file tree
Showing 47 changed files with 147 additions and 140 deletions.
2 changes: 1 addition & 1 deletion src/main/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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
8 changes: 4 additions & 4 deletions src/main/javassist/ClassPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1154,13 +1154,13 @@ public Class toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain)
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/javassist/CtClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public abstract class CtClass {
/**
* 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.
Expand All @@ -80,7 +80,7 @@ public abstract class CtClass {
*/
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.");
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/javassist/CtField.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,18 @@ public Object getConstantValue() {
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 :
Expand Down
8 changes: 4 additions & 4 deletions src/main/javassist/bytecode/ConstPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,13 @@ public Object getLdcValue(int index) {
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;

Expand Down
8 changes: 4 additions & 4 deletions src/main/javassist/bytecode/analysis/Subroutine.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ public class Subroutine {

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() {
return 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() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/javassist/bytecode/analysis/SubroutineScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public Subroutine[] scan(MethodInfo method) throws BadBytecode {

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);
Expand Down Expand Up @@ -103,10 +103,10 @@ private boolean scanOp(int pos, CodeIterator iter, Subroutine sub) throws BadByt
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/javassist/bytecode/annotation/AnnotationImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ public Object invoke(Object proxy, Method method, Object[] args)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public BooleanMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Boolean(getValue());
return Boolean.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ByteMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Byte(getValue());
return Byte.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CharMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Character(getValue());
return Character.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public DoubleMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Double(getValue());
return Double.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public FloatMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Float(getValue());
return Float.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public IntegerMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Integer(getValue());
return Integer.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public LongMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Long(getValue());
return Long.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ShortMemberValue(ConstPool cp) {
}

Object getValue(ClassLoader cl, ClassPool cp, Method m) {
return new Short(getValue());
return Short.valueOf(getValue());
}

Class getType(ClassLoader cl) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/javassist/bytecode/stackmap/BasicBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private Mark makeMark(HashMap table, int pos, BasicBlock[] jump,

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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/javassist/compiler/CodeGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ private void atBreakStmnt(Stmnt st, boolean notCont)
"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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/javassist/compiler/KeywordTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public int lookup(String name) {
}

public void append(String name, int t) {
put(name, new Integer(t));
put(name, Integer.valueOf(t));
}
}
4 changes: 2 additions & 2 deletions src/main/javassist/compiler/MemberCodeGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected void atTryStmnt(Stmnt st) throws CompileError {
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
}

Expand All @@ -235,7 +235,7 @@ protected void atTryStmnt(Stmnt st) throws CompileError {

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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/javassist/tools/rmi/ObjectImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public Object lookupObject(String name) throws ObjectNotFoundException
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) });
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/javassist/util/proxy/FactoryHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ public static Class toClass(ClassFile cf, ClassLoader loader, ProtectionDomain d
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);
Expand Down
9 changes: 8 additions & 1 deletion src/main/javassist/util/proxy/SerializedProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -82,10 +83,16 @@ Object readResolve() throws ObjectStreamException {
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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception {
ctClass.debugWriteFile();
Class<?> cc = ctClass.toClass();
System.out.println(cc.getName());
InvalidStackMapFrame obj = (InvalidStackMapFrame)cc.newInstance();
InvalidStackMapFrame obj = (InvalidStackMapFrame)cc.getDeclaredConstructor().newInstance();
obj.bytecodeVerifyError();
}
}
2 changes: 1 addition & 1 deletion src/test/javassist/JvstTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ public void testToString() throws Exception {
}

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"));
}

Expand Down
12 changes: 6 additions & 6 deletions src/test/javassist/JvstTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1423,32 +1423,32 @@ public void testStaticFinal() throws Exception {
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);
Expand Down
Loading

0 comments on commit 0ebd27d

Please sign in to comment.