Class SignatureTck
java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.SignatureTck
Erasure and generic signatures: descriptors, Signature attributes, type annotations and member flags of
generated classes, compared with the classes javac writes from the same declarations.
A backend runs these tests by extending this class and implementing
AbstractByteCodeWriterTck.write(io.micronaut.sourcegen.model.ObjectDef).
- Since:
- 2.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSignatureTck.AnnotatedClassBound<T extends Number>Annotation on a class variable's bound.static classSignatureTck.AnnotatedDependentBound<T extends U, U extends Number>Annotated type-variable bound occupies the class-bound slot.static classSignatureTck.AnnotatedGenericArrays<T extends Number>Annotations at multiple array levels.static classAnnotated interface bounds keep their distinct bound indexes.static classAnnotation on a method variable's bound.static classAn annotated generic exception without other generic uses.static classSignatureTck.AnnotatedNestedBounds<T extends Comparable<List<? extends T>>>Nested type argument in a bound.static classSignatureTck.AnnotatedObjectIntersection<T extends Object & Runnable>Explicit annotated Object intersection bounds remain class bounds.static classExplicit Object wildcard bounds retain their type annotations.static classAnnotated generic superclass.static classAnnotated generic superinterface.static classAnnotated generic and concrete throws.static classAnnotations on class and method variable uses.static classAnnotations on both wildcard directions.static classArray rank distinguishes generic overloads.static final recordSignatureTck.BoundedRecord<T extends Number, U extends T>Record with dependent bounded components.static classSignatureTck.ClassBound<T extends Number>Name-only bounded class references and arrays.static classSignatureTck.CrossScope<T extends Number>Method bounds reference class variables.static classWrong erasure must not collapse two legal overloads into one descriptor.static classSignatureTck.ForwardBounds<A extends B, B extends Number>A bound can refer to a later declaration.static classGeneric array bridge parameters.static classGeneric scalar bridge parameters.static classA covariant generic method with a method exception variable.static classGeneric constructors have method-scoped bounds.static interfaceSignatureTck.GenericInterface<T extends Number & Serializable>An interface with dependent variables and generic exceptions.static classSignatureTck.GenericOverloads<T extends CharSequence>Different bounds distinguish class-variable and method-variable overloads.static classMethod-scoped generic exception.static classSignatureTck.Inheritance<T extends Number>Parameterized superclass and superinterface signatures.static interfaceGeneric throwing contract for inherited method-scoped exception checks.static classInherited method-scoped checked exception.static classA bridge inherited from a method declaring its own exception variable.static interfaceGeneric throwing contract for inherited bridge checks.static classInherited concrete implementation with a checked exception.static classAn inherited bridge retains checked exception metadata.static classInterface-only intersection bounds.static interfaceSignatureTck.InterfaceMethodShadow<A extends B, B extends Number>An interface method can shadow a class bound's name.static classSignatureTck.Intersection<T extends Number & Runnable>Intersection with a class as its first bound.static classSignatureTck.LongClassChain<A extends B, B extends C, C extends D, D extends E, E extends F, F extends G, G extends H, H extends I, I extends J, J extends K, K extends L, L extends Number>Long class bound chains.static classLong method bound chains.static interfaceMethod variables belong to the inherited method.static classBounded method references.static interfaceScalar method variables belong to the inherited method.static classSignatureTck.MethodBoundToClass<A extends Number>A method variable may use a class variable as its bound.static classMethod variables reference other method variables.static classIntersection bounds of a generic method.static classOrdinary and generic exceptions coexist in a method signature.static classSignatureTck.Mutual<A extends Comparable<B>, B extends Comparable<A>>Mutually recursive bounds terminate at parameterized erasure.static final recordSignatureTck.NestedRecord<T extends Comparable<? super T>>Record with recursive bounds and nested arrays.static classSignatureTck.NestedWildcards<T extends Number>Deeply nested wildcards and arrays.static classBridge descriptors retain the explicit Object bound.static interfaceSignatureTck.ObjectFirstContract<T extends Object & Runnable>Explicit Object remains the leftmost erasure.static classSignatureTck.ObjectIntersection<T extends Object & Runnable>An explicit Object bound determines erasure.static classPlain signature fixture.static classSignatureTck.Recursive<T extends Comparable<? super T>>A recursively bounded variable with a lower wildcard.static classRecursive method bounds erase to their raw interface.static classSelf references and covariant bridge metadata.static classSignatureTck.Shadowed<T extends CharSequence>Method variables shadow their class namesakes.static classSignatureTck.ShadowedClassBoundChain<A extends B, B extends Number>Class bounds retain their declaration scope when a method shadows a bound's name.static classSignatureTck.ShadowedExceptionBound<E extends Exception, T extends E>Exception erasure retains the class declaration scope.static classSignatureTck.SignatureStress<A extends Number & Serializable, B extends A>Combines dependent class bounds, nested wildcard arrays, method bounds and a generic exception.static interfaceA covariant redeclaration requires a concrete bridge.static classA bridge has an erased signature and no method variables.static classjavac's synchronized method.static interfaceContract whose bridge must retain the erased method exception.static classSignatureTck.ThrowsOnly<E extends Exception>Class-scoped generic exception used only in throws.static classUnbounded class and method variables.static classA constructor variable need not appear in its parameters.static classA method variable need not appear in its parameters or result.static classjavac's volatile and transient fields, public for reflection to read them.static classNested wildcards, member types and generic arrays. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidannotatedGenericSignaturesMatchJavac(Class<?> reference, boolean inline, String part) Checks annotations at every nested type path, as well as ordinary generic metadata.voidvoidvoidvoidvoidgenericInterfaceSignaturesMatchJavac(Class<?> reference, boolean inline, String part) Compares abstract interface declarations with javac, including covariant generic redeclarations.voidgenericRecordSignaturesMatchJavac(Class<?> reference, boolean inline, String part) Checks generic record components and their expanded fields, accessors and constructor.voidgenericSignaturesMatchJavac(Class<?> reference, boolean inline, String part) Checks metadata and descriptors independently, with name-only and inline-bound references.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidMethods inherited from class AbstractByteCodeWriterTck
assertCall, caller, callWithParameter, classShape, declaredFields, declaredMethods, define, defineInPackage, genericShape, invoke, list, load, outcome, run, run, run, selection, selection, shape, write
-
Constructor Details
-
SignatureTck
public SignatureTck()
-
-
Method Details
-
methodVariableUsesItsDeclaredBound
-
methodVariableShadowsClassVariable
-
methodVariableArrayUsesChainedBound
-
classVariableArrayUsesChainedBound
-
explicitObjectFirstIntersectionErasesToObject
-
retainsUnusedMethodTypeParameters
-
retainsGenericExceptionVariable
-
writesAbstractMethodWithParameters
-
genericConstructorUsesItsOwnBound
-
recursiveClassBoundPreservesSignature
-
nestedWildcardsAndGenericArraysPreserveSignature
-
enumMethodRetainsItsOwnGenericSignatureAndErasedDescriptor
-
genericSignaturesMatchJavac
@ParameterizedTest(name="{0} / {1} / {2}") @MethodSource("genericSignatureCases") public void genericSignaturesMatchJavac(Class<?> reference, boolean inline, String part) throws Exception Checks metadata and descriptors independently, with name-only and inline-bound references.- Parameters:
reference- The fixture javac compiledinline- Whether the model writes type variables inline with their bounds rather than by namepart- The part of the class compared with javac's- Throws:
Exception- If the generated class cannot be loaded
-
genericInterfaceSignaturesMatchJavac
@ParameterizedTest(name="{0} / {1} / {2}") @MethodSource("genericInterfaceCases") public void genericInterfaceSignaturesMatchJavac(Class<?> reference, boolean inline, String part) throws Exception Compares abstract interface declarations with javac, including covariant generic redeclarations.- Parameters:
reference- The fixture javac compiledinline- Whether the model writes type variables inline with their bounds rather than by namepart- The part of the class compared with javac's- Throws:
Exception- If the generated class cannot be loaded
-
annotatedGenericSignaturesMatchJavac
@ParameterizedTest(name="{0} / {1} / {2}") @MethodSource("annotatedSignatureCases") public void annotatedGenericSignaturesMatchJavac(Class<?> reference, boolean inline, String part) throws Exception Checks annotations at every nested type path, as well as ordinary generic metadata.- Parameters:
reference- The fixture javac compiledinline- Whether the model writes type variables inline with their bounds rather than by namepart- The part of the class compared with javac's- Throws:
Exception- If the generated class cannot be loaded
-
genericRecordSignaturesMatchJavac
@ParameterizedTest(name="{0} / {1} / {2}") @MethodSource("genericRecordCases") public void genericRecordSignaturesMatchJavac(Class<?> reference, boolean inline, String part) throws Exception Checks generic record components and their expanded fields, accessors and constructor.- Parameters:
reference- The fixture javac compiledinline- Whether the model writes type variables inline with their bounds rather than by namepart- The part of the class compared with javac's- Throws:
Exception- If the generated class cannot be loaded
-
genericSignaturesOfAnEnumMatchJavac
-
synchronizedMethodKeepsItsFlag
-
volatileAndTransientFieldsKeepTheirFlags
-