public FieldInfo(ClassInfo info, Field field) { super(field); this.declaringClass = info; this.name = field.getName(); this.type = Type.getType(field.getType()).getDescriptor(); this.field = field; }
public AnnotationInfo(Annotation annotation) { this(Type.getType(annotation.annotationType()).getDescriptor()); }
@Override protected void createInstanceVariables(ClassWriter cw, Class<?> classToProxy, String classFileName) { // variable #1, the Provider<?> for the Contextual Instance cw.visitField(Opcodes.ACC_PRIVATE, FIELD_INSTANCE_PROVIDER, Type.getDescriptor(Provider.class), null, null).visitEnd(); // variable #2, the Method[] for all protected methods cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, FIELD_PROTECTED_METHODS, Type.getDescriptor(Method[].class), null, null).visitEnd(); }
public Annotatable(AnnotatedElement element) { for (Annotation annotation : getAnnotations(element)) { annotations.add(new AnnotationInfo(Type.getType(annotation.annotationType()).getDescriptor())); } }
public AnnotationInfo(String name) { final Type type = Type.getType(name); name = type.getClassName(); if (name == null) { name = type.getDescriptor(); // name was already a class name } this.name = name; }
@Override protected void createInstanceVariables(ClassWriter cw, Class<?> classToProxy, String classFileName) { // variable #1, the delegation point cw.visitField(Opcodes.ACC_PRIVATE, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy), null, null).visitEnd(); // variable #2, the invocation handler cw.visitField(Opcodes.ACC_PRIVATE, FIELD_INTERCEPTOR_HANDLER, Type.getDescriptor(InterceptorHandler.class), null, null).visitEnd(); // variable #3, the Method[] of all intercepted methods. cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, FIELD_INTERCEPTED_METHODS, Type.getDescriptor(Method[].class), null, null).visitEnd(); }
public String getType() { // if this method starts to be used internally move this to constructors and just return type final Type t = Type.getType(type); if (t.getClassName() == null) { return t.getDescriptor(); } return t.getClassName(); }
if (hasInterceptors) { cw .visitField(ACC_PRIVATE, FIELD_INTERCEPTOR_HANDLER, Type.getDescriptor(InterceptorHandler.class), null, null) .visitEnd(); cw .visitField(ACC_PRIVATE | ACC_STATIC, FIELD_INTERCEPTED_METHODS, Type.getDescriptor(Method[].class), null, null) .visitEnd();
mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));
"(" + Type.getDescriptor(parameterType) + ")L" + wrapperType + ";", false); mv.visitInsn(AASTORE);
"(" + Type.getDescriptor(parameterType) + ")L" + wrapperType + ";", false); mv.visitInsn(Opcodes.AASTORE);
mv.visitFieldInsn(Opcodes.GETSTATIC, proxyClassFileName, FIELD_PROTECTED_METHODS, Type.getDescriptor(Method[].class)); mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_INSTANCE_PROVIDER, Type.getDescriptor(Provider.class)); "()" + Type.getDescriptor(returnType), false);
mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_INSTANCE_PROVIDER, Type.getDescriptor(Provider.class));
@Override protected void createSerialisation(ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName) { String[] exceptionTypeNames = {Type.getType(ObjectStreamException.class).getInternalName()}; MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, "writeReplace", "()Ljava/lang/Object;", null, exceptionTypeNames); // fill method body mv.visitCode(); // load the contextual instance Provider mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_INSTANCE_PROVIDER, Type.getDescriptor(Provider.class)); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); }
mv .visitFieldInsn(PUTFIELD, proxyClassFileName, FIELD_INTERCEPTOR_HANDLER, Type.getDescriptor(InterceptorHandler.class));
mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy)); mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_INTERCEPTOR_HANDLER, Type.getDescriptor(InterceptorHandler.class));
mv.visitFieldInsn(Opcodes.PUTFIELD, proxyClassFileName, FIELD_INSTANCE_PROVIDER, Type.getDescriptor(Provider.class));
@Override protected void createSerialisation(ClassWriter cw, String proxyClassFileName, Class<?> classToProxy, String classFileName) { String[] exceptionTypeNames = {Type.getType(ObjectStreamException.class).getInternalName()}; MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, "writeReplace", "()Ljava/lang/Object;", null, exceptionTypeNames); // fill method body mv.visitCode(); // load the contextual instance Provider mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_INTERCEPTOR_HANDLER, Type.getDescriptor(InterceptorHandler.class)); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); }
FIELD_BEAN_PASSIVATION_ID, Type.getDescriptor(String.class), null, null).visitEnd();
Type.getDescriptor(InterceptorHandler.class)); mv.visitFieldInsn(GETSTATIC, proxyClassFileName, FIELD_INTERCEPTED_METHODS, Type.getDescriptor(Method[].class)); "()" + Type.getDescriptor(returnType), false);