Registration pipeline
Registration is the bridge between JVM source code and Godot's runtime type system. It answers two different questions:
- Which classes and members should Godot know about?
- How should each selected class or member behave in Godot?
Selection and configuration are separate responsibilities.
An annotation can participate in either question:
@Script,@Visible,@Emit, and@Registerselect declarations.@Tool,@Export, property hints, and@Rpcconfigure declarations.@Notificationboth selects a method and supplies its notification value.- Some configuration annotations are themselves meta-annotated with a selection annotation. Whether that implied selection counts depends on the registration mode.
The mode changes selection. It does not remove compatibility requirements or change what the annotations mean after a declaration has been selected.
The pipeline at a glance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Kotlin, Java, and Scala encode properties, annotations, and accessors differently, so the front end first reconstructs a language-neutral view.
Stage 1: compiling user code
The normal JVM compilation tasks run first. Depending on the configured languages, that can include:
compileKotlincompileJavacompileScala
Registration reads the completed compilation output. New or changed declarations become available after a successful build.
The registration task receives:
- the compiled user classpath
- the compiled output roots that identify project-owned classes
- the project name
- the selected annotation-processing mode
The default mode is Inferred.
Stage 2: discovering candidate classes
ClassGraph scans the compiled classpath. A candidate script class must:
- inherit
godot.core.KtObject, normally through a Godot API type such asNode,Resource, or one of their descendants - be user code rather than a generated Godot base binding
- have an identifiable Kotlin, Java, or Scala source file
Automatic mode does not make arbitrary JVM classes into Godot scripts. It
automatically selects from this candidate set of Godot-compatible classes.
Language identification uses the source-file extension stored in bytecode:
.ktselects Kotlin reconstruction.javaselects Java reconstruction.scalaselects Scala reconstruction
An unknown language is skipped with a warning because the processor cannot safely guess how its bytecode maps back to source-level properties and signals.
The editor associates a source resource with a compiled class by fully qualified name. parse_source_script_fqname in cpp/api/script/source_script_parser.cpp combines the package with the class following @Script. Without that annotation, it looks for a class whose simple name matches the filename. The registrar does not reconstruct source paths.
Stage 3: reconstructing a logical class
The processor normalizes each candidate into a LogicalClassShape containing:
- the class and its annotations
- logical properties
- logical signals
- logical methods
Only declared members are placed in this local shape. Inherited Godot API members are not copied into every child.
Why language normalization is necessary
A source property does not have one universal JVM representation.
Kotlin may emit:
- a backing field
- getter and setter methods
- a synthetic annotation carrier
- delegated-property support fields
Java may expose:
- a public field
- JavaBean-style
getX,isX, andsetXmethods
Scala commonly exposes:
- an accessor named like the property
- a setter named
property_$eq
The language adapter reconstructs those representations into one logical property and merges relevant annotations from the field, getter, setter, and language-specific annotation carriers.
Accessor-shaped methods
A method can look like both a property accessor and a callable function. Registration intent resolves the ambiguity:
@Visibleindicates property intent.@Registerindicates function intent.- both can register both views.
- without an explicit function intent, an accessor remains a property rather than becoming a duplicate callable.
This decision happens after the language adapter has identified the shape.
Stage 4: selecting declarations
The selected AnnotationProcessingMode controls which logical declarations
enter the registration model.
Selection matrix
Every mode works the same way. RegistrationPolicy first identifies the
candidates: a public class that is not an object, and its public instance
members. Annotations are then resolved identically in every mode,
meta-annotations included:
1 2 3 4 5 | |
The mode only decides which annotation is assumed on a candidate that has none written. A written annotation replaces that default:
| Declaration | Explicit | Inferred | Automatic |
|---|---|---|---|
| Class | @Script |
@Script |
assumed @Script |
| Property | @Visible |
@Visible |
assumed @Export |
| Signal | @Emit |
assumed @Emit |
assumed @Emit |
| Method | @Register or @Notification |
@Register, or a mappable Godot override assumed @Register |
assumed @Register |
| Property exposure | written @Export/@Storage/@Visible |
same | @Export unless written |
A registration annotation written on something that is not a candidate (a
private or static member, an object, an overload sharing a registered name)
is recorded on the ScriptClass as a rejected declaration and
RejectedDeclarationCheck fails the build with it. The IDE plugin reports the
same cases as warnings.
Explicit mode: spelling out the public Godot surface
Explicit mode assumes nothing. Overriding _ready does not register it and a
SignalN member is not a signal until @Emit is written. Annotations that
carry a registration annotation still register on their own: @Export,
@Rpc and a property hint are enough.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Use Explicit mode when the source should visibly describe the complete Godot API boundary.
Inferred mode: following annotation meaning
Inferred mode additionally assumes @Register on compatible overrides of Godot
base methods and @Emit on every signal member, so configuration alone
registers a class:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Ordinary project methods still need @Register, written or carried. Inferred
does not mean every public method is exposed.
Custom project annotations can participate in the same mechanism by being meta-annotated with the built-in annotations.
Automatic mode: selecting compatible declarations
Automatic mode selects compatible declarations by shape and type:
- all public candidate Godot classes
- all public mappable properties
- all logical signals
- all public mappable methods
Properties are exported by default.
1 2 3 4 5 6 7 8 9 10 11 | |
Annotations remain useful as metadata:
1 2 3 4 5 6 7 | |
Here the property and function would already be selected. The annotations configure the Inspector and networking behavior.
Stage 5: mapping annotations to metadata
Once a declaration is selected, annotations configure the final model.
Class metadata
@Script(className = "...")supplies a custom registered name.@Toolrecords editor-time script metadata. Tool mode itself is not implemented yet.
Without a custom name, registration.nameMode determines how the default name
is computed.
Property metadata
@Exportmarks a property for the Inspector; it carries@Storage, which carries@Visible.- Automatic properties are exported by default; a written
@Visibleor@Storagereplaces that default. - property-hint annotations configure controls such as numeric ranges, file pickers, multiline text, colors, enums, and flags.
Property registration and Inspector export are related but distinct:
- a registered property is available to Godot
- an exported property is additionally presented in the Inspector
Signal metadata
The signal type provides its parameter types. @Emit can provide friendly
parameter names. Without explicit names, generated names such as param1 are
used.
Function metadata
@Rpccreates an RPC configuration.@Notification(value)marks a selected method as a notification handler.
@Notification is special: automatic method selection does not turn an
ordinary method into a notification handler. The annotation is still
required because its numeric notification value is metadata that cannot be
inferred.
Stage 6: building and validating the registration model
Selected declarations are mapped into:
ScriptClassRegisteredPropertyRegisteredSignalRegisteredFunctionRegisteredConstructor
Creating this model resolves:
- registered names
- Godot base classes and script inheritance
- property binding through a property reference or accessor methods
- parameter and return types
- property mutability and nullability
- property hints
- RPC and notification configuration
The model is then checked as a whole. Registration fails when an invalid Godot-facing API would be generated.
Class requirements
- A registered class must inherit a Godot-compatible type.
- A public parameterless constructor is optional. When present, the generated registrar exposes it for Godot instantiation; constructors with parameters remain JVM-only.
- Registered names must be unique within the known JVM registration set.
- Generic classes cannot be exposed as concrete Godot script types.
Function requirements
- Registered methods must be public.
- Parameters and return values must be mappable to Godot.
- Unrelated JVM source classes cannot appear in the exposed signature.
- A function can have at most 16 parameters.
- Generic registered methods are not supported.
Property requirements
A registered property must be public through its field or accessors and use a supported Godot-facing type, including:
- supported primitives and strings
- Godot core types
- Godot
NodeandResourcetypes java.util.Listof enums- enums
BitField<Enum>
Additional constraints include:
- Godot core types and primitive-like registered values cannot be nullable.
- Godot core types cannot use
lateinit; provide a default value. - a property can have only one effective editor hint
- a hint must match the property type
- a
BitFieldenum can have at most 32 entries
Registered Kotlin val properties are allowed and are exposed read-only.
Mutability is not a universal requirement.
Signal requirements
- The logical signal must resolve to a
Signaltype. - Typed signal arity is limited by the available
Signal0throughSignal16families. - Signals should be stable immutable members; replacing a signal instance would break the registered connection identity.
RPC requirements
An RPC method must also be a selected registered function. This happens:
- through
@Rpc's meta-annotation in every mode - through automatic method selection in Automatic mode
A non-zero transfer channel only has an effect with
UNRELIABLE_ORDERED; other transfer modes produce a warning.
Stage 7: generating registrar source
The back end consumes only the validated model. It does not repeat language-specific bytecode interpretation.
For each registered class it generates a registrar that records:
- the registered class name
- source file name for language identification, without a reconstructed path
- registered supertypes
- Godot base type
- abstract/concrete state
- constructor, when a public parameterless constructor exists
- signals
- properties
- notification handlers
- functions and RPC configuration
Abstract classes get registrar metadata for inheritance and default-value support but are not instantiated and do not directly register concrete members.
Stage 8: packaging and runtime loading
The Gradle plugin compiles the generated registrar code and packages it with the user project artifacts. At runtime:
- the JVM bootstrap discovers the generated registrars
- each registrar describes its class to the Godot-JVM bridge
- Godot creates script instances through the registered constructor
- generated bindings route property, signal, function, RPC, and notification operations between Godot and the JVM
The registration mode is a build-time selection policy. Runtime code consumes the resulting registrar and does not re-evaluate the annotations.
The next chapter covers the registrar generator's input model and how to debug its Gradle task.
In the editor, JAR registrations and physical script resources are reconciled by fully qualified class name. The JAR and script reloading chapter later covers resource ownership, placeholders, and reload order.
Inheritance behavior
Registration preserves the script family rather than flattening every inherited member into every class.
Expected behavior:
- exposed parent members remain available to children
- a child override supplies the child behavior
- an un-annotated override keeps the parent's registration; an annotated override with the same parameter list replaces it
- interfaces and abstract script classes participate in the registered type family
- only locally declared members are reconstructed in a class's logical shape
This avoids duplicate registrations while retaining normal JVM dispatch.
Build mode and IDE mode must agree
The Gradle build mode is configured in build.gradle.kts:
1 2 3 4 5 | |
The IntelliJ plugin stores its inspection mode as project editor state. Set it under Settings | Godot-JVM | Annotation processing mode.
These settings currently have separate owners. Keep them on the same value:
- Gradle decides what the build registers.
- IntelliJ decides what the editor reports.
Both default to Inferred.
Diagnosing unexpected registration
Trace a missing declaration through class discovery, language reconstruction, mode selection, and model validation. Inspect the first stage that excludes it. If the build and IDE disagree, compare their registration modes before changing policy.
Ownership boundaries
The registration implementation intentionally keeps a short chain of responsibility:
JvmLanguage: reconstruct source meaning from language-specific bytecodeRegistrationPolicy: decide what the selected mode includesRegistrationMapper: create the final model and attach metadata- registration-model checks: reject invalid Godot-facing APIs
- registrar generator: emit code from valid models
- Gradle plugin: order tasks and package outputs
- IntelliJ plugin: report the same expected policy while editing
When changing behavior, update the narrowest owner and add coverage across Kotlin, Java, Scala, and all three registration modes where applicable.
Editor default instances
The editor instantiates each concrete script class outside a scene to read exported property defaults. Constructors and field initializers therefore also run during registration reloads. A node allocated there without scene ownership or explicit freeing can leak on each rebuild. Saved Inspector values are applied later to scene instances; constructors only see the initial defaults.