[foreign-memaccess+abi] RFR: 8298532: Declare private constructors for FFM internal Architecture implementations

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Dec 13 12:12:39 UTC 2022


On Tue, 13 Dec 2022 11:24:21 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes declaring AArch64Architecture and X86_64Architecture final and creating a private constructor so that this redundant byte code can be eliminated:
> 
> 
>  public jdk.internal.foreign.abi.x64.X86_64Architecture(); 
>     Code: 
>        0: aload_0 
>        1: invokespecial #1 // Method java/lang/Object."<init>":()V 
>        4: return 
> 
>  public jdk.internal.foreign.abi.aarch64.AArch64Architectur(); 
>     Code: 
>        0: aload_0 
>        1: invokespecial #1 // Method java/lang/Object."<init>":()V 
>        4: return 
> 
> 
> and other potential optimizations can be unlocked.

Just a quick clarification: this change does not alter the shape of the bytecode. That is, a constructor is still emitted by javac (with the corresponding supercall to `Object::<init>`). The only difference is that the constructor is now `private`, so it doesn't show up with a simple `javap` or even with `javap -v`, because `javap` filters out non-public members by default. To show all members, `javap -p -v` should be used instead, which would then reveal the private constructor.

That said, this change makes the nature of the class (as a bag of statics) more explicit, so I still support it.

-------------

PR: https://git.openjdk.org/panama-foreign/pull/760


More information about the panama-dev mailing list