RFR: JDK-8266670: Better modeling of access flags in core reflection [v20]

Joe Darcy darcy at openjdk.java.net
Tue Jun 14 02:25:02 UTC 2022


On Wed, 1 Jun 2022 05:09:42 GMT, ExE Boss <duke at openjdk.java.net> wrote:

>> Or `AbstractMethodError`, which is what `Executable::getParameterCount()` does:
>> https://github.com/openjdk/jdk/blob/e751b7b1b6f7269a1fe20c07748c726536388f6d/src/java.base/share/classes/java/lang/reflect/Executable.java#L248-L258
>
> Actually, it should probably be `UnsupportedOperationException` instead.

Hmm. If we had sealed classes and interfaces back in JDK 1.1 when Member was added, it most likely would have been added as sealed interface. But, we didn't have sealed interfaces back then so Member can (potentially) be extended by anyone. IIRC, there are a few classes implementing Member outside of the JDK.

So, when adding a new method would JDK 20, the method should certainly have be default method. I think throwing UnsupportedOperationException in the default is marginally better than the alternatives. I'll update the PR accordingly in a subsequent push. Thanks.

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

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


More information about the core-libs-dev mailing list