In Java bytecode anonymous classes really aren't any different than any
other class, except for a few minor details. These differences don't
matter at all to the remapping process. SomeClass$1 could be remapped
to SomeClass$200 or even SomeClass$AnotherClass and it would
decompile the same, since in bytecode these are just class references.
In source code however, anonymous class naming is very important and
isn't nearly as flexible. They are generated by the compiler based on
their location in the source file, which makes them very fragile to
changes.
For bytecode remapping this isn't an issue, but we do need to worry
about this for source code remapping. When this mapping comes along:
It's actually rather unclear what that even means from a source code
perspective, and handling that remapping case is unclear. This commit
attempts to address this by being a little more flexible when remapping
members of anonymous classes by doing the following:
First, check for the member signature in the class the member is in
If the first check fails, check if the member is inside an anonymous
class. If not, skip to step 5.
Look for a sibling class of the original class whose obfuscated name
matches our original class's deobfuscated name. If found, check for
the member signature there.
If that doesn't work, look for a sibling class of the original class
whose deobfuscated name matches our original class's obfuscated
name. If found, check for the member signature there.
If none of those checks work, complete the original class's mappings
with the inheritanceProvider and check one final time.
A few notes to point out:
This probably won't cover every case, but in my testing checking both
and 4. finds every case successfully. We may need to revisit this
if a situation comes up where those 2 checks aren't enough.
When referring to the class's obfuscated and deobfuscated names, I'm
just referring to the numeric name. That is, for SomeClass$1, the
name that I'm referring to here is just the 1.
In Java bytecode anonymous classes really aren't any different than any other class, except for a few minor details. These differences don't matter at all to the remapping process.
SomeClass$1
could be remapped toSomeClass$200
or evenSomeClass$AnotherClass
and it would decompile the same, since in bytecode these are just class references. In source code however, anonymous class naming is very important and isn't nearly as flexible. They are generated by the compiler based on their location in the source file, which makes them very fragile to changes.For bytecode remapping this isn't an issue, but we do need to worry about this for source code remapping. When this mapping comes along:
It's actually rather unclear what that even means from a source code perspective, and handling that remapping case is unclear. This commit attempts to address this by being a little more flexible when remapping members of anonymous classes by doing the following:
A few notes to point out:
SomeClass$1
, the name that I'm referring to here is just the1
.