001/* 002 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package jdk.internal.jvmci.meta; 024 025import java.lang.invoke.*; 026 027/** 028 * Interface to access the internals of the {@link MethodHandle} implementation of the VM. An 029 * implementation of this interface is usually required to access non-public classes, methods, and 030 * fields of {@link MethodHandle}, i.e., data that is not standardized by the Java specification. 031 */ 032public interface MethodHandleAccessProvider { 033 034 /** 035 * Identification for methods defined on the class {@link MethodHandle} that are processed by 036 * the {@link MethodHandleAccessProvider}. 037 */ 038 public enum IntrinsicMethod { 039 /** The method {@code MethodHandle.invokeBasic}. */ 040 INVOKE_BASIC, 041 /** The method {@code MethodHandle.linkToStatic}. */ 042 LINK_TO_STATIC, 043 /** The method {@code MethodHandle.linkToSpecial}. */ 044 LINK_TO_SPECIAL, 045 /** The method {@code MethodHandle.linkToVirtual}. */ 046 LINK_TO_VIRTUAL, 047 /** The method {@code MethodHandle.linkToInterface}. */ 048 LINK_TO_INTERFACE 049 } 050 051 /** 052 * Returns the method handle method intrinsic identifier for the provided method, or 053 * {@code null} if the method is not an intrinsic processed by this interface. 054 */ 055 IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method); 056 057 /** 058 * Resolves the invocation target for an invocation of {@link IntrinsicMethod#INVOKE_BASIC 059 * MethodHandle.invokeBasic} with the given constant receiver {@link MethodHandle}. Returns 060 * {@code null} if the invocation target is not available at this time. 061 * <p> 062 * The first invocations of a method handle can use an interpreter to lookup the actual invoked 063 * method; frequently executed method handles can use Java bytecode generation to avoid the 064 * interpreter overhead. If the parameter forceBytecodeGeneration is set to true, the VM should 065 * try to generate bytecodes before this method returns. 066 */ 067 ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration); 068 069 /** 070 * Resolves the invocation target for an invocation of a {@code MethodHandle.linkTo*} method 071 * with the given constant member name. The member name is the last parameter of the 072 * {@code linkTo*} method. Returns {@code null} if the invocation target is not available at 073 * this time. 074 */ 075 ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName); 076}