Java. cglib . .
, Java -, , , , Game IGame.
class GameInvocationHandler implements InvocationHandler
{
private Game game;
public GameInvocationHandler(Game game)
{
this.game = game;
}
Object invoke(Object proxy, Method method, Object[] args)
{
if (method.toGenericString().contains("act()")
{
return null;
}
else
{
return method.invoke(game, args);
}
}
}
Class proxyClass = Proxy.getProxyClass(Foo.class.getClassLoader(), IGame.class);
IGame f = (IGame) proxyClass.getConstructor(InvocationHandler.class).newInstance(new Object[] { });