Clean up warnings in CGLIB fork

This commit is contained in:
Sam Brannen 2022-08-13 16:03:28 +02:00
parent 6ba31acf35
commit d6d629a8eb
29 changed files with 431 additions and 231 deletions

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type; import org.springframework.asm.Type;
abstract public class ClassInfo { abstract public class ClassInfo {
@ -28,6 +28,7 @@ abstract public class ClassInfo {
abstract public Type[] getInterfaces(); abstract public Type[] getInterfaces();
abstract public int getModifiers(); abstract public int getModifiers();
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) if (o == null)
return false; return false;
@ -36,10 +37,12 @@ abstract public class ClassInfo {
return getType().equals(((ClassInfo)o).getType()); return getType().equals(((ClassInfo)o).getType());
} }
@Override
public int hashCode() { public int hashCode() {
return getType().hashCode(); return getType().hashCode();
} }
@Override
public String toString() { public String toString() {
// TODO: include modifiers, superType, interfaces // TODO: include modifiers, superType, interfaces
return getType().getClassName(); return getType().getClassName();

View File

@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import java.io.*; import java.util.Arrays;
import java.util.*;
import org.springframework.asm.*; import org.springframework.asm.Label;
import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Type;
/** /**
* @author Juozas Baliuka, Chris Nokleberg * @author Juozas Baliuka, Chris Nokleberg
@ -81,26 +84,26 @@ public class CodeEmitter extends LocalVariablesSorter {
argumentTypes = sig.getArgumentTypes(); argumentTypes = sig.getArgumentTypes();
} }
@Override
public ClassInfo getClassInfo() { public ClassInfo getClassInfo() {
return classInfo; return classInfo;
} }
@Override
public int getModifiers() { public int getModifiers() {
return access; return access;
} }
@Override
public Signature getSignature() { public Signature getSignature() {
return sig; return sig;
} }
@Override
public Type[] getExceptionTypes() { public Type[] getExceptionTypes() {
return exceptionTypes; return exceptionTypes;
} }
public Attribute getAttribute() {
// TODO
return null;
}
} }
CodeEmitter(ClassEmitter ce, MethodVisitor mv, int access, Signature sig, Type[] exceptionTypes) { CodeEmitter(ClassEmitter ce, MethodVisitor mv, int access, Signature sig, Type[] exceptionTypes) {
@ -843,6 +846,7 @@ public class CodeEmitter extends LocalVariablesSorter {
} }
} }
@Override
public void visitMaxs(int maxStack, int maxLocals) { public void visitMaxs(int maxStack, int maxLocals) {
if (!TypeUtils.isAbstract(state.access)) { if (!TypeUtils.isAbstract(state.access)) {
mv.visitMaxs(0, 0); mv.visitMaxs(0, 0);

View File

@ -13,10 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import java.util.*; import java.util.ArrayList;
import java.lang.reflect.Array; import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/** /**
* @author Chris Nokleberg * @author Chris Nokleberg
@ -74,4 +80,3 @@ public class CollectionUtils {
return indexes; return indexes;
} }
} }

View File

@ -13,15 +13,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import org.springframework.asm.ClassWriter; import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import org.springframework.asm.ClassReader; import org.springframework.asm.ClassReader;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.asm.Opcodes; import org.springframework.asm.ClassWriter;
import java.io.*;
import java.lang.reflect.Constructor;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class DebuggingClassWriter extends ClassVisitor { public class DebuggingClassWriter extends ClassVisitor {
@ -50,6 +55,7 @@ public class DebuggingClassWriter extends ClassVisitor {
super(Constants.ASM_API, new ClassWriter(flags)); super(Constants.ASM_API, new ClassWriter(flags));
} }
@Override
public void visit(int version, public void visit(int version,
int access, int access,
String name, String name,

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core;
import java.util.Set; package org.springframework.cglib.core;
/** /**
* The default policy used by {@link AbstractClassGenerator}. * The default policy used by {@link AbstractClassGenerator}.
@ -35,6 +34,7 @@ public class DefaultNamingPolicy implements NamingPolicy {
*/ */
private final static boolean STRESS_HASH_CODE = Boolean.getBoolean("org.springframework.cglib.test.stressHashCodes"); private final static boolean STRESS_HASH_CODE = Boolean.getBoolean("org.springframework.cglib.test.stressHashCodes");
@Override
public String getClassName(String prefix, String source, Object key, Predicate names) { public String getClassName(String prefix, String source, Object key, Predicate names) {
if (prefix == null) { if (prefix == null) {
prefix = "org.springframework.cglib.empty.Object"; prefix = "org.springframework.cglib.empty.Object";
@ -61,11 +61,14 @@ public class DefaultNamingPolicy implements NamingPolicy {
return "ByCGLIB"; return "ByCGLIB";
} }
@Override
public int hashCode() { public int hashCode() {
return getTag().hashCode(); return getTag().hashCode();
} }
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
return (o instanceof DefaultNamingPolicy) && ((DefaultNamingPolicy) o).getTag().equals(getTag()); return (o instanceof DefaultNamingPolicy defaultNamingPolicy) &&
defaultNamingPolicy.getTag().equals(getTag());
} }
} }

View File

@ -13,15 +13,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.cglib.core.internal.CustomizerRegistry;
import org.springframework.asm.Label; import org.springframework.asm.Label;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.internal.CustomizerRegistry;
@SuppressWarnings({"rawtypes", "unchecked", "static", "fallthrough", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "static", "fallthrough", "deprecation"})
public class EmitUtils { public class EmitUtils {
@ -123,7 +132,7 @@ public class EmitUtils {
e.load_local(loopvar); e.load_local(loopvar);
e.load_local(array); e.load_local(array);
e.arraylength(); e.arraylength();
e.if_icmp(e.LT, loopbody); e.if_icmp(CodeEmitter.LT, loopbody);
} }
/** /**
@ -160,7 +169,7 @@ public class EmitUtils {
e.load_local(loopvar); e.load_local(loopvar);
e.load_local(array1); e.load_local(array1);
e.arraylength(); e.arraylength();
e.if_icmp(e.LT, loopbody); e.if_icmp(CodeEmitter.LT, loopbody);
} }
public static void string_switch(CodeEmitter e, String[] strings, int switchStyle, ObjectSwitchCallback callback) { public static void string_switch(CodeEmitter e, String[] strings, int switchStyle, ObjectSwitchCallback callback) {
@ -193,6 +202,7 @@ public class EmitUtils {
final Label def = e.make_label(); final Label def = e.make_label();
final Label end = e.make_label(); final Label end = e.make_label();
final Map buckets = CollectionUtils.bucket(Arrays.asList(strings), new Transformer() { final Map buckets = CollectionUtils.bucket(Arrays.asList(strings), new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return ((String)value).length(); return ((String)value).length();
} }
@ -200,10 +210,12 @@ public class EmitUtils {
e.dup(); e.dup();
e.invoke_virtual(Constants.TYPE_STRING, STRING_LENGTH); e.invoke_virtual(Constants.TYPE_STRING, STRING_LENGTH);
e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label ignore_end) throws Exception { public void processCase(int key, Label ignore_end) throws Exception {
List bucket = (List)buckets.get(key); List bucket = (List)buckets.get(key);
stringSwitchHelper(e, bucket, callback, def, end, 0); stringSwitchHelper(e, bucket, callback, def, end, 0);
} }
@Override
public void processDefault() { public void processDefault() {
e.goTo(def); e.goTo(def);
} }
@ -222,6 +234,7 @@ public class EmitUtils {
final int index) throws Exception { final int index) throws Exception {
final int len = ((String)strings.get(0)).length(); final int len = ((String)strings.get(0)).length();
final Map buckets = CollectionUtils.bucket(strings, new Transformer() { final Map buckets = CollectionUtils.bucket(strings, new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return ((String)value).charAt(index); return ((String)value).charAt(index);
} }
@ -230,6 +243,7 @@ public class EmitUtils {
e.push(index); e.push(index);
e.invoke_virtual(Constants.TYPE_STRING, STRING_CHAR_AT); e.invoke_virtual(Constants.TYPE_STRING, STRING_CHAR_AT);
e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label ignore_end) throws Exception { public void processCase(int key, Label ignore_end) throws Exception {
List bucket = (List)buckets.get(key); List bucket = (List)buckets.get(key);
if (index + 1 == len) { if (index + 1 == len) {
@ -239,6 +253,7 @@ public class EmitUtils {
stringSwitchHelper(e, bucket, callback, def, end, index + 1); stringSwitchHelper(e, bucket, callback, def, end, index + 1);
} }
} }
@Override
public void processDefault() { public void processDefault() {
e.goTo(def); e.goTo(def);
} }
@ -260,6 +275,7 @@ public class EmitUtils {
final ObjectSwitchCallback callback, final ObjectSwitchCallback callback,
final boolean skipEquals) throws Exception { final boolean skipEquals) throws Exception {
final Map buckets = CollectionUtils.bucket(Arrays.asList(strings), new Transformer() { final Map buckets = CollectionUtils.bucket(Arrays.asList(strings), new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return value.hashCode(); return value.hashCode();
} }
@ -269,13 +285,14 @@ public class EmitUtils {
e.dup(); e.dup();
e.invoke_virtual(Constants.TYPE_OBJECT, HASH_CODE); e.invoke_virtual(Constants.TYPE_OBJECT, HASH_CODE);
e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label ignore_end) throws Exception { public void processCase(int key, Label ignore_end) throws Exception {
List bucket = (List)buckets.get(key); List bucket = (List)buckets.get(key);
Label next = null; Label next = null;
if (skipEquals && bucket.size() == 1) { if (skipEquals && bucket.size() == 1) {
if (skipEquals) if (skipEquals)
e.pop(); e.pop();
callback.processCase((String)bucket.get(0), end); callback.processCase(bucket.get(0), end);
} else { } else {
for (Iterator it = bucket.iterator(); it.hasNext();) { for (Iterator it = bucket.iterator(); it.hasNext();) {
String string = (String)it.next(); String string = (String)it.next();
@ -288,15 +305,16 @@ public class EmitUtils {
e.push(string); e.push(string);
e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS); e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS);
if (it.hasNext()) { if (it.hasNext()) {
e.if_jump(e.EQ, next = e.make_label()); e.if_jump(CodeEmitter.EQ, next = e.make_label());
e.pop(); e.pop();
} else { } else {
e.if_jump(e.EQ, def); e.if_jump(CodeEmitter.EQ, def);
} }
callback.processCase(string, end); callback.processCase(string, end);
} }
} }
} }
@Override
public void processDefault() { public void processDefault() {
e.pop(); e.pop();
} }
@ -403,14 +421,14 @@ public class EmitUtils {
} else { } else {
e.swap(Type.INT_TYPE, type); e.swap(Type.INT_TYPE, type);
e.push(multiplier); e.push(multiplier);
e.math(e.MUL, Type.INT_TYPE); e.math(CodeEmitter.MUL, Type.INT_TYPE);
e.swap(type, Type.INT_TYPE); e.swap(type, Type.INT_TYPE);
if (TypeUtils.isPrimitive(type)) { if (TypeUtils.isPrimitive(type)) {
hash_primitive(e, type); hash_primitive(e, type);
} else { } else {
hash_object(e, type, registry); hash_object(e, type, registry);
} }
e.math(e.ADD, Type.INT_TYPE); e.math(CodeEmitter.ADD, Type.INT_TYPE);
} }
} }
@ -420,6 +438,7 @@ public class EmitUtils {
e.dup(); e.dup();
e.ifnull(skip); e.ifnull(skip);
EmitUtils.process_array(e, type, new ProcessArrayCallback() { EmitUtils.process_array(e, type, new ProcessArrayCallback() {
@Override
public void processElement(Type type) { public void processElement(Type type) {
hash_code(e, type, multiplier, registry); hash_code(e, type, multiplier, registry);
} }
@ -461,7 +480,7 @@ public class EmitUtils {
case Type.BOOLEAN: case Type.BOOLEAN:
// f ? 0 : 1 // f ? 0 : 1
e.push(1); e.push(1);
e.math(e.XOR, Type.INT_TYPE); e.math(CodeEmitter.XOR, Type.INT_TYPE);
break; break;
case Type.FLOAT: case Type.FLOAT:
// Float.floatToIntBits(f) // Float.floatToIntBits(f)
@ -480,8 +499,8 @@ public class EmitUtils {
// (int)(f ^ (f >>> 32)) // (int)(f ^ (f >>> 32))
e.dup2(); e.dup2();
e.push(32); e.push(32);
e.math(e.USHR, Type.LONG_TYPE); e.math(CodeEmitter.USHR, Type.LONG_TYPE);
e.math(e.XOR, Type.LONG_TYPE); e.math(CodeEmitter.XOR, Type.LONG_TYPE);
e.cast_numeric(Type.LONG_TYPE, Type.INT_TYPE); e.cast_numeric(Type.LONG_TYPE, Type.INT_TYPE);
} }
@ -506,6 +525,7 @@ public class EmitUtils {
*/ */
public static void not_equals(final CodeEmitter e, Type type, final Label notEquals, final CustomizerRegistry registry) { public static void not_equals(final CodeEmitter e, Type type, final Label notEquals, final CustomizerRegistry registry) {
(new ProcessArrayCallback() { (new ProcessArrayCallback() {
@Override
public void processElement(Type type) { public void processElement(Type type) {
not_equals_helper(e, type, notEquals, registry, this); not_equals_helper(e, type, notEquals, registry, this);
} }
@ -518,7 +538,7 @@ public class EmitUtils {
CustomizerRegistry registry, CustomizerRegistry registry,
ProcessArrayCallback callback) { ProcessArrayCallback callback) {
if (TypeUtils.isPrimitive(type)) { if (TypeUtils.isPrimitive(type)) {
e.if_cmp(type, e.NE, notEquals); e.if_cmp(type, CodeEmitter.NE, notEquals);
} else { } else {
Label end = e.make_label(); Label end = e.make_label();
nullcmp(e, notEquals, end); nullcmp(e, notEquals, end);
@ -528,7 +548,7 @@ public class EmitUtils {
e.arraylength(); e.arraylength();
e.swap(); e.swap();
e.arraylength(); e.arraylength();
e.if_icmp(e.EQ, checkContents); e.if_icmp(CodeEmitter.EQ, checkContents);
e.pop2(); e.pop2();
e.goTo(notEquals); e.goTo(notEquals);
e.mark(checkContents); e.mark(checkContents);
@ -545,7 +565,7 @@ public class EmitUtils {
} }
} }
e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS); e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS);
e.if_jump(e.EQ, notEquals); e.if_jump(CodeEmitter.EQ, notEquals);
} }
e.mark(end); e.mark(end);
} }
@ -610,6 +630,7 @@ public class EmitUtils {
final CustomizerRegistry registry) { final CustomizerRegistry registry) {
final ArrayDelimiters d = (delims != null) ? delims : DEFAULT_DELIMITERS; final ArrayDelimiters d = (delims != null) ? delims : DEFAULT_DELIMITERS;
ProcessArrayCallback callback = new ProcessArrayCallback() { ProcessArrayCallback callback = new ProcessArrayCallback() {
@Override
public void processElement(Type type) { public void processElement(Type type) {
append_string_helper(e, type, d, registry, this); append_string_helper(e, type, d, registry, this);
e.push(d.inside); e.push(d.inside);
@ -686,7 +707,7 @@ public class EmitUtils {
e.dup(); e.dup();
e.invoke_virtual(Constants.TYPE_STRING_BUFFER, LENGTH); e.invoke_virtual(Constants.TYPE_STRING_BUFFER, LENGTH);
e.push(amt); e.push(amt);
e.math(e.SUB, Type.INT_TYPE); e.math(CodeEmitter.SUB, Type.INT_TYPE);
e.invoke_virtual(Constants.TYPE_STRING_BUFFER, SET_LENGTH); e.invoke_virtual(Constants.TYPE_STRING_BUFFER, SET_LENGTH);
} }
@ -732,6 +753,7 @@ public class EmitUtils {
try { try {
final Map cache = new HashMap(); final Map cache = new HashMap();
final ParameterTyper cached = new ParameterTyper() { final ParameterTyper cached = new ParameterTyper() {
@Override
public Type[] getParameterTypes(MethodInfo member) { public Type[] getParameterTypes(MethodInfo member) {
Type[] types = (Type[])cache.get(member); Type[] types = (Type[])cache.get(member);
if (types == null) { if (types == null) {
@ -745,15 +767,18 @@ public class EmitUtils {
if (useName) { if (useName) {
e.swap(); e.swap();
final Map buckets = CollectionUtils.bucket(members, new Transformer() { final Map buckets = CollectionUtils.bucket(members, new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return ((MethodInfo)value).getSignature().getName(); return ((MethodInfo)value).getSignature().getName();
} }
}); });
String[] names = (String[])buckets.keySet().toArray(new String[buckets.size()]); String[] names = (String[])buckets.keySet().toArray(new String[buckets.size()]);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() { EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label dontUseEnd) throws Exception { public void processCase(Object key, Label dontUseEnd) throws Exception {
member_helper_size(e, (List)buckets.get(key), callback, cached, def, end); member_helper_size(e, (List)buckets.get(key), callback, cached, def, end);
} }
@Override
public void processDefault() throws Exception { public void processDefault() throws Exception {
e.goTo(def); e.goTo(def);
} }
@ -781,6 +806,7 @@ public class EmitUtils {
final Label def, final Label def,
final Label end) throws Exception { final Label end) throws Exception {
final Map buckets = CollectionUtils.bucket(members, new Transformer() { final Map buckets = CollectionUtils.bucket(members, new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return typer.getParameterTypes((MethodInfo)value).length; return typer.getParameterTypes((MethodInfo)value).length;
} }
@ -788,10 +814,12 @@ public class EmitUtils {
e.dup(); e.dup();
e.arraylength(); e.arraylength();
e.process_switch(EmitUtils.getSwitchKeys(buckets), new ProcessSwitchCallback() { e.process_switch(EmitUtils.getSwitchKeys(buckets), new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label dontUseEnd) throws Exception { public void processCase(int key, Label dontUseEnd) throws Exception {
List bucket = (List)buckets.get(key); List bucket = (List)buckets.get(key);
member_helper_type(e, bucket, callback, typer, def, end, new BitSet()); member_helper_type(e, bucket, callback, typer, def, end, new BitSet());
} }
@Override
public void processDefault() throws Exception { public void processDefault() throws Exception {
e.goTo(def); e.goTo(def);
} }
@ -816,7 +844,7 @@ public class EmitUtils {
e.invoke_virtual(Constants.TYPE_CLASS, GET_NAME); e.invoke_virtual(Constants.TYPE_CLASS, GET_NAME);
e.push(TypeUtils.emulateClassGetName(types[i])); e.push(TypeUtils.emulateClassGetName(types[i]));
e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS); e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS);
e.if_jump(e.EQ, def); e.if_jump(CodeEmitter.EQ, def);
} }
} }
e.pop(); e.pop();
@ -829,6 +857,7 @@ public class EmitUtils {
for (int i = 0; i < example.length; i++) { for (int i = 0; i < example.length; i++) {
final int j = i; final int j = i;
Map test = CollectionUtils.bucket(members, new Transformer() { Map test = CollectionUtils.bucket(members, new Transformer() {
@Override
public Object transform(Object value) { public Object transform(Object value) {
return TypeUtils.emulateClassGetName(typer.getParameterTypes((MethodInfo)value)[j]); return TypeUtils.emulateClassGetName(typer.getParameterTypes((MethodInfo)value)[j]);
} }
@ -852,9 +881,11 @@ public class EmitUtils {
final Map fbuckets = buckets; final Map fbuckets = buckets;
String[] names = (String[])buckets.keySet().toArray(new String[buckets.size()]); String[] names = (String[])buckets.keySet().toArray(new String[buckets.size()]);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() { EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label dontUseEnd) throws Exception { public void processCase(Object key, Label dontUseEnd) throws Exception {
member_helper_type(e, (List)fbuckets.get(key), callback, typer, def, end, checked); member_helper_type(e, (List)fbuckets.get(key), callback, typer, def, end, checked);
} }
@Override
public void processDefault() throws Exception { public void processDefault() throws Exception {
e.goTo(def); e.goTo(def);
} }

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type; import org.springframework.asm.Type;
abstract public class MethodInfo { abstract public class MethodInfo {
@ -28,6 +28,7 @@ abstract public class MethodInfo {
abstract public Signature getSignature(); abstract public Signature getSignature();
abstract public Type[] getExceptionTypes(); abstract public Type[] getExceptionTypes();
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) if (o == null)
return false; return false;
@ -36,10 +37,12 @@ abstract public class MethodInfo {
return getSignature().equals(((MethodInfo)o).getSignature()); return getSignature().equals(((MethodInfo)o).getSignature());
} }
@Override
public int hashCode() { public int hashCode() {
return getSignature().hashCode(); return getSignature().hashCode();
} }
@Override
public String toString() { public String toString() {
// TODO: include modifiers, exceptions // TODO: include modifiers, exceptions
return getSignature().toString(); return getSignature().toString();

View File

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core; package org.springframework.cglib.core;
import java.lang.reflect.*; import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class MethodInfoTransformer implements Transformer public class MethodInfoTransformer implements Transformer
{ {
@ -25,11 +27,12 @@ public class MethodInfoTransformer implements Transformer
return INSTANCE; return INSTANCE;
} }
@Override
public Object transform(Object value) { public Object transform(Object value) {
if (value instanceof Method) { if (value instanceof Method method) {
return ReflectUtils.getMethodInfo((Method)value); return ReflectUtils.getMethodInfo(method);
} else if (value instanceof Constructor) { } else if (value instanceof Constructor<?> constructor) {
return ReflectUtils.getMethodInfo((Constructor)value); return ReflectUtils.getMethodInfo(constructor);
} else { } else {
throw new IllegalArgumentException("cannot get method info for " + value); throw new IllegalArgumentException("cannot get method info for " + value);
} }

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.core;
import java.util.Set; package org.springframework.cglib.core;
/** /**
* Customize the generated class name for {@link AbstractClassGenerator}-based utilities. * Customize the generated class name for {@link AbstractClassGenerator}-based utilities.
@ -39,5 +38,6 @@ public interface NamingPolicy {
* correctly implement <code>equals</code> and <code>hashCode</code> * correctly implement <code>equals</code> and <code>hashCode</code>
* to avoid generating too many classes. * to avoid generating too many classes.
*/ */
@Override
boolean equals(Object o); boolean equals(Object o);
} }

View File

@ -21,11 +21,11 @@ public class WeakCacheKey<T> extends WeakReference<T> {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof WeakCacheKey)) { if (!(obj instanceof WeakCacheKey<?> weakCacheKey)) {
return false; return false;
} }
Object ours = get(); Object ours = get();
Object theirs = ((WeakCacheKey) obj).get(); Object theirs = weakCacheKey.get();
return ours != null && theirs != null && ours.equals(theirs); return ours != null && theirs != null && ours.equals(theirs);
} }

View File

@ -1,10 +1,13 @@
package org.springframework.cglib.core.internal; package org.springframework.cglib.core.internal;
import org.springframework.cglib.core.Customizer; import java.util.ArrayList;
import org.springframework.cglib.core.FieldTypeCustomizer; import java.util.Collections;
import org.springframework.cglib.core.KeyFactoryCustomizer; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*; import org.springframework.cglib.core.Customizer;
import org.springframework.cglib.core.KeyFactoryCustomizer;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class CustomizerRegistry { public class CustomizerRegistry {

View File

@ -13,12 +13,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.proxy; package org.springframework.cglib.proxy;
import java.util.*; import java.util.HashMap;
import org.springframework.cglib.core.*; import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.asm.Label; import org.springframework.asm.Label;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.ClassEmitter;
import org.springframework.cglib.core.ClassInfo;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.CollectionUtils;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.Local;
import org.springframework.cglib.core.MethodInfo;
import org.springframework.cglib.core.ObjectSwitchCallback;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.Transformer;
import org.springframework.cglib.core.TypeUtils;
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) @SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
class MethodInterceptorGenerator class MethodInterceptorGenerator
@ -42,8 +58,6 @@ implements CallbackGenerator
TypeUtils.parseType("org.springframework.cglib.proxy.MethodInterceptor"); TypeUtils.parseType("org.springframework.cglib.proxy.MethodInterceptor");
private static final Signature GET_DECLARED_METHODS = private static final Signature GET_DECLARED_METHODS =
TypeUtils.parseSignature("java.lang.reflect.Method[] getDeclaredMethods()"); TypeUtils.parseSignature("java.lang.reflect.Method[] getDeclaredMethods()");
private static final Signature GET_DECLARING_CLASS =
TypeUtils.parseSignature("Class getDeclaringClass()");
private static final Signature FIND_METHODS = private static final Signature FIND_METHODS =
TypeUtils.parseSignature("java.lang.reflect.Method[] findMethods(String[], java.lang.reflect.Method[])"); TypeUtils.parseSignature("java.lang.reflect.Method[] findMethods(String[], java.lang.reflect.Method[])");
private static final Signature MAKE_PROXY = private static final Signature MAKE_PROXY =
@ -66,12 +80,11 @@ implements CallbackGenerator
private static final Signature TO_STRING = private static final Signature TO_STRING =
TypeUtils.parseSignature("String toString()"); TypeUtils.parseSignature("String toString()");
private static final Transformer METHOD_TO_CLASS = new Transformer(){ private static final Transformer METHOD_TO_CLASS = new Transformer(){
@Override
public Object transform(Object value) { public Object transform(Object value) {
return ((MethodInfo)value).getClassInfo(); return ((MethodInfo)value).getClassInfo();
} }
}; };
private static final Signature CSTRUCT_SIGNATURE =
TypeUtils.parseConstructor("String, String");
private String getMethodField(Signature impl) { private String getMethodField(Signature impl) {
return impl.getName() + "$Method"; return impl.getName() + "$Method";
@ -80,6 +93,7 @@ implements CallbackGenerator
return impl.getName() + "$Proxy"; return impl.getName() + "$Proxy";
} }
@Override
public void generate(ClassEmitter ce, Context context, List methods) { public void generate(ClassEmitter ce, Context context, List methods) {
Map sigMap = new HashMap(); Map sigMap = new HashMap();
for (Iterator it = methods.iterator(); it.hasNext();) { for (Iterator it = methods.iterator(); it.hasNext();) {
@ -143,6 +157,7 @@ implements CallbackGenerator
} }
} }
@Override
public void generateStatic(CodeEmitter e, Context context, List methods) throws Exception { public void generateStatic(CodeEmitter e, Context context, List methods) throws Exception {
/* generates: /* generates:
static { static {
@ -220,10 +235,12 @@ implements CallbackGenerator
e.load_arg(0); e.load_arg(0);
e.invoke_virtual(Constants.TYPE_OBJECT, TO_STRING); e.invoke_virtual(Constants.TYPE_OBJECT, TO_STRING);
ObjectSwitchCallback callback = new ObjectSwitchCallback() { ObjectSwitchCallback callback = new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label end) { public void processCase(Object key, Label end) {
e.getfield((String)sigMap.get(key)); e.getfield((String)sigMap.get(key));
e.return_value(); e.return_value();
} }
@Override
public void processDefault() { public void processDefault() {
e.aconst_null(); e.aconst_null();
e.return_value(); e.return_value();

View File

@ -13,16 +13,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.proxy; package org.springframework.cglib.proxy;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
import java.lang.reflect.Constructor; import java.util.ArrayList;
import java.lang.reflect.Modifier; import java.util.Collections;
import java.util.*; import java.util.HashMap;
import org.springframework.cglib.core.*; import java.util.Iterator;
import java.util.Map;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.ClassesKey;
import org.springframework.cglib.core.KeyFactory;
import org.springframework.cglib.core.ReflectUtils;
/** /**
* <code>Mixin</code> allows * <code>Mixin</code> allows
@ -106,10 +111,12 @@ abstract public class Mixin {
super(SOURCE); super(SOURCE);
} }
@Override
protected ClassLoader getDefaultClassLoader() { protected ClassLoader getDefaultClassLoader() {
return classes[0].getClassLoader(); // is this right? return classes[0].getClassLoader(); // is this right?
} }
@Override
protected ProtectionDomain getProtectionDomain() { protected ProtectionDomain getProtectionDomain() {
return ReflectUtils.getProtectionDomain(classes[0]); return ReflectUtils.getProtectionDomain(classes[0]);
} }
@ -170,6 +177,7 @@ abstract public class Mixin {
return (Mixin)super.create(KEY_FACTORY.newInstance(style, ReflectUtils.getNames( classes ), route)); return (Mixin)super.create(KEY_FACTORY.newInstance(style, ReflectUtils.getNames( classes ), route));
} }
@Override
public void generateClass(ClassVisitor v) { public void generateClass(ClassVisitor v) {
switch (style) { switch (style) {
case STYLE_INTERFACES: case STYLE_INTERFACES:
@ -184,10 +192,12 @@ abstract public class Mixin {
} }
} }
@Override
protected Object firstInstance(Class type) { protected Object firstInstance(Class type) {
return ((Mixin)ReflectUtils.newInstance(type)).newInstance(delegates); return ((Mixin)ReflectUtils.newInstance(type)).newInstance(delegates);
} }
@Override
protected Object nextInstance(Object instance) { protected Object nextInstance(Object instance) {
return ((Mixin)instance).newInstance(delegates); return ((Mixin)instance).newInstance(delegates);
} }

View File

@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.proxy; package org.springframework.cglib.proxy;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Member;
import org.springframework.cglib.core.CodeGenerationException; import org.springframework.cglib.core.CodeGenerationException;
/** /**
@ -40,6 +41,7 @@ public class Proxy implements Serializable {
protected InvocationHandler h; protected InvocationHandler h;
private static final CallbackFilter BAD_OBJECT_METHOD_FILTER = new CallbackFilter() { private static final CallbackFilter BAD_OBJECT_METHOD_FILTER = new CallbackFilter() {
@Override
public int accept(Method method) { public int accept(Method method) {
if (method.getDeclaringClass().getName().equals("java.lang.Object")) { if (method.getDeclaringClass().getName().equals("java.lang.Object")) {
String name = method.getName(); String name = method.getName();

View File

@ -13,14 +13,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.reflect; package org.springframework.cglib.reflect;
import java.lang.reflect.*; import java.lang.reflect.Method;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
import org.springframework.cglib.*;
import org.springframework.cglib.core.*;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.ClassEmitter;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.KeyFactory;
import org.springframework.cglib.core.MethodInfo;
import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
// TODO: don't require exact match for return type // TODO: don't require exact match for return type
@ -133,11 +143,13 @@ abstract public class MethodDelegate {
return gen.create(); return gen.create();
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
MethodDelegate other = (MethodDelegate)obj; MethodDelegate other = (MethodDelegate)obj;
return (other != null && target == other.target) && eqMethod.equals(other.eqMethod); return (other != null && target == other.target) && eqMethod.equals(other.eqMethod);
} }
@Override
public int hashCode() { public int hashCode() {
return target.hashCode() ^ eqMethod.hashCode(); return target.hashCode() ^ eqMethod.hashCode();
} }
@ -181,10 +193,12 @@ abstract public class MethodDelegate {
this.iface = iface; this.iface = iface;
} }
@Override
protected ClassLoader getDefaultClassLoader() { protected ClassLoader getDefaultClassLoader() {
return targetClass.getClassLoader(); return targetClass.getClassLoader();
} }
@Override
protected ProtectionDomain getProtectionDomain() { protected ProtectionDomain getProtectionDomain() {
return ReflectUtils.getProtectionDomain(targetClass); return ReflectUtils.getProtectionDomain(targetClass);
} }
@ -195,14 +209,17 @@ abstract public class MethodDelegate {
return (MethodDelegate)super.create(key); return (MethodDelegate)super.create(key);
} }
@Override
protected Object firstInstance(Class type) { protected Object firstInstance(Class type) {
return ((MethodDelegate)ReflectUtils.newInstance(type)).newInstance(target); return ((MethodDelegate)ReflectUtils.newInstance(type)).newInstance(target);
} }
@Override
protected Object nextInstance(Object instance) { protected Object nextInstance(Object instance) {
return ((MethodDelegate)instance).newInstance(target); return ((MethodDelegate)instance).newInstance(target);
} }
@Override
public void generateClass(ClassVisitor v) throws NoSuchMethodException { public void generateClass(ClassVisitor v) throws NoSuchMethodException {
Method proxy = ReflectUtils.findInterfaceMethod(iface); Method proxy = ReflectUtils.findInterfaceMethod(iface);
final Method method = targetClass.getMethod(methodName, proxy.getParameterTypes()); final Method method = targetClass.getMethod(methodName, proxy.getParameterTypes());

View File

@ -13,15 +13,27 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.reflect; package org.springframework.cglib.reflect;
import java.lang.reflect.*;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
import java.util.*; import java.util.ArrayList;
import org.springframework.cglib.core.*; import java.util.Arrays;
import java.util.List;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.ClassEmitter;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.Local;
import org.springframework.cglib.core.MethodInfo;
import org.springframework.cglib.core.ProcessArrayCallback;
import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
abstract public class MulticastDelegate implements Cloneable { abstract public class MulticastDelegate implements Cloneable {
@ -82,10 +94,12 @@ abstract public class MulticastDelegate implements Cloneable {
super(SOURCE); super(SOURCE);
} }
@Override
protected ClassLoader getDefaultClassLoader() { protected ClassLoader getDefaultClassLoader() {
return iface.getClassLoader(); return iface.getClassLoader();
} }
@Override
protected ProtectionDomain getProtectionDomain() { protected ProtectionDomain getProtectionDomain() {
return ReflectUtils.getProtectionDomain(iface); return ReflectUtils.getProtectionDomain(iface);
} }
@ -99,6 +113,7 @@ abstract public class MulticastDelegate implements Cloneable {
return (MulticastDelegate)super.create(iface.getName()); return (MulticastDelegate)super.create(iface.getName());
} }
@Override
public void generateClass(ClassVisitor cv) { public void generateClass(ClassVisitor cv) {
final MethodInfo method = ReflectUtils.getMethodInfo(ReflectUtils.findInterfaceMethod(iface)); final MethodInfo method = ReflectUtils.getMethodInfo(ReflectUtils.findInterfaceMethod(iface));
@ -152,6 +167,7 @@ abstract public class MulticastDelegate implements Cloneable {
e.super_getfield("targets", Constants.TYPE_OBJECT_ARRAY); e.super_getfield("targets", Constants.TYPE_OBJECT_ARRAY);
final Local result2 = result; final Local result2 = result;
EmitUtils.process_array(e, Constants.TYPE_OBJECT_ARRAY, new ProcessArrayCallback() { EmitUtils.process_array(e, Constants.TYPE_OBJECT_ARRAY, new ProcessArrayCallback() {
@Override
public void processElement(Type type) { public void processElement(Type type) {
e.checkcast(Type.getType(iface)); e.checkcast(Type.getType(iface));
e.load_args(); e.load_args();
@ -168,11 +184,13 @@ abstract public class MulticastDelegate implements Cloneable {
e.end_method(); e.end_method();
} }
@Override
protected Object firstInstance(Class type) { protected Object firstInstance(Class type) {
// make a new instance in case first object is used with a long list of targets // make a new instance in case first object is used with a long list of targets
return ((MulticastDelegate)ReflectUtils.newInstance(type)).newInstance(); return ((MulticastDelegate)ReflectUtils.newInstance(type)).newInstance();
} }
@Override
protected Object nextInstance(Object instance) { protected Object nextInstance(Object instance) {
return ((MulticastDelegate)instance).newInstance(); return ((MulticastDelegate)instance).newInstance();
} }

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform;
import org.springframework.asm.*; package org.springframework.cglib.transform;
public class ClassFilterTransformer extends AbstractClassFilterTransformer { public class ClassFilterTransformer extends AbstractClassFilterTransformer {
private ClassFilter filter; private ClassFilter filter;
@ -25,6 +24,7 @@ public class ClassFilterTransformer extends AbstractClassFilterTransformer {
this.filter = filter; this.filter = filter;
} }
@Override
protected boolean accept(int version, int access, String name, String signature, String superName, String[] interfaces) { protected boolean accept(int version, int access, String name, String signature, String superName, String[] interfaces) {
return filter.accept(name.replace('/', '.')); return filter.accept(name.replace('/', '.'));
} }

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform;
import org.springframework.asm.Attribute; package org.springframework.cglib.transform;
public interface MethodFilter { public interface MethodFilter {
// TODO: pass class name too? // TODO: pass class name too?

View File

@ -13,21 +13,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform; package org.springframework.cglib.transform;
import org.springframework.cglib.core.ClassGenerator;
import org.springframework.cglib.core.Transformer;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.cglib.core.ClassGenerator;
public class TransformingClassGenerator implements ClassGenerator { public class TransformingClassGenerator implements ClassGenerator {
private ClassGenerator gen; private final ClassGenerator gen;
private ClassTransformer t; private final ClassTransformer t;
public TransformingClassGenerator(ClassGenerator gen, ClassTransformer t) { public TransformingClassGenerator(ClassGenerator gen, ClassTransformer t) {
this.gen = gen; this.gen = gen;
this.t = t; this.t = t;
} }
@Override
public void generateClass(ClassVisitor v) throws Exception { public void generateClass(ClassVisitor v) throws Exception {
t.setTarget(v); t.setTarget(v);
gen.generateClass(t); gen.generateClass(t);

View File

@ -13,20 +13,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform; package org.springframework.cglib.transform;
import java.util.*; import org.springframework.asm.ClassReader;
import org.springframework.cglib.core.ClassGenerator; import org.springframework.cglib.core.ClassGenerator;
import org.springframework.asm.*;
public class TransformingClassLoader extends AbstractClassLoader { public class TransformingClassLoader extends AbstractClassLoader {
private ClassTransformerFactory t; private final ClassTransformerFactory t;
public TransformingClassLoader(ClassLoader parent, ClassFilter filter, ClassTransformerFactory t) { public TransformingClassLoader(ClassLoader parent, ClassFilter filter, ClassTransformerFactory t) {
super(parent, parent, filter); super(parent, parent, filter);
this.t = t; this.t = t;
} }
@Override
protected ClassGenerator getGenerator(ClassReader r) { protected ClassGenerator getGenerator(ClassReader r) {
ClassTransformer t2 = t.newInstance(); ClassTransformer t2 = t.newInstance();
return new TransformingClassGenerator(super.getGenerator(r), t2); return new TransformingClassGenerator(super.getGenerator(r), t2);

View File

@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform.impl; package org.springframework.cglib.transform.impl;
import org.springframework.cglib.transform.*;
import org.springframework.cglib.core.*;
import org.springframework.asm.ClassVisitor;
import org.springframework.asm.MethodVisitor;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
import org.springframework.cglib.transform.ClassEmitterTransformer;
public class AccessFieldTransformer extends ClassEmitterTransformer { public class AccessFieldTransformer extends ClassEmitterTransformer {
private Callback callback; private Callback callback;
@ -33,6 +34,7 @@ public class AccessFieldTransformer extends ClassEmitterTransformer {
String getPropertyName(Type owner, String fieldName); String getPropertyName(Type owner, String fieldName);
} }
@Override
public void declare_field(int access, final String name, Type type, Object value) { public void declare_field(int access, final String name, Type type, Object value) {
super.declare_field(access, name, type, value); super.declare_field(access, name, type, value);

View File

@ -13,14 +13,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform.impl; package org.springframework.cglib.transform.impl;
import org.springframework.cglib.transform.*; import java.lang.reflect.Method;
import java.lang.reflect.*; import java.lang.reflect.Modifier;
import java.util.*;
import org.springframework.cglib.core.*;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.CodeGenerationException;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
import org.springframework.cglib.transform.ClassEmitterTransformer;
/** /**
* @author Juozas Baliuka * @author Juozas Baliuka
@ -47,6 +53,7 @@ public class AddDelegateTransformer extends ClassEmitterTransformer {
} }
} }
@Override
public void begin_class(int version, int access, String className, Type superType, Type[] interfaces, String sourceFile) { public void begin_class(int version, int access, String className, Type superType, Type[] interfaces, String sourceFile) {
if(!TypeUtils.isInterface(access)){ if(!TypeUtils.isInterface(access)){
@ -71,11 +78,13 @@ public class AddDelegateTransformer extends ClassEmitterTransformer {
} }
} }
@Override
public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) { public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) {
final CodeEmitter e = super.begin_method(access, sig, exceptions); final CodeEmitter e = super.begin_method(access, sig, exceptions);
if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) { if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) {
return new CodeEmitter(e) { return new CodeEmitter(e) {
private boolean transformInit = true; private boolean transformInit = true;
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
super.visitMethodInsn(opcode, owner, name, desc, itf); super.visitMethodInsn(opcode, owner, name, desc, itf);
if (transformInit && opcode == Constants.INVOKESPECIAL) { if (transformInit && opcode == Constants.INVOKESPECIAL) {
@ -115,6 +124,3 @@ public class AddDelegateTransformer extends ClassEmitterTransformer {
e.end_method(); e.end_method();
} }
} }

View File

@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform.impl; package org.springframework.cglib.transform.impl;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.asm.Type;
import org.springframework.cglib.core.CodeEmitter; import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants; import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.MethodInfo; import org.springframework.cglib.core.MethodInfo;
@ -24,9 +26,6 @@ import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature; import org.springframework.cglib.core.Signature;
import org.springframework.cglib.transform.ClassEmitterTransformer; import org.springframework.cglib.transform.ClassEmitterTransformer;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type;
/** /**
* @author Mark Hobson * @author Mark Hobson
*/ */
@ -44,10 +43,12 @@ public class AddInitTransformer extends ClassEmitterTransformer {
} }
} }
@Override
public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) { public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) {
final CodeEmitter emitter = super.begin_method(access, sig, exceptions); final CodeEmitter emitter = super.begin_method(access, sig, exceptions);
if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) { if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) {
return new CodeEmitter(emitter) { return new CodeEmitter(emitter) {
@Override
public void visitInsn(int opcode) { public void visitInsn(int opcode) {
if (opcode == Constants.RETURN) { if (opcode == Constants.RETURN) {
load_this(); load_this();
@ -60,4 +61,3 @@ public class AddInitTransformer extends ClassEmitterTransformer {
return emitter; return emitter;
} }
} }

View File

@ -13,14 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform.impl; package org.springframework.cglib.transform.impl;
import org.springframework.cglib.transform.*; import java.util.HashMap;
import java.util.*; import java.util.Map;
import org.springframework.cglib.core.*;
import org.springframework.asm.Attribute;
import org.springframework.asm.Label; import org.springframework.asm.Label;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.CodeGenerationException;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.ObjectSwitchCallback;
import org.springframework.cglib.core.ProcessSwitchCallback;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
import org.springframework.cglib.transform.ClassEmitterTransformer;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class FieldProviderTransformer extends ClassEmitterTransformer { public class FieldProviderTransformer extends ClassEmitterTransformer {
@ -48,6 +57,7 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
private int access; private int access;
private Map fields; private Map fields;
@Override
public void begin_class(int version, int access, String className, Type superType, Type[] interfaces, String sourceFile) { public void begin_class(int version, int access, String className, Type superType, Type[] interfaces, String sourceFile) {
if (!TypeUtils.isAbstract(access)) { if (!TypeUtils.isAbstract(access)) {
interfaces = TypeUtils.add(interfaces, FIELD_PROVIDER); interfaces = TypeUtils.add(interfaces, FIELD_PROVIDER);
@ -57,6 +67,7 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
super.begin_class(version, access, className, superType, interfaces, sourceFile); super.begin_class(version, access, className, superType, interfaces, sourceFile);
} }
@Override
public void declare_field(int access, String name, Type type, Object value) { public void declare_field(int access, String name, Type type, Object value) {
super.declare_field(access, name, type, value); super.declare_field(access, name, type, value);
@ -65,6 +76,7 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
} }
} }
@Override
public void end_class() { public void end_class() {
if (!TypeUtils.isInterface(access)) { if (!TypeUtils.isInterface(access)) {
try { try {
@ -137,12 +149,14 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
e.load_arg(1); e.load_arg(1);
e.load_arg(0); e.load_arg(0);
e.process_switch(indexes, new ProcessSwitchCallback() { e.process_switch(indexes, new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label end) throws Exception { public void processCase(int key, Label end) throws Exception {
Type type = (Type)fields.get(names[key]); Type type = (Type)fields.get(names[key]);
e.unbox(type); e.unbox(type);
e.putfield(names[key]); e.putfield(names[key]);
e.return_value(); e.return_value();
} }
@Override
public void processDefault() throws Exception { public void processDefault() throws Exception {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index"); e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
} }
@ -155,12 +169,14 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
e.load_this(); e.load_this();
e.load_arg(0); e.load_arg(0);
e.process_switch(indexes, new ProcessSwitchCallback() { e.process_switch(indexes, new ProcessSwitchCallback() {
@Override
public void processCase(int key, Label end) throws Exception { public void processCase(int key, Label end) throws Exception {
Type type = (Type)fields.get(names[key]); Type type = (Type)fields.get(names[key]);
e.getfield(names[key]); e.getfield(names[key]);
e.box(type); e.box(type);
e.return_value(); e.return_value();
} }
@Override
public void processDefault() throws Exception { public void processDefault() throws Exception {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index"); e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
} }
@ -175,12 +191,14 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
e.load_this(); e.load_this();
e.load_arg(0); e.load_arg(0);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() { EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label end) { public void processCase(Object key, Label end) {
Type type = (Type)fields.get(key); Type type = (Type)fields.get(key);
e.getfield((String)key); e.getfield((String)key);
e.box(type); e.box(type);
e.return_value(); e.return_value();
} }
@Override
public void processDefault() { public void processDefault() {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name"); e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
} }
@ -194,12 +212,14 @@ public class FieldProviderTransformer extends ClassEmitterTransformer {
e.load_arg(1); e.load_arg(1);
e.load_arg(0); e.load_arg(0);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() { EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label end) { public void processCase(Object key, Label end) {
Type type = (Type)fields.get(key); Type type = (Type)fields.get(key);
e.unbox(type); e.unbox(type);
e.putfield((String)key); e.putfield((String)key);
e.return_value(); e.return_value();
} }
@Override
public void processDefault() { public void processDefault() {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name"); e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
} }

View File

@ -13,18 +13,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.transform.impl; package org.springframework.cglib.transform.impl;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import org.springframework.cglib.core.*;
import org.springframework.cglib.transform.*;
import org.springframework.asm.Attribute;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.asm.ClassVisitor; import org.springframework.cglib.core.Block;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
import org.springframework.cglib.transform.ClassEmitterTransformer;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public class UndeclaredThrowableTransformer extends ClassEmitterTransformer { public class UndeclaredThrowableTransformer extends ClassEmitterTransformer {
private Type wrapper;
private final Type wrapper;
public UndeclaredThrowableTransformer(Class wrapper) { public UndeclaredThrowableTransformer(Class wrapper) {
this.wrapper = Type.getType(wrapper); this.wrapper = Type.getType(wrapper);
@ -41,6 +47,7 @@ public class UndeclaredThrowableTransformer extends ClassEmitterTransformer {
throw new IllegalArgumentException(wrapper + " does not have a single-arg constructor that takes a Throwable"); throw new IllegalArgumentException(wrapper + " does not have a single-arg constructor that takes a Throwable");
} }
@Override
public CodeEmitter begin_method(int access, final Signature sig, final Type[] exceptions) { public CodeEmitter begin_method(int access, final Signature sig, final Type[] exceptions) {
CodeEmitter e = super.begin_method(access, sig, exceptions); CodeEmitter e = super.begin_method(access, sig, exceptions);
if (TypeUtils.isAbstract(access) || sig.equals(Constants.SIG_STATIC)) { if (TypeUtils.isAbstract(access) || sig.equals(Constants.SIG_STATIC)) {
@ -51,6 +58,7 @@ public class UndeclaredThrowableTransformer extends ClassEmitterTransformer {
/* init */ { /* init */ {
handler = begin_block(); handler = begin_block();
} }
@Override
public void visitMaxs(int maxStack, int maxLocals) { public void visitMaxs(int maxStack, int maxLocals) {
handler.end(); handler.end();
EmitUtils.wrap_undeclared_throwable(this, handler, exceptions, wrapper); EmitUtils.wrap_undeclared_throwable(this, handler, exceptions, wrapper);

View File

@ -13,12 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.util; package org.springframework.cglib.util;
import java.lang.reflect.*;
import java.util.Comparator; import java.util.Comparator;
import org.springframework.cglib.core.*;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.ClassesKey;
import org.springframework.cglib.core.ReflectUtils;
/** /**
* For the efficient sorting of multiple arrays in parallel. * For the efficient sorting of multiple arrays in parallel.
@ -173,6 +176,7 @@ abstract public class ParallelSorter extends SorterTemplate {
} }
} }
@Override
protected int compare(int i, int j) { protected int compare(int i, int j) {
return comparer.compare(i, j); return comparer.compare(i, j);
} }
@ -190,6 +194,7 @@ abstract public class ParallelSorter extends SorterTemplate {
this.cmp = cmp; this.cmp = cmp;
} }
@Override
public int compare(int i, int j) { public int compare(int i, int j) {
return cmp.compare(a[i], a[j]); return cmp.compare(a[i], a[j]);
} }
@ -198,6 +203,7 @@ abstract public class ParallelSorter extends SorterTemplate {
static class ObjectComparer implements Comparer { static class ObjectComparer implements Comparer {
private Object[] a; private Object[] a;
public ObjectComparer(Object[] a) { this.a = a; } public ObjectComparer(Object[] a) { this.a = a; }
@Override
public int compare(int i, int j) { public int compare(int i, int j) {
return ((Comparable)a[i]).compareTo(a[j]); return ((Comparable)a[i]).compareTo(a[j]);
} }
@ -206,12 +212,14 @@ abstract public class ParallelSorter extends SorterTemplate {
static class IntComparer implements Comparer { static class IntComparer implements Comparer {
private int[] a; private int[] a;
public IntComparer(int[] a) { this.a = a; } public IntComparer(int[] a) { this.a = a; }
@Override
public int compare(int i, int j) { return a[i] - a[j]; } public int compare(int i, int j) { return a[i] - a[j]; }
} }
static class LongComparer implements Comparer { static class LongComparer implements Comparer {
private long[] a; private long[] a;
public LongComparer(long[] a) { this.a = a; } public LongComparer(long[] a) { this.a = a; }
@Override
public int compare(int i, int j) { public int compare(int i, int j) {
long vi = a[i]; long vi = a[i];
long vj = a[j]; long vj = a[j];
@ -222,6 +230,7 @@ abstract public class ParallelSorter extends SorterTemplate {
static class FloatComparer implements Comparer { static class FloatComparer implements Comparer {
private float[] a; private float[] a;
public FloatComparer(float[] a) { this.a = a; } public FloatComparer(float[] a) { this.a = a; }
@Override
public int compare(int i, int j) { public int compare(int i, int j) {
float vi = a[i]; float vi = a[i];
float vj = a[j]; float vj = a[j];
@ -232,6 +241,7 @@ abstract public class ParallelSorter extends SorterTemplate {
static class DoubleComparer implements Comparer { static class DoubleComparer implements Comparer {
private double[] a; private double[] a;
public DoubleComparer(double[] a) { this.a = a; } public DoubleComparer(double[] a) { this.a = a; }
@Override
public int compare(int i, int j) { public int compare(int i, int j) {
double vi = a[i]; double vi = a[i];
double vj = a[j]; double vj = a[j];
@ -242,12 +252,14 @@ abstract public class ParallelSorter extends SorterTemplate {
static class ShortComparer implements Comparer { static class ShortComparer implements Comparer {
private short[] a; private short[] a;
public ShortComparer(short[] a) { this.a = a; } public ShortComparer(short[] a) { this.a = a; }
@Override
public int compare(int i, int j) { return a[i] - a[j]; } public int compare(int i, int j) { return a[i] - a[j]; }
} }
static class ByteComparer implements Comparer { static class ByteComparer implements Comparer {
private byte[] a; private byte[] a;
public ByteComparer(byte[] a) { this.a = a; } public ByteComparer(byte[] a) { this.a = a; }
@Override
public int compare(int i, int j) { return a[i] - a[j]; } public int compare(int i, int j) { return a[i] - a[j]; }
} }
@ -260,6 +272,7 @@ abstract public class ParallelSorter extends SorterTemplate {
super(SOURCE); super(SOURCE);
} }
@Override
protected ClassLoader getDefaultClassLoader() { protected ClassLoader getDefaultClassLoader() {
return null; // TODO return null; // TODO
} }
@ -272,6 +285,7 @@ abstract public class ParallelSorter extends SorterTemplate {
return (ParallelSorter)super.create(ClassesKey.create(arrays)); return (ParallelSorter)super.create(ClassesKey.create(arrays));
} }
@Override
public void generateClass(ClassVisitor v) throws Exception { public void generateClass(ClassVisitor v) throws Exception {
if (arrays.length == 0) { if (arrays.length == 0) {
throw new IllegalArgumentException("No arrays specified to sort"); throw new IllegalArgumentException("No arrays specified to sort");
@ -284,10 +298,12 @@ abstract public class ParallelSorter extends SorterTemplate {
new ParallelSorterEmitter(v, getClassName(), arrays); new ParallelSorterEmitter(v, getClassName(), arrays);
} }
@Override
protected Object firstInstance(Class type) { protected Object firstInstance(Class type) {
return ((ParallelSorter)ReflectUtils.newInstance(type)).newInstance(arrays); return ((ParallelSorter)ReflectUtils.newInstance(type)).newInstance(arrays);
} }
@Override
protected Object nextInstance(Object instance) { protected Object nextInstance(Object instance) {
return ((ParallelSorter)instance).newInstance(arrays); return ((ParallelSorter)instance).newInstance(arrays);
} }

View File

@ -13,13 +13,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.util; package org.springframework.cglib.util;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.springframework.cglib.core.*;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.ClassEmitter;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.Local;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
class ParallelSorterEmitter extends ClassEmitter { class ParallelSorterEmitter extends ClassEmitter {
private static final Type PARALLEL_SORTER = private static final Type PARALLEL_SORTER =

View File

@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.util;
import java.util.*; package org.springframework.cglib.util;
abstract class SorterTemplate { abstract class SorterTemplate {
private static final int MERGESORT_THRESHOLD = 12; private static final int MERGESORT_THRESHOLD = 12;

View File

@ -13,16 +13,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.cglib.util; package org.springframework.cglib.util;
import java.util.*; import java.util.Arrays;
import org.springframework.cglib.core.*; import java.util.List;
import org.springframework.asm.ClassVisitor; import org.springframework.asm.ClassVisitor;
import org.springframework.asm.Label; import org.springframework.asm.Label;
import org.springframework.asm.Type; import org.springframework.asm.Type;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.ClassEmitter;
import org.springframework.cglib.core.CodeEmitter;
import org.springframework.cglib.core.Constants;
import org.springframework.cglib.core.EmitUtils;
import org.springframework.cglib.core.KeyFactory;
import org.springframework.cglib.core.ObjectSwitchCallback;
import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.core.TypeUtils;
/** /**
* This class implements a simple String->int mapping for a fixed set of keys. * This class implements a simple String &rarr; int mapping for a fixed set of keys.
*/ */
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
abstract public class StringSwitcher { abstract public class StringSwitcher {
@ -104,6 +116,7 @@ abstract public class StringSwitcher {
this.fixedInput = fixedInput; this.fixedInput = fixedInput;
} }
@Override
protected ClassLoader getDefaultClassLoader() { protected ClassLoader getDefaultClassLoader() {
return getClass().getClassLoader(); return getClass().getClassLoader();
} }
@ -117,6 +130,7 @@ abstract public class StringSwitcher {
return (StringSwitcher)super.create(key); return (StringSwitcher)super.create(key);
} }
@Override
public void generateClass(ClassVisitor v) throws Exception { public void generateClass(ClassVisitor v) throws Exception {
ClassEmitter ce = new ClassEmitter(v); ClassEmitter ce = new ClassEmitter(v);
ce.begin_class(Constants.V1_8, ce.begin_class(Constants.V1_8,
@ -131,10 +145,12 @@ abstract public class StringSwitcher {
final List stringList = Arrays.asList(strings); final List stringList = Arrays.asList(strings);
int style = fixedInput ? Constants.SWITCH_STYLE_HASHONLY : Constants.SWITCH_STYLE_HASH; int style = fixedInput ? Constants.SWITCH_STYLE_HASHONLY : Constants.SWITCH_STYLE_HASH;
EmitUtils.string_switch(e, strings, style, new ObjectSwitchCallback() { EmitUtils.string_switch(e, strings, style, new ObjectSwitchCallback() {
@Override
public void processCase(Object key, Label end) { public void processCase(Object key, Label end) {
e.push(ints[stringList.indexOf(key)]); e.push(ints[stringList.indexOf(key)]);
e.return_value(); e.return_value();
} }
@Override
public void processDefault() { public void processDefault() {
e.push(-1); e.push(-1);
e.return_value(); e.return_value();
@ -144,10 +160,12 @@ abstract public class StringSwitcher {
ce.end_class(); ce.end_class();
} }
@Override
protected Object firstInstance(Class type) { protected Object firstInstance(Class type) {
return (StringSwitcher)ReflectUtils.newInstance(type); return ReflectUtils.newInstance(type);
} }
@Override
protected Object nextInstance(Object instance) { protected Object nextInstance(Object instance) {
return instance; return instance;
} }