Rust printer: LinkedHashMap/LinkedHashSet map to HashMap/HashSet, losing insertion order

Aperta
#199 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, rust
Ambito
backend

Direzione di ricerca

Read RustTypes around lines 70 and 76 to trace how Java linked collections are mapped. Then inspect ControlFlowGraph.subroutines, processJsrRanges, BytecodeSourceMapper, and the renamer's rename result to see where iteration order affects output. Check the fernflower tests that compare decompiled text; done means linked maps and sets preserve insertion order and those tests pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug front-end:rust

RustTypes maps java.util.LinkedHashMap to HashMap and java.util.LinkedHashSet to HashSet (RustTypes ~l.70, ~l.76). Java guarantees insertion order for both; Rust's hash collections iterate in an arbitrary order that changes from run to run.

That matters wherever the iteration order reaches output or decisions. On fernflower:

  • ControlFlowGraph.subroutines is a LinkedHashMap, and its order feeds the JSR-range sort in processJsrRanges;
  • BytecodeSourceMapper and the renamer's rename result are LinkedHashMaps, and they decide the order of what the decompiler writes.

The fernflower tests compare decompiled text, so they would fail on order alone.

Options:

  • an insertion-ordered map in crate::jrt, a small wrapper of a Vec plus a HashMap index;
  • the indexmap crate, if the translation may have dependencies.

Either way the mapping should keep the guarantee Java's type gives. A HashMap should only be printed where the program never depends on the order, and the analysis cannot tell us that today.

🤖 Generated with Claude Code

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
48m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.