Skip to content

Comments

[UnusedMethod] Handle reflective method references#5525

Open
electrum wants to merge 1 commit intogoogle:masterfrom
electrum:unusedmethod
Open

[UnusedMethod] Handle reflective method references#5525
electrum wants to merge 1 commit intogoogle:masterfrom
electrum:unusedmethod

Conversation

@electrum
Copy link

@electrum electrum commented Feb 22, 2026

Handles Class.getMethod, getDeclaredMethod, getConstructor, getDeclaredConstructor, and MethodHandles.Lookup.findStatic, findVirtual, findSpecial, findConstructor. Only suppresses findings when the method name, owner class, and parameter types can all be statically resolved.

This is cleaner than adding @Keep everywhere, and avoids the problem that methods with @Keep can later become unused. IntelliJ IDEA understands static reflection as method usage, and this gives Error Prone the same ability.

@electrum electrum force-pushed the unusedmethod branch 2 times, most recently from 1a422d3 to 1371a8b Compare February 22, 2026 19:08
Handles Class.getMethod, getDeclaredMethod, getConstructor,
getDeclaredConstructor, and MethodHandles.Lookup.findStatic,
findVirtual, findSpecial, findConstructor. Only suppresses findings
when the method name, owner class, and parameter types can all be
statically resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant