Skip to content
Permalink
Browse files
8224243: Add implSpec's to AccessibleObject and seal Executable
Reviewed-by: alanb
  • Loading branch information
jddarcy committed May 25, 2021
1 parent 594d454 commit 0b7735938407fad5c2dbfb509d2d47bf172305e9
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -497,6 +497,7 @@ public final boolean canAccess(Object obj) {
/**
* Constructor: only used by the Java Virtual Machine.
*/
@Deprecated(since="17")
protected AccessibleObject() {}

// Indicates whether language-level access checks are overridden
@@ -520,12 +521,16 @@ protected AccessibleObject() {}
* <p> Note that any annotation returned by this method is a
* declaration annotation.
*
* @implSpec
* The default implementation throws {@link
* UnsupportedOperationException}; subclasses should override this method.
*
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
@Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
throw new AssertionError("All subclasses should override this method");
throw new UnsupportedOperationException("All subclasses should override this method");
}

/**
@@ -545,12 +550,16 @@ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
* <p> Note that any annotations returned by this method are
* declaration annotations.
*
* @implSpec
* The default implementation throws {@link
* UnsupportedOperationException}; subclasses should override this method.
*
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
throw new AssertionError("All subclasses should override this method");
throw new UnsupportedOperationException("All subclasses should override this method");
}

/**
@@ -606,11 +615,15 @@ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
* <p> Note that any annotations returned by this method are
* declaration annotations.
*
* @implSpec
* The default implementation throws {@link
* UnsupportedOperationException}; subclasses should override this method.
*
* @since 1.5
*/
@Override
public Annotation[] getDeclaredAnnotations() {
throw new AssertionError("All subclasses should override this method");
throw new UnsupportedOperationException("All subclasses should override this method");
}

// Shared access checking logic.
@@ -47,11 +47,12 @@
*
* @since 1.8
*/
public abstract class Executable extends AccessibleObject
implements Member, GenericDeclaration {
public abstract sealed class Executable extends AccessibleObject
implements Member, GenericDeclaration permits Constructor, Method {
/*
* Only grant package-visibility to the constructor.
*/
@SuppressWarnings("deprecation")
Executable() {}

/**
@@ -116,6 +116,7 @@ private FieldRepository getGenericInfo() {
/**
* Package-private constructor
*/
@SuppressWarnings("deprecation")
Field(Class<?> declaringClass,
String name,
Class<?> type,

1 comment on commit 0b77359

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 0b77359 May 25, 2021

Please sign in to comment.