Skip to content

Instantly share code, notes, and snippets.

@zhuyifan2013
Created February 3, 2020 09:06
Show Gist options
  • Save zhuyifan2013/3ae8bedd7867a3d59b48654e12959df5 to your computer and use it in GitHub Desktop.
Save zhuyifan2013/3ae8bedd7867a3d59b48654e12959df5 to your computer and use it in GitHub Desktop.
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
/**
* VM options: -XX:MaxMetaspaceSize=10m
*/
public class MethodAreaError {
public static void main(String[] args) throws Throwable {
while (true) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(MyObject.class);
enhancer.setUseCache(false);
enhancer.setCallback(new MethodInterceptor() {
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
return methodProxy.invokeSuper(o,args);
}
});
enhancer.create();
}
}
static class MyObject {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment