protected static void buildGetMethod ( final Class < ? > originalClass , final String className , final Class < ? > superClass , final Method getterMethod , final ClassWriter cw ) { final Class < ? > fieldType = getterMethod . getReturnType ( ) ; Method overridingMethod ; try { overridingMethod = superClass . getMethod ( getOverridingGetMethodName ( fieldType ) , InternalWorkingMemory . class , Object . class ) ; } catch ( final Exception e ) { throw new RuntimeException ( "This is a bug. Please report back to JBoss Rules team." , e ) ; } final MethodVisitor mv = cw . visitMethod ( Opcodes . ACC_PUBLIC , overridingMethod . getName ( ) , Type . getMethodDescriptor ( overridingMethod ) , null , null ) ; mv . visitCode ( ) ; final Label l0 = new Label ( ) ; mv . visitLabel ( l0 ) ; mv . visitVarInsn ( Opcodes . ALOAD , 2 ) ; mv . visitTypeInsn ( Opcodes . CHECKCAST , Type . getInternalName ( originalClass ) ) ; if ( originalClass . isInterface ( ) ) { mv . visitMethodInsn ( Opcodes . INVOKEINTERFACE , Type . getInternalName ( originalClass ) , getterMethod . getName ( ) , Type . getMethodDescriptor ( getterMethod ) ) ; } else { mv . visitMethodInsn ( Opcodes . INVOKEVIRTUAL , Type . getInternalName ( originalClass ) , getterMethod . getName ( ) , Type . getMethodDescriptor ( getterMethod ) ) ; } mv . visitInsn ( Type . getType ( fieldType ) . getOpcode ( Opcodes . IRETURN ) ) ; final Label l1 = new Label ( ) ; mv . visitLabel ( l1 ) ; mv . visitLocalVariable ( "this" , "L" + className + ";" , null , l0 , l1 , 0 ) ; mv . visitLocalVariable ( "workingMemory" , Type . getDescriptor ( InternalWorkingMemory . class ) , null , l0 , l1 , 1 ) ; mv . visitLocalVariable ( "object" , Type . getDescriptor ( Object . class ) , null , l0 , l1 , 2 ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; }
Creates the proxy reader method for the given method