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

Abierto
#199 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, rust
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
48 min
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.