Package org.mvel2.optimizers.impl.asm
Interface ProducesBytecode
-
public interface ProducesBytecode
APropertyHandler
that implements this class advertises the to theASMAccessorOptimizer
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:
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.SampleBeanAccessorpublic 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;"); }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
produceBytecodeGet(org.objectweb.asm.MethodVisitor mv, java.lang.String propertyName, VariableResolverFactory factory)
void
produceBytecodePut(org.objectweb.asm.MethodVisitor mv, java.lang.String propertyName, VariableResolverFactory factory)
-
-
-
Method Detail
-
produceBytecodeGet
void produceBytecodeGet(org.objectweb.asm.MethodVisitor mv, java.lang.String propertyName, VariableResolverFactory factory)
-
produceBytecodePut
void produceBytecodePut(org.objectweb.asm.MethodVisitor mv, java.lang.String propertyName, VariableResolverFactory factory)
-
-