Phase 03: Kotlin metadata ingest
Status: Planned
Deliverables
package3/kotlin/metadata/classreader.go— minimal JVM class file parser (JVMS §4.1-§4.7) that extractsRuntimeVisibleAnnotations→kotlin/Metadatafields (k,mv,d1,d2,xs,xi).package3/kotlin/metadata/proto/— auto-generated protobuf Go bindings from JetBrains'kotlin-metadata.proto(schema version 9).package3/kotlin/metadata/ingest.go—IngestJAR(jarPath string) (*APIObject, error)— open the JAR, iterate.classfiles, extract metadata, decode protobuf, build theAPIObjecttree.package3/kotlin/metadata/model.go—APIObject,Function,Property,Constructor,KotlinType,ClassKindtypes (the language-neutral API surface model).package3/kotlin/metadata/schema.go— schema version compatibility check;ErrUnsupportedMetadataVersionfor pre-1.4 schema.
Class file parsing scope
The class file parser implements only what is needed for annotation extraction:
- Magic number validation (
0xCAFEBABE). - Constant pool parsing (needed for annotation type name and string value resolution).
- Skip: fields, methods, code attributes.
RuntimeVisibleAnnotationsattribute on the class descriptor only.- Annotation element value decoding for:
e(enum),s(string),B/C/D/F/I/J/S/Z(primitives),[(array),@(nested annotation).
The parser does not implement a full JVMS §4 class file reader. Unknown attribute types are skipped. This keeps the parser at ~300 lines of Go.
Gate
Extract API surface from [email protected]:
- At least 847 functions extracted (matches research note §04 figure).
- 234 types with metadata.
delayfunction hasisSuspend = true.CoroutineScopeinterface detected.Jobsealed hierarchy detected withSupervisorJobandCompletableJobsubclasses.@kotlin.Metadatamissing (Java-only class): produces opaqueAPIObjectwithKind = JavaClass, no functions.- Schema version
[1, 1, 0](pre-1.4): producesErrUnsupportedMetadataVersion.