Search in sources :

Example 1 with StaticMethodInformation

use of org.jboss.weld.util.bytecode.StaticMethodInformation in project core by weld.

the class DecoratorProxyFactory method addHandlerInitializerMethod.

/**
 * calls _initMH on the method handler and then stores the result in the
 * methodHandler field as then new methodHandler
 */
private void addHandlerInitializerMethod(ClassFile proxyClassType, ClassMethod staticConstructor) throws Exception {
    ClassMethod classMethod = proxyClassType.addMethod(AccessFlag.PRIVATE, INIT_MH_METHOD_NAME, BytecodeUtils.VOID_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT);
    final CodeAttribute b = classMethod.getCodeAttribute();
    b.aload(0);
    StaticMethodInformation methodInfo = new StaticMethodInformation(INIT_MH_METHOD_NAME, new Class[] { Object.class }, void.class, classMethod.getClassFile().getName());
    invokeMethodHandler(classMethod, methodInfo, false, DEFAULT_METHOD_RESOLVER, staticConstructor);
    b.checkcast(MethodHandler.class);
    b.putfield(classMethod.getClassFile().getName(), METHOD_HANDLER_FIELD_NAME, DescriptorUtils.makeDescriptor(MethodHandler.class));
    b.returnInstruction();
    BeanLogger.LOG.createdMethodHandlerInitializerForDecoratorProxy(getBeanType());
}
Also used : CodeAttribute(org.jboss.classfilewriter.code.CodeAttribute) ClassMethod(org.jboss.classfilewriter.ClassMethod) StaticMethodInformation(org.jboss.weld.util.bytecode.StaticMethodInformation)

Aggregations

ClassMethod (org.jboss.classfilewriter.ClassMethod)1 CodeAttribute (org.jboss.classfilewriter.code.CodeAttribute)1 StaticMethodInformation (org.jboss.weld.util.bytecode.StaticMethodInformation)1