Java 类org.objectweb.asm.TypeReference 实例源码

项目:DirectLeaks-AntiReleak-Remover    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:DirectLeaks-AntiReleak-Remover    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:DirectLeaks-AntiReleak-Remover    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:fastAOP    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:fastAOP    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:fastAOP    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:JReFrameworker    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:BitPlus    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:BitPlus    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:BitPlus    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:asm-legacy-svn-clone    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:asm-legacy-svn-clone    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:asm-legacy-svn-clone    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE
            && sort != TypeReference.METHOD_REFERENCE
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodOtherTest.java   
@Test
@SuppressWarnings("unchecked")
public void testReceiverTypeTypeAnnotationsRuntimeRetention() throws Exception {
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getReceiverType()).thenReturn(simpleAnnotatedType);
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    MethodAttributeAppender.ForInstrumentedMethod.INCLUDING_RECEIVER.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeReference(TypeReference.METHOD_RECEIVER).getValue(),
            null,
            Type.getDescriptor(AbstractAttributeAppenderTest.Baz.class),
            true);
    verifyNoMoreInteractions(methodVisitor);
    verify(methodDescription).getDeclaredAnnotations();
    verify(methodDescription).getParameters();
    verify(methodDescription).getReturnType();
    verify(methodDescription).getExceptionTypes();
    verify(methodDescription).getTypeVariables();
    verify(methodDescription).getReceiverType();
    verifyNoMoreInteractions(methodDescription);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodOtherTest.java   
@Test
@SuppressWarnings("unchecked")
public void testReceiverTypeTypeAnnotationsClassFileRetention() throws Exception {
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getReceiverType()).thenReturn(simpleAnnotatedType);
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    MethodAttributeAppender.ForInstrumentedMethod.INCLUDING_RECEIVER.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeReference(TypeReference.METHOD_RECEIVER).getValue(),
            null,
            Type.getDescriptor(AbstractAttributeAppenderTest.QuxBaz.class),
            false);
    verifyNoMoreInteractions(methodVisitor);
    verify(methodDescription).getDeclaredAnnotations();
    verify(methodDescription).getParameters();
    verify(methodDescription).getReturnType();
    verify(methodDescription).getExceptionTypes();
    verify(methodDescription).getTypeVariables();
    verify(methodDescription).getReceiverType();
    verifyNoMoreInteractions(methodDescription);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodReturnTypeTypeAnnotationRuntimeRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(simpleAnnotatedType);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeReference(TypeReference.METHOD_RETURN).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodReturnTypeTypeAnnotationClassFileRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(simpleAnnotatedType);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeReference(TypeReference.METHOD_RETURN).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodExceptionTypeTypeAnnotationRuntimeRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Explicit(simpleAnnotatedType));
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newExceptionReference(0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodExceptionTypeTypeAnnotationClassFileRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Explicit(simpleAnnotatedType));
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newExceptionReference(0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodParameterTypeTypeAnnotationRuntimeRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    ParameterDescription parameterDescription = mock(ParameterDescription.class);
    when(parameterDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(parameterDescription.getType()).thenReturn(simpleAnnotatedType);
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Explicit<ParameterDescription>(parameterDescription));
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newFormalParameterReference(0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testMethodParameterTypeTypeAnnotationClassFileRetention() throws Exception {
    when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    ParameterDescription parameterDescription = mock(ParameterDescription.class);
    when(parameterDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(parameterDescription.getType()).thenReturn(simpleAnnotatedType);
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Explicit<ParameterDescription>(parameterDescription));
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newFormalParameterReference(0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testTypeVariableTypeAnnotationRuntimeRetention() throws Exception {
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(annotatedTypeVariable));
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.METHOD_TYPE_PARAMETER, 0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.METHOD_TYPE_PARAMETER_BOUND, 0, 0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyZeroInteractions(methodVisitor);
}
项目:byte-buddy    文件:MethodAttributeAppenderForInstrumentedMethodTest.java   
@Test
@SuppressWarnings("unchecked")
public void testTypeVariableTypeAnnotations() throws Exception {
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Empty<ParameterDescription>());
    when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
    when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(annotatedTypeVariable));
    when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
    when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.METHOD_TYPE_PARAMETER, 0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verify(methodVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.METHOD_TYPE_PARAMETER_BOUND, 0, 0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(methodVisitor);
}
项目:byte-buddy    文件:TypeAttributeAppenderForInstrumentedTypeTest.java   
@Test
public void testSuperClassTypeAnnotationClassFileRetention() throws Exception {
    when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
    when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Empty());
    when(simpleAnnotatedType.getDeclaredAnnotations())
            .thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(instrumentedType.getSuperClass()).thenReturn(simpleAnnotatedType);
    TypeAttributeAppender.ForInstrumentedType.INSTANCE.apply(classVisitor, instrumentedType, annotationValueFilter);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newSuperTypeReference(-1).getValue(), null, Type.getDescriptor(QuxBaz.class), false);
    verifyNoMoreInteractions(classVisitor);
    verify(instrumentedType).getDeclaredAnnotations();
    verify(instrumentedType).getSuperClass();
    verify(instrumentedType).getInterfaces();
    verify(instrumentedType).getTypeVariables();
    verifyNoMoreInteractions(instrumentedType);
}
项目:byte-buddy    文件:TypeAttributeAppenderForInstrumentedTypeTest.java   
@Test
public void testTypeVariableTypeAnnotationRuntimeRetention() throws Exception {
    when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(annotatedTypeVariable));
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Empty());
    when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    TypeAttributeAppender.ForInstrumentedType.INSTANCE.apply(classVisitor, instrumentedType, annotationValueFilter);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.CLASS_TYPE_PARAMETER, 0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.CLASS_TYPE_PARAMETER_BOUND, 0, 0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyNoMoreInteractions(classVisitor);
    verify(instrumentedType).getDeclaredAnnotations();
    verify(instrumentedType).getSuperClass();
    verify(instrumentedType).getInterfaces();
    verify(instrumentedType).getTypeVariables();
    verifyNoMoreInteractions(instrumentedType);
}
项目:byte-buddy    文件:TypeAttributeAppenderForInstrumentedTypeTest.java   
@Test
public void testTypeVariableTypeAnnotations() throws Exception {
    when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(annotatedTypeVariable));
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Empty());
    when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    TypeAttributeAppender.ForInstrumentedType.INSTANCE.apply(classVisitor, instrumentedType, annotationValueFilter);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.CLASS_TYPE_PARAMETER, 0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.CLASS_TYPE_PARAMETER_BOUND, 0, 0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(classVisitor);
    verify(instrumentedType).getDeclaredAnnotations();
    verify(instrumentedType).getSuperClass();
    verify(instrumentedType).getInterfaces();
    verify(instrumentedType).getTypeVariables();
    verifyNoMoreInteractions(instrumentedType);
}
项目:byte-buddy    文件:TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java   
@Test
public void testTypeVariableTypeAnnotationRuntimeRetention() throws Exception {
    when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(pseudoType, annotatedTypeVariable));
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
    when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Empty());
    when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    new TypeAttributeAppender.ForInstrumentedType.Differentiating(0, 1, 0).apply(classVisitor, instrumentedType, annotationValueFilter);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.CLASS_TYPE_PARAMETER, 1).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.CLASS_TYPE_PARAMETER_BOUND, 1, 0).getValue(),
            null,
            Type.getDescriptor(Baz.class),
            true);
    verifyNoMoreInteractions(classVisitor);
    verify(instrumentedType).getDeclaredAnnotations();
    verify(instrumentedType).getInterfaces();
    verify(instrumentedType).getTypeVariables();
    verifyNoMoreInteractions(instrumentedType);
}
项目:byte-buddy    文件:TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java   
@Test
public void testTypeVariableTypeAnnotations() throws Exception {
    when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Explicit(pseudoType, annotatedTypeVariable));
    when(annotatedTypeVariable.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(annotatedTypeVariableBound.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance()));
    when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Empty());
    when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    new TypeAttributeAppender.ForInstrumentedType.Differentiating(0, 1, 0).apply(classVisitor, instrumentedType, annotationValueFilter);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterReference(TypeReference.CLASS_TYPE_PARAMETER, 1).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verify(classVisitor).visitTypeAnnotation(TypeReference.newTypeParameterBoundReference(TypeReference.CLASS_TYPE_PARAMETER_BOUND, 1, 0).getValue(),
            null,
            Type.getDescriptor(QuxBaz.class),
            false);
    verifyNoMoreInteractions(classVisitor);
    verify(instrumentedType).getDeclaredAnnotations();
    verify(instrumentedType).getInterfaces();
    verify(instrumentedType).getTypeVariables();
    verifyNoMoreInteractions(instrumentedType);
}
项目:ow2-asm    文件:CheckClassAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkState();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.CLASS_TYPE_PARAMETER
            && sort != TypeReference.CLASS_TYPE_PARAMETER_BOUND
            && sort != TypeReference.CLASS_EXTENDS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:ow2-asm    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEndMethod();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.METHOD_TYPE_PARAMETER
            && sort != TypeReference.METHOD_TYPE_PARAMETER_BOUND
            && sort != TypeReference.METHOD_RETURN
            && sort != TypeReference.METHOD_RECEIVER
            && sort != TypeReference.METHOD_FORMAL_PARAMETER
            && sort != TypeReference.THROWS) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:ow2-asm    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitInsnAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.INSTANCEOF && sort != TypeReference.NEW
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_RECEIVER
            && sort != TypeReference.METHOD_REFERENCE_RECEIVER
            && sort != TypeReference.CAST
            && sort != TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
            && sort != TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
            && sort != TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitInsnAnnotation(typeRef,
            typePath, desc, visible));
}
项目:DirectLeaks-AntiReleak-Remover    文件:CheckFieldAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEnd();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.FIELD) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}
项目:DirectLeaks-AntiReleak-Remover    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitTryCatchAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.EXCEPTION_PARAMETER) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTryCatchAnnotation(
            typeRef, typePath, desc, visible));
}
项目:DirectLeaks-AntiReleak-Remover    文件:CheckMethodAdapter.java   
@Override
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
        TypePath typePath, Label[] start, Label[] end, int[] index,
        String desc, boolean visible) {
    checkStartCode();
    checkEndCode();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.LOCAL_VARIABLE
            && sort != TypeReference.RESOURCE_VARIABLE) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    checkDesc(desc, false);
    if (start == null || end == null || index == null
            || end.length != start.length || index.length != start.length) {
        throw new IllegalArgumentException(
                "Invalid start, end and index arrays (must be non null and of identical length");
    }
    for (int i = 0; i < start.length; ++i) {
        checkLabel(start[i], true, "start label");
        checkLabel(end[i], true, "end label");
        checkUnsignedShort(index[i], "Invalid variable index");
        int s = labels.get(start[i]).intValue();
        int e = labels.get(end[i]).intValue();
        if (e < s) {
            throw new IllegalArgumentException(
                    "Invalid start and end labels (end must be greater than start)");
        }
    }
    return super.visitLocalVariableAnnotation(typeRef, typePath, start,
            end, index, desc, visible);
}
项目:fastAOP    文件:CheckFieldAdapter.java   
@Override
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
        final TypePath typePath, final String desc, final boolean visible) {
    checkEnd();
    int sort = typeRef >>> 24;
    if (sort != TypeReference.FIELD) {
        throw new IllegalArgumentException("Invalid type reference sort 0x"
                + Integer.toHexString(sort));
    }
    CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
    CheckMethodAdapter.checkDesc(desc, false);
    return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef,
            typePath, desc, visible));
}