CGlib 是一个强大的, 高性能和高质量代码生成工具, 通常可以用它在运行期, 扩展已有Java代码类的功能或者实现某些接口; 并不能代理静态方法;
JDK: 1.8 CGLib
代码示例
1 . 需要被代理的类
package com.test.reflect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
/**
* @author Hinsteny
* @Describtion
* @date 2016/12/2
* @copyright: 2016 All rights reserved.
*/
public class ScholarImpl implements Scholar {
static final private Logger logger = LoggerFactory.getLogger(ScholarImpl.class);
public static String printTime(){
logger.info("Now time is {}", LocalDateTime.now().toString());
return "Time";
}
@Override
public String searching(String theme) {
logger.info("Scholar do search {}", theme);
return "success";
}
}
package com.test.reflect;
/**
* @author Hinsteny
* @Describtion
* @date 2016/12/2
* @copyright: 2016 All rights reserved.
*/
public interface Scholar {
String LOCAL = "CHIBA";
String searching(String theme);
default String infoLocal(){
return this.LOCAL;
}
}
2 . 实现MethodInterceptor接口可以进行方法执行拦截代理
package com.test.reflect.CGLib;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
/**
* @author Hinsteny
* @Describtion
* @date 2016/12/7
* @copyright: 2016 All rights reserved.
*/
public class MyInterceptor implements MethodInterceptor {
static final private Logger logger = LoggerFactory.getLogger(MyInterceptor.class);
@Override
public Object intercept(Object obj, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
logger.info("do something before method {}", method.getName());
logger.info("obj: {}", obj.getClass().getName()); //由CGLib动态生成的代理类的class name
logger.info("method: {}", methodProxy.getSignature().getName()); //被代理对象中此次调用的方法名称
logger.info("methodProxy: {}", methodProxy.getSuperName()); //代理对象中此次调用的方面名称
Object object = methodProxy.invokeSuper(obj, objects); //调用代理类实例上的methodProxy方法的父类方法
logger.info("do something after method {}", method.getName());
return object;
}
}
3 . 生成代理示例的工具类
package com.test.reflect.CGLib;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
/**
* @author Hinsteny
* @Describtion
* @date 2016/12/7
* @copyright: 2016 All rights reserved.
*/
public class CGLibProxy {
/**
*
* @param obj 被委托代理的对象
* @param callback 代理注入的逻辑
* @param <T> 被委托代理对象的类型
* @return
*/
public static <T> T getInstance(final T obj, MethodInterceptor callback){
Enhancer enhancer = new Enhancer(); //增强类
//不同于JDK的动态代理。它不能在创建代理时传obj对 象,obj对象必须被CGLIB包来创建
enhancer.setSuperclass(obj.getClass()); //设置被代理类字节码(obj将被代理类设置成父类;作为产生的代理的父类传进来的)。CGLIB依据字节码生成被代理类的子类
enhancer.setCallback(callback); //设置回调函数,即一个方法拦截
return (T)enhancer.create(); //创建代理类
}
/**
*
* @param type 被委托代理的类型
* @param callback 代理注入的逻辑
* @param <T> 被委托代理对象的具体类型
* @return
*/
public static <T> T getInstance(final Class<T> type, MethodInterceptor callback){
Enhancer enhancer = new Enhancer(); //增强类
//不同于JDK的动态代理。它不能在创建代理时传obj对 象,obj对象必须被CGLIB包来创建
enhancer.setSuperclass(type); //设置被代理类字节码
enhancer.setCallback(callback); //设置回调函数,即一个方法拦截
return (T)enhancer.create(); //创建代理类
}
}
4 . 生成代理对象的关键代码
// 创建代理对象实例
private Object createHelper() {
this.validate();
if(this.superclass != null) {
this.setNamePrefix(this.superclass.getName());
} else if(this.interfaces != null) {
this.setNamePrefix(this.interfaces[ReflectUtils.findPackageProtected(this.interfaces)].getName());
}
return super.create(KEY_FACTORY.newInstance(this.superclass != null?this.superclass.getName():null, ReflectUtils.getNames(this.interfaces), this.filter, this.callbackTypes, this.useFactory, this.interceptDuringConstruction, this.serialVersionUID));
}
//组装生成代理对象
public void generateClass(ClassVisitor v) {
ClassEmitter ce = new ClassEmitter(v);
Method newInstance = ReflectUtils.findNewInstance(this.keyInterface);
if(!newInstance.getReturnType().equals(KeyFactory.class$java$lang$Object == null?(KeyFactory.class$java$lang$Object = KeyFactory.class$("java.lang.Object")):KeyFactory.class$java$lang$Object)) {
throw new IllegalArgumentException("newInstance method must return Object");
} else {
Type[] parameterTypes = TypeUtils.getTypes(newInstance.getParameterTypes());
ce.begin_class(46, 1, this.getClassName(), KeyFactory.KEY_FACTORY, new Type[]{Type.getType(this.keyInterface)}, "<generated>");
EmitUtils.null_constructor(ce);
EmitUtils.factory_method(ce, ReflectUtils.getSignature(newInstance));
int seed = 0;
CodeEmitter e = ce.begin_method(1, TypeUtils.parseConstructor(parameterTypes), (Type[])null);
e.load_this();
e.super_invoke_constructor();
e.load_this();
int hc;
for(hc = 0; hc < parameterTypes.length; ++hc) {
seed += parameterTypes[hc].hashCode();
ce.declare_field(18, this.getFieldName(hc), parameterTypes[hc], (Object)null);
e.dup();
e.load_arg(hc);
e.putfield(this.getFieldName(hc));
}
e.return_value();
e.end_method();
e = ce.begin_method(1, KeyFactory.HASH_CODE, (Type[])null);
hc = this.constant != 0?this.constant:KeyFactory.PRIMES[Math.abs(seed) % KeyFactory.PRIMES.length];
int hm = this.multiplier != 0?this.multiplier:KeyFactory.PRIMES[Math.abs(seed * 13) % KeyFactory.PRIMES.length];
e.push(hc);
for(int fail = 0; fail < parameterTypes.length; ++fail) {
e.load_this();
e.getfield(this.getFieldName(fail));
EmitUtils.hash_code(e, parameterTypes[fail], hm, this.customizer);
}
e.return_value();
e.end_method();
e = ce.begin_method(1, KeyFactory.EQUALS, (Type[])null);
Label var11 = e.make_label();
e.load_arg(0);
e.instance_of_this();
e.if_jump(153, var11);
int i;
for(i = 0; i < parameterTypes.length; ++i) {
e.load_this();
e.getfield(this.getFieldName(i));
e.load_arg(0);
e.checkcast_this();
e.getfield(this.getFieldName(i));
EmitUtils.not_equals(e, parameterTypes[i], var11, this.customizer);
}
e.push(1);
e.return_value();
e.mark(var11);
e.push(0);
e.return_value();
e.end_method();
e = ce.begin_method(1, KeyFactory.TO_STRING, (Type[])null);
e.new_instance(Constants.TYPE_STRING_BUFFER);
e.dup();
e.invoke_constructor(Constants.TYPE_STRING_BUFFER);
for(i = 0; i < parameterTypes.length; ++i) {
if(i > 0) {
e.push(", ");
e.invoke_virtual(Constants.TYPE_STRING_BUFFER, KeyFactory.APPEND_STRING);
}
e.load_this();
e.getfield(this.getFieldName(i));
EmitUtils.append_string(e, parameterTypes[i], EmitUtils.DEFAULT_DELIMITERS, this.customizer);
}
e.invoke_virtual(Constants.TYPE_STRING_BUFFER, KeyFactory.TO_STRING);
e.return_value();
e.end_method();
ce.end_class();
}
}
5 . 单元测试代理功能实现结果
package com.test.reflect.CGLib;
import com.test.reflect.ScholarImpl;
import net.sf.cglib.core.DefaultGeneratorStrategy;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* @author Hinsteny
* @Describtion
* @date 2016/12/2
* @copyright: 2016 All rights reserved.
*/
public class CGLibProxyTest {
static final private Logger logger = LoggerFactory.getLogger(CGLibProxyTest.class);
/**
* 根据一个java class对象生成其自身的代理对象, 并测试执行它相关的方法
*/
@Test
public void testProxy_1(){
// 代理工厂
CGLibProxy proxy = new CGLibProxy();
// 获取生成的动态代理对象
ScholarImpl scholar = proxy.getInstance(ScholarImpl.class, new MyInterceptor());
logger.info("Scholar local is {}", scholar.LOCAL);
logger.info("Scholar default method do and result is {}", scholar.infoLocal());
logger.info("ScholarImpl printTime method do {}", scholar.printTime());
String theme = "knowledge";
String result = scholar.searching(theme);
logger.info("result is {}", result);
}
/**
* 根据一个java 实例对象生成其自身的代理对象, 并测试执行它相关的方法
*/
@Test
public void testProxy_2(){
// 元对象(被代理对象)
ScholarImpl managerImpl = new ScholarImpl();
// 代理工厂
CGLibProxy proxy = new CGLibProxy();
// 获取生成的动态代理对象
ScholarImpl scholar = proxy.getInstance(managerImpl, new MyInterceptor());
logger.info("Scholar local is {}", scholar.LOCAL);
logger.info("Scholar default method do and result is {}", scholar.infoLocal());
logger.info("ScholarImpl printTime method do {}", scholar.printTime());
String theme = "knowledge";
String result = scholar.searching(theme);
logger.info("result is {}", result);
}
/**
* 获取动态生成代理对象字节码文件, 反编译查看源码
*/
@Test
public void testGetProxyClass_1(){
// 代理工厂
CGLibProxy proxy = new CGLibProxy();
String filePath = "D://data/CGLib$ProxyScholarImpl.class";
OutputStream out = null;
try {
out = new FileOutputStream(filePath);
// 获取生成的动态代理对象
ScholarImpl scholar = getProxyInstance(ScholarImpl.class, new MyInterceptor(), out);
logger.info("Class file is local in {}", filePath);
scholar.printTime();
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
if (out != null)
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private <T> T getProxyInstance(final Class<T> type, MethodInterceptor callback, OutputStream out){
Enhancer enhancer = new Enhancer(); //增强类
enhancer.setSuperclass(type); //设置被代理类字节码
enhancer.setStrategy(new DefaultGeneratorStrategy() {
protected byte[] transform(byte[] b) {
// do something with bytes here
try {
out.write(b);
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}});
enhancer.setCallback(callback); //设置回调函数,即一个方法拦截
return (T)enhancer.create(); //创建代理类
}
}
6 . 反编译查看生成动态类源代码
package com.test.reflect;
import java.lang.reflect.*;
import net.sf.cglib.proxy.*;
import net.sf.cglib.core.*;
public class ScholarImpl$$EnhancerByCGLIB$$fd902d67 extends ScholarImpl implements Factory
{
private boolean CGLIB$BOUND;
private static final ThreadLocal CGLIB$THREAD_CALLBACKS;
private static final Callback[] CGLIB$STATIC_CALLBACKS;
private MethodInterceptor CGLIB$CALLBACK_0;
private static final Method CGLIB$searching$0$Method;
private static final MethodProxy CGLIB$searching$0$Proxy;
private static final Object[] CGLIB$emptyArgs;
private static final Method CGLIB$finalize$1$Method;
private static final MethodProxy CGLIB$finalize$1$Proxy;
private static final Method CGLIB$equals$2$Method;
private static final MethodProxy CGLIB$equals$2$Proxy;
private static final Method CGLIB$toString$3$Method;
private static final MethodProxy CGLIB$toString$3$Proxy;
private static final Method CGLIB$hashCode$4$Method;
private static final MethodProxy CGLIB$hashCode$4$Proxy;
private static final Method CGLIB$clone$5$Method;
private static final MethodProxy CGLIB$clone$5$Proxy;
private static final Method CGLIB$infoLocal$6$Method;
private static final MethodProxy CGLIB$infoLocal$6$Proxy;
static void CGLIB$STATICHOOK1() {
CGLIB$THREAD_CALLBACKS = new ThreadLocal();
CGLIB$emptyArgs = new Object[0];
final Class<?> forName = Class.forName("com.test.reflect.ScholarImpl$$EnhancerByCGLIB$$fd902d67");
final Class<?> forName2;
final Method[] methods = ReflectUtils.findMethods(new String[] { "finalize", "()V", "equals", "(Ljava/lang/Object;)Z", "toString", "()Ljava/lang/String;", "hashCode", "()I", "clone", "()Ljava/lang/Object;" }, (forName2 = Class.forName("java.lang.Object")).getDeclaredMethods());
CGLIB$finalize$1$Method = methods[0];
CGLIB$finalize$1$Proxy = MethodProxy.create((Class)forName2, (Class)forName, "()V", "finalize", "CGLIB$finalize$1");
CGLIB$equals$2$Method = methods[1];
CGLIB$equals$2$Proxy = MethodProxy.create((Class)forName2, (Class)forName, "(Ljava/lang/Object;)Z", "equals", "CGLIB$equals$2");
CGLIB$toString$3$Method = methods[2];
CGLIB$toString$3$Proxy = MethodProxy.create((Class)forName2, (Class)forName, "()Ljava/lang/String;", "toString", "CGLIB$toString$3");
CGLIB$hashCode$4$Method = methods[3];
CGLIB$hashCode$4$Proxy = MethodProxy.create((Class)forName2, (Class)forName, "()I", "hashCode", "CGLIB$hashCode$4");
CGLIB$clone$5$Method = methods[4];
CGLIB$clone$5$Proxy = MethodProxy.create((Class)forName2, (Class)forName, "()Ljava/lang/Object;", "clone", "CGLIB$clone$5");
final Class<?> forName3;
CGLIB$searching$0$Method = ReflectUtils.findMethods(new String[] { "searching", "(Ljava/lang/String;)Ljava/lang/String;" }, (forName3 = Class.forName("com.test.reflect.ScholarImpl")).getDeclaredMethods())[0];
CGLIB$searching$0$Proxy = MethodProxy.create((Class)forName3, (Class)forName, "(Ljava/lang/String;)Ljava/lang/String;", "searching", "CGLIB$searching$0");
final Class<?> forName4;
CGLIB$infoLocal$6$Method = ReflectUtils.findMethods(new String[] { "infoLocal", "()Ljava/lang/String;" }, (forName4 = Class.forName("com.test.reflect.Scholar")).getDeclaredMethods())[0];
CGLIB$infoLocal$6$Proxy = MethodProxy.create((Class)forName4, (Class)forName, "()Ljava/lang/String;", "infoLocal", "CGLIB$infoLocal$6");
}
final String CGLIB$searching$0(final String s) {
return super.searching(s);
}
public final String searching(final String s) {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
return (String)cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$searching$0$Method, new Object[] { s }, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$searching$0$Proxy);
}
return super.searching(s);
}
final void CGLIB$finalize$1() throws Throwable {
super.finalize();
}
protected final void finalize() throws Throwable {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$finalize$1$Method, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$emptyArgs, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$finalize$1$Proxy);
return;
}
super.finalize();
}
final boolean CGLIB$equals$2(final Object o) {
return super.equals(o);
}
public final boolean equals(final Object o) {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
final Object intercept = cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$equals$2$Method, new Object[] { o }, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$equals$2$Proxy);
return intercept != null && (boolean)intercept;
}
return super.equals(o);
}
final String CGLIB$toString$3() {
return super.toString();
}
public final String toString() {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
return (String)cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$toString$3$Method, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$emptyArgs, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$toString$3$Proxy);
}
return super.toString();
}
final int CGLIB$hashCode$4() {
return super.hashCode();
}
public final int hashCode() {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
final Object intercept = cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$hashCode$4$Method, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$emptyArgs, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$hashCode$4$Proxy);
return (intercept == null) ? 0 : ((Number)intercept).intValue();
}
return super.hashCode();
}
final Object CGLIB$clone$5() throws CloneNotSupportedException {
return super.clone();
}
protected final Object clone() throws CloneNotSupportedException {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
return cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$clone$5$Method, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$emptyArgs, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$clone$5$Proxy);
}
return super.clone();
}
final String CGLIB$infoLocal$6() {
return super.infoLocal();
}
public final String infoLocal() {
MethodInterceptor cglib$CALLBACK_2;
MethodInterceptor cglib$CALLBACK_0;
if ((cglib$CALLBACK_0 = (cglib$CALLBACK_2 = this.CGLIB$CALLBACK_0)) == null) {
CGLIB$BIND_CALLBACKS(this);
cglib$CALLBACK_2 = (cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0);
}
if (cglib$CALLBACK_0 != null) {
return (String)cglib$CALLBACK_2.intercept((Object)this, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$infoLocal$6$Method, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$emptyArgs, ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$infoLocal$6$Proxy);
}
return super.infoLocal();
}
public static MethodProxy CGLIB$findMethodProxy(final Signature signature) {
final String string = signature.toString();
switch (string.hashCode()) {
case -1574182249: {
if (string.equals("finalize()V")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$finalize$1$Proxy;
}
break;
}
case -508378822: {
if (string.equals("clone()Ljava/lang/Object;")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$clone$5$Proxy;
}
break;
}
case -452504005: {
if (string.equals("searching(Ljava/lang/String;)Ljava/lang/String;")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$searching$0$Proxy;
}
break;
}
case 5376168: {
if (string.equals("infoLocal()Ljava/lang/String;")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$infoLocal$6$Proxy;
}
break;
}
case 1826985398: {
if (string.equals("equals(Ljava/lang/Object;)Z")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$equals$2$Proxy;
}
break;
}
case 1913648695: {
if (string.equals("toString()Ljava/lang/String;")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$toString$3$Proxy;
}
break;
}
case 1984935277: {
if (string.equals("hashCode()I")) {
return ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$hashCode$4$Proxy;
}
break;
}
}
return null;
}
public ScholarImpl$$EnhancerByCGLIB$$fd902d67() {
CGLIB$BIND_CALLBACKS(this);
}
public static void CGLIB$SET_THREAD_CALLBACKS(final Callback[] array) {
ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$THREAD_CALLBACKS.set(array);
}
public static void CGLIB$SET_STATIC_CALLBACKS(final Callback[] cglib$STATIC_CALLBACKS) {
CGLIB$STATIC_CALLBACKS = cglib$STATIC_CALLBACKS;
}
private static final void CGLIB$BIND_CALLBACKS(final Object o) {
final ScholarImpl$$EnhancerByCGLIB$$fd902d67 scholarImpl$$EnhancerByCGLIB$$fd902d67 = (ScholarImpl$$EnhancerByCGLIB$$fd902d67)o;
if (!scholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$BOUND) {
scholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$BOUND = true;
Object o2;
if ((o2 = ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$THREAD_CALLBACKS.get()) != null || (o2 = ScholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$STATIC_CALLBACKS) != null) {
scholarImpl$$EnhancerByCGLIB$$fd902d67.CGLIB$CALLBACK_0 = (MethodInterceptor)((Callback[])o2)[0];
}
}
}
public Object newInstance(final Callback[] array) {
CGLIB$SET_THREAD_CALLBACKS(array);
final ScholarImpl$$EnhancerByCGLIB$$fd902d67 scholarImpl$$EnhancerByCGLIB$$fd902d67 = new ScholarImpl$$EnhancerByCGLIB$$fd902d67();
CGLIB$SET_THREAD_CALLBACKS(null);
return scholarImpl$$EnhancerByCGLIB$$fd902d67;
}
public Object newInstance(final Callback callback) {
CGLIB$SET_THREAD_CALLBACKS(new Callback[] { callback });
final ScholarImpl$$EnhancerByCGLIB$$fd902d67 scholarImpl$$EnhancerByCGLIB$$fd902d67 = new ScholarImpl$$EnhancerByCGLIB$$fd902d67();
CGLIB$SET_THREAD_CALLBACKS(null);
return scholarImpl$$EnhancerByCGLIB$$fd902d67;
}
public Object newInstance(final Class[] array, final Object[] array2, final Callback[] array3) {
CGLIB$SET_THREAD_CALLBACKS(array3);
switch (array.length) {
case 0: {
final ScholarImpl$$EnhancerByCGLIB$$fd902d67 scholarImpl$$EnhancerByCGLIB$$fd902d67 = new ScholarImpl$$EnhancerByCGLIB$$fd902d67();
CGLIB$SET_THREAD_CALLBACKS(null);
return scholarImpl$$EnhancerByCGLIB$$fd902d67;
}
default: {
throw new IllegalArgumentException("Constructor not found");
}
}
}
public Callback getCallback(final int n) {
CGLIB$BIND_CALLBACKS(this);
Object cglib$CALLBACK_0 = null;
switch (n) {
case 0: {
cglib$CALLBACK_0 = this.CGLIB$CALLBACK_0;
break;
}
default: {
cglib$CALLBACK_0 = null;
break;
}
}
return (Callback)cglib$CALLBACK_0;
}
public void setCallback(final int n, final Callback callback) {
switch (n) {
case 0: {
this.CGLIB$CALLBACK_0 = (MethodInterceptor)callback;
break;
}
}
}
public Callback[] getCallbacks() {
CGLIB$BIND_CALLBACKS(this);
return new Callback[] { this.CGLIB$CALLBACK_0 };
}
public void setCallbacks(final Callback[] array) {
this.CGLIB$CALLBACK_0 = (MethodInterceptor)array[0];
}
static {
CGLIB$STATICHOOK1();
}
}