org.objectweb.asm.TypeReference Java Examples
The following examples show how to use
org.objectweb.asm.TypeReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitInsnAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitInsnAnnotation(typeRef, typePath, descriptor, visible)); }
Example #3
Source File: CheckClassAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkState(); int sort = new TypeReference(typeRef).getSort(); 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)); } checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #4
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitEndNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #5
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitInsnAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitInsnAnnotation(typeRef, typePath, descriptor, visible)); }
Example #6
Source File: MethodAttributeAppenderForInstrumentedMethodOtherTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #7
Source File: MethodAttributeAppenderForInstrumentedMethodOtherTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #9
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #11
Source File: CheckClassAdapter.java From Concurnas with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkState(); int sort = new TypeReference(typeRef).getSort(); 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)); } checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #12
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #14
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #15
Source File: MethodAttributeAppenderForInstrumentedMethodTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #16
Source File: TypeAttributeAppenderForInstrumentedTypeTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #17
Source File: TypeAttributeAppenderForInstrumentedTypeTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #18
Source File: TypeAttributeAppenderForInstrumentedTypeTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #19
Source File: TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #20
Source File: TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java From byte-buddy with Apache License 2.0 | 6 votes |
@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); }
Example #21
Source File: CheckMethodAdapter.java From Concurnas with MIT License | 6 votes |
@Override public AnnotationVisitor visitInsnAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitInsnAnnotation(typeRef, typePath, descriptor, visible)); }
Example #22
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitEndNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #23
Source File: CheckMethodAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
@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); }
Example #24
Source File: CheckClassAdapter.java From JReFrameworker with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkState(); int sort = new TypeReference(typeRef).getSort(); 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)); } checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #25
Source File: CheckMethodAdapter.java From Concurnas with MIT License | 6 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitEndNotCalled(); int sort = new TypeReference(typeRef).getSort(); 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 + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(version, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #26
Source File: TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java From byte-buddy with Apache License 2.0 | 5 votes |
@Test public void testInterfaceTypeAnnotationRuntimeRetention() throws Exception { when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Empty()); when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Explicit(pseudoType, simpleAnnotatedType)); when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance())); when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); new TypeAttributeAppender.ForInstrumentedType.Differentiating(0, 0, 1).apply(classVisitor, instrumentedType, annotationValueFilter); verify(classVisitor).visitTypeAnnotation(TypeReference.newSuperTypeReference(1).getValue(), null, Type.getDescriptor(Baz.class), true); verifyNoMoreInteractions(classVisitor); verify(instrumentedType).getDeclaredAnnotations(); verify(instrumentedType).getInterfaces(); verify(instrumentedType).getTypeVariables(); verifyNoMoreInteractions(instrumentedType); }
Example #27
Source File: TypeAttributeAppenderForInstrumentedTypeDifferentiatingTest.java From byte-buddy with Apache License 2.0 | 5 votes |
@Test public void testInterfaceTypeAnnotations() throws Exception { when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Empty()); when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Explicit(pseudoType, simpleAnnotatedType)); when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance())); when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); new TypeAttributeAppender.ForInstrumentedType.Differentiating(0, 0, 1).apply(classVisitor, instrumentedType, annotationValueFilter); verify(classVisitor).visitTypeAnnotation(TypeReference.newSuperTypeReference(1).getValue(), null, Type.getDescriptor(QuxBaz.class), false); verifyNoMoreInteractions(classVisitor); verify(instrumentedType).getDeclaredAnnotations(); verify(instrumentedType).getInterfaces(); verify(instrumentedType).getTypeVariables(); verifyNoMoreInteractions(instrumentedType); }
Example #28
Source File: TypeAttributeAppenderForInstrumentedTypeTest.java From byte-buddy with Apache License 2.0 | 5 votes |
@Test public void testInterfaceTypeAnnotations() throws Exception { when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Empty()); when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Explicit(simpleAnnotatedType)); when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new QuxBaz.Instance())); when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); TypeAttributeAppender.ForInstrumentedType.INSTANCE.apply(classVisitor, instrumentedType, annotationValueFilter); verify(classVisitor).visitTypeAnnotation(TypeReference.newSuperTypeReference(0).getValue(), null, Type.getDescriptor(QuxBaz.class), false); verifyNoMoreInteractions(classVisitor); verify(instrumentedType).getDeclaredAnnotations(); verify(instrumentedType).getSuperClass(); verify(instrumentedType).getInterfaces(); verify(instrumentedType).getTypeVariables(); verifyNoMoreInteractions(instrumentedType); }
Example #29
Source File: CheckFieldAdapter.java From Concurnas with MIT License | 5 votes |
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { checkVisitEndNotCalled(); int sort = new TypeReference(typeRef).getSort(); if (sort != TypeReference.FIELD) { throw new IllegalArgumentException( "Invalid type reference sort 0x" + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRef(typeRef); CheckMethodAdapter.checkDescriptor(Opcodes.V1_5, descriptor, false); return new CheckAnnotationAdapter( super.visitTypeAnnotation(typeRef, typePath, descriptor, visible)); }
Example #30
Source File: TypeAttributeAppenderForInstrumentedTypeTest.java From byte-buddy with Apache License 2.0 | 5 votes |
@Test public void testInterfaceTypeAnnotationRuntimeRetention() throws Exception { when(instrumentedType.getTypeVariables()).thenReturn(new TypeList.Generic.Empty()); when(instrumentedType.getInterfaces()).thenReturn(new TypeList.Generic.Explicit(simpleAnnotatedType)); when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance())); when(instrumentedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); TypeAttributeAppender.ForInstrumentedType.INSTANCE.apply(classVisitor, instrumentedType, annotationValueFilter); verify(classVisitor).visitTypeAnnotation(TypeReference.newSuperTypeReference(0).getValue(), null, Type.getDescriptor(Baz.class), true); verifyNoMoreInteractions(classVisitor); verify(instrumentedType).getDeclaredAnnotations(); verify(instrumentedType).getSuperClass(); verify(instrumentedType).getInterfaces(); verify(instrumentedType).getTypeVariables(); verifyNoMoreInteractions(instrumentedType); }