javac flag to suppress synthetic members?

Jonathan Gibbons jonathan.gibbons at oracle.com
Mon Dec 21 23:53:37 UTC 2015


A version of javac that translates source files into class files that 
don't match the original source sounds very suspect to me.

-- Jon


On 12/21/2015 03:47 PM, Jesse Wilson wrote:
>
> 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/20bf3644/attachment-0001.html>


More information about the compiler-dev mailing list