author | mchung |
Thu, 04 Oct 2018 08:45:21 -0700 | |
changeset 52015 | 821bfc24d750 |
parent 50091 | 05979f6ba560 |
child 52380 | 6b31efbf833e |
permissions | -rw-r--r-- |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
1 |
/* |
45332
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
2 |
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
4 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
10 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
15 |
* accompanied this code). |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
16 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
20 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
23 |
* questions. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
24 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
25 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
26 |
package java.lang.reflect; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
27 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
28 |
import java.lang.annotation.*; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
29 |
import java.util.Map; |
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
30 |
import java.util.Objects; |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
31 |
import java.util.StringJoiner; |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
32 |
|
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
33 |
import jdk.internal.misc.SharedSecrets; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
34 |
import sun.reflect.annotation.AnnotationParser; |
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
35 |
import sun.reflect.annotation.AnnotationSupport; |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
36 |
import sun.reflect.annotation.TypeAnnotationParser; |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
37 |
import sun.reflect.annotation.TypeAnnotation; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
38 |
import sun.reflect.generics.repository.ConstructorRepository; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
39 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
40 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
41 |
* A shared superclass for the common functionality of {@link Method} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
42 |
* and {@link Constructor}. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
43 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
44 |
* @since 1.8 |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
45 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
46 |
public abstract class Executable extends AccessibleObject |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
47 |
implements Member, GenericDeclaration { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
48 |
/* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
49 |
* Only grant package-visibility to the constructor. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
50 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
51 |
Executable() {} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
52 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
53 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
54 |
* Accessor method to allow code sharing |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
55 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
56 |
abstract byte[] getAnnotationBytes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
57 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
58 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
59 |
* Does the Executable have generic information. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
60 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
61 |
abstract boolean hasGenericInformation(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
62 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
63 |
abstract ConstructorRepository getGenericInfo(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
64 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
65 |
boolean equalParamTypes(Class<?>[] params1, Class<?>[] params2) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
66 |
/* Avoid unnecessary cloning */ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
67 |
if (params1.length == params2.length) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
68 |
for (int i = 0; i < params1.length; i++) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
69 |
if (params1[i] != params2[i]) |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
70 |
return false; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
71 |
} |
10142
43c81972df7b
7073296: Executable.equalParamTypes() incorrectly returns true when the number of params differs.
mduigou
parents:
10127
diff
changeset
|
72 |
return true; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
73 |
} |
10142
43c81972df7b
7073296: Executable.equalParamTypes() incorrectly returns true when the number of params differs.
mduigou
parents:
10127
diff
changeset
|
74 |
return false; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
75 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
76 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
77 |
Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
78 |
return AnnotationParser.parseParameterAnnotations( |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
79 |
parameterAnnotations, |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
80 |
SharedSecrets.getJavaLangAccess(). |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
81 |
getConstantPool(getDeclaringClass()), |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
82 |
getDeclaringClass()); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
83 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
84 |
|
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
85 |
void printModifiersIfNonzero(StringBuilder sb, int mask, boolean isDefault) { |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
86 |
int mod = getModifiers() & mask; |
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
87 |
|
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
88 |
if (mod != 0 && !isDefault) { |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
89 |
sb.append(Modifier.toString(mod)).append(' '); |
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
90 |
} else { |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
91 |
int access_mod = mod & Modifier.ACCESS_MODIFIERS; |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
92 |
if (access_mod != 0) |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
93 |
sb.append(Modifier.toString(access_mod)).append(' '); |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
94 |
if (isDefault) |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
95 |
sb.append("default "); |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
96 |
mod = (mod & ~Modifier.ACCESS_MODIFIERS); |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
97 |
if (mod != 0) |
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
98 |
sb.append(Modifier.toString(mod)).append(' '); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
99 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
100 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
101 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
102 |
String sharedToString(int modifierMask, |
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
103 |
boolean isDefault, |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
104 |
Class<?>[] parameterTypes, |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
105 |
Class<?>[] exceptionTypes) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
106 |
try { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
107 |
StringBuilder sb = new StringBuilder(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
108 |
|
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
109 |
printModifiersIfNonzero(sb, modifierMask, isDefault); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
110 |
specificToStringHeader(sb); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
111 |
sb.append('('); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
112 |
StringJoiner sj = new StringJoiner(","); |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
113 |
for (Class<?> parameterType : parameterTypes) { |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
114 |
sj.add(parameterType.getTypeName()); |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
115 |
} |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
116 |
sb.append(sj.toString()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
117 |
sb.append(')'); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
118 |
|
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
119 |
if (exceptionTypes.length > 0) { |
39825
6441823cea46
8162539: Test fails because it expects a blank between method signature and throws exception
darcy
parents:
39731
diff
changeset
|
120 |
StringJoiner joiner = new StringJoiner(",", " throws ", ""); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
121 |
for (Class<?> exceptionType : exceptionTypes) { |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
122 |
joiner.add(exceptionType.getTypeName()); |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
123 |
} |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
124 |
sb.append(joiner.toString()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
125 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
126 |
return sb.toString(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
127 |
} catch (Exception e) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
128 |
return "<" + e + ">"; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
129 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
130 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
131 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
132 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
133 |
* Generate toString header information specific to a method or |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
134 |
* constructor. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
135 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
136 |
abstract void specificToStringHeader(StringBuilder sb); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
137 |
|
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
138 |
String sharedToGenericString(int modifierMask, boolean isDefault) { |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
139 |
try { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
140 |
StringBuilder sb = new StringBuilder(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
141 |
|
16729
3b26e313ad81
8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents:
16058
diff
changeset
|
142 |
printModifiersIfNonzero(sb, modifierMask, isDefault); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
143 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
144 |
TypeVariable<?>[] typeparms = getTypeParameters(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
145 |
if (typeparms.length > 0) { |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
146 |
StringJoiner sj = new StringJoiner(",", "<", "> "); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
147 |
for(TypeVariable<?> typeparm: typeparms) { |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
148 |
sj.add(typeparm.getTypeName()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
149 |
} |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
150 |
sb.append(sj.toString()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
151 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
152 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
153 |
specificToGenericStringHeader(sb); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
154 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
155 |
sb.append('('); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
156 |
StringJoiner sj = new StringJoiner(","); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
157 |
Type[] params = getGenericParameterTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
158 |
for (int j = 0; j < params.length; j++) { |
16743
b0b34102bb4c
6298888: Add toGenericString to j.l.Class and getTypeName to j.l.reflect.Type
darcy
parents:
16729
diff
changeset
|
159 |
String param = params[j].getTypeName(); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
160 |
if (isVarArgs() && (j == params.length - 1)) // replace T[] with T... |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
161 |
param = param.replaceFirst("\\[\\]$", "..."); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
162 |
sj.add(param); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
163 |
} |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
164 |
sb.append(sj.toString()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
165 |
sb.append(')'); |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
166 |
|
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
167 |
Type[] exceptionTypes = getGenericExceptionTypes(); |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
168 |
if (exceptionTypes.length > 0) { |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
169 |
StringJoiner joiner = new StringJoiner(",", " throws ", ""); |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
170 |
for (Type exceptionType : exceptionTypes) { |
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
171 |
joiner.add(exceptionType.getTypeName()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
172 |
} |
39731
7a4bc90065bd
8161500: Use getTypeName and StringJoiner in core reflection toString methods
darcy
parents:
32834
diff
changeset
|
173 |
sb.append(joiner.toString()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
174 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
175 |
return sb.toString(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
176 |
} catch (Exception e) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
177 |
return "<" + e + ">"; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
178 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
179 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
180 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
181 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
182 |
* Generate toGenericString header information specific to a |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
183 |
* method or constructor. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
184 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
185 |
abstract void specificToGenericStringHeader(StringBuilder sb); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
186 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
187 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
188 |
* Returns the {@code Class} object representing the class or interface |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
189 |
* that declares the executable represented by this object. |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
190 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
191 |
public abstract Class<?> getDeclaringClass(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
192 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
193 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
194 |
* Returns the name of the executable represented by this object. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
195 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
196 |
public abstract String getName(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
197 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
198 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
199 |
* Returns the Java language {@linkplain Modifier modifiers} for |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
200 |
* the executable represented by this object. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
201 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
202 |
public abstract int getModifiers(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
203 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
204 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
205 |
* Returns an array of {@code TypeVariable} objects that represent the |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
206 |
* type variables declared by the generic declaration represented by this |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
207 |
* {@code GenericDeclaration} object, in declaration order. Returns an |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
208 |
* array of length 0 if the underlying generic declaration declares no type |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
209 |
* variables. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
210 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
211 |
* @return an array of {@code TypeVariable} objects that represent |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
212 |
* the type variables declared by this generic declaration |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
213 |
* @throws GenericSignatureFormatError if the generic |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
214 |
* signature of this generic declaration does not conform to |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
215 |
* the format specified in |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
216 |
* <cite>The Java™ Virtual Machine Specification</cite> |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
217 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
218 |
public abstract TypeVariable<?>[] getTypeParameters(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
219 |
|
42997
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
220 |
// returns shared array of parameter types - must never give it out |
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
221 |
// to the untrusted code... |
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
222 |
abstract Class<?>[] getSharedParameterTypes(); |
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
223 |
|
49273
af8ab4f90a32
8199862: Examine ProxyBuilder::referencedTypes startup cost
redestad
parents:
47216
diff
changeset
|
224 |
// returns shared array of exception types - must never give it out |
af8ab4f90a32
8199862: Examine ProxyBuilder::referencedTypes startup cost
redestad
parents:
47216
diff
changeset
|
225 |
// to the untrusted code... |
af8ab4f90a32
8199862: Examine ProxyBuilder::referencedTypes startup cost
redestad
parents:
47216
diff
changeset
|
226 |
abstract Class<?>[] getSharedExceptionTypes(); |
af8ab4f90a32
8199862: Examine ProxyBuilder::referencedTypes startup cost
redestad
parents:
47216
diff
changeset
|
227 |
|
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
228 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
229 |
* Returns an array of {@code Class} objects that represent the formal |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
230 |
* parameter types, in declaration order, of the executable |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
231 |
* represented by this object. Returns an array of length |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
232 |
* 0 if the underlying executable takes no parameters. |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
233 |
* |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
234 |
* @return the parameter types for the executable this object |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
235 |
* represents |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
236 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
237 |
public abstract Class<?>[] getParameterTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
238 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
239 |
/** |
17177 | 240 |
* Returns the number of formal parameters (whether explicitly |
241 |
* declared or implicitly declared or neither) for the executable |
|
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
242 |
* represented by this object. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
243 |
* |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
244 |
* @return The number of formal parameters for the executable this |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
245 |
* object represents |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
246 |
*/ |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
247 |
public int getParameterCount() { |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
248 |
throw new AbstractMethodError(); |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
249 |
} |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
250 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
251 |
/** |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
252 |
* Returns an array of {@code Type} objects that represent the formal |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
253 |
* parameter types, in declaration order, of the executable represented by |
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
254 |
* this object. Returns an array of length 0 if the |
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
255 |
* underlying executable takes no parameters. |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
256 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
257 |
* <p>If a formal parameter type is a parameterized type, |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
258 |
* the {@code Type} object returned for it must accurately reflect |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
259 |
* the actual type parameters used in the source code. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
260 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
261 |
* <p>If a formal parameter type is a type variable or a parameterized |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
262 |
* type, it is created. Otherwise, it is resolved. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
263 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
264 |
* @return an array of {@code Type}s that represent the formal |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
265 |
* parameter types of the underlying executable, in declaration order |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
266 |
* @throws GenericSignatureFormatError |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
267 |
* if the generic method signature does not conform to the format |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
268 |
* specified in |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
269 |
* <cite>The Java™ Virtual Machine Specification</cite> |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
270 |
* @throws TypeNotPresentException if any of the parameter |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
271 |
* types of the underlying executable refers to a non-existent type |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
272 |
* declaration |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
273 |
* @throws MalformedParameterizedTypeException if any of |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
274 |
* the underlying executable's parameter types refer to a parameterized |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
275 |
* type that cannot be instantiated for any reason |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
276 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
277 |
public Type[] getGenericParameterTypes() { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
278 |
if (hasGenericInformation()) |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
279 |
return getGenericInfo().getParameterTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
280 |
else |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
281 |
return getParameterTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
282 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
283 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
284 |
/** |
27491
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
285 |
* Behaves like {@code getGenericParameterTypes}, but returns type |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
286 |
* information for all parameters, including synthetic parameters. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
287 |
*/ |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
288 |
Type[] getAllGenericParameterTypes() { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
289 |
final boolean genericInfo = hasGenericInformation(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
290 |
|
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
291 |
// Easy case: we don't have generic parameter information. In |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
292 |
// this case, we just return the result of |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
293 |
// getParameterTypes(). |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
294 |
if (!genericInfo) { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
295 |
return getParameterTypes(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
296 |
} else { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
297 |
final boolean realParamData = hasRealParameterData(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
298 |
final Type[] genericParamTypes = getGenericParameterTypes(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
299 |
final Type[] nonGenericParamTypes = getParameterTypes(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
300 |
final Type[] out = new Type[nonGenericParamTypes.length]; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
301 |
final Parameter[] params = getParameters(); |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
302 |
int fromidx = 0; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
303 |
// If we have real parameter data, then we use the |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
304 |
// synthetic and mandate flags to our advantage. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
305 |
if (realParamData) { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
306 |
for (int i = 0; i < out.length; i++) { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
307 |
final Parameter param = params[i]; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
308 |
if (param.isSynthetic() || param.isImplicit()) { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
309 |
// If we hit a synthetic or mandated parameter, |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
310 |
// use the non generic parameter info. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
311 |
out[i] = nonGenericParamTypes[i]; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
312 |
} else { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
313 |
// Otherwise, use the generic parameter info. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
314 |
out[i] = genericParamTypes[fromidx]; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
315 |
fromidx++; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
316 |
} |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
317 |
} |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
318 |
} else { |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
319 |
// Otherwise, use the non-generic parameter data. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
320 |
// Without method parameter reflection data, we have |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
321 |
// no way to figure out which parameters are |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
322 |
// synthetic/mandated, thus, no way to match up the |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
323 |
// indexes. |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
324 |
return genericParamTypes.length == nonGenericParamTypes.length ? |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
325 |
genericParamTypes : nonGenericParamTypes; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
326 |
} |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
327 |
return out; |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
328 |
} |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
329 |
} |
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
330 |
|
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
331 |
/** |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
332 |
* Returns an array of {@code Parameter} objects that represent |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
333 |
* all the parameters to the underlying executable represented by |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
334 |
* this object. Returns an array of length 0 if the executable |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
335 |
* has no parameters. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
336 |
* |
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
337 |
* <p>The parameters of the underlying executable do not necessarily |
15655
d9ab4d9ee4f2
8007405: Update java.lang.reflect API to replace SYNTHESIZED with MANDATED
alanb
parents:
15511
diff
changeset
|
338 |
* have unique names, or names that are legal identifiers in the |
d9ab4d9ee4f2
8007405: Update java.lang.reflect API to replace SYNTHESIZED with MANDATED
alanb
parents:
15511
diff
changeset
|
339 |
* Java programming language (JLS 3.8). |
d9ab4d9ee4f2
8007405: Update java.lang.reflect API to replace SYNTHESIZED with MANDATED
alanb
parents:
15511
diff
changeset
|
340 |
* |
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
341 |
* @throws MalformedParametersException if the class file contains |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
342 |
* a MethodParameters attribute that is improperly formatted. |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
343 |
* @return an array of {@code Parameter} objects representing all |
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
344 |
* the parameters to the executable this object represents. |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
345 |
*/ |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
346 |
public Parameter[] getParameters() { |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
347 |
// TODO: This may eventually need to be guarded by security |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
348 |
// mechanisms similar to those in Field, Method, etc. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
349 |
// |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
350 |
// Need to copy the cached array to prevent users from messing |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
351 |
// with it. Since parameters are immutable, we can |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
352 |
// shallow-copy. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
353 |
return privateGetParameters().clone(); |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
354 |
} |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
355 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
356 |
private Parameter[] synthesizeAllParams() { |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
357 |
final int realparams = getParameterCount(); |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
358 |
final Parameter[] out = new Parameter[realparams]; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
359 |
for (int i = 0; i < realparams; i++) |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
360 |
// TODO: is there a way to synthetically derive the |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
361 |
// modifiers? Probably not in the general case, since |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
362 |
// we'd have no way of knowing about them, but there |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
363 |
// may be specific cases. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
364 |
out[i] = new Parameter("arg" + i, 0, this, i); |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
365 |
return out; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
366 |
} |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
367 |
|
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
368 |
private void verifyParameters(final Parameter[] parameters) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
369 |
final int mask = Modifier.FINAL | Modifier.SYNTHETIC | Modifier.MANDATED; |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
370 |
|
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
371 |
if (getParameterTypes().length != parameters.length) |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
372 |
throw new MalformedParametersException("Wrong number of parameters in MethodParameters attribute"); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
373 |
|
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
374 |
for (Parameter parameter : parameters) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
375 |
final String name = parameter.getRealName(); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
376 |
final int mods = parameter.getModifiers(); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
377 |
|
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
378 |
if (name != null) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
379 |
if (name.isEmpty() || name.indexOf('.') != -1 || |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
380 |
name.indexOf(';') != -1 || name.indexOf('[') != -1 || |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
381 |
name.indexOf('/') != -1) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
382 |
throw new MalformedParametersException("Invalid parameter name \"" + name + "\""); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
383 |
} |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
384 |
} |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
385 |
|
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
386 |
if (mods != (mods & mask)) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
387 |
throw new MalformedParametersException("Invalid parameter modifiers"); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
388 |
} |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
389 |
} |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
390 |
} |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
391 |
|
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
392 |
private Parameter[] privateGetParameters() { |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
393 |
// Use tmp to avoid multiple writes to a volatile. |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
394 |
Parameter[] tmp = parameters; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
395 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
396 |
if (tmp == null) { |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
397 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
398 |
// Otherwise, go to the JVM to get them |
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
399 |
try { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
400 |
tmp = getParameters0(); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
401 |
} catch(IllegalArgumentException e) { |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
402 |
// Rethrow ClassFormatErrors |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
403 |
throw new MalformedParametersException("Invalid constant pool index"); |
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
404 |
} |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
405 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
406 |
// If we get back nothing, then synthesize parameters |
18775
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
407 |
if (tmp == null) { |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
408 |
hasRealParameterData = false; |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
409 |
tmp = synthesizeAllParams(); |
18775
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
410 |
} else { |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
411 |
hasRealParameterData = true; |
20506
d826dd5f8e10
8020981: Update methods of java.lang.reflect.Parameter to throw correct exceptions
emc
parents:
20482
diff
changeset
|
412 |
verifyParameters(tmp); |
18775
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
413 |
} |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
414 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
415 |
parameters = tmp; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
416 |
} |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
417 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
418 |
return tmp; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
419 |
} |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
420 |
|
18775
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
421 |
boolean hasRealParameterData() { |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
422 |
// If this somehow gets called before parameters gets |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
423 |
// initialized, force it into existence. |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
424 |
if (parameters == null) { |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
425 |
privateGetParameters(); |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
426 |
} |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
427 |
return hasRealParameterData; |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
428 |
} |
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
429 |
|
fa61a37ed42b
8016285: Add java.lang.reflect.Parameter.isNamePresent()
emc
parents:
18546
diff
changeset
|
430 |
private transient volatile boolean hasRealParameterData; |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
431 |
private transient volatile Parameter[] parameters; |
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
432 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
433 |
private native Parameter[] getParameters0(); |
21361
6e4ef4e0097f
8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents:
21316
diff
changeset
|
434 |
native byte[] getTypeAnnotationBytes0(); |
20482
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
435 |
|
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
436 |
// Needed by reflectaccess |
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
437 |
byte[] getTypeAnnotationBytes() { |
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
438 |
return getTypeAnnotationBytes0(); |
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
439 |
} |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
440 |
|
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
441 |
/** |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
442 |
* Returns an array of {@code Class} objects that represent the |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
443 |
* types of exceptions declared to be thrown by the underlying |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
444 |
* executable represented by this object. Returns an array of |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
445 |
* length 0 if the executable declares no exceptions in its {@code |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
446 |
* throws} clause. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
447 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
448 |
* @return the exception types declared as being thrown by the |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
449 |
* executable this object represents |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
450 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
451 |
public abstract Class<?>[] getExceptionTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
452 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
453 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
454 |
* Returns an array of {@code Type} objects that represent the |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
455 |
* exceptions declared to be thrown by this executable object. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
456 |
* Returns an array of length 0 if the underlying executable declares |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
457 |
* no exceptions in its {@code throws} clause. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
458 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
459 |
* <p>If an exception type is a type variable or a parameterized |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
460 |
* type, it is created. Otherwise, it is resolved. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
461 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
462 |
* @return an array of Types that represent the exception types |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
463 |
* thrown by the underlying executable |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
464 |
* @throws GenericSignatureFormatError |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
465 |
* if the generic method signature does not conform to the format |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
466 |
* specified in |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
467 |
* <cite>The Java™ Virtual Machine Specification</cite> |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
468 |
* @throws TypeNotPresentException if the underlying executable's |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
469 |
* {@code throws} clause refers to a non-existent type declaration |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
470 |
* @throws MalformedParameterizedTypeException if |
11996
19e65c956b22
7149626: (reflect) Improve javadoc of java.lang.reflect.Executable
darcy
parents:
10342
diff
changeset
|
471 |
* the underlying executable's {@code throws} clause refers to a |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
472 |
* parameterized type that cannot be instantiated for any reason |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
473 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
474 |
public Type[] getGenericExceptionTypes() { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
475 |
Type[] result; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
476 |
if (hasGenericInformation() && |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
477 |
((result = getGenericInfo().getExceptionTypes()).length > 0)) |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
478 |
return result; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
479 |
else |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
480 |
return getExceptionTypes(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
481 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
482 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
483 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
484 |
* Returns a string describing this {@code Executable}, including |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
485 |
* any type parameters. |
18546
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
17450
diff
changeset
|
486 |
* @return a string describing this {@code Executable}, including |
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
17450
diff
changeset
|
487 |
* any type parameters |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
488 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
489 |
public abstract String toGenericString(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
490 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
491 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
492 |
* Returns {@code true} if this executable was declared to take a |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
493 |
* variable number of arguments; returns {@code false} otherwise. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
494 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
495 |
* @return {@code true} if an only if this executable was declared |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
496 |
* to take a variable number of arguments. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
497 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
498 |
public boolean isVarArgs() { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
499 |
return (getModifiers() & Modifier.VARARGS) != 0; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
500 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
501 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
502 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
503 |
* Returns {@code true} if this executable is a synthetic |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
504 |
* construct; returns {@code false} otherwise. |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
505 |
* |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
506 |
* @return true if and only if this executable is a synthetic |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
507 |
* construct as defined by |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
508 |
* <cite>The Java™ Language Specification</cite>. |
14910 | 509 |
* @jls 13.1 The Form of a Binary |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
510 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
511 |
public boolean isSynthetic() { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
512 |
return Modifier.isSynthetic(getModifiers()); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
513 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
514 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
515 |
/** |
19838
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
516 |
* Returns an array of arrays of {@code Annotation}s that |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
517 |
* represent the annotations on the formal parameters, in |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
518 |
* declaration order, of the {@code Executable} represented by |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
519 |
* this object. Synthetic and mandated parameters (see |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
520 |
* explanation below), such as the outer "this" parameter to an |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
521 |
* inner class constructor will be represented in the returned |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
522 |
* array. If the executable has no parameters (meaning no formal, |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
523 |
* no synthetic, and no mandated parameters), a zero-length array |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
524 |
* will be returned. If the {@code Executable} has one or more |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
525 |
* parameters, a nested array of length zero is returned for each |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
526 |
* parameter with no annotations. The annotation objects contained |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
527 |
* in the returned arrays are serializable. The caller of this |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
528 |
* method is free to modify the returned arrays; it will have no |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
529 |
* effect on the arrays returned to other callers. |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
530 |
* |
19838
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
531 |
* A compiler may add extra parameters that are implicitly |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
532 |
* declared in source ("mandated"), as well as parameters that |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
533 |
* are neither implicitly nor explicitly declared in source |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
534 |
* ("synthetic") to the parameter list for a method. See {@link |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
535 |
* java.lang.reflect.Parameter} for more information. |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
536 |
* |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
537 |
* @see java.lang.reflect.Parameter |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
538 |
* @see java.lang.reflect.Parameter#getAnnotations |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
539 |
* @return an array of arrays that represent the annotations on |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
540 |
* the formal and implicit parameters, in declaration order, of |
e2815bcfacf0
6962494: Update documentation on Executable.getParameterAnnotations()
emc
parents:
18775
diff
changeset
|
541 |
* the executable represented by this object |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
542 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
543 |
public abstract Annotation[][] getParameterAnnotations(); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
544 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
545 |
Annotation[][] sharedGetParameterAnnotations(Class<?>[] parameterTypes, |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
546 |
byte[] parameterAnnotations) { |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
547 |
int numParameters = parameterTypes.length; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
548 |
if (parameterAnnotations == null) |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
549 |
return new Annotation[numParameters][0]; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
550 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
551 |
Annotation[][] result = parseParameterAnnotations(parameterAnnotations); |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
552 |
|
45332
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
553 |
if (result.length != numParameters && |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
554 |
handleParameterNumberMismatch(result.length, numParameters)) { |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
555 |
Annotation[][] tmp = new Annotation[result.length+1][]; |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
556 |
// Shift annotations down one to account for an implicit leading parameter |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
557 |
System.arraycopy(result, 0, tmp, 1, result.length); |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
558 |
tmp[0] = new Annotation[0]; |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
559 |
result = tmp; |
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
560 |
} |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
561 |
return result; |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
562 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
563 |
|
45332
9c9e51c44638
8074977: Constructor.getAnnotatedParameterTypes returns wrong value
darcy
parents:
42997
diff
changeset
|
564 |
abstract boolean handleParameterNumberMismatch(int resultLength, int numParameters); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
565 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
566 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
567 |
* {@inheritDoc} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
568 |
* @throws NullPointerException {@inheritDoc} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
569 |
*/ |
10342
ca0984bc9d32
7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents:
10142
diff
changeset
|
570 |
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
571 |
Objects.requireNonNull(annotationClass); |
15511
8f45487ac694
8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
15510
diff
changeset
|
572 |
return annotationClass.cast(declaredAnnotations().get(annotationClass)); |
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
573 |
} |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
574 |
|
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
575 |
/** |
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
576 |
* {@inheritDoc} |
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
577 |
* @throws NullPointerException {@inheritDoc} |
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
578 |
*/ |
15659
e575dab44ff5
8007278: Rename j.l.r.AnnotatedElement.getAnnotations(Class) to getAnnotationsByType(Class)
jfranck
parents:
15655
diff
changeset
|
579 |
@Override |
e575dab44ff5
8007278: Rename j.l.r.AnnotatedElement.getAnnotations(Class) to getAnnotationsByType(Class)
jfranck
parents:
15655
diff
changeset
|
580 |
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) { |
14676
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
581 |
Objects.requireNonNull(annotationClass); |
985410ec95e3
7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
14342
diff
changeset
|
582 |
|
21316
ca0a7cd228c9
8004912: Repeating annotations - getAnnotationsByType(Class<T>) is not working as expected for few inheritance scenarios
alundblad
parents:
20506
diff
changeset
|
583 |
return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
584 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
585 |
|
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
586 |
/** |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
587 |
* {@inheritDoc} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
588 |
*/ |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
589 |
public Annotation[] getDeclaredAnnotations() { |
15511
8f45487ac694
8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents:
15510
diff
changeset
|
590 |
return AnnotationParser.toArray(declaredAnnotations()); |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
591 |
} |
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
592 |
|
28431
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
593 |
private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
594 |
|
28431
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
595 |
private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() { |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
596 |
Map<Class<? extends Annotation>, Annotation> declAnnos; |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
597 |
if ((declAnnos = declaredAnnotations) == null) { |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
598 |
synchronized (this) { |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
599 |
if ((declAnnos = declaredAnnotations) == null) { |
50091
05979f6ba560
8202113: Reflection API is causing caller classes to leak
mchung
parents:
49273
diff
changeset
|
600 |
Executable root = (Executable)getRoot(); |
28431
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
601 |
if (root != null) { |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
602 |
declAnnos = root.declaredAnnotations(); |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
603 |
} else { |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
604 |
declAnnos = AnnotationParser.parseAnnotations( |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
605 |
getAnnotationBytes(), |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
606 |
SharedSecrets.getJavaLangAccess(). |
28431
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
607 |
getConstantPool(getDeclaringClass()), |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
608 |
getDeclaringClass() |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
609 |
); |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
610 |
} |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
611 |
declaredAnnotations = declAnnos; |
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
612 |
} |
26455
195a6f3e0cd0
8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents:
25991
diff
changeset
|
613 |
} |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
614 |
} |
28431
a5c817e7ddb5
8068736: Avoid synchronization on Executable/Field.declaredAnnotations
redestad
parents:
27491
diff
changeset
|
615 |
return declAnnos; |
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
616 |
} |
15294
df55735ea03c
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents:
14910
diff
changeset
|
617 |
|
16058
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
618 |
/** |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
619 |
* Returns an {@code AnnotatedType} object that represents the use of a type to |
17436
79483ba40c55
8013541: Revise javadoc for Executable.getAnnotatedReturnType()
jfranck
parents:
17177
diff
changeset
|
620 |
* specify the return type of the method/constructor represented by this |
16058
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
621 |
* Executable. |
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
622 |
* |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
623 |
* If this {@code Executable} object represents a constructor, the {@code |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
624 |
* AnnotatedType} object represents the type of the constructed object. |
16058
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
625 |
* |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
626 |
* If this {@code Executable} object represents a method, the {@code |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
627 |
* AnnotatedType} object represents the use of a type to specify the return |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
628 |
* type of the method. |
16058
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
629 |
* |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
630 |
* @return an object representing the return type of the method |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
631 |
* or constructor represented by this {@code Executable} |
16058
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
632 |
*/ |
5b8d8cec6280
8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents:
15659
diff
changeset
|
633 |
public abstract AnnotatedType getAnnotatedReturnType(); |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
634 |
|
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
635 |
/* Helper for subclasses of Executable. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
636 |
* |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
637 |
* Returns an AnnotatedType object that represents the use of a type to |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
638 |
* specify the return type of the method/constructor represented by this |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
639 |
* Executable. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
640 |
*/ |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
641 |
AnnotatedType getAnnotatedReturnType0(Type returnType) { |
20482
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
642 |
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(), |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
643 |
SharedSecrets.getJavaLangAccess(). |
17450
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
644 |
getConstantPool(getDeclaringClass()), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
645 |
this, |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
646 |
getDeclaringClass(), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
647 |
returnType, |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
648 |
TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN); |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
649 |
} |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
650 |
|
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
651 |
/** |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
652 |
* Returns an {@code AnnotatedType} object that represents the use of a |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
653 |
* type to specify the receiver type of the method/constructor represented |
25982
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
654 |
* by this {@code Executable} object. |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
655 |
* |
25982
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
656 |
* The receiver type of a method/constructor is available only if the |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
657 |
* method/constructor has a receiver parameter (JLS 8.4.1). If this {@code |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
658 |
* Executable} object <em>represents an instance method or represents a |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
659 |
* constructor of an inner member class</em>, and the |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
660 |
* method/constructor <em>either</em> has no receiver parameter or has a |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
661 |
* receiver parameter with no annotations on its type, then the return |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
662 |
* value is an {@code AnnotatedType} object representing an element with no |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
663 |
* annotations. |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
664 |
* |
25982
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
665 |
* If this {@code Executable} object represents a static method or |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
666 |
* represents a constructor of a top level, static member, local, or |
28864
6a1e63fb3fa9
8072843: Typo in the description of the j.l.r.Executable.getAnnotatedReceiverType
darcy
parents:
28431
diff
changeset
|
667 |
* anonymous class, then the return value is null. |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
668 |
* |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
669 |
* @return an object representing the receiver type of the method or |
25982
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
670 |
* constructor represented by this {@code Executable} or {@code null} if |
724303cf59ba
8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents:
24709
diff
changeset
|
671 |
* this {@code Executable} can not have a receiver parameter |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
672 |
*/ |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
673 |
public AnnotatedType getAnnotatedReceiverType() { |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
674 |
if (Modifier.isStatic(this.getModifiers())) |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
675 |
return null; |
20482
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
676 |
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(), |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
677 |
SharedSecrets.getJavaLangAccess(). |
17450
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
678 |
getConstantPool(getDeclaringClass()), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
679 |
this, |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
680 |
getDeclaringClass(), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
681 |
getDeclaringClass(), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
682 |
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER); |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
683 |
} |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
684 |
|
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
685 |
/** |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
686 |
* Returns an array of {@code AnnotatedType} objects that represent the use |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
687 |
* of types to specify formal parameter types of the method/constructor |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
688 |
* represented by this Executable. The order of the objects in the array |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
689 |
* corresponds to the order of the formal parameter types in the |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
690 |
* declaration of the method/constructor. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
691 |
* |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
692 |
* Returns an array of length 0 if the method/constructor declares no |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
693 |
* parameters. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
694 |
* |
18546
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
17450
diff
changeset
|
695 |
* @return an array of objects representing the types of the |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
696 |
* formal parameters of the method or constructor represented by this |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
697 |
* {@code Executable} |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
698 |
*/ |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
699 |
public AnnotatedType[] getAnnotatedParameterTypes() { |
20482
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
700 |
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(), |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
701 |
SharedSecrets.getJavaLangAccess(). |
17450
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
702 |
getConstantPool(getDeclaringClass()), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
703 |
this, |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
704 |
getDeclaringClass(), |
27491
1c0081281564
8055063: Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
emc
parents:
26455
diff
changeset
|
705 |
getAllGenericParameterTypes(), |
17450
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
706 |
TypeAnnotation.TypeAnnotationTarget.METHOD_FORMAL_PARAMETER); |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
707 |
} |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
708 |
|
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
709 |
/** |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
710 |
* Returns an array of {@code AnnotatedType} objects that represent the use |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
711 |
* of types to specify the declared exceptions of the method/constructor |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
712 |
* represented by this Executable. The order of the objects in the array |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
713 |
* corresponds to the order of the exception types in the declaration of |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
714 |
* the method/constructor. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
715 |
* |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
716 |
* Returns an array of length 0 if the method/constructor declares no |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
717 |
* exceptions. |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
718 |
* |
18546
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
17450
diff
changeset
|
719 |
* @return an array of objects representing the declared |
20481
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
720 |
* exceptions of the method or constructor represented by this {@code |
2735b307d256
8007072: Update Core Reflection for Type Annotations to match latest spec
jfranck
parents:
19838
diff
changeset
|
721 |
* Executable} |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
722 |
*/ |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
723 |
public AnnotatedType[] getAnnotatedExceptionTypes() { |
20482
6dc1f81f522c
8009719: core reflection should get type annotation data from the VM lazily
jfranck
parents:
20481
diff
changeset
|
724 |
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(), |
32834
e1dca5fe4de3
8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents:
28864
diff
changeset
|
725 |
SharedSecrets.getJavaLangAccess(). |
17450
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
726 |
getConstantPool(getDeclaringClass()), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
727 |
this, |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
728 |
getDeclaringClass(), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
729 |
getGenericExceptionTypes(), |
0f704861915e
8007073: Implement Core Reflection for Type Annotations on parameters
jfranck
parents:
17436
diff
changeset
|
730 |
TypeAnnotation.TypeAnnotationTarget.THROWS); |
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
731 |
} |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
15294
diff
changeset
|
732 |
|
10127
c85d1ec57ee7
7007535: (reflect) Please generalize Constructor and Method
darcy
parents:
diff
changeset
|
733 |
} |