Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Support manual constant uninlining #2395

Open
NebelNidas opened this issue Jan 18, 2025 · 2 comments
Open

[feature] Support manual constant uninlining #2395

NebelNidas opened this issue Jan 18, 2025 · 2 comments

Comments

@NebelNidas
Copy link
Contributor

NebelNidas commented Jan 18, 2025

Describe your idea

javac tends to inline constants, leading to magic numbers appearing all over the decompiled code. A method like this:

boolean place(ItemPlacementContext context, BlockState state) {
   return context.getWorld().setBlockState(context.getBlockPos(), state, Block.NOTIFY_LISTENERS | Block.REDRAW_ON_MAIN_THREAD | Block.FORCE_STATE);
}

will be turned into this:

boolean place(ItemPlacementContext context, BlockState state) {
   return context.getWorld().setBlockState(context.getBlockPos(), state, 26);
}

Using Unpick, a tool developed by the Minecraft modding community, this process can be manually reversed. Unpick itself operates on Java bytecode, so it is not applicable to Android apps, but the file format for these "unpick definitions" is bytecode-independent and support for it could be integrated into JADX too. I'm bringing this up now since there's currently a discussion going on in its issue tracker regarding a potential v3 format, intended to be integrated natively into the Vineflower decompiler.

@skylot
Copy link
Owner

skylot commented Jan 18, 2025

Nice idea for a new jadx plugin!
Similar plugin for Android: jadx-android-linter-plugin developed by @nitram84

@Beast833
Copy link

Nice idea for a new jadx plugin!
Similar plugin for Android: jadx-android-linter-plugin developed by @nitram84

Give me cli command to use this but no gui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants