javac flag to suppress synthetic members?

Jesse Wilson jesse at swank.ca
Mon Dec 21 23:47:56 UTC 2015


I’m using javac to build libraries that target both Android and desktop
Java. Android is particularly sensitive to the size of the compiled
classes. But smaller classes improves performance everywhere.

I’ve noticed that javac likes to synthesize additional members to build
visibility trampolines for nested classes. In the compiled code for OkHttp
<https://github.com/square/okhttp/>, nearly 10% of the method references
are synthetic!

I’m tempted to create a classfile rewriter to remove these synthetic
members. It’d have to promote some private things to package-private to
make the synthetic things unnecessary.

One alternative to classfile magic would be a new javac flag like
--avoid-synthetic-members. Such a flag would change private members to
package-private when those members were accessed by nested classes. The
compiled code would be smaller, run faster, and have less weird garbage in
the stack traces.

Are javac maintainers receptive to a patch that adds such a flag? What’s
the process of turning this proposal into a feature?

Thanks.
Jesse Wilson
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20151221/125cba89/attachment.html>


More information about the compiler-dev mailing list