8225540: In core reflection note whether returned annotations are declaration or type annotations

Reviewed-by: alanb, prappo
This commit is contained in:
Joe Darcy 2020-04-09 14:16:17 -07:00
parent b7d5172b89
commit 455d2e7cea
13 changed files with 209 additions and 24 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, 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
@ -544,6 +544,9 @@ public abstract class Executable extends AccessibleObject
* ("synthetic") to the parameter list for a method. See {@link
* java.lang.reflect.Parameter} for more information.
*
* <p>Note that any annotations returned by this method are
* declaration annotations.
*
* @see java.lang.reflect.Parameter
* @see java.lang.reflect.Parameter#getAnnotations
* @return an array of arrays that represent the annotations on
@ -577,6 +580,7 @@ public abstract class Executable extends AccessibleObject
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
@Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return annotationClass.cast(declaredAnnotations().get(annotationClass));
@ -584,6 +588,7 @@ public abstract class Executable extends AccessibleObject
/**
* {@inheritDoc}
*
* @throws NullPointerException {@inheritDoc}
*/
@Override
@ -596,6 +601,7 @@ public abstract class Executable extends AccessibleObject
/**
* {@inheritDoc}
*/
@Override
public Annotation[] getDeclaredAnnotations() {
return AnnotationParser.toArray(declaredAnnotations());
}