Expand description
Proc-macro implementation for inline_java.
Provides three proc macros for embedding Java in Rust:
All macros require the user to write a static <T> run(...) method
where T is one of: byte, short, int, long, float, double,
boolean, char, String, T[], List<T>, or Optional<T> —
including arbitrarily nested types like List<List<Integer>>,
Optional<List<String>>, Optional<List<Optional<Integer[]>>>, etc.
§Wire format (Java → Rust, stdout)
The macro generates a main() that binary-serialises run()’s return
value to stdout via DataOutputStream (raw UTF-8 for top-level String
scalars).
Encoding per type:
Boxed(String)at top level: raw UTF-8 (no length prefix)Boxed(String)inside a container: 4-byte BE length + UTF-8 bytesPrimitive/Boxed(non-String): fixed-width big-endian bytes viaDataOutputStreamArray(T)/List(T): 4-byte BE count + N × encode(T)Optional(T): 1-byte tag (0=absent, 1=present) + encode(T) if present
§Wire format (Rust → Java, stdin)
Parameters declared in run(...) are serialised by Rust and piped to the
child process’s stdin. Java reads them with DataInputStream.
§Options
All three macros accept zero or more key = "value" pairs before the Java body,
comma-separated. Recognised keys:
javac = "<args>"— extra arguments passed verbatim tojavac(shell-quoted; single/double quotes respected).java = "<args>"— extra arguments passed verbatim tojava(shell-quoted; single/double quotes respected).