I have a Java dynamic proxy with an invoke method that looks like this: @Overridepublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {    Object result;    try {        //Not sure if this line is ok?        Token token = (Token) args[0];        System.out.println(Token with id: +token.getId()+  was passed);        result = method.invoke(realObject, args);    } catch (InvocationTargetException e) {        throw e.getTargetException();    } catch (Exception e) {        throw new RuntimeException(unexpected invocation exception:  + e.getMessage());    } finally {        System.out.println(after method  + method.getName());    }    return result;}Would it be considered bad practice to pull out and cast that Token object from the args array?The problem I can see is that it means the proxy isn't generic and in fact will only work for method invocations that pass an instance of a Token object as the first parameter.
Is it ok to pull out specific arguments from a Java dynamic proxy invocation?
java