RFR: 8372410: ThreadFactory used by Thread.Builder::factory uses non-optimal VarHandle
Francesco Nigro
duke at openjdk.org
Tue Nov 25 03:42:43 UTC 2025
On Mon, 24 Nov 2025 19:23:14 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> This is not the first time this VarHandle problem is hit - see #16451
>
>> This has bitten me lot of times @liach 😢 Including others while reading/writing oop fields into arrays too; it would be nice to get an option to fail fast with an exception enabled via diagnostic args eg EnableStrictPolymorphicSignature Although Javac should be able to detect it too, thinking about it twice
>
> This can be done using [`VarHandle::withInvokeExactBehavior`](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/invoke/VarHandle.html#withInvokeExactBehavior()) on a per var handle basis. C2 can constant fold the type-check away as well.
@JornVernee thanks 🙏 I admit it's the first time I see this method, wow
@JornVernee thanks 🙏 I admit it's the first time I see this method, wow
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28475#issuecomment-3573655519
PR Comment: https://git.openjdk.org/jdk/pull/28475#issuecomment-3573655546
More information about the core-libs-dev
mailing list