Path: blob/aarch64-shenandoah-jdk8u272-b10/nashorn/src/jdk/internal/dynalink/CallSiteDescriptor.java
48580 views
/*1* Copyright (c) 2010, 2013, 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*/2425/*26* This file is available under and governed by the GNU General Public27* License version 2 only, as published by the Free Software Foundation.28* However, the following notice accompanied the original version of this29* file, and Oracle licenses the original version of this file under the BSD30* license:31*/32/*33Copyright 2009-2013 Attila Szegedi3435Licensed under both the Apache License, Version 2.0 (the "Apache License")36and the BSD License (the "BSD License"), with licensee being free to37choose either of the two at their discretion.3839You may not use this file except in compliance with either the Apache40License or the BSD License.4142If you choose to use this file in compliance with the Apache License, the43following notice applies to you:4445You may obtain a copy of the Apache License at4647http://www.apache.org/licenses/LICENSE-2.04849Unless required by applicable law or agreed to in writing, software50distributed under the License is distributed on an "AS IS" BASIS,51WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or52implied. See the License for the specific language governing53permissions and limitations under the License.5455If you choose to use this file in compliance with the BSD License, the56following notice applies to you:5758Redistribution and use in source and binary forms, with or without59modification, are permitted provided that the following conditions are60met:61* Redistributions of source code must retain the above copyright62notice, this list of conditions and the following disclaimer.63* Redistributions in binary form must reproduce the above copyright64notice, this list of conditions and the following disclaimer in the65documentation and/or other materials provided with the distribution.66* Neither the name of the copyright holder nor the names of67contributors may be used to endorse or promote products derived from68this software without specific prior written permission.6970THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS71IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED72TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A73PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER74BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR75CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF76SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR77BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,78WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR79OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF80ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.81*/8283package jdk.internal.dynalink;8485import java.lang.invoke.MethodHandles.Lookup;86import java.lang.invoke.MethodType;87import jdk.internal.dynalink.support.CallSiteDescriptorFactory;8889/**90* An immutable descriptor of a call site. It is an immutable object that contains all the information about a call91* site: the class performing the lookups, the name of the method being invoked, and the method signature. The library92* has a default {@link CallSiteDescriptorFactory} for descriptors that you can use, or you can create your own93* descriptor classes, especially if you need to add further information (values passed in additional parameters to the94* bootstrap method) to them. Call site descriptors are used in this library in place of passing a real call site to95* guarding linkers so they aren't tempted to directly manipulate the call sites. The constructors of built-in96* {@link RelinkableCallSite} implementations all need a call site descriptor. Even if you create your own call site97* descriptors consider using {@link CallSiteDescriptorFactory#tokenizeName(String)} in your implementation.98*99* @author Attila Szegedi100*/101public interface CallSiteDescriptor {102/**103* The index of the name token that will carry the operation scheme prefix (usually, "dyn").104*/105public static final int SCHEME = 0;106/**107* The index of the name token that will usually carry the operation name.108*/109110public static final int OPERATOR=1;111/**112* The index of the name token that will usually carry a name of an operand (of a property, method, etc.)113*/114115public static final int NAME_OPERAND=2;116117/**118* Character used to delimit tokens in an call site name.119*/120public static final String TOKEN_DELIMITER = ":";121122/**123* Character used to delimit operation names in a composite operation specification.124*/125public static final String OPERATOR_DELIMITER = "|";126127/**128* Returns the number of tokens in the name of the method at the call site. Method names are tokenized with the129* colon ":" character, i.e. "dyn:getProp:color" would be the name used to describe a method that retrieves the130* property named "color" on the object it is invoked on.131* @return the number of tokens in the name of the method at the call site.132*/133public int getNameTokenCount();134135/**136* Returns the <i>i<sup>th</sup></i> token in the method name at the call site. Method names are tokenized with the137* colon ":" character.138* @param i the index of the token. Must be between 0 (inclusive) and {@link #getNameTokenCount()} (exclusive)139* @throws IllegalArgumentException if the index is outside the allowed range.140* @return the <i>i<sup>th</sup></i> token in the method name at the call site. The returned strings are interned.141*/142public String getNameToken(int i);143144/**145* Returns the name of the method at the call site. Note that the object internally only stores the tokenized name,146* and has to reconstruct the full name from tokens on each invocation.147* @return the name of the method at the call site.148*/149public String getName();150151/**152* The type of the method at the call site.153*154* @return type of the method at the call site.155*/156public MethodType getMethodType();157158/**159* Returns the lookup passed to the bootstrap method.160* @return the lookup passed to the bootstrap method.161*/162public Lookup getLookup();163164/**165* Creates a new call site descriptor from this descriptor, which is identical to this, except it changes the method166* type.167*168* @param newMethodType the new method type169* @return a new call site descriptor, with the method type changed.170*/171public CallSiteDescriptor changeMethodType(MethodType newMethodType);172173}174175176