Home /Modules/impl/CONVERTER-MAPPING-AUDIT.md

CONVERTER-MAPPING-AUDIT.md

impl/subjects/conversion/CONVERTER-MAPPING-AUDIT.md · 191 line(s) · markdown

Java-to-SLeeLa converter mapping audit

Date: 2026-11-14 Scope: C++ converter (sleelactl/convert), SLeeLa-native converter (lib/java/converter), and their shared subject (impl/subjects/conversion/conversion.model). This audit does not authorize changes to the compiler, VM, or general runtime.

Status vocabulary

1. Mapping and semantic-law audit

AreaCurrent findingStatusRequired next step
Primitive type inventoryThe model lists all eight Java primitives, but the C++ translator also hard-codes operand classes and numeric ranks.Implemented, duplicatedMake type class/rank/promotion decisions model-driven.
floatC++ has a dedicated JavaFloat.f32 path for arithmetic, comparisons, casts and increments. The model does not declare promote float, float binary-operation rows, or float cast rows.Implemented, converter-specificExpress the supported float laws in the model and have both converters consume them.
Numeric promotionThe model has byte/short/char/int/long/double promotion rows, but no float promotion row. Mixed numeric promotion is partly hard-coded in C++.PartialCover JLS binary numeric promotion, including float and all widening paths.
Casts and wideningThe model has int/long/double casts, but the C++ translator special-cases float and some coercions.Implemented, duplicatedAudit every primitive source/target pair and make the model authoritative.
Compound assignmentThe model lists int/long/double/text/boolean cases; float is currently handled by C++ special paths rather than a float row.PartialVerify narrowing, promotion, and one-time lvalue evaluation for every supported operator.
Boxing/unboxingThe model lists a subset of wrapper classes; C++ rejects boxed types in declarations/casts and treats some wrappers as primitive operands.PartialDefine wrapper coverage and fail-closed rules consistently.
Library result typesThe shared model has extensive ret and field rows.Implemented, shared dataVerify provenance/version against JDK 28, overload-sensitive results, and generic substitutions.
Built-in call qualificationThe model has qualify rows, but C++ still has a separate builtin_names.h table.Implemented, duplicatedRemove the second authority or mechanically verify exact set equality.
String conversiontostr and chartext rows exist; native and C++ implementations read different subsets.Partial parityTest all text-conversion call sites and null/reference behavior in both converters.

Important observation: the C++ README says the translator has no Java semantic rules of its own, but classOf, rankOf, float lowering, and portions of coercion/promotion currently encode behavior in C++. The documentation should not claim full model authority until those paths are data-driven or explicitly documented as converter mechanics.

2. Identifier and converter parity

The collision audit records 13 problematic Java identifiers. The native converter already globally renames require, usualgc, usualmem, int64, and int128; the C++ reserved-name set did not. This pass adds those five names to the C++ set and adds a differential regression input at sleelactl/convert/tests/java/ReservedIdentifiers.java.

Remaining identifier work:

The C++ converter fails closed per compilation unit. The SLeeLa-native converter intentionally emits per-member throwing stubs. These are different products and must not share a single “converted successfully” status. Reports must distinguish complete conversion, partial/stubbed output, and refusal.

3. Generic types and overload resolution

C++ converter

SLeeLa-native converter

Required shared behavior

  1. Preserve declared type variables and their bounds in the project symbol index, even if emitted SLeeLa uses erasure.
  2. Instantiate generic parameter and return types at each call site.
  3. Implement Java invocation applicability phases and most-specific selection.
  4. Account for primitive widening, reference widening, boxing/unboxing, varargs, and generic inference in the correct order.
  5. Detect ambiguous and unresolved invocations; refuse them with source-located diagnostics rather than selecting the first candidate.
  6. Pass the resolved functional-interface target to lambda and method-reference lowering.

4. Imports and cross-package symbols

The C++ parser now retains explicit type imports and explicit/wildcard static imports. Conflicting explicit type imports fail with import-ambiguous; unqualified static method calls are resolved only after ordinary in-scope lookup, and multiple applicable static-import owners fail with static-import-ambiguous. Imported static owners are reduced to the model's simple owner name. This is not yet a complete Java name-resolution engine: wildcard type-import package indexing, module readability, package-private accessibility, and nested type imports remain open. The SLeeLa-native converter already records package and import tokens for class literals, but does not yet share the C++ project symbol resolver.

5. Lambda and method-reference target typing

Existing work is significant: the C++ converter collects functional-interface signatures and defers lambda arguments until a target parameter is selected. The SLeeLa-native converter has a defunctionalized lambda representation and supports selected lambda/method-reference forms.

Remaining work is to make target typing a consequence of the same resolved method signature in both converters. Cover generic functional-interface substitutions, intersection targets, primitive-specialized functional interfaces, library method-reference signatures, and overloaded method references where generic SAM types are involved. Preserve receiver evaluation exactly once and at reference creation time. Do not count an unknown-target stub as successful conversion.

Acceptance checks for this pass

Immediate work queue

  1. Complete the primitive-law audit and move float, all promotion, and cast decisions into the shared model; the native expression pass currently uses shared widening only for the supported integer/long/double promotion paths.
  2. Consolidate identifier rename and built-in qualification data, retaining context-sensitive rename categories.
  3. Complete C++ invocation applicability and specificity beyond the current supported subset: boxing/unboxing, bounded/class/nested generic inference, wildcard capture, and the remaining JLS ambiguity rules. Add focused differential fixtures before claiming broader coverage.
  4. Extend the SLeeLa-native signature index toward overload-aware resolution, add generic SAM substitution, and implement the same direct generic method inference subset as C++.
  5. Complete package-aware symbol identity for colliding simple type names, wildcard type-import indexing, module/accessibility checks, and static nested-type imports. Add whole-run staging to C++ and SHA-256 source/model/converter/output provenance to the SLeeLa-native converter.