本文整理汇总了Java中org.objectweb.asm.TypeReference类的典型用法代码示例。如果您正苦于以下问题:Java TypeReference类的具体用法?Java TypeReference怎么用?Java TypeReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeReference类属于org.objectweb.asm包,在下文中一共展示了TypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitTypeAnnotation
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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));
}
示例2: visitTypeAnnotation
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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));
}
示例3: visitInsnAnnotation
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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));
}
示例4: testReceiverTypeTypeAnnotationsRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例5: testReceiverTypeTypeAnnotationsClassFileRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例6: testMethodReturnTypeTypeAnnotationRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例7: testMethodReturnTypeTypeAnnotationClassFileRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例8: testMethodExceptionTypeTypeAnnotationRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例9: testMethodExceptionTypeTypeAnnotationClassFileRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例10: testMethodParameterTypeTypeAnnotationRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例11: testMethodParameterTypeTypeAnnotationClassFileRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例12: testTypeVariableTypeAnnotationRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例13: testTypeVariableTypeAnnotations
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例14: testSuperClassTypeAnnotationClassFileRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}
示例15: testTypeVariableTypeAnnotationRuntimeRetention
import org.objectweb.asm.TypeReference; //导入依赖的package包/类
@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);
}