On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:

> The Class.getModifiers() method is implemented as a native method in 
> java.lang.Class to access a field that we've calculated when creating the 
> mirror.  The field is final after that point. The VM doesn't need it anymore, 
> so there's no real need for the jdk code to call into the VM to get it.  This 
> moves the field to Java and removes the intrinsic code.  I promoted the 
> compute_modifiers() functions to return int since that's how java.lang.Class 
> uses the value.  It should really be an unsigned short though.
> 
> There's a couple of JMH benchmarks added with this change.  One does show 
> that for array classes for non-bootstrap class loader, this results in one 
> extra load which in a long loop of just that, is observable.  I don't think 
> this is real life code. The other benchmarks added show no regression.
> 
> Tested with tier1-8.

This pull request has now been integrated.

Changeset: c9cadbd2
Author:    Coleen Phillimore <cole...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/c9cadbd23fb13933b8968f283d27842cd35f8d6f
Stats:     217 lines in 31 files changed: 71 ins; 127 del; 19 mod

8346567: Make Class.getModifiers() non-native

Reviewed-by: alanb, vlivanov, yzheng, dlong

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

PR: https://git.openjdk.org/jdk/pull/22652

Reply via email to