Home /Modules/java/README.md

README.md

lib/java/converter/README.md · 509 line(s) · markdown

/lib/java/converter: Java source to SLeeLa source

Container. Java container content (SLEELA.syntax section 38.4). Nothing here is part of the SLeeLa specification or adds syntax to SLeeLa.

Status: 0.7.8, best effort (2026-11-14). Output stays at syntax 3.1 (also written 3.01) by the owner's decision; syntax 3.1 sections 45 and 46 forms are not used (.kiro/steering/java-converter-lib.md). The operand laws come from the shared conversion model, impl/subjects/conversion/conversion.model (read by JConvModel), the same data sleelactl java-convert reads. Output declares #sleela 3.1 and uses its forms (SLEELA.syntax section 44): array initializers, character literals, labels, and jumps that run finally. Revise the rules here as the language and the library close the gaps listed in section 6. Changes since 0.1.0 are in section 8.

Relation to sleelactl java-convert. A separate converter, written in C/C++ under sleelactl/convert/ with its Java semantics in impl/subjects/conversion/conversion.model, landed on master the same day. Its always-on steering (.kiro/steering/java-to-sleela-conversion.md) requires behavioural equivalence proven against a real JDK and fails closed per file. This module is the SLeeLa-language, best-effort converter that was asked for in /lib/java/converter: it fails loud per member (a stub that throws), so a file with one unconvertible member still yields the rest of its type. It does not claim equivalence. Its known near-misses are listed in section 6.6; refused constructs are listed in section 4.

Policy (decided 2026-11-13 by the repository owner): per-member stubs. lib/java/converter keeps the rest of a type when one member cannot be converted, and marks that member with a stub that throws. It does not adopt the whole-file refusal of sleelactl java-convert. Where both converters share a law (the binop, tostr rows of conversion.model), this module applies the same template, so the two agree on what the converted code computes.

1. What it is

A SLeeLa program that walks a Java source tree recursively and writes the equivalent SLeeLa source files, one per Java type, under an output tree with the same folders. Run on the JDK sources (the <module>/<package>/<Type>.java layout of a JDK src.zip), it produces the JDK 28 type tree as converted SLeeLa: java.base/java/util/Optional.java becomes java.base/java/util/Optional.sleela.

Every Java-to-SLeeLa decision with functional or declarative significance is taken in this module, in one place: JConvRules.sleela holds the table, and the other units apply it.

The output is not written into lib/java/jdk-28. That tier is curated (API-derived, no Java source text) and the converter refuses to write there. Converted files are derived from the Java source. Each one keeps the licence comment of its source, because a conversion of OpenJDK code is a derivative work under its licence (GPLv2 with the Classpath Exception).

2. Running it

# unpack a JDK source tree (any tree of .java files works)
mkdir -p /tmp/jdk-src && cd /tmp/jdk-src && unzip -q "$JAVA_HOME/lib/src.zip"

# convert java.util (public JDK 28 types only), from the repository root
JCONV_IN=/tmp/jdk-src JCONV_OUT=/tmp/jdk28-sleela JCONV_FILTER=java.base/java/util \
  bash lib/java/converter/run-converter.sh
VariableMeaningDefault
JCONV_INroot of the Java source treerequired
JCONV_OUTroot of the SLeeLa output tree./jdk28-converted
JCONV_SCOPEapi: only types listed in lib/java/jdk-28/INDEX.tsv; all: every .java fileapi
JCONV_FILTERonly paths starting with this prefixnone
JCONV_LIMITstop after this many filesno limit
JCONV_INTint32 (Java 32-bit int) or int (64-bit SLeeLa int)int32
JCONV_COMMENTSkeep or drop (the licence comment is always kept)keep
JCONV_MODELthe conversion model to read$SLEELA_HOME/impl/subjects/conversion/conversion.model
JCONV_BUNDLE1: nested types go into the document of their top-level type, so a converted program runs as one document; 0: one file per type (Outer.Inner.sleela, the library layout)0
JCONV_BATCHJava files per VM run; run-converter.sh starts the next run after the last file, so memory stays at one batch (0: one run)500
JCONV_TEST_STOP_INtest only: stop the VM in this Java file (relative path) after its output is written, to exercise the restart belownone

sleela run treats every argument as a source file, so the settings travel in the environment. The script names only JConvMain.sleela; the loader finds the other units in /lib by name. Naming every file makes each one resolve library units again and duplicates classes (lib/java/STATUS.md section 6).

Memory stays at one batch. The VM never frees a plain String it has made (they live in its intern table until it exits), so one VM run over a large tree grows: about 1.7 GB for the whole JDK, more for a larger tree. JConvMain ends its run after JCONV_BATCH files (default 500) and writes BATCH <last file> to .jconv-progress; run-converter.sh starts the next run after that file, with the report and totals carried on. Measured on the whole JDK (4,127 files, 9 runs): peak 335 MB instead of about 1.7 GB, 235 s instead of 203 s (about 4 s to start each run), output byte-for-byte the same.

One file cannot end the run. A VM runtime error (a converter fault on some input) stops the VM, and a SLeeLa program cannot catch it. JConvMain therefore writes the file it is on to $JCONV_OUT/.jconv-progress and saves its totals to $JCONV_OUT/.jconv-state after every file. When the VM stops inside a file, run-converter.sh restarts the converter after that file: the file's partial output is removed, the report lists it as failed with the VM message, and the totals and the report carry on from the saved state. A finished run removes both files; a run that gives up keeps .jconv-progress, naming the file.

Output: one .sleela per type (nested types as Outer.Inner.sleela, as lib/java/jdk-28 names them), plus CONVERSION-REPORT.tsv (one line per Java file, written as the run goes) and CONVERSION-SUMMARY.md.

Speed: about 3 seconds per Java file on the source-built VM (16 files, 13,552 output lines in 50 s). The 4,721 public JDK 28 types are therefore a run of several hours. Use JCONV_FILTER to convert one package or module at a time.

3. The rules (all in JConvRules and applied by JConvLexer / JConvRewriter / JConvTranslator)

#JavaSLeeLa outputWhy
1Identifiers that are SLeeLa keywords or built-ins: print, close, record, struct, require, sealed, yield, Sleela, Any, utf16, int64, int128trailing _ (close_) at declaration and every uselib/java/jdk-28/PURPOSE.md row 27. close is the Munction reach-handle built-in on every receiver; print is a statement keyword
1bUnqualified call to a method named like a VM built-in (read, write, sleep, join, lock, ...)this.read(...), or Type.read(...) for a static methodan unqualified call binds to the built-in (steering sleela-authoring-gotchas.md)
1c$ in an identifier_S_not a SLeeLa identifier character
2intint32 (or int with JCONV_INT=int)int32 wraps at 32 bits on store, cast, parameter and return, as Java does (impl/frontend/compiler.cpp emitJavaNarrow). Plain int is 64-bit
2bbyte, short, char, long, float, double, booleankeptbyte/short/char wrap at their width on store and cast
2cGeneric type arguments (List<String>, new HashMap<>(), Foo.<T>bar())erasedSLEELA.syntax 38.1. Class type parameters are kept as data in JAVA_TYPE_PARAMETERS, method type parameters in @generic("<T>") (the jdk-28 convention), and type variables erase to Any
2dFully qualified names java.util.ListListthe import java.jdk-28; tier resolves the simple name
2ex instanceof String(x instanceof string || x instanceof utf16)a Java String is either SLeeLa string kind (only for a receiver without calls, so it is not evaluated twice)
2gT x = expr; and return expr; with T a primitive, String or a known class (not an array: the compiler rejects array casts)T x = (T) (expr);javac inserts the same checkcast. SLeeLa rejects an erased Any stored into a typed variable. Not for interfaces: a runtime cast to an interface fails in the VM today
3strictfp, sealed, non-sealed, permitsdroppedno SLeeLa meaning (Java 17 made floating point strict; sealing is a compile-time check)
3bprotected on an instance member@JavaProtectedSLeeLa reserves protected for static members
3cfinal on locals and parametersdroppedSLeeLa rejects it there; final fields are kept
3dpublic, static on a typedroppedevery converted type is a top-level SLeeLa class
3eJava annotations (@Override, @Deprecated, ...)droppedmetadata only in Java, and they would clash with SLeeLa annotations
3fInterface fieldsstatic final addedexplicit constant
4class / interfaceclass / interface (extends, implements kept)
4benum E { A, B(1); ... }class E with static final E A = new E("A", 0);, fields enumName / enumOrdinal, name(), ordinal(), toString(), compareTo, values(), valueOf(String); declared constructors get the name and ordinal firstSLeeLa has no enum declaration (SLEELA.syntax 43.5); this is the shape of the jdk-28 enums
4crecord R(int x, String y)class R with final fields, the canonical constructor, accessors, toString (R[x=1, y=a]), equals, hashCode. A compact constructor runs its body, then assigns the fieldsthe record hashCode algorithm is unspecified by Java
4d@interfacean empty interface, with the elements kept as a commentannotations carry no SLeeLa behavior
4eNested type Outer.Innerits own file Outer.Inner.sleela, class Innerthe jdk-28 layout
4fstatic { ... }static int slStaticInitN_ = slStaticInitN(); and the block as that methodit runs at class initialization, in source order
4gInstance initializer { ... }int slInstanceInitN_ = slInstanceInitN();it runs for each new instance before the constructor body
5Literals: octal, hexadecimal and binary int literalsdecimal, wrapped to the int range (0xFFFFFFFF is (-1), 0x80000000L stays positive)Java reads them that way
5b.5, 5., 1e5, 1.5f0.5, 5.0, 1.0e5, 1.5SLeeLa number forms
5cEscapes \s, octal \12, \uXXXX, surrogate pairsdecoded and written in SLeeLa formSLeeLa knows fewer escapes
5dText blocks """string literal, incidental indentation removed (JLS 3.10.6)
5e'a''a' (SLeeLa 3.1 character literal, 44.2), or "a" next to a string in +a SLeeLa character literal is its integer code, so "x" + 'a' would print x97; a surrogate stays its integer code
5f//, /* */, /** */<< ... >> on their own line, inner >> / << separatedthe only multi-line comment form; /* */ is not SLeeLa
6a.length on an arrayarrayLength(a)SLeeLa arrays have no length member (not for this.length)
6bint a[]int32[] a
6c{1, 2, 3}, {{1, 2}, {3}} and new int[]{...}kept (SLeeLa 3.1 array initializer, 44.3)
6dnew int[n]kept: numeric and boolean arrays start at zero / false (44.3 fill kind; int32 since the 2026-11-13 compiler fix)
6eint a = 1, b = 2;one declaration per variable
6ffor (...) ;, while (...) ;{ } bodySLeeLa has no empty statement
6ifor (int i = 0, j = n; c; i++, j--) body{ int i = 0; int j = n; for (; c; ) { slForN: { body } i++; j--; } }, each continue of the loop becomes break slForN;SLeeLa for takes one initializer and one update; the labeled block (44.4) keeps Java order on continue. A body that is itself if / for / while / switch / try without braces stays a stub (reason 11)
6jif (o instanceof T v [&& rest]) S [else S2]if (o instanceof T) { T v = (T) (o); [if (rest)] S } [else S2] (else only without && rest)SLeeLa has no pattern variable. Only when o is a name chain without calls (it is evaluated twice) and T a class (a cast to an interface fails at run time)
6kreturn o instanceof T v && rest;if (!(o instanceof T)) { return false; } T v = (T) (o); return rest;the equals shape; same conditions
6lLabels, break label, continue label, return / break / continue through finallykeptSLeeLa 3.1 (44.4, 44.5)
6mx++ and (a = b) used as a valuekeptthe language evaluates both (43.6 rule 12); the value wraps at 32 bits only when stored
7aa << n, a >> n, a >>> n with a of type int; x <<= n and friendsthe function of the model's binop int << / >> / >>> row (JavaOperands.shlInt(a, n), shrInt, ushrInt); x = JavaOperands.ushrInt(x, n)read from conversion.model: Java masks the count to 5 bits and works in 32 bits (h ^ (h >>> 16) in HashMap.hash was wrong before). long shifts are already exact and stay
7ba double or float shown as text (string concatenation, println)the model's tostr double template (Double.toString(x))Java prints 2.0, SLeeLa 2
7ca char shown as textthe model's tostr char template (JavaText.plainIfRepresentable(JavaText.codePointU(c)))Java prints z, SLeeLa 122
7eint + - * & | ^ ~ and shift left whose value leaves int arithmetic (a comparison, /, %, shift right, string text, an argument, an index, a cast to long / double, a store into a non-int)JavaOperands.toInt(...) around the whole chain (the model's cast long int row)these operators agree with arithmetic modulo 2^32, so one wrap where the value is used gives the Java result; a chain stored into an int stays native (the store wraps). if (count + 1 < 0) and long x = a * b now compute as Java does
7fint / and % (and /=, %= on an int name) unless the divisor is a nonzero literalthe model's binop int / and % rows (JavaOperands.divInt, remInt)exact, including Integer.MIN_VALUE / -1, and a catchable ArithmeticException on zero (the VM division by zero was fatal; since SLEELA.syntax 37.5 it is catchable inside a try too)
7doperand types for 7a to 7cfields of the type and declarations of the member (parameters, locals, for, catch), array elements, casts, literals, and call chains: Math.sqrt(x), s.charAt(i), s.length(), sb.reverse().toString(), Integer.MAX_VALUE, own methods, through the model's ret and field rows (@arg0: the type of the first argument)a name declared with two types in one member, an overloaded own method with two result types, or a member the model does not type makes the operand unknown, and an unknown operand is left as written: the pass never guesses
6gassertdroppedJava runs with assertions disabled by default, so the statement is not evaluated
6hSystem.out.println(x)print(x)System.out.print (no newline) is a stub (reason 23): print always adds one
8aa lambda x -> e, (a, b) -> e, (int a, int b) -> { ... } (0 to 2 parameters)new SLJavaLambda(N, new Any[]{this, k, ...}) at the site; the body becomes Any slLambdaN(Any[] slEnv, Any slA, Any slB) in the same class, which declares each captured local from slEnv and each parameter from slA / slB; the document gets one generated SLJavaLambdaTable whose call forwards N to it (JConvLambda)defunctionalization, lib/java/jdk-28/LOWERING.md section 2. Java captures only effectively final locals, so copying their values at the site is exact. An instance context stores this in slEnv[0] and the body is an instance method, so fields, methods and this read as written. An untyped parameter takes its type from the target: a declaration Function<Integer, Integer> f = ..., the method return type for return x -> ..., the declared parameter of a method of this file the lambda is passed to, or the result type argument of an enclosing lambda (a -> b -> ...); boxes become primitives (Integer is int32); else Any. Not lowered (stub reason 1): a switch arrow, more than two parameters, a captured local or parameter of array type (a cast to an array type does not compile)
8ba method referencelowered like 8a: System.out::println (a Consumer); with a known target interface this::m, name::m (the receiver is evaluated once, at the reference), Type::m (static, or unbound for String and own instance methods) and Type::newthe arity and the parameter types come from the target interface. Without a target, or Type::m of another class (static or unbound cannot be told apart), stub reason 2
8dan inner (non-static) class class Inner declared in a classthe field Outer slOuter (only in a base inner class) and a first constructor parameter slOuterArg (a default constructor is written when there is none); this.slOuter = slOuterArg; after an explicit super(...) of a non-inner superclass, else first; this(...) and super(...) of an inner superclass pass slOuterArg on. new Inner(a) becomes new Inner(this, a) in the outer class and new Inner(this.slOuter, a) in a sibling inner class; Outer.this becomes this.slOuter, Inner.this becomes this; an unqualified member of the outer class becomes this.slOuter.x (instance) or Outer.x (static) (JConvOuter)JLS 8.1.3, 15.9.2, 15.8.4; lib/java/jdk-28/LOWERING.md section 2.4. A name is left alone when it is a local, a member of the inner class, or possibly inherited (JLS 6.4.1: the class and its supertypes come before the enclosing class): inherited names come from the model ret / field rows or a type of the file written earlier, and when the superclass is unknown no method name is rewritten, so a doubt gives a check error, never a call to the wrong method. Not lowered: outer.new Inner(), an anonymous or local class (reasons 3, 14), a static method of an inner class reaching an outer instance member
8ca variable, field, parameter, return type or cast of a functional interface type (Function, Comparator, Runnable, the 43 of java.util.function, ...)Anyso f.apply(x) dispatches at run time (SLEELA.syntax 43.7) to SLJavaLambda.apply or to a program class that implements the interface. A class of the file with the same name is kept

4. Fail-loud stubs (rule 5 of JConvRules)

A member that uses a construct SLeeLa cannot express yet is converted to a stub that throws UnsupportedOperationException("not converted to SLeeLa (<reason>): <Type>.<member>"), with @throwable("java.lang.UnsupportedOperationException"), and the original Java body kept beside it as a comment for manual conversion. A gap therefore fails loudly at the call and never returns a wrong answer (lib/java/jdk-28/PURPOSE.md). A field with such an initializer keeps its declaration with the Java zero value and is listed in the report. An initializer block with such a construct is not run, and is listed in the report.

CodeReason
1lambda or switch arrow (lambdas lowered since 0.6, rule 8a; still a stub: switch arrows and the lambdas 8a lists)
2method reference (lowered since 0.6 where rule 8b applies)
3anonymous class
4labeled statement (retired in 0.2)
5switch expression or multi-label case
6pattern matching instanceof outside the two lowered shapes (rules 6j, 6k)
7try-with-resources
8var
9class literal X.class (retired in 0.7.4: rule 8e lowers it to Class.ofLiteral)
10qualified this or super (Iface.super.m(), Outer.this of a class that is not the enclosing class; Outer.this of the enclosing class is lowered since 0.7, rule 8d)
11comma in a for header whose body is an unbraced compound statement
12multi-dimensional array creation
13return, break or continue inside a try that has finally (retired in 0.2: 44.5)
14local class inside a method
15hexadecimal floating point literal
16unpaired surrogate in a string or char literal
17native method
18nested array initializer (retired in 0.2: 44.3)
20enum constant with a class body (the body is dropped and reported)
22static member of java.lang.String (valueOf, format, join, ...): String is a SLeeLa keyword and cannot be a static receiver, and lowering valueOf to "" + x would print a double or char in SLeeLa form
23System.out.print without a newline

5. Every converted file

Each output file carries, in order: a header naming the Java type, module and source; the licence comment of the Java source; #sleela 3.1; spark; (Java style declarative, SLEELA.syntax 43.2); import java.jdk-28;; the type's Javadoc; the class with the Metadata Class block (author, copyright, trademark and corporation are taken from the licence comment: Oracle / OpenJDK, GPLv2 with the Classpath Exception, Java, Oracle Corporation; metaScienceRating = 3 marks unverified converted code); the housing fields javaType, javaModule, javaSource (SLEELA.syntax 38.4); the members; the generated helpers; and a closing comment with the member and stub counts. Interfaces get no Metadata block (their fields would be constants).

6. Measured result and known gaps (2026-11-13, converter 0.2.0)

Sample: 17 files from the OpenJDK 25.0.2 src.zip (Math, Record, Override, Runnable, DayOfWeek, AbstractList, BitSet, HashMap, HexFormat, Objects, Optional, OptionalInt, StringJoiner, StringTokenizer, UUID, Adler32, CRC32), JCONV_SCOPE=all.

Measure0.1.00.2.00.3.00.3.0, JCONV_BUNDLE=1
Java files converted16 of 1716 of 1716 of 1716 of 17 (UUID.java skipped: non-ASCII bytes)
SLeeLa files written36363616 (one document per Java file)
Types / members36 / 62736 / 62736 / 62736 / 627
Members stubbed (fail loud)47 (7.5%)35 (5.6%)35 (5.6%)35 (5.6%)
Files with a syntax error0000
sleela check errors in total892902903553
Typed-pass rewrites in the output (0.4.0 with model 1.1.0 / without the model file)40 / 40
0.5.0 int wraps (toInt) / divInt, remInt calls in the output88 / 7 (check numbers unchanged, 0 syntax errors)
Same, compiler with SLEELA.syntax 43.7 (calls on Any, interfaces at run time)522 (11 files with an error)
0.7.0, inner classes (JConvOuter, rule 8d): stubbed members / check errors26 / 475 (11 files with an error, 0 syntax errors)
Files with no sleela check error8 of 368 of 368 of 365 of 16

0.6.0, lambdas (2026-11-13). The 17-file sample has no lambda outside a member that is a stub for another reason, so its numbers do not move (522 check errors, 35 stubs). On the eight most lambda-dense files of OpenJDK 25.0.2 java.util (Spliterator, Map, Comparator, PrimitiveIterator, Formattable, DoubleSummaryStatistics, Optional, Currency), with JCONV_BUNDLE=1: 31 stubbed members before, 15 after; 17 lambdas and 3 method references lowered. samples/lambda/LambdaDemo.java (typed and untyped parameters, captures, this, block bodies, a curried lambda, a lambda passed to a method, System.out::println, Type::m, this::m, String::length) runs all 17 lines identical to OpenJDK 25.0.2 (samples/LambdaDemo.java.expected.txt, samples/LambdaDemo.sleela.expected.txt).

0.7.0, inner classes (2026-11-13). On the 17-file sample, bundled: stubs 35 to 26 (nine Outer.this members of HashMap, AbstractList and others no longer need reason 10) and check errors 522 to 475, 0 syntax errors. HashMap alone writes 45 slOuter references. By message, the remaining errors are mostly "instance method ... must be called on an instance" (94: statics written as instance methods in the jdk-28 units), "use of undeclared variable" (71: names of JDK-internal or not yet resolved types), and errors that follow from those. Both samples still run identical.

0.2.0 removed 12 stubs (the ten for headers with commas and two pattern instanceof members). 0.4.0 changes what the converted code computes, not whether it compiles, so the check numbers are those of 0.3.0. On these 17 JDK files the model's ret rows add no typed rewrite beyond names, literals and casts (40 either way): the JDK code here seldom shifts or prints a library call result directly. In ordinary programs they do (the sample program, below). Bundling removes 39% of the check errors, because a nested type declared in the same document resolves by its simple name; the remaining errors come from the library and the language, not from conversion slips: by message (0.3.0), mostly "use of undeclared variable" (inner classes reaching the fields of the enclosing instance, lowered since 0.7.0), "struct ... has no field" (inherited types that do not resolve), and "instance method ... must be called on an instance" (statics written as instance methods in the jdk-28 units).

Behaviour, side by side with a real JDK. samples/demo/ConvDemo.java (plain procedural Java: int overflow, hex / octal / binary literals, a string hash loop, an array initializer and a nested one, .length, new int[n], multi-declaration, char literals and a switch over them, narrowing casts, an enum, a static initializer, a text block, the ternary, a for with commas and continue, a labeled continue / break, return through finally, pattern instanceof in if and return, int shifts inside expressions including h ^ (h >>> 16), >>>=, a long shift, double and char values in string concatenation and println, results of Math.sqrt, Math.abs, charAt, length(), a StringBuilder chain and an own double method in concatenation) converts with no stub, as do overflow checks, a long from an int product, division and remainder by zero caught as ArithmeticException, Integer.MIN_VALUE / -1, the binary-search midpoint and Math.abs(Integer.MIN_VALUE). With JCONV_BUNDLE=1 it runs as one document and prints all 31 lines identical to OpenJDK 25.0.2 (samples/ConvDemo.java.expected.txt against samples/ConvDemo.sleela.expected.txt).

Reproduce:

# from the repository root
JCONV_IN=lib/java/converter/samples JCONV_OUT=/tmp/conv-demo JCONV_SCOPE=all JCONV_BUNDLE=1 bash lib/java/converter/run-converter.sh
R=$(pwd); (cd /tmp/conv-demo/demo && SLEELA_HOME=$R SLEELA_LIB=$R/lib "$R/impl/build/sleela" run ConvDemo.sleela) | grep -v -E '^\[memory-manager\]|^verification|\[security\]|\[defender\]' > /tmp/conv-demo/sleela.out
diff lib/java/converter/samples/ConvDemo.java.expected.txt /tmp/conv-demo/sleela.out

A runnable conversion must be one document, which is what JCONV_BUNDLE=1 writes: several files given to sleela run duplicate the library units, and a converted type in a separate file whose name is also a JDK 28 type (Color, as java.awt.Color) loses to the JDK 28 tier (SLEELA.syntax 43.4). Declared in the same document it wins.

The remaining check errors in the JDK sample are not conversion slips. They are gaps of the language and library, in this order of weight:

  1. Nested and inner types do not resolve. The loader does not load Outer.Inner.sleela (PURPOSE.md row 4). Since 0.7.0 an inner class reaches its enclosing instance (this.slOuter.size, this.slOuter.modCount in HashMap.KeySet, rule 8d); a nested type still resolves only inside its bundled document. Writing nested types inline (SLEELA.syntax 14, hoisted as Outer__Inner) was measured on 2026-11-13 and is not a way out yet: only a plain nested class with fields and methods works; a nested class must be named Outer.Inner even inside Outer; a nested constructor that calls super(...), a nested class that extends another, static members of a nested class (Outer.S.K), new Outer.C[1], and a nested interface all fail.
  2. JDK-internal types are not in the tier. jdk.internal.access.JavaLangAccess, jdk.internal.util.Preconditions, ZipUtils and the like are not public API and have no lib/java/jdk-28 file. Converting with JCONV_SCOPE=all produces them, but they are mostly native or VM-intrinsic.
  3. jdk-28 library units expose some statics as instance methods (Float.isNaN, Objects.checkIndex, Arrays.copyOf, Character.charCount: STATUS.md section 6).
  4. An Any value is not assignable to a typed variable or return type without a cast (method 'stream' returns Any, expected Stream). Since 2026-11-13 calls on an Any receiver dispatch at run time, and casts, instanceof and catch see implemented interfaces (SLEELA.syntax 43.7); a call whose method no loaded class declares is still an error.
  5. Files with non-ASCII bytes were skipped until 0.7.3 (12 of the 15,020 files in the JDK src.zip): the VM read built-in cut its 4,095-byte pieces anywhere, so a UTF-8 character could be split between two of them. Since 2026-11-14 read holds an incomplete character back for the next piece (impl/core/sleela_core.c, read_utf8_piece), and all 12 convert with their characters intact in comments (string and char literals are written as \uXXXX, as before). Still refused, with the reason in the report: a file that is not valid UTF-8 (checked with iconv; without iconv, any non-ASCII byte, the old rule) and a file with a NUL byte, which a plain String cannot hold.
  6. Near-misses the token-level conversion cannot see (it has no expression types where the typed pass cannot see them): an operand whose kind is unknown (a call the model does not type, an interface-typed receiver, a generic result) is left as written, so a double there still prints in SLeeLa form (9, not 9.0); an int chain whose other operand is of unknown kind is wrapped (exact, sometimes unneeded). Stores into int array elements do not wrap in the VM, so a[i] = x + y keeps a 64-bit value until it is read through a wrap. switch over enum constants is not lowered.

The whole JDK in one run (0.7.1, 2026-11-14). Input: the OpenJDK 25.0.2 src.zip, unpacked (15,020 .java files in 69 modules), JCONV_SCOPE=api, JCONV_BUNDLE=1, compiler impl/build/sleela:

MeasureResult
Java files selected (public JDK 28 types)4,127
Converted / skipped / failed4,120 / 7 / 0
SLeeLa files written4,174
Types / members6,651 / 84,382
Members stubbed (fail loud)3,890 (4.6%)
Time173 s
Peak memory of the VMabout 1.7 GB

Before 0.7.1 this run could not finish. java.base alone was killed by the kernel at 16 GB after 1,200 of its 1,388 files, and with that fixed the run then stopped at javax.swing.plaf.basic.BasicLookAndFeel. Three fixes:

  1. Memory. The VM never frees a plain String, so JConvEmitter growing a 16,000-byte buffer by appending kept every intermediate copy (122 MB for HashMap.java alone). It now writes each piece straight to the file; HashMap.java peaks at the 57 MB of an empty run. Output unchanged.
  2. Members over 64 KB. A stubbed member keeps its Java body as a comment. BasicLookAndFeel.initComponentDefaults is 69,967 bytes, more than a plain String holds, so the comment became a UTF-16 String and the next + stopped the VM (Java String concatenation requires two UTF-16 String values). keptComment now writes such comments a line at a time. Output unchanged for every smaller member.
  3. Method declarations named like a VM built-in (read, write, lock, accept, ...). The call-site rule that writes this.read() or Owner.read() was also applied to the declaration, giving public int32 this.read() {, a syntax error. 514 declarations in the JDK (481 instance, 33 static) were written that way. The typed pass then also misread those methods, so their int arithmetic missed 107 wraps (JavaOperands.toInt and the shift and division calls), now present.

The 17-file sample and both demo programs give the same output as before (ConvDemo 31 of 31 and LambdaDemo 17 of 17 lines identical to OpenJDK).

What remains for a whole-tree conversion, measured on this run:

More of the model applied (0.7.6, 2026-11-14). JConvModel now reads every cast row and the chartext rows of conversion.model, and the typed pass applies them: a cast from double to int, long, short, byte or char is written with its row (JavaOperands.d2i, d2l, ...: Java saturates, and NaN is 0, JLS 5.1.3; the VM cast did neither, so (int) 1e20 gave 0), and a char argument of a chartext member (StringBuilder.append, insert, and the StringBuffer ones) goes through tostr char, so sb.append('{') appends the brace and not 123. New sample samples/model/ModelDemo.java (narrowing casts, double to integral, long division, remainder and shifts, -Integer.MIN_VALUE, compound assignment and ++ on narrow types, char as text): 12 of 12 lines the same as OpenJDK 25.0.2. In the 17-file sample this fixed 10 lines, among them BitSet.toString (b.append('{')) and the HashMap capacity casts.

Class literals (rule 8e, 0.7.4, 2026-11-14). T.class is written as Class.ofLiteral("<binary name>", <kind>). The binary name is the one Class.getName() reports in Java: a type the file declares with its nesting (classlit.ClassLitDemo$Inner$Deeper), else a single-type import, the package, java.lang or a wildcard import when lib/java/jdk-28/INDEX.tsv lists the type, else the package; int, void; arrays as [I, [[Ljava.lang.String;. The kind (1 class, 2 interface, 3 enum, 4 record, 5 annotation, 6 primitive, 7 array, 0 not known) comes from the declaration or the index (JConvClassLit). lib/java/jdk-28 java.lang.Class now carries an implementation block: the same name gives the same object (so == works), and getName, getSimpleName, getCanonicalName, getPackageName, getTypeName, toString, descriptorString, isPrimitive, isArray, isInterface, isEnum, isRecord, isAnnotation, componentType, getComponentType and desiredAssertionStatus are exact. A Class not made for a literal, or an answer that needs a kind not known, throws instead of returning a default. samples/classlit/ClassLitDemo.java (own nested types, enum, record, interface, annotation, imported and nested JDK types, primitives, void, arrays, ==, a literal in a static field) prints all 23 lines the same as OpenJDK 25.0.2. Whole JDK: stubs 3,912 to 2,141 (reason 9 from 1,890 to 0).

Two fixes it needed. A reference operand of a string + whose declared type is a class is now shown through toString() with the model row tostr reference (JavaFormat.objectText, null is "null"), as sleelactl java-convert already did; before, SLeeLa printed the VM handle (Class#15). It is not applied to Any, Object, String, boxed values, arrays or type variables. And the VM initialised statics in one pass, so a library class linked after the program wiped its registry (SLEELA.syntax 43.9).

Speed (2026-11-13). The 17-file sample above converts in 6.6 s (it took 66 s). Nothing in the converter changed and the output is byte-for-byte the same. The time was in the VM: every runtime plain String (each concatenation, each number written as text) was looked up in the VM intern table by comparing it with every String made so far, and nothing is ever removed from that table. A converter run makes hundreds of thousands of Strings (loading conversion.model alone makes about 18,000), so each one cost more than the last, and writing one output token took about 320 microseconds in a large file. The table now has a hash index (intern() in impl/core/sleela_core.c), and impl/examples/string_intern_scaling.sleela checks that the cost stays flat. Measured on HashMap.java (13,373 tokens): writing the output 3,799 ms to 54 ms, the typed pass 1,441 ms to 164 ms. What remains per run is mostly VM start-up and reading the model (3.7 s measured with no file to convert), so a larger tree gains more than the sample shows. Use impl/build/sleela or the refreshed working-binaries/sleela.

Close a gap in the language, VM or library first. Then remove or relax the rule in JConvRules that works around it, re-run the converter, and update this table.

7. Units

UnitRole
JConvMainentry point: settings, walk, convert, summary
JConvConfigsettings from the environment; INDEX.tsv scope set and type kinds
JConvWalkerrecursive directory traversal (oslsListDirectory, osIsDir)
JConvSourceloads a file in 4,095-byte pieces; code units and slices
JConvLexerJava tokens; literal and comment forms rewritten to SLeeLa
JConvRulesthe decision table (renames, types, modifiers, built-ins, stub reasons)
JConvModelreads the shared conversion model (ret, field, binop int shifts / division / remainder, cast long int, tostr)
JConvExprthe expression half of the typed pass: statements, precedence tree, wraps and calls (rules 7a to 7f)
JConvOuterinner classes: registry, outer context, slOuter rewrites
JConvClassLitclass literals (rule 8e): the file's types, imports and package; binary names and kinds
JConvLambdalambda and method reference lowering (rules 8a, 8b): sites, target typing, captures, body methods, the SLJavaLambdaTable of the document
JConvRewritertoken-level rewriting, the fail-loud scan, declaration and cast post-pass, helpers
JConvTranslatorfiles, types, members, enum / record lowering, nested types, stubs, metadata
JConvEmitterlayout and buffered output below the 65,536-byte String limit
JConvReportCONVERSION-REPORT.tsv and CONVERSION-SUMMARY.md
run-converter.shruns JConvMain with the settings
samples/demo/ConvDemo.java, its JDK output ConvDemo.java.expected.txt and its converted output ConvDemo.sleela.expected.txt (section 6)

8. Changes

VersionChange
0.1.0First cut: walk, lex, rewrite, translate, stubs, report
0.7.8The built-in call names come from the model: new qualify rows in conversion.model (170 measured names, section 9d; sleelactl/convert/conv_model.c accepts the kind, its differential suite 32/32). JConvRules.isBuiltinCallName reads them (it knew about 40), so an own method named like any VM built-in is called this.m() / Owner.m(). New sample samples/qualify, identical to OpenJDK
0.7.7Rule 1b: a name next that is not called (variable, parameter, field) becomes next_; SLeeLa read it as the integer 1 with no error. next() calls keep their name. Measured collisions: impl/subjects/conversion/IDENTIFIER-COLLISIONS.md. New sample samples/nextname, 2 of 2 lines identical to OpenJDK
0.7.6Model rows applied: every cast row (double to integral saturates, NaN is 0) and the chartext rows (a char argument of StringBuilder.append / insert is text). Intersection casts lowered (rule 8f). New sample samples/model, 12 of 12 lines identical to OpenJDK
0.7.5Bounded memory: JCONV_BATCH (default 500) ends a VM run after that many files and run-converter.sh starts the next after the last one, reusing the per-file state of 0.7.2 (a planned stop is not a failure). Whole JDK: peak 335 MB (was about 1.7 GB), output identical
0.7.4Class literals (rule 8e): T.class lowered to Class.ofLiteral(binary name, kind) (JConvClassLit; jdk-28 java.lang.Class implementation block). String.class no longer taken for a String static (reason 22). A class-typed operand of a string + goes through toString() (model row tostr reference). New sample samples/classlit, 23 of 23 lines identical to OpenJDK. Whole JDK: 2,141 stubs (was 3,912)
0.7.3Non-ASCII Java files convert: the VM read built-in no longer splits a UTF-8 character between pieces, so JConvSource accepts any valid UTF-8 file (it refused every non-ASCII byte) and refuses only invalid UTF-8 and NUL bytes, naming which. The 12 non-ASCII JDK files (7 of them public API) convert with no syntax error; the 17-file sample now converts 17 of 17 (UUID.java), the other 16 outputs unchanged
0.7.2Per-file isolation: a VM runtime error inside one Java file no longer ends the run. JConvMain records progress and totals after every file; run-converter.sh restarts after the file that stopped the VM, which is reported as failed with the VM message and its partial output removed. Default JCONV_OUT is now the caller's ./jdk28-converted (it was resolved after the script's cd, inside lib/java/converter). Test hook JCONV_TEST_STOP_IN
0.7.1Whole-tree runs: the emitter writes pieces directly instead of growing a String buffer (memory flat: the JDK java.base run had been killed at 16 GB); kept Java bodies over 64 KB are written as comments line by line (keptComment, was a VM stop on BasicLookAndFeel); a method declared with a VM built-in name (read, write, ...) is no longer written as this.read / Owner.read (514 declarations in the JDK; the typed pass now reaches them). All 4,120 convertible public JDK types in one run, 173 s. 17-file sample output unchanged
0.7.0JConvOuter: inner (non-static) classes get Outer slOuter and a first constructor parameter slOuterArg; new Inner(..) passes this (or this.slOuter from a sibling inner class); Outer.this becomes this.slOuter; an unqualified outer member becomes this.slOuter.x or Outer.x unless it is a local, an own member or possibly inherited (model ret / field rows). Stub reason 10 kept only for other qualified this / super. JDK sample, bundled: 26 stubs (was 35), 475 check errors (was 522), 0 syntax errors; both samples still identical
0.6.0JConvLambda: lambdas and method references lowered to (id, env) (rules 8a, 8b); functional interface types written as Any (8c), relying on SLEELA.syntax 43.7 (calls on Any). New sample samples/lambda/LambdaDemo.java, 17 of 17 lines identical. On eight lambda-dense java.util files the stubbed members fall from 31 to 15
0.5.0JConvExpr: an expression parser (JLS precedence) on the output tokens of each member; rules 7a to 7c moved onto the tree and rules 7e, 7f added (int wrap where the value leaves int arithmetic; divInt / remInt). In the JDK sample it writes 88 wraps and 7 division calls, with 0 syntax errors and the check numbers unchanged. The sample program gains overflow checks, long from an int product, division by zero caught, MIN / -1, the binary-search midpoint, and runs all 31 lines identical. Library fixes found by it: jdk-28 Math.abs(int) at MIN_VALUE, Math.absExact(int) now throws
0.4.0Model-driven: JConvModel reads conversion.model (shift functions, tostr templates, 8,964 ret rows of model 1.1.0, field rows); the typed pass types call chains through them (rule 7d). Built-in defaults only when the file cannot be read (the summary says which). The sample program gains library and own-method calls and runs all 29 lines identical, which needed the jdk-28 Math.sqrt to be correctly rounded (fixed the same day)
0.3.0Policy recorded: per-member stubs. Typed pass (rules 7a to 7d): int shifts through JavaOperands, double / char string conversion through Double.toString / JavaText, the same templates as the binop / tostr rows of conversion.model. JCONV_BUNDLE=1: one document per Java file, nested types inside (39% fewer check errors on the JDK sample; the sample program runs with all lines identical)
0.2.0Output declares #sleela 3.1 and uses its forms: array initializers and new T[n] kept (the slArray_* / slZeroArray_* helpers are gone), character literals kept, labels and jumps through finally kept (stub reasons 4, 13, 18 retired). New lowerings: for headers with commas (6i), pattern instanceof in two exact shapes (6j, 6k). No cast to array types (the compiler rejects them). Compiler fix alongside: new int32[n] starts at 0 (impl/frontend/compiler.cpp arrayFillKind)