< prev index next >

src/java.base/share/classes/jdk/internal/access/JavaLangInvokeAccess.java

Print this page

 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  *
 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.
 24  */
 25 
 26 package jdk.internal.access;
 27 
 28 import jdk.internal.foreign.abi.NativeEntryPoint;
 29 



 30 import java.lang.foreign.MemoryLayout;


 31 import java.lang.invoke.MethodHandle;

 32 import java.lang.invoke.MethodType;
 33 import java.lang.invoke.VarHandle;
 34 import java.lang.reflect.Constructor;
 35 import java.lang.reflect.Field;
 36 import java.nio.ByteOrder;
 37 import java.util.List;
 38 import java.util.Map;
 39 import java.util.stream.Stream;
 40 
 41 public interface JavaLangInvokeAccess {
 42     /**
 43      * Returns the declaring class for the given ResolvedMethodName.
 44      * Used by {@code StackFrameInfo}.
 45      */
 46     Class<?> getDeclaringClass(Object rmname);
 47 
 48     /**
 49      * Returns the {@code MethodType} for the given method descriptor
 50      * and class loader.
 51      * Used by {@code StackFrameInfo}.

153      * The invoker class is a hidden class which has the same
154      * defining class loader, runtime package, and protection domain
155      * as the given caller class.
156      */
157     MethodHandle reflectiveInvoker(Class<?> caller);
158 
159     /**
160      * A best-effort method that tries to find any exceptions thrown by the given method handle.
161      * @param handle the handle to check
162      * @return an array of exceptions, or {@code null}.
163      */
164     Class<?>[] exceptionTypes(MethodHandle handle);
165 
166     /**
167      * Returns a method handle that allocates an instance of the given class
168      * and then invoke the given constructor of one of its superclasses.
169      *
170      * This method should only be used by ReflectionFactory::newConstructorForSerialization.
171      */
172     MethodHandle serializableConstructor(Class<?> decl, Constructor<?> ctorToCall) throws IllegalAccessException;

















173 }

 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  *
 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.
 24  */
 25 
 26 package jdk.internal.access;
 27 
 28 import jdk.internal.foreign.abi.NativeEntryPoint;
 29 
 30 import java.lang.constant.ClassDesc;
 31 import java.lang.constant.MethodHandleDesc;
 32 import java.lang.constant.MethodTypeDesc;
 33 import java.lang.foreign.MemoryLayout;
 34 import java.lang.invoke.CallSite;
 35 import java.lang.invoke.LambdaConversionException;
 36 import java.lang.invoke.MethodHandle;
 37 import java.lang.invoke.MethodHandles;
 38 import java.lang.invoke.MethodType;
 39 import java.lang.invoke.VarHandle;
 40 import java.lang.reflect.Constructor;
 41 import java.lang.reflect.Field;
 42 import java.nio.ByteOrder;
 43 import java.util.List;
 44 import java.util.Map;
 45 import java.util.stream.Stream;
 46 
 47 public interface JavaLangInvokeAccess {
 48     /**
 49      * Returns the declaring class for the given ResolvedMethodName.
 50      * Used by {@code StackFrameInfo}.
 51      */
 52     Class<?> getDeclaringClass(Object rmname);
 53 
 54     /**
 55      * Returns the {@code MethodType} for the given method descriptor
 56      * and class loader.
 57      * Used by {@code StackFrameInfo}.

159      * The invoker class is a hidden class which has the same
160      * defining class loader, runtime package, and protection domain
161      * as the given caller class.
162      */
163     MethodHandle reflectiveInvoker(Class<?> caller);
164 
165     /**
166      * A best-effort method that tries to find any exceptions thrown by the given method handle.
167      * @param handle the handle to check
168      * @return an array of exceptions, or {@code null}.
169      */
170     Class<?>[] exceptionTypes(MethodHandle handle);
171 
172     /**
173      * Returns a method handle that allocates an instance of the given class
174      * and then invoke the given constructor of one of its superclasses.
175      *
176      * This method should only be used by ReflectionFactory::newConstructorForSerialization.
177      */
178     MethodHandle serializableConstructor(Class<?> decl, Constructor<?> ctorToCall) throws IllegalAccessException;
179 
180     record ReflectableLambdaInfo(ClassDesc quotedClass, ClassDesc funcOpClass,
181                                  MethodHandle extractOpHandle, MethodHandle opHandle) { }
182 
183     CallSite metafactoryInternal(MethodHandles.Lookup caller,
184                                                String interfaceMethodName,
185                                                MethodType factoryType,
186                                                MethodType interfaceMethodType,
187                                                MethodHandle implementation,
188                                                MethodType dynamicMethodType,
189                                                ReflectableLambdaInfo reflectableLambdaInfo) throws LambdaConversionException;
190 
191     CallSite altMetafactoryInternal(MethodHandles.Lookup caller,
192                                     String interfaceMethodName,
193                                     MethodType factoryType,
194                                     ReflectableLambdaInfo reflectableLambdaInfo,
195                                     Object... args) throws LambdaConversionException;
196 }
< prev index next >