Skip to main content

Crate fabric_rs_codegen

Crate fabric_rs_codegen 

Source
Expand description

Pure-Rust JVM bytecode generator, JAR SDK indexer, and Rust binding emitter for FLR v2.

fabric-rs-codegen synthesizes verifiable .class files (complete with automatic StackMapTable frames) without requiring javac or Java ASM at package time:

  • jvm_writer: Constant pool builder, bytecode instruction emitter (CodeWriter), annotations, and .class serializer.
  • class_reader: Classfile parser for JAR indexing (build_sdk_index_from_jars) and constant-pool relocation (relocate_class_bytes).
  • bootstrap_gen: Isolated per-mod FlrLoader.class, RustBootstrap.class, and optional NativeBridge.class.
  • mixin_gen: SpongePowered Mixin .class synthesis, MixinTrampolines.class, *.mixins.json, and *.refmap.json.
  • subclass_gen: Custom Java subclass .class emission with flrHandle, overrides, and invokespecial super bridges.
  • rust_emitter: Generates typed Rust wrappers (emit_rust_binding) used by bind_class! and cargo fabric bindings.

Re-exports§

pub use bootstrap_gen::generate_native_bridge;
pub use bootstrap_gen::generate_neoforge_bootstrap;
pub use bootstrap_gen::generate_neoforge_event_relay;
pub use bootstrap_gen::generate_rust_bootstrap;
pub use bootstrap_gen::relocate_runtime_loader;
pub use class_reader::build_sdk_index_from_jars;
pub use class_reader::parse_class_bytes;
pub use class_reader::relocate_class_bytes;
pub use jvm_writer::access_flags;
pub use jvm_writer::opcodes;
pub use jvm_writer::Annotation;
pub use jvm_writer::BootstrapMethod;
pub use jvm_writer::ClassWriter;
pub use jvm_writer::CodeWriter;
pub use jvm_writer::ElementValue;
pub use jvm_writer::ExceptionHandler;
pub use jvm_writer::FieldWriter;
pub use jvm_writer::InnerClassEntry;
pub use jvm_writer::LabelId;
pub use jvm_writer::MethodHandleKind;
pub use jvm_writer::MethodWriter;
pub use jvm_writer::VerificationType;
pub use mixin_gen::generate_mixin_class;
pub use mixin_gen::generate_mixins_json;
pub use mixin_gen::generate_refmap_json;
pub use rust_emitter::emit_rust_binding;
pub use subclass_gen::generate_subclass_bytes;

Modules§

bootstrap_gen
Isolated per-mod loader, RustBootstrap, and dynamic NativeBridge generators. Isolated per-mod FlrLoader.class, RustBootstrap.class, and NativeBridge.class generators.
class_reader
JVM .class reader, constant-pool class relocator, and JAR SDK indexer. JVM classfile parser for SDK indexing and constant-pool class relocation.
jvm_writer
Pure-Rust JVM classfile writer with basic-block label patching and StackMapTable generation. Pure-Rust JVM .class file builder supporting StackMapTable, annotations, and labels.
mixin_gen
Mixin classfile, trampoline, config, and Intermediary refmap generators. SpongePowered Mixin .class, MixinTrampolines.class, JSON config, and refmap generators.
rust_emitter
Rust wrapper struct/method code emitter backing bind_class! and cargo fabric bindings. Typed Rust wrapper code emitter for bind_class! and cargo fabric bindings.
stack_map
Automatic CFG dataflow bytecode analyzer for StackMapTable and frame limits. Automatic JVM CFG dataflow analyzer for StackMapTable generation and max_stack/max_locals.
subclass_gen
Custom Java subclass .class and SubclassTrampolines generators. Custom Java subclass .class and SubclassTrampolines.class bytecode generators.