Path: blob/master/src/java.base/share/classes/jdk/internal/access/JavaLangReflectAccess.java
41159 views
/*1* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package jdk.internal.access;2627import java.lang.reflect.*;28import jdk.internal.reflect.*;2930/** An interface which gives privileged packages Java-level access to31internals of java.lang.reflect. */3233public interface JavaLangReflectAccess {34/** Creates a new java.lang.reflect.Constructor. Access checks as35per java.lang.reflect.AccessibleObject are not overridden. */36public <T> Constructor<T> newConstructor(Class<T> declaringClass,37Class<?>[] parameterTypes,38Class<?>[] checkedExceptions,39int modifiers,40int slot,41String signature,42byte[] annotations,43byte[] parameterAnnotations);4445/** Gets the MethodAccessor object for a java.lang.reflect.Method */46public MethodAccessor getMethodAccessor(Method m);4748/** Sets the MethodAccessor object for a java.lang.reflect.Method */49public void setMethodAccessor(Method m, MethodAccessor accessor);5051/** Gets the ConstructorAccessor object for a52java.lang.reflect.Constructor */53public ConstructorAccessor getConstructorAccessor(Constructor<?> c);5455/** Sets the ConstructorAccessor object for a56java.lang.reflect.Constructor */57public void setConstructorAccessor(Constructor<?> c,58ConstructorAccessor accessor);5960/** Gets the byte[] that encodes TypeAnnotations on an Executable. */61public byte[] getExecutableTypeAnnotationBytes(Executable ex);6263/** Gets the "slot" field from a Constructor (used for serialization) */64public int getConstructorSlot(Constructor<?> c);6566/** Gets the "signature" field from a Constructor (used for serialization) */67public String getConstructorSignature(Constructor<?> c);6869/** Gets the "annotations" field from a Constructor (used for serialization) */70public byte[] getConstructorAnnotations(Constructor<?> c);7172/** Gets the "parameterAnnotations" field from a Constructor (used for serialization) */73public byte[] getConstructorParameterAnnotations(Constructor<?> c);7475/** Gets the shared array of parameter types of an Executable. */76public Class<?>[] getExecutableSharedParameterTypes(Executable ex);7778//79// Copying routines, needed to quickly fabricate new Field,80// Method, and Constructor objects from templates81//8283/** Makes a "child" copy of a Method */84public Method copyMethod(Method arg);8586/** Makes a copy of this non-root a Method */87public Method leafCopyMethod(Method arg);8889/** Makes a "child" copy of a Field */90public Field copyField(Field arg);9192/** Makes a "child" copy of a Constructor */93public <T> Constructor<T> copyConstructor(Constructor<T> arg);9495/** Gets the root of the given AccessibleObject object; null if arg is the root */96public <T extends AccessibleObject> T getRoot(T obj);9798/** Tests if this is a trusted final field */99public boolean isTrustedFinalField(Field f);100101/** Returns a new instance created by the given constructor with access check */102public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)103throws IllegalAccessException, InstantiationException, InvocationTargetException;104}105106107