RFR: 8224243: Make AccessibleObject a sealed class [v2]

Joe Darcy joe.darcy at oracle.com
Mon May 24 19:07:55 UTC 2021


Hi Alan,

On 5/22/2021 9:41 AM, Alan Bateman wrote:
> On Fri, 21 May 2021 02:42:50 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>
>>> Conceptually, AccessbileObject is a sealed class with a protected constructor stating
>>>
>>>      Constructor: only used by the Java Virtual Machine.
>>>
>>> With the language now supporting sealed classes, the AccessbileObject should be marked as sealed.
>>>
>>> Executable and Field are the subclasses of AccessbileObject in the JDK; as Executable has subclasses, it is marked as non-sealed.
>>>
>>> Please also review the corresponding CSR:
>>>
>>> https://bugs.openjdk.java.net/browse/JDK-8224243
>> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
>>
>>    Update in response to review feedback.
> src/java.base/share/classes/java/lang/reflect/AccessibleObject.java line 533:
>
>> 531:     @Override
>> 532:     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
>> 533:         throw new IllegalStateException("All subclasses should override this method");
> I'm not sure that ISE is the most appropriate exception here because there isn't an alternative state that would accept the input. UOE might be better.
>
> The new proposal to just seal Executable looks reasonable.
>
Yeah; I was looking over which exception type to use. On the whole, UOE 
looks a bit better; I've updated the PR accordingly.

Thanks,

-Joe





More information about the core-libs-dev mailing list