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

Đang mở
#199 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, rust
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
1
Fork
1
Merge trung bình
48 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeLaser/maddi

Tất cả issue của CodeLaser/maddi

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.