Class ByteCodeGenerator
java.lang.Object
io.micronaut.sourcegen.generator.AbstractByteCodeGenerator
io.micronaut.sourcegen.generator.bytecode.jdk.ByteCodeGenerator
- All Implemented Interfaces:
SourceGenerator
Sourcegen generator entry point for the JDK backend.
The writer uses the annotation-processing context to reconstruct the source and class paths visible to the current compilation. It emits normalized classfiles directly when all referenced types are resolvable and preserves annotation-processing round semantics with a Java source fallback when a peer generated type is not yet available.
- Since:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAnnotation-processor option holding the compilation's class path, separated byFile.pathSeparator.static final StringAnnotation-processor option holding additional source roots, separated byFile.pathSeparator, which javac may read when a generated class references a type that is still being compiled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.inject.visitor.VisitorContext.Languageprotected booleanwriteClass(ObjectDef objectDef, @Nullable ClassTypeDef outerType, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element[] originatingElements) Emit one definition.Methods inherited from class AbstractByteCodeGenerator
write, write
-
Field Details
-
SOURCE_PATH_OPTION
Annotation-processor option holding additional source roots, separated byFile.pathSeparator, which javac may read when a generated class references a type that is still being compiled. Builds whose sources live outsidesrc/main/javaandsrc/test/javaof the project directory, for example shared source sets, should pass those roots through this option.- See Also:
-
CLASS_PATH_OPTION
Annotation-processor option holding the compilation's class path, separated byFile.pathSeparator. An annotation processor cannot see the class path javac was started with, only its own processor path, so builds whose generated classes reference compile-scope dependencies should pass that class path here for the source fallback to resolve them.- See Also:
-
-
Constructor Details
-
ByteCodeGenerator
public ByteCodeGenerator()
-
-
Method Details
-
getLanguage
public io.micronaut.inject.visitor.VisitorContext.Language getLanguage()- Returns:
- The source language of the generator
-
writeClass
protected boolean writeClass(ObjectDef objectDef, @Nullable ClassTypeDef outerType, io.micronaut.inject.visitor.VisitorContext context, io.micronaut.inject.ast.Element[] originatingElements) throws Exception Description copied from class:AbstractByteCodeGeneratorEmit one definition.- Specified by:
writeClassin classAbstractByteCodeGenerator- Parameters:
objectDef- The definitionouterType- The enclosing type, ornullcontext- The visitor contextoriginatingElements- Originating elements- Returns:
truewhen member definitions should be traversed- Throws:
Exception- If emission fails
-