A {@link org.mvel2.integration.PropertyHandler} that implements this class advertises the to the{@link ASMAccessorOptimizer} that it is able to generate bytecode for it's custom resolvers.
The two methods defined by this interface (one for get, and one for set accessors) are passed an ASM MethodVistor object. It is to be assumed by the implementor that the JIT has already produced the necessary bytecode up until this point. The implementor most only implement the necessary bytecode instructions to retrieve the property, leaving the resultant value on the stack.
DO NOT implement bytecode that calls a return instruction such as ARETURN. This will be done automatically by the JIT.
See the following example:
public void produceBytecodeGet(MethodVisitor mv, String propertyName, VariableResolverFactory variableResolverFactory) { mv.visitTypeInsn(CHECKCAST, "org/mvel/tests/main/res/SampleBean"); mv.visitLdcInsn(propertyName); mv.visitMethodInsn(INVOKEVIRTUAL, "org/mvel/tests/main/res/SampleBean", "getProperty", "(Ljava/lang/String;)Ljava/lang/Object;"); }
This example (correctly) presumes that the property of interest exists on the stack, and simply performs the necessary CHECKCAST, and call to the needed method in the accessor to translate the property call.
This is taken from a working example which you can examine in the MVEL unit tests. The class is: org.mvel.tests.main.res.SampleBeanAccessor