RFR: 8346567: Make Class.getModifiers() non-native [v6]

Coleen Phillimore coleenp at openjdk.org
Thu Feb 6 23:26:31 UTC 2025


> 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.

Coleen Phillimore has updated the pull request incrementally with two additional commits since the last revision:

 - Remove ??? in the code.
 - Hide Class.modifiers field.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22652/files
  - new: https://git.openjdk.org/jdk/pull/22652/files/146e2551..304a17ee

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22652&range=05
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22652&range=04-05

  Stats: 6 lines in 3 files changed: 1 ins; 1 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/22652.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22652/head:pull/22652

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


More information about the serviceability-dev mailing list