On Fri, 10 Apr 2026 06:16:36 GMT, Alan Bateman <[email protected]> wrote:

>> src/java.base/share/classes/java/util/ServiceLoader.java line 624:
>> 
>>> 622:         try {
>>> 623:             ctor = clazz.getConstructor();
>>> 624:         } catch (NoSuchMethodException | LinkageError e) {
>> 
>> Hello Alan, unlike `Class.forName(...)` which specifies the `LinkageError` 
>> from that method, the `Class.getConstructor()` doesn't currently specify 
>> this error. Should that documentation be updated (as a separate work) to 
>> specify this?
>
> There is discussion about that in a few JBS issues, esp. in the JDK 9 time 
> frame and in the context of code using reflective guards to deal with 
> optional dependences. I don't think there was a conclusion to change 
> Class.getConstructor docs to align with existing behavior.

Thank you Alan, I'll read through those discussions. Looking more closely 
through the test introduced in this PR, I now realize that the LinkageError 
comes from a Constructor which isn't the no-arg Constructor being looked up 
here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30405#discussion_r3062613073

Reply via email to