> ServiceLoader specifies its iterator methods to throw > ServiceConfigurationError (SCE) when there is an error locating, loading or > instantiating a service provider. > > There are linkage error cases where the LinkageError is propagated rather > than throwing SCE with the LinkageError as cause. These typically arise in > "bad environments" such as a mismatch between compile-time and run-time, > missing dependencies, or maybe instrumentation/injection that has modified > classes with references to classes that are not visible at run-time. > > The behavior for these cases has varied a bit over time. Since JDK 9 (when > ServiceLoader was significantly re-implemented), a LinkageError thrown by > Class.forName when attempting to load a service provider class is propagated > without throwing SCE. Since JDK 24 (when support for the security manager was > removed), if getting the no-arg the constructor triggers class loading and a > LinkageError is thrown then is propagated without throwing SCE. > > The proposal here is to change the implementation to throw SCE consistently > for these cases. This would be observable change so there is a CSR to review > the impact. > > One of the existing tests for "bad" annotation processors needed to be > updated to handle the ServiceConfigurationError as that test had worked > around the issue and was handling the cause instead.
Alan Bateman has updated the pull request incrementally with one additional commit since the last revision: Fix typo in test methd name ------------- Changes: - all: https://git.openjdk.org/jdk/pull/30405/files - new: https://git.openjdk.org/jdk/pull/30405/files/de0bbd37..1be5db8e Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=30405&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30405&range=00-01 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/30405.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/30405/head:pull/30405 PR: https://git.openjdk.org/jdk/pull/30405
