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

未关闭
#199 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java, rust
领域
backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Java
星标
1
派生
1
平均合并
48 分钟
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CodeLaser/maddi 的其他 Issue

查看 CodeLaser/maddi 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。