author | mchung |
Tue, 23 Jul 2019 20:03:03 -0700 | |
changeset 57503 | 042dfb697624 |
parent 52020 | src/java.base/share/classes/jdk/internal/reflect/LangReflectAccess.java@4c247dde38ed |
permissions | -rw-r--r-- |
2 | 1 |
/* |
57503
042dfb697624
8219774: Reexamine the initialization of LangReflectAccess shared secret at AccessibleObject::<clinit>
mchung
parents:
52020
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
57503
042dfb697624
8219774: Reexamine the initialization of LangReflectAccess shared secret at AccessibleObject::<clinit>
mchung
parents:
52020
diff
changeset
|
26 |
package jdk.internal.access; |
2 | 27 |
|
28 |
import java.lang.reflect.*; |
|
57503
042dfb697624
8219774: Reexamine the initialization of LangReflectAccess shared secret at AccessibleObject::<clinit>
mchung
parents:
52020
diff
changeset
|
29 |
import jdk.internal.reflect.*; |
2 | 30 |
|
31 |
/** An interface which gives privileged packages Java-level access to |
|
32 |
internals of java.lang.reflect. */ |
|
33 |
||
57503
042dfb697624
8219774: Reexamine the initialization of LangReflectAccess shared secret at AccessibleObject::<clinit>
mchung
parents:
52020
diff
changeset
|
34 |
public interface JavaLangReflectAccess { |
2 | 35 |
/** Creates a new java.lang.reflect.Constructor. Access checks as |
36 |
per java.lang.reflect.AccessibleObject are not overridden. */ |
|
37 |
public <T> Constructor<T> newConstructor(Class<T> declaringClass, |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
38 |
Class<?>[] parameterTypes, |
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
39 |
Class<?>[] checkedExceptions, |
2 | 40 |
int modifiers, |
41 |
int slot, |
|
42 |
String signature, |
|
43 |
byte[] annotations, |
|
44 |
byte[] parameterAnnotations); |
|
45 |
||
46 |
/** Gets the MethodAccessor object for a java.lang.reflect.Method */ |
|
47 |
public MethodAccessor getMethodAccessor(Method m); |
|
48 |
||
49 |
/** Sets the MethodAccessor object for a java.lang.reflect.Method */ |
|
50 |
public void setMethodAccessor(Method m, MethodAccessor accessor); |
|
51 |
||
52 |
/** Gets the ConstructorAccessor object for a |
|
53 |
java.lang.reflect.Constructor */ |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
54 |
public ConstructorAccessor getConstructorAccessor(Constructor<?> c); |
2 | 55 |
|
56 |
/** Sets the ConstructorAccessor object for a |
|
57 |
java.lang.reflect.Constructor */ |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
58 |
public void setConstructorAccessor(Constructor<?> c, |
2 | 59 |
ConstructorAccessor accessor); |
60 |
||
15510
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
5506
diff
changeset
|
61 |
/** Gets the byte[] that encodes TypeAnnotations on an Executable. */ |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
5506
diff
changeset
|
62 |
public byte[] getExecutableTypeAnnotationBytes(Executable ex); |
898d924a7efd
8004698: Implement Core Reflection for Type Annotations
jfranck
parents:
5506
diff
changeset
|
63 |
|
2 | 64 |
/** Gets the "slot" field from a Constructor (used for serialization) */ |
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
65 |
public int getConstructorSlot(Constructor<?> c); |
2 | 66 |
|
67 |
/** Gets the "signature" field from a Constructor (used for serialization) */ |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
68 |
public String getConstructorSignature(Constructor<?> c); |
2 | 69 |
|
70 |
/** Gets the "annotations" field from a Constructor (used for serialization) */ |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
71 |
public byte[] getConstructorAnnotations(Constructor<?> c); |
2 | 72 |
|
73 |
/** Gets the "parameterAnnotations" field from a Constructor (used for serialization) */ |
|
3959
05a07c0a273b
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents:
2
diff
changeset
|
74 |
public byte[] getConstructorParameterAnnotations(Constructor<?> c); |
2 | 75 |
|
42997
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
76 |
/** Gets the shared array of parameter types of an Executable. */ |
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
77 |
public Class<?>[] getExecutableSharedParameterTypes(Executable ex); |
5f83f2054eca
8172190: Re-apply the fix for bugs 8062389, 8029459, 8061950
plevart
parents:
42948
diff
changeset
|
78 |
|
2 | 79 |
// |
80 |
// Copying routines, needed to quickly fabricate new Field, |
|
81 |
// Method, and Constructor objects from templates |
|
82 |
// |
|
83 |
||
84 |
/** Makes a "child" copy of a Method */ |
|
85 |
public Method copyMethod(Method arg); |
|
86 |
||
32268
9fe7ee60d49d
8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents:
25859
diff
changeset
|
87 |
/** Makes a copy of this non-root a Method */ |
9fe7ee60d49d
8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents:
25859
diff
changeset
|
88 |
public Method leafCopyMethod(Method arg); |
9fe7ee60d49d
8073056: Repeating annotations throws java.security.AccessControlException with a SecurityManager
jfranck
parents:
25859
diff
changeset
|
89 |
|
2 | 90 |
/** Makes a "child" copy of a Field */ |
91 |
public Field copyField(Field arg); |
|
92 |
||
93 |
/** Makes a "child" copy of a Constructor */ |
|
94 |
public <T> Constructor<T> copyConstructor(Constructor<T> arg); |
|
50091
05979f6ba560
8202113: Reflection API is causing caller classes to leak
mchung
parents:
47216
diff
changeset
|
95 |
|
05979f6ba560
8202113: Reflection API is causing caller classes to leak
mchung
parents:
47216
diff
changeset
|
96 |
/** Gets the root of the given AccessibleObject object; null if arg is the root */ |
05979f6ba560
8202113: Reflection API is causing caller classes to leak
mchung
parents:
47216
diff
changeset
|
97 |
public <T extends AccessibleObject> T getRoot(T obj); |
52020
4c247dde38ed
8206240: java.lang.Class.newInstance() is causing caller to leak
mchung
parents:
50091
diff
changeset
|
98 |
|
4c247dde38ed
8206240: java.lang.Class.newInstance() is causing caller to leak
mchung
parents:
50091
diff
changeset
|
99 |
/** Returns a new instance created by the given constructor with access check */ |
4c247dde38ed
8206240: java.lang.Class.newInstance() is causing caller to leak
mchung
parents:
50091
diff
changeset
|
100 |
public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller) |
4c247dde38ed
8206240: java.lang.Class.newInstance() is causing caller to leak
mchung
parents:
50091
diff
changeset
|
101 |
throws IllegalAccessException, InstantiationException, InvocationTargetException; |
2 | 102 |
} |