aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
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/main
parent35fb5b39f86ef92661a0f672780bb000692fc580 (diff)
parent5ea5b6695cf3ecb9896b9e9ce02f089b893101a4 (diff)
downloadjavassist-fd1b5fa8cdf07a6b153bbc606fe1ab78c2be6c26.tar.gz
javassist-fd1b5fa8cdf07a6b153bbc606fe1ab78c2be6c26.zip
Merge branch 'test/java9-jigsaw'
Diffstat (limited to 'src/main')
-rw-r--r--src/main/javassist/ClassClassPath.java20
-rw-r--r--src/main/javassist/ClassPool.java12
-rw-r--r--src/main/javassist/ClassPoolTail.java20
-rw-r--r--src/main/javassist/CtClass.java2
-rw-r--r--src/main/javassist/CtField.java10
-rw-r--r--src/main/javassist/LoaderClassPath.java54
-rw-r--r--src/main/javassist/ModuleClassPath.java127
-rw-r--r--src/main/javassist/bytecode/ClassFile.java10
-rw-r--r--src/main/javassist/bytecode/ConstPool.java8
-rw-r--r--src/main/javassist/bytecode/analysis/Subroutine.java8
-rw-r--r--src/main/javassist/bytecode/analysis/SubroutineScanner.java8
-rw-r--r--src/main/javassist/bytecode/annotation/AnnotationImpl.java4
-rw-r--r--src/main/javassist/bytecode/annotation/BooleanMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/ByteMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/CharMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/DoubleMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/FloatMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/IntegerMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/LongMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/annotation/ShortMemberValue.java2
-rw-r--r--src/main/javassist/bytecode/stackmap/BasicBlock.java2
-rw-r--r--src/main/javassist/compiler/CodeGen.java2
-rw-r--r--src/main/javassist/compiler/KeywordTable.java2
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java4
-rw-r--r--src/main/javassist/tools/rmi/ObjectImporter.java2
-rw-r--r--src/main/javassist/util/proxy/FactoryHelper.java8
-rw-r--r--src/main/javassist/util/proxy/SerializedProxy.java9
27 files changed, 270 insertions, 58 deletions
diff --git a/src/main/javassist/ClassClassPath.java b/src/main/javassist/ClassClassPath.java
index 3cb8790c..c0a24d35 100644
--- a/src/main/javassist/ClassClassPath.java
+++ b/src/main/javassist/ClassClassPath.java
@@ -19,6 +19,8 @@ package javassist;
import java.io.InputStream;
import java.net.URL;
+import javassist.bytecode.ClassFile;
+
/**
* A search-path for obtaining a class file
* by <code>getResourceAsStream()</code> in <code>java.lang.Class</code>.
@@ -38,11 +40,19 @@ import java.net.URL;
* <code>ClassClassPath</code> uses a class object representing
* the class including the code snippet above.
*
+ * <p>Class files in a named module are private to that module.
+ * This method cannot obtain class files in named modules.
+ * </p>
+ *
* @see ClassPool#insertClassPath(ClassPath)
* @see ClassPool#appendClassPath(ClassPath)
* @see LoaderClassPath
+ * @see ModuleClassPath
*/
public class ClassClassPath implements ClassPath {
+ private static final boolean useJigsaw
+ = ClassFile.MAJOR_VERSION >= ClassFile.JAVA_9;
+
private Class thisClass;
/** Creates a search path.
@@ -70,9 +80,9 @@ public class ClassClassPath implements ClassPath {
/**
* Obtains a class file by <code>getResourceAsStream()</code>.
*/
- public InputStream openClassfile(String classname) {
- String jarname = "/" + classname.replace('.', '/') + ".class";
- return thisClass.getResourceAsStream(jarname);
+ public InputStream openClassfile(String classname) throws NotFoundException {
+ String filename = '/' + classname.replace('.', '/') + ".class";
+ return thisClass.getResourceAsStream(filename);
}
/**
@@ -81,8 +91,8 @@ public class ClassClassPath implements ClassPath {
* @return null if the class file could not be found.
*/
public URL find(String classname) {
- String jarname = "/" + classname.replace('.', '/') + ".class";
- return thisClass.getResource(jarname);
+ String filename = '/' + classname.replace('.', '/') + ".class";
+ return thisClass.getResource(filename);
}
/**
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java
index c90c2c74..c5d3c09a 100644
--- a/src/main/javassist/ClassPool.java
+++ b/src/main/javassist/ClassPool.java
@@ -220,10 +220,12 @@ public class ClassPool {
* </pre>
*
* <p>If the default class pool cannot find any class files,
- * try <code>ClassClassPath</code> and <code>LoaderClassPath</code>.
+ * try <code>ClassClassPath</code>, <code>ModuleClassPath</code>,
+ * or <code>LoaderClassPath</code>.
*
* @see ClassClassPath
* @see LoaderClassPath
+ * @see ModuleClassPath
*/
public static synchronized ClassPool getDefault() {
if (defaultPool == null) {
@@ -1152,13 +1154,13 @@ public class ClassPool {
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);
diff --git a/src/main/javassist/ClassPoolTail.java b/src/main/javassist/ClassPoolTail.java
index 2fd952b7..3e77f250 100644
--- a/src/main/javassist/ClassPoolTail.java
+++ b/src/main/javassist/ClassPoolTail.java
@@ -16,11 +16,17 @@
package javassist;
-import java.io.*;
-import java.util.jar.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Hashtable;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
final class ClassPathList {
ClassPathList next;
@@ -234,7 +240,13 @@ final class ClassPoolTail {
}
public ClassPath appendSystemPath() {
- return appendClassPath(new ClassClassPath());
+ if (javassist.bytecode.ClassFile.MAJOR_VERSION < javassist.bytecode.ClassFile.JAVA_9) {
+ return appendClassPath(new ClassClassPath());
+ }
+ else {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return appendClassPath(new LoaderClassPath(cl, true));
+ }
}
public ClassPath insertClassPath(String pathname)
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index 31e86044..4ff04c0e 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -69,7 +69,7 @@ public abstract class CtClass {
/**
* The version number of this release.
*/
- public static final String version = "3.21.0-GA";
+ public static final String version = "3.22.0-CR1";
/**
* Prints the version number and the copyright notice.
diff --git a/src/main/javassist/CtField.java b/src/main/javassist/CtField.java
index 15a6d6f0..f9d8051b 100644
--- a/src/main/javassist/CtField.java
+++ b/src/main/javassist/CtField.java
@@ -416,18 +416,18 @@ public class CtField extends CtMember {
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 :
diff --git a/src/main/javassist/LoaderClassPath.java b/src/main/javassist/LoaderClassPath.java
index a1580537..daf43c20 100644
--- a/src/main/javassist/LoaderClassPath.java
+++ b/src/main/javassist/LoaderClassPath.java
@@ -31,6 +31,10 @@ import java.lang.ref.WeakReference;
*
* <p>The given class loader must have both <code>getResourceAsStream()</code>
* and <code>getResource()</code>.
+ *
+ * <p>Class files in a named module are private to that module.
+ * This method cannot obtain class files in named modules.
+ * </p>
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
* @author Shigeru Chiba
@@ -38,15 +42,45 @@ import java.lang.ref.WeakReference;
* @see ClassPool#insertClassPath(ClassPath)
* @see ClassPool#appendClassPath(ClassPath)
* @see ClassClassPath
+ * @see ModuleClassPath
*/
public class LoaderClassPath implements ClassPath {
private WeakReference clref;
/**
+ * If true, this search path implicitly includes
+ * a {@code ModuleClassPath} as a fallback.
+ * For backward compatibility, this field is set to true
+ * if the JVM is Java 9 or later. It can be false in
+ * Java 9 but the behavior of {@code LoadClassPath} will
+ * be different from its behavior in Java 8 or older.
+ *
+ * <p>This field must be false if the JVM is Java 8 or older.
+ *
+ * @since 3.21
+ */
+ public static boolean fallbackOnModuleClassPath
+ = javassist.bytecode.ClassFile.MAJOR_VERSION >= javassist.bytecode.ClassFile.JAVA_9;
+
+ private static ModuleClassPath moduleClassPath = null;
+
+ private boolean doFallback;
+
+ /**
* Creates a search path representing a class loader.
*/
public LoaderClassPath(ClassLoader cl) {
+ this(cl, fallbackOnModuleClassPath);
+ }
+
+ LoaderClassPath(ClassLoader cl, boolean fallback) {
clref = new WeakReference(cl);
+ doFallback = fallback;
+ if (fallback)
+ synchronized (LoaderClassPath.class) {
+ if (moduleClassPath == null)
+ moduleClassPath = new ModuleClassPath();
+ }
}
public String toString() {
@@ -62,13 +96,18 @@ public class LoaderClassPath implements ClassPath {
* This method calls <code>getResourceAsStream(String)</code>
* on the class loader.
*/
- public InputStream openClassfile(String classname) {
+ public InputStream openClassfile(String classname) throws NotFoundException {
String cname = classname.replace('.', '/') + ".class";
ClassLoader cl = (ClassLoader)clref.get();
if (cl == null)
return null; // not found
- else
- return cl.getResourceAsStream(cname);
+ else {
+ InputStream is = cl.getResourceAsStream(cname);
+ if (is == null && doFallback)
+ return moduleClassPath.openClassfile(classname);
+ else
+ return is;
+ }
}
/**
@@ -83,8 +122,13 @@ public class LoaderClassPath implements ClassPath {
ClassLoader cl = (ClassLoader)clref.get();
if (cl == null)
return null; // not found
- else
- return cl.getResource(cname);
+ else {
+ URL url = cl.getResource(cname);
+ if (url == null && doFallback)
+ return moduleClassPath.find(classname);
+ else
+ return url;
+ }
}
/**
diff --git a/src/main/javassist/ModuleClassPath.java b/src/main/javassist/ModuleClassPath.java
new file mode 100644
index 00000000..20f0e430
--- /dev/null
+++ b/src/main/javassist/ModuleClassPath.java
@@ -0,0 +1,127 @@
+/*
+ * Javassist, a Java-bytecode translator toolkit.
+ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. Alternatively, the contents of this file may be used under
+ * the terms of the GNU Lesser General Public License Version 2.1 or later,
+ * or the Apache License Version 2.0.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ */
+
+package javassist;
+
+import java.io.InputStream;
+import java.lang.reflect.Layer;
+import java.lang.reflect.Module;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * A search-path for obtaining a class file
+ * by <code>getResourceAsStream()</code> in <code>java.lang.reflect.Module</code>.
+ *
+ * @see ClassPool#insertClassPath(ClassPath)
+ * @see ClassPool#appendClassPath(ClassPath)
+ * @see LoaderClassPath
+ * @see ClassClassPath
+ * @see 3.21
+ */
+public class ModuleClassPath implements ClassPath {
+ private HashMap packages = new HashMap();
+
+ ModuleClassPath() { this(Layer.boot()); }
+
+ /**
+ * Constructs a search path.
+ *
+ * @param layer the layer used to obtain a class file.
+ */
+ public ModuleClassPath(Layer layer) {
+ while (layer != null) {
+ Set modules = layer.modules();
+ Iterator it = modules.iterator();
+ while (it.hasNext())
+ addPackages((Module)it.next());
+
+ layer = layer.parent().orElse(null);
+ }
+ }
+
+ /**
+ * Constructs a search path.
+ *
+ * @param m the module used to obtain a class file.
+ */
+ public ModuleClassPath(Module m) {
+ addPackages(m);
+ }
+
+ private void addPackages(Module m) {
+ String[] names = m.getPackages();
+ for (int i = 0; i < names.length; i++)
+ packages.put(names[i], m);
+ }
+
+ /**
+ * Obtains a class file by <code>getResourceAsStream()</code>.
+ */
+ public InputStream openClassfile(String classname) throws NotFoundException {
+ String filename = classname.replace('.', '/') + ".class";
+ Module m = (Module)packages.get(getPackageName(classname));
+ if (m == null)
+ return null;
+ else
+ try {
+ return m.getResourceAsStream(filename);
+ }
+ catch (java.io.IOException e) {
+ throw new NotFoundException(classname, e);
+ }
+ }
+
+ /**
+ * Obtains the URL of the specified class file.
+ *
+ * @return null if the class file could not be found.
+ */
+ public URL find(String classname) {
+ String filename = classname.replace('.', '/') + ".class";
+ Module m = (Module)packages.get(getPackageName(classname));
+ if (m == null)
+ return null;
+ else
+ try {
+ InputStream is = m.getResourceAsStream(filename);
+ if (is == null)
+ return null;
+ else {
+ is.close();
+ return new URL("jar:file:unknown.jar!/" + filename);
+ }
+ }
+ catch (java.io.IOException e) {
+ return null;
+ }
+ }
+
+ private static String getPackageName(String name) {
+ int i = name.lastIndexOf('.');
+ if (i > 0)
+ return name.substring(0, i);
+ else
+ return "";
+ }
+
+ /**
+ * Does nothing.
+ */
+ public void close() {}
+}
diff --git a/src/main/javassist/bytecode/ClassFile.java b/src/main/javassist/bytecode/ClassFile.java
index 5e0cba4d..d97ac735 100644
--- a/src/main/javassist/bytecode/ClassFile.java
+++ b/src/main/javassist/bytecode/ClassFile.java
@@ -118,6 +118,12 @@ public final class ClassFile {
public static final int JAVA_8 = 52;
/**
+ * The major version number of class files
+ * for JDK 1.9.
+ */
+ public static final int JAVA_9 = 53;
+
+ /**
* The major version number of class files created
* from scratch. The default value is 47 (JDK 1.3).
* It is 49 (JDK 1.5)
@@ -128,6 +134,8 @@ public final class ClassFile {
* if the JVM supports <code>java.lang.invoke.CallSite</code>.
* It is 52 (JDK 1.8)
* if the JVM supports <code>java.util.function.Function</code>.
+ * It is 53 (JDK 1.9)
+ * if the JVM supports <code>java.lang.reflect.Module</code>.
*/
public static final int MAJOR_VERSION;
@@ -142,6 +150,8 @@ public final class ClassFile {
ver = JAVA_7;
Class.forName("java.util.function.Function");
ver = JAVA_8;
+ Class.forName("java.lang.reflect.Module");
+ ver = JAVA_9;
}
catch (Throwable t) {}
MAJOR_VERSION = ver;
diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java
index 06df1327..86d7eb40 100644
--- a/src/main/javassist/bytecode/ConstPool.java
+++ b/src/main/javassist/bytecode/ConstPool.java
@@ -567,13 +567,13 @@ public final class ConstPool {
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;
diff --git a/src/main/javassist/bytecode/analysis/Subroutine.java b/src/main/javassist/bytecode/analysis/Subroutine.java
index ca0d1737..381ed6ab 100644
--- a/src/main/javassist/bytecode/analysis/Subroutine.java
+++ b/src/main/javassist/bytecode/analysis/Subroutine.java
@@ -34,11 +34,11 @@ 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() {
@@ -46,11 +46,11 @@ public class Subroutine {
}
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() {
diff --git a/src/main/javassist/bytecode/analysis/SubroutineScanner.java b/src/main/javassist/bytecode/analysis/SubroutineScanner.java
index 8cf688f5..c0af816a 100644
--- a/src/main/javassist/bytecode/analysis/SubroutineScanner.java
+++ b/src/main/javassist/bytecode/analysis/SubroutineScanner.java
@@ -62,10 +62,10 @@ public class SubroutineScanner implements Opcode {
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);
@@ -103,10 +103,10 @@ public class SubroutineScanner implements Opcode {
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);
diff --git a/src/main/javassist/bytecode/annotation/AnnotationImpl.java b/src/main/javassist/bytecode/annotation/AnnotationImpl.java
index dabf1f44..babac927 100644
--- a/src/main/javassist/bytecode/annotation/AnnotationImpl.java
+++ b/src/main/javassist/bytecode/annotation/AnnotationImpl.java
@@ -131,12 +131,12 @@ public class AnnotationImpl implements InvocationHandler {
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)
diff --git a/src/main/javassist/bytecode/annotation/BooleanMemberValue.java b/src/main/javassist/bytecode/annotation/BooleanMemberValue.java
index 17756900..b005ad5a 100644
--- a/src/main/javassist/bytecode/annotation/BooleanMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/BooleanMemberValue.java
@@ -59,7 +59,7 @@ public class BooleanMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Boolean(getValue());
+ return Boolean.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/ByteMemberValue.java b/src/main/javassist/bytecode/annotation/ByteMemberValue.java
index 63aad72a..d0fb5c61 100644
--- a/src/main/javassist/bytecode/annotation/ByteMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/ByteMemberValue.java
@@ -59,7 +59,7 @@ public class ByteMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Byte(getValue());
+ return Byte.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/CharMemberValue.java b/src/main/javassist/bytecode/annotation/CharMemberValue.java
index 1b991d29..ce5d4199 100644
--- a/src/main/javassist/bytecode/annotation/CharMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/CharMemberValue.java
@@ -60,7 +60,7 @@ public class CharMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Character(getValue());
+ return Character.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/DoubleMemberValue.java b/src/main/javassist/bytecode/annotation/DoubleMemberValue.java
index f8b417fa..0f18a72d 100644
--- a/src/main/javassist/bytecode/annotation/DoubleMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/DoubleMemberValue.java
@@ -61,7 +61,7 @@ public class DoubleMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Double(getValue());
+ return Double.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/FloatMemberValue.java b/src/main/javassist/bytecode/annotation/FloatMemberValue.java
index 35152fdd..3bf07ef0 100644
--- a/src/main/javassist/bytecode/annotation/FloatMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/FloatMemberValue.java
@@ -61,7 +61,7 @@ public class FloatMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Float(getValue());
+ return Float.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/IntegerMemberValue.java b/src/main/javassist/bytecode/annotation/IntegerMemberValue.java
index 6783b827..83e4e70f 100644
--- a/src/main/javassist/bytecode/annotation/IntegerMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/IntegerMemberValue.java
@@ -66,7 +66,7 @@ public class IntegerMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Integer(getValue());
+ return Integer.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/LongMemberValue.java b/src/main/javassist/bytecode/annotation/LongMemberValue.java
index eafb5b82..7f0c6fec 100644
--- a/src/main/javassist/bytecode/annotation/LongMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/LongMemberValue.java
@@ -60,7 +60,7 @@ public class LongMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Long(getValue());
+ return Long.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/annotation/ShortMemberValue.java b/src/main/javassist/bytecode/annotation/ShortMemberValue.java
index 909c09ee..82a6f59e 100644
--- a/src/main/javassist/bytecode/annotation/ShortMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/ShortMemberValue.java
@@ -60,7 +60,7 @@ public class ShortMemberValue extends MemberValue {
}
Object getValue(ClassLoader cl, ClassPool cp, Method m) {
- return new Short(getValue());
+ return Short.valueOf(getValue());
}
Class getType(ClassLoader cl) {
diff --git a/src/main/javassist/bytecode/stackmap/BasicBlock.java b/src/main/javassist/bytecode/stackmap/BasicBlock.java
index 79ec5a77..7a643609 100644
--- a/src/main/javassist/bytecode/stackmap/BasicBlock.java
+++ b/src/main/javassist/bytecode/stackmap/BasicBlock.java
@@ -196,7 +196,7 @@ public class BasicBlock {
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);
diff --git a/src/main/javassist/compiler/CodeGen.java b/src/main/javassist/compiler/CodeGen.java
index e02884de..ab02d8cf 100644
--- a/src/main/javassist/compiler/CodeGen.java
+++ b/src/main/javassist/compiler/CodeGen.java
@@ -595,7 +595,7 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
"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);
diff --git a/src/main/javassist/compiler/KeywordTable.java b/src/main/javassist/compiler/KeywordTable.java
index 3f0025fe..5f516e3d 100644
--- a/src/main/javassist/compiler/KeywordTable.java
+++ b/src/main/javassist/compiler/KeywordTable.java
@@ -28,6 +28,6 @@ public final class KeywordTable extends java.util.HashMap {
}
public void append(String name, int t) {
- put(name, new Integer(t));
+ put(name, Integer.valueOf(t));
}
}
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index b1f932ca..07c113a3 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -209,7 +209,7 @@ public class MemberCodeGen extends CodeGen {
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
}
@@ -235,7 +235,7 @@ public class MemberCodeGen extends CodeGen {
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;
}
diff --git a/src/main/javassist/tools/rmi/ObjectImporter.java b/src/main/javassist/tools/rmi/ObjectImporter.java
index 476ec3c8..43b62039 100644
--- a/src/main/javassist/tools/rmi/ObjectImporter.java
+++ b/src/main/javassist/tools/rmi/ObjectImporter.java
@@ -189,7 +189,7 @@ public class ObjectImporter implements java.io.Serializable {
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) });
}
/**
diff --git a/src/main/javassist/util/proxy/FactoryHelper.java b/src/main/javassist/util/proxy/FactoryHelper.java
index 9b2b791c..b17b78ed 100644
--- a/src/main/javassist/util/proxy/FactoryHelper.java
+++ b/src/main/javassist/util/proxy/FactoryHelper.java
@@ -152,13 +152,13 @@ public class FactoryHelper {
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);
diff --git a/src/main/javassist/util/proxy/SerializedProxy.java b/src/main/javassist/util/proxy/SerializedProxy.java
index 36425a88..a0485da0 100644
--- a/src/main/javassist/util/proxy/SerializedProxy.java
+++ b/src/main/javassist/util/proxy/SerializedProxy.java
@@ -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;
@@ -82,10 +83,16 @@ class SerializedProxy implements Serializable {
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());
}