Class ByteCodeWriterTck

java.lang.Object
io.micronaut.sourcegen.bytecode.tck.ByteCodeWriterTck

public abstract class ByteCodeWriterTck extends Object
The behaviour every bytecode backend must provide, asserted through the classes a backend writes rather than through the bytecode it emits, so that the same tests hold for any backend.

A backend runs the TCK by extending this class and implementing write(ObjectDef). Assertions about a particular backend's encoding, such as the exact instructions it selects or the fallbacks it offers, belong in that backend's own tests.

Since:
2.2
  • Constructor Details

    • ByteCodeWriterTck

      public ByteCodeWriterTck()
  • Method Details

    • write

      protected abstract byte[] write(ObjectDef definition)
      Writes one definition to class file bytes with the backend under test.

      An implementation should assert whatever its backend guarantees about how the bytes were produced, such as verifying them or refusing a fallback path, so that a backend cannot pass the TCK by quietly declining to write the definition itself.

      Parameters:
      definition - The definition to write
      Returns:
      The class file bytes
    • define

      protected final Class<?> define(ObjectDef definition) throws ClassNotFoundException
      Loads a definition written by write(ObjectDef).
      Parameters:
      definition - The definition to write and load
      Returns:
      The loaded class
      Throws:
      ClassNotFoundException - If the class cannot be loaded
    • writesEveryIntegerMathOperationAndWidePrimitiveOperations

      @Test public void writesEveryIntegerMathOperationAndWidePrimitiveOperations() throws Exception
      Throws:
      Exception
    • writesAllComparisonsForIntegralAndFloatingPointValues

      @Test public void writesAllComparisonsForIntegralAndFloatingPointValues() throws Exception
      Throws:
      Exception
    • writesCastsBoxingNullChecksEqualityInstanceOfAndArrays

      @Test public void writesCastsBoxingNullChecksEqualityInstanceOfAndArrays() throws Exception
      Throws:
      Exception
    • writesWhileLoopsAndFinallyOnReturnAndThrow

      @Test public void writesWhileLoopsAndFinallyOnReturnAndThrow() throws Exception
      Throws:
      Exception
    • writesReflectedGenericBridgeAndGenericSignatures

      @Test public void writesReflectedGenericBridgeAndGenericSignatures() throws Exception
      Throws:
      Exception
    • invokesMethodsThroughInterfaceBoundTypeVariables

      @Test public void invokesMethodsThroughInterfaceBoundTypeVariables() throws Exception
      Throws:
      Exception
    • verifiesHierarchyFromGeneratedModelDefinitions

      @Test public void verifiesHierarchyFromGeneratedModelDefinitions() throws Exception
      Throws:
      Exception
    • writesReferencesToAMemberTypeByItsBinaryName

      @Test public void writesReferencesToAMemberTypeByItsBinaryName() throws Exception
      Throws:
      Exception
    • writesEmptyWideGenericAndBridgedRecords

      @Test public void writesEmptyWideGenericAndBridgedRecords() throws Exception
      Throws:
      Exception
    • writesExplicitSuperConstructorsAndObjectCreation

      @Test public void writesExplicitSuperConstructorsAndObjectCreation() throws Exception
      Throws:
      Exception
    • writesBooleanCompositionConditionalExpressionsAndArraySizes

      @Test public void writesBooleanCompositionConditionalExpressionsAndArraySizes() throws Exception
      Throws:
      Exception
    • writesCatchVariablesThrowsAndDeclarationMetadata

      @Test public void writesCatchVariablesThrowsAndDeclarationMetadata() throws Exception
      Throws:
      Exception
    • writesGenericRecordSignaturesAndRecordsWithAnAdditionalConstructor

      @Test public void writesGenericRecordSignaturesAndRecordsWithAnAdditionalConstructor() throws Exception
      Throws:
      Exception
    • writesSuperCallsAndSuperConstructorDelegation

      @Test public void writesSuperCallsAndSuperConstructorDelegation() throws Exception
      Throws:
      Exception
    • writesDefaultMethodCallsOnAnInterfaceReceiverWithInvokeInterface

      @Test public void writesDefaultMethodCallsOnAnInterfaceReceiverWithInvokeInterface() throws Exception
      Throws:
      Exception
    • writesArrayConstantsAndMultiDimensionalArrays

      @Test public void writesArrayConstantsAndMultiDimensionalArrays() throws Exception
      Throws:
      Exception
    • writesVoidMethodsThatReturnAnExpression

      @Test public void writesVoidMethodsThatReturnAnExpression() throws Exception
      Throws:
      Exception
    • writesUnboxingOfAnyNumberAndCastsThroughUnrelatedTypes

      @Test public void writesUnboxingOfAnyNumberAndCastsThroughUnrelatedTypes() throws Exception
      Throws:
      Exception
    • writesConstructorsWhoseSuperCallUsesAnEarlierLocal

      @Test public void writesConstructorsWhoseSuperCallUsesAnEarlierLocal() throws Exception
      Throws:
      Exception
    • writesSwitchesSharingOneBodyAcrossManyKeys

      @Test public void writesSwitchesSharingOneBodyAcrossManyKeys() throws Exception
      Throws:
      Exception
    • writesNestedCastsWithoutUnboxingAndReboxingAReference

      @Test public void writesNestedCastsWithoutUnboxingAndReboxingAReference() throws Exception
      Throws:
      Exception
    • writesBoxedConstantsSmallPrimitivesAndPrimitiveHashCodes

      @Test public void writesBoxedConstantsSmallPrimitivesAndPrimitiveHashCodes() throws Exception
      Throws:
      Exception
    • writesInterfacesWithAbstractDefaultAndStaticMethods

      @Test public void writesInterfacesWithAbstractDefaultAndStaticMethods() throws Exception
      Throws:
      Exception
    • writesEnums

      @Test public void writesEnums() throws Exception
      Throws:
      Exception
    • writesTryWhoseCatchCompletesInsideAnIfBranch

      @Test public void writesTryWhoseCatchCompletesInsideAnIfBranch() throws Exception
      Throws:
      Exception
    • writesConstructorDelegationWithoutRepeatingFieldInitializers

      @Test public void writesConstructorDelegationWithoutRepeatingFieldInitializers() throws Exception
      Throws:
      Exception