Fix field initialization and refactor DecompileClass - #10
Merged
Conversation
leslieyip02
force-pushed
the
fix/field-default-value
branch
from
September 7, 2026 06:01
ff69314 to
28578ed
Compare
DecompileClass
leslieyip02
force-pushed
the
fix/field-default-value
branch
2 times, most recently
from
September 8, 2026 03:23
ee1ee59 to
53f2224
Compare
- Break up big methods (i.e. decompileMethod and decompileClass) into helpers for better readability - Renamed some variables for readability - Update access modifiers - Use JavadocComment instead of BlockComment for file-level comment
leslieyip02
force-pushed
the
fix/field-default-value
branch
from
September 10, 2026 08:21
53f2224 to
8f1a661
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix field initialization
The
DecompileClass.decompileFieldalways assigns an initializer:jade/src/main/kotlin/org/ucombinator/jade/decompile/DecompileClass.kt
Lines 161 to 177 in 2dc48dd
It does so by decompiling the node's value as a literal and using that literal as the field's initializer. However, consider the following:
Under the current logic,
node.valueisnull, sodecompileLiteral(node.value)is alsonull. When runningjade decompile Foo.class ., the result isThis is wrong since
nullcannot be assigned to primitives. This can be fixed by omitting theinitializerargument ifnode.valueisnull. Applying the fix, the decompiled result can then be recompiled:If we do set an initial
value, the value is set in the constructor (this seems correct?):Refactor
Additionally,
DecompileClasswas also refactored and improved:DecompileClassDecompileClassa. De-bloat large methods (i.e.
decompileMethodanddecompileClass) with helper functionsb. Readability improvements (i.e. renamed some variables for better clarity, reorganized certain sections of code)
c. Adding file-level comment using
JavadocCommentinstead ofBlockComment(the previous approach had alignment issues)