--- a/jdk/src/share/classes/java/lang/reflect/Executable.java Sat Jan 26 16:57:02 2013 +0000
+++ b/jdk/src/share/classes/java/lang/reflect/Executable.java Tue Jan 29 10:32:49 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -31,6 +31,8 @@
import java.util.Objects;
import sun.reflect.annotation.AnnotationParser;
import sun.reflect.annotation.AnnotationSupport;
+import sun.reflect.annotation.TypeAnnotationParser;
+import sun.reflect.annotation.TypeAnnotation;
import sun.reflect.generics.repository.ConstructorRepository;
/**
@@ -50,6 +52,7 @@
* Accessor method to allow code sharing
*/
abstract byte[] getAnnotationBytes();
+ abstract byte[] getTypeAnnotationBytes();
/**
* Does the Executable have generic information.
@@ -470,4 +473,86 @@
return declaredAnnotations;
}
+
+ /* Helper for subclasses of Executable.
+ *
+ * Returns an AnnotatedType object that represents the use of a type to
+ * specify the return type of the method/constructor represented by this
+ * Executable.
+ *
+ * @since 1.8
+ */
+ AnnotatedType getAnnotatedReturnType0(Type returnType) {
+ return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ this,
+ getDeclaringClass(),
+ returnType,
+ TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN_TYPE);
+ }
+
+ /**
+ * Returns an AnnotatedType object that represents the use of a type to
+ * specify the receiver type of the method/constructor represented by this
+ * Executable. The receiver type of a method/constructor is available only
+ * if the method/constructor declares a formal parameter called 'this'.
+ *
+ * Returns null if this Executable represents a constructor or instance
+ * method that either declares no formal parameter called 'this', or
+ * declares a formal parameter called 'this' with no annotations on its
+ * type.
+ *
+ * Returns null if this Executable represents a static method.
+ *
+ * @since 1.8
+ */
+ public AnnotatedType getAnnotatedReceiverType() {
+ return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ this,
+ getDeclaringClass(),
+ getDeclaringClass(),
+ TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
+ }
+
+ /**
+ * Returns an array of AnnotatedType objects that represent the use of
+ * types to specify formal parameter types of the method/constructor
+ * represented by this Executable. The order of the objects in the array
+ * corresponds to the order of the formal parameter types in the
+ * declaration of the method/constructor.
+ *
+ * Returns an array of length 0 if the method/constructor declares no
+ * parameters.
+ *
+ * @since 1.8
+ */
+ public AnnotatedType[] getAnnotatedParameterTypes() {
+ throw new UnsupportedOperationException("Not yet");
+ }
+
+ /**
+ * Returns an array of AnnotatedType objects that represent the use of
+ * types to specify the declared exceptions of the method/constructor
+ * represented by this Executable. The order of the objects in the array
+ * corresponds to the order of the exception types in the declaration of
+ * the method/constructor.
+ *
+ * Returns an array of length 0 if the method/constructor declares no
+ * exceptions.
+ *
+ * @since 1.8
+ */
+ public AnnotatedType[] getAnnotatedExceptionTypes() {
+ return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ this,
+ getDeclaringClass(),
+ getGenericExceptionTypes(),
+ TypeAnnotation.TypeAnnotationTarget.THROWS);
+ }
+
}