|
RPNXCortado
C++23 JVM class-file, bytecode, validation, and JAR toolkit
|
Cortado uses the same owning class-file model for parsed and generated input. This makes transformation a continuation of code generation rather than a separate API.
The builder initializes its interner from the exact existing pool. Equal new constants reuse their first existing indexes, while unrelated existing entries retain their order. The following mutable accessors expose the exact model:
access_flags() and version();fields() and methods();attributes(); andconstant_pool().References returned from member vectors follow ordinary std::vector invalidation rules. Prefer finishing one mutation before appending another member if you retain references.
add_field and add_method use the same shared interner as parsed members. When directly constructing an attribute, intern its predefined name and every referenced value through constant_pool() before inserting it into the context-appropriate attribute variant.
The validation and serialization boundary is unchanged:
Strict serialization rejects misplaced standard attributes, incompatible constant kinds, version-gated features, bad descriptors, invalid code offsets, and other model inconsistencies. Unknown attributes remain byte-for-byte payloads and can be retained during transformations.
A jar_entry always owns uncompressed data. Its compression member chooses stored or raw-DEFLATE encoding when serialize_jar is called.
Keep JAR names slash-separated. A manifest belongs at the case-sensitive path META-INF/MANIFEST.MF; executable archives also need a correctly formatted Main-Class header and a generated static main method with descriptor ([Ljava/lang/String;)V.
The JAR writer preserves entry order, comments, supported flags, timestamps, and attributes. It emits an ordinary single-disk, non-Zip64 ZIP archive. It rejects unsupported flags, compression methods, field sizes, and entry counts rather than silently changing format.
After generation, validate the artifact with the real JVM tools appropriate to your target version:
The tutorial archive intentionally contains a library class rather than a Main-Class, so the first command applies directly. The repository's Hello World example demonstrates the executable-JAR shape.
Return to the tutorial index or consult the complete rpnx::cortado API reference.