jdk/src/share/classes/java/dyn/ConstantCallSite.java
author jrose
Wed, 08 Sep 2010 18:40:23 -0700
changeset 7052 963a5baf2ba3
parent 7051 1c545d70a157
child 7555 a279ebc3b25c
permissions -rw-r--r--
6980096: JSR 292 reflective lookup should throw checked exceptions Summary: Make NoAccessException be a checked exception. Also remove JavaMethodHandle. Reviewed-by: twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7051
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     1
/*
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     4
 *
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    10
 *
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    15
 * accompanied this code).
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    16
 *
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    20
 *
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    23
 * questions.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    24
 */
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    25
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    26
package java.dyn;
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    27
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    28
/**
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    29
 * A {@code ConstantCallSite} is a {@link CallSite} whose target is permanent, and can never be changed.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    30
 * The only way to relink an {@code invokedynamic} instruction bound to a {@code ConstantCallSite} is
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    31
 * to invalidate the instruction as a whole.
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    32
 * @author John Rose, JSR 292 EG
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    33
 */
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    34
public class ConstantCallSite extends CallSite {
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    35
    /** Create a call site with a permanent target. */
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    36
    public ConstantCallSite(MethodHandle target) {
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    37
        super(target);
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    38
    }
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    39
    /** Throw an {@link IllegalArgumentException}, because this kind of call site cannot change its target. */
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    40
    @Override public final void setTarget(MethodHandle ignore) {
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    41
        throw new IllegalArgumentException("ConstantCallSite");
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    42
    }
1c545d70a157 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
diff changeset
    43
}