classfile: intern constant-pool entries on write (fix LVTT/LVT ClassFormatError)
ristretto's ConstantPool never deduplicates: every add_* pushes a new entry. HotSpot matches each LocalVariableTypeTable entry to a LocalVariableTable entry by raw name_index, so when a name (e.g. a local's) was interned twice the two tables got different indices and the class failed to load: 'ClassFormatError: LVTT entry ... does not match any LVT entry'. The writer now memoizes every pool builder by its semantic key and rebuilds composite constants (Class/NameAndType/Fieldref/Methodref/MethodHandle/ Dynamic) from our own utf8/class primitives so ristretto never mints a shadow Utf8. This also shrinks the pool (no more ldc -> ldc_w widening that changed code length on a pure round-trip). Split pool.rs into a pool/ module (refs in pool/refs.rs) to respect the file-size gate. Regression test: tests/pool asserts the written pool has no duplicate CONSTANT_Utf8. Verified: pure parse->write of the neoforge jar (92 classes) now loads under java -Xverify:all with 0 errors.
This commit is contained in:
parent
a2e4c69210
commit
f08bf60635
10 changed files with 509 additions and 206 deletions
|
|
@ -27,9 +27,19 @@
|
|||
`ClassNotFoundException` в рантайме.
|
||||
- Рефлексия через строки мы ловим автоматически (анализ `Class.forName`,
|
||||
`getMethod`/`getField` и т.п.), но динамическую конкатенацию — нет.
|
||||
- JSON-(де)сериализация по именам полей (Gson/Jackson/`Codec`) не ловится:
|
||||
биндинг идёт через `X.class`-литерал, не строку — см. `todo.md` §2.
|
||||
- Для библиотек `rename_public_members = false` по умолчанию: менять
|
||||
публичный API библиотеки — сломать всех потребителей.
|
||||
|
||||
Шесть стилей имён (`ShortLatin`, `IlO0`, `Unicode`, `MixedLatin`,
|
||||
`DecoyWords`, `Plausible`) — компромисс по-разному: `IlO0`/`Unicode` явно
|
||||
сигнализируют «это обфускация», `Plausible` маскируется под обычный
|
||||
прикладной код (`TextureCache`, `resolveToken`), ценой того, что при
|
||||
ручном чтении он менее заметно отличается от настоящей логики, чем
|
||||
намеренный мусор — скрыть обфускацию и скрыть её цену ценой чуть большей
|
||||
путаницы для собственной команды при отладке маппингов.
|
||||
|
||||
**Статус: готово.**
|
||||
|
||||
## 2. Шифрование строк (`Strings`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue