RFR: 8346781: [JVMCI] Limit ServiceLoader to class initializers
Doug Simon
dnsimon at openjdk.org
Mon Dec 23 18:06:06 UTC 2024
In the context of libgraal, the current use of ServiceLoader in JVMCI is problematic as libgraal does all class loading at image build time. There are static fields such as `JVMCIServiceLocator.cachedLocators` that need to be initialized [via reflection](https://github.com/oracle/graal/blob/30492c3f7847a13ae7f8dc50663a5a039e49a8e7/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/libgraal/BuildTime.java#L175-L180) when building libgraal.
This PR removes the need for such reflection by moving all use of ServiceLoader in JVMCI into `<clinit>` methods. These methods are executed when building libgraal.
-------------
Commit messages:
- remove non-native-image build time use of ServiceLoader
- make Cleaner.clean public
Changes: https://git.openjdk.org/jdk/pull/22869/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22869&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8346781
Stats: 166 lines in 7 files changed: 10 ins; 126 del; 30 mod
Patch: https://git.openjdk.org/jdk/pull/22869.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22869/head:pull/22869
PR: https://git.openjdk.org/jdk/pull/22869
More information about the hotspot-compiler-dev
mailing list