You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, cglib team. I encountered some problem when make proxy support towards the bean with constructor params. e.g when I want to some proxy usecases towards jedis (framework integration with redis server). here comes my code like this with enhancer:
public T getInstance(T target, Class[] args, Object[] argsValue) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(target.getClass());
enhancer.setCallback(this);
return (T) enhancer.create(args, argsValue);
}
the target is jedis like this:
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands {
public Jedis(final String host) {
super(host);
}
public Jedis(final String host, final int port) {
super(host, port);
}
public Jedis(final String host, final int port, final int timeout) {
super(host, port, timeout);
}
public Jedis(JedisShardInfo shardInfo) {
super(shardInfo);
}
public Jedis(URI uri) {
super(uri);
}
//omitted
}
when I want to proxy jedis, the constructor for such is for such
public Jedis(final String host, final int port, final int timeout) {
super(host, port, timeout);
}
so here comes the class info and arguments comes like this
Class[] args = new Class[] {String.class, Integer.class, Integer.class};
Object[] arguments = new Object[] {jedis.getClient().getHost(), jedis.getClient().getPort(),
jedis.getClient().getTimeout()};
if such above is not wrong, the cglib will help to create the proxy class with enhancer. but here comes my exception stracktrace:
Caused by: java.lang.NoSuchMethodException: redis.clients.jedis.Jedis$$EnhancerByCGLIB$$e2ffdb0f.(java.lang.String, java.lang.Integer, java.lang.Integer)
at java.lang.Class.getConstructor0(Class.java:2902)
at java.lang.Class.getDeclaredConstructor(Class.java:2066)
at net.sf.cglib.core.ReflectUtils.getConstructor(ReflectUtils.java:244)
... 14 more
I don't know the reason and whether I was wrong. hope someone could point out my mistake with cglib.
The text was updated successfully, but these errors were encountered:
Hi, cglib team. I encountered some problem when make proxy support towards the bean with constructor params. e.g when I want to some proxy usecases towards jedis (framework integration with redis server). here comes my code like this with enhancer:
public T getInstance(T target, Class[] args, Object[] argsValue) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(target.getClass());
enhancer.setCallback(this);
return (T) enhancer.create(args, argsValue);
}
the target is jedis like this:
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands {
public Jedis(final String host) {
super(host);
}
}
when I want to proxy jedis, the constructor for such is for such
public Jedis(final String host, final int port, final int timeout) {
super(host, port, timeout);
}
so here comes the class info and arguments comes like this
Class[] args = new Class[] {String.class, Integer.class, Integer.class};
Object[] arguments = new Object[] {jedis.getClient().getHost(), jedis.getClient().getPort(),
jedis.getClient().getTimeout()};
if such above is not wrong, the cglib will help to create the proxy class with enhancer. but here comes my exception stracktrace:
Caused by: java.lang.NoSuchMethodException: redis.clients.jedis.Jedis$$EnhancerByCGLIB$$e2ffdb0f.(java.lang.String, java.lang.Integer, java.lang.Integer)
at java.lang.Class.getConstructor0(Class.java:2902)
at java.lang.Class.getDeclaredConstructor(Class.java:2066)
at net.sf.cglib.core.ReflectUtils.getConstructor(ReflectUtils.java:244)
... 14 more
I don't know the reason and whether I was wrong. hope someone could point out my mistake with cglib.
The text was updated successfully, but these errors were encountered: