src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java
author jlaskey
Thu, 21 Jun 2018 08:58:59 -0300
changeset 50695 36ca515343e0
parent 47216 71c04702a3d5
permissions -rw-r--r--
8203637: Fix Sources Reviewed-by: hannesw, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     1
/*
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     4
 *
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    10
 *
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    15
 * accompanied this code).
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    16
 *
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    20
 *
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    23
 * questions.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    24
 */
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    25
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    26
/*
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    27
 * This file is available under and governed by the GNU General Public
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    28
 * License version 2 only, as published by the Free Software Foundation.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    29
 * However, the following notice accompanied the original version of this
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    30
 * file, and Oracle licenses the original version of this file under the BSD
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    31
 * license:
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    32
 */
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    33
/*
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    34
   Copyright 2009-2013 Attila Szegedi
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    35
50695
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    36
   Redistribution and use in source and binary forms, with or without
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    37
   modification, are permitted provided that the following conditions are
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    38
   met:
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    39
   * Redistributions of source code must retain the above copyright
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    40
     notice, this list of conditions and the following disclaimer.
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    41
   * Redistributions in binary form must reproduce the above copyright
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    42
     notice, this list of conditions and the following disclaimer in the
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    43
     documentation and/or other materials provided with the distribution.
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    44
   * Neither the name of the copyright holder nor the names of
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    45
     contributors may be used to endorse or promote products derived from
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    46
     this software without specific prior written permission.
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    47
50695
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    48
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    49
   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    50
   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    51
   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    52
   BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    53
   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    54
   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    55
   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    56
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    57
   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36ca515343e0 8203637: Fix Sources
jlaskey
parents: 47216
diff changeset
    58
   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    59
*/
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    60
34447
ec4c069f9436 8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents: 33342
diff changeset
    61
package jdk.dynalink.beans;
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    62
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    63
import java.lang.invoke.MethodHandle;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    64
import java.lang.invoke.MethodHandles;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    65
import java.lang.invoke.MethodType;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    66
import java.lang.reflect.AccessibleObject;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    67
import java.lang.reflect.Constructor;
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
    68
import java.lang.reflect.Executable;
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    69
import java.lang.reflect.Member;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    70
import java.lang.reflect.Method;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    71
import java.lang.reflect.Modifier;
33341
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
    72
import java.security.AccessControlContext;
33331
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
    73
import java.security.AccessController;
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
    74
import java.security.PrivilegedAction;
34447
ec4c069f9436 8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents: 33342
diff changeset
    75
import jdk.dynalink.CallSiteDescriptor;
36686
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34447
diff changeset
    76
import jdk.dynalink.SecureLookupSupplier;
34447
ec4c069f9436 8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents: 33342
diff changeset
    77
import jdk.dynalink.internal.AccessControlContextFactory;
ec4c069f9436 8141338: Move jdk.internal.dynalink package to jdk.dynalink
attila
parents: 33342
diff changeset
    78
import jdk.dynalink.linker.support.Lookup;
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
    79
import jdk.internal.reflect.CallerSensitive;
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
    80
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    81
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    82
/**
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    83
 * A dynamic method bound to exactly one Java method or constructor that is caller sensitive. Since the target method is
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    84
 * caller sensitive, it doesn't cache a method handle but rather uses the passed lookup object in
33331
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
    85
 * {@link #getTarget(CallSiteDescriptor)} to unreflect a method handle from the reflective member on
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    86
 * every request.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    87
 */
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    88
class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
33341
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
    89
    private static final AccessControlContext GET_LOOKUP_CONTEXT =
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
    90
            AccessControlContextFactory.createAccessControlContext(
36686
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34447
diff changeset
    91
                    SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
33341
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
    92
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    93
    // Typed as "AccessibleObject" as it can be either a method or a constructor.
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    94
    // If we were Java8-only, we could use java.lang.reflect.Executable
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    95
    private final AccessibleObject target;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    96
    private final MethodType type;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    97
32441
8401a09d1b0d 8134939: Improve toString method of Dynalink DynamicMethod objects
attila
parents: 25865
diff changeset
    98
    CallerSensitiveDynamicMethod(final AccessibleObject target) {
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
    99
        super(getName(target));
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   100
        this.target = target;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   101
        this.type = getMethodType(target);
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   102
    }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   103
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 18841
diff changeset
   104
    private static String getName(final AccessibleObject target) {
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   105
        final Member m = (Member)target;
32441
8401a09d1b0d 8134939: Improve toString method of Dynalink DynamicMethod objects
attila
parents: 25865
diff changeset
   106
        final boolean constructor = m instanceof Constructor;
8401a09d1b0d 8134939: Improve toString method of Dynalink DynamicMethod objects
attila
parents: 25865
diff changeset
   107
        return getMethodNameWithSignature(getMethodType(target), constructor ? m.getName() :
8401a09d1b0d 8134939: Improve toString method of Dynalink DynamicMethod objects
attila
parents: 25865
diff changeset
   108
            getClassAndMethodName(m.getDeclaringClass(), m.getName()), !constructor);
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   109
    }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   110
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   111
    @Override
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   112
    MethodType getMethodType() {
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   113
        return type;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   114
    }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   115
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 18841
diff changeset
   116
    private static MethodType getMethodType(final AccessibleObject ao) {
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   117
        final boolean isMethod = ao instanceof Method;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   118
        final Class<?> rtype = isMethod ? ((Method)ao).getReturnType() : ((Constructor<?>)ao).getDeclaringClass();
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   119
        final Class<?>[] ptypes = isMethod ? ((Method)ao).getParameterTypes() : ((Constructor<?>)ao).getParameterTypes();
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   120
        final MethodType type = MethodType.methodType(rtype, ptypes);
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   121
        final Member m = (Member)ao;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   122
        return type.insertParameterTypes(0,
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   123
                isMethod ?
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   124
                        Modifier.isStatic(m.getModifiers()) ?
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   125
                                Object.class :
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   126
                                m.getDeclaringClass() :
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   127
                        StaticClass.class);
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   128
    }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   129
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   130
    @Override
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   131
    boolean isVarArgs() {
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   132
        return target instanceof Method ? ((Method)target).isVarArgs() : ((Constructor<?>)target).isVarArgs();
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   133
    }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   134
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   135
    @Override
33331
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
   136
    MethodHandle getTarget(final CallSiteDescriptor desc) {
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
   137
        final MethodHandles.Lookup lookup = AccessController.doPrivileged(
33341
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
   138
                (PrivilegedAction<MethodHandles.Lookup>)()->desc.getLookup(),
cc9fa3638714 8139905: Add a convenience AccessControlContext factory
attila
parents: 33337
diff changeset
   139
                GET_LOOKUP_CONTEXT);
33331
273e6a10de22 8139435: Make sure CallSiteDescriptor.getLookup is subject to a security check
attila
parents: 33007
diff changeset
   140
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   141
        if(target instanceof Method) {
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   142
            final MethodHandle mh = unreflect(lookup, (Method)target);
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   143
            if(Modifier.isStatic(((Member)target).getModifiers())) {
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   144
                return StaticClassIntrospector.editStaticMethodHandle(mh);
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   145
            }
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   146
            return mh;
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   147
        }
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   148
        return StaticClassIntrospector.editConstructorMethodHandle(unreflectConstructor(lookup,
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   149
                (Constructor<?>)target));
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   150
    }
25252
e8bfc909db53 8043232: Index selection of overloaded java new constructors
sundar
parents: 24778
diff changeset
   151
e8bfc909db53 8043232: Index selection of overloaded java new constructors
sundar
parents: 24778
diff changeset
   152
    @Override
e8bfc909db53 8043232: Index selection of overloaded java new constructors
sundar
parents: 24778
diff changeset
   153
    boolean isConstructor() {
e8bfc909db53 8043232: Index selection of overloaded java new constructors
sundar
parents: 24778
diff changeset
   154
        return target instanceof Constructor;
e8bfc909db53 8043232: Index selection of overloaded java new constructors
sundar
parents: 24778
diff changeset
   155
    }
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   156
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   157
    private static MethodHandle unreflect(final MethodHandles.Lookup lookup, final Method m) {
41502
5772044e1a21 8167614: Avoid module dependency from jdk.dynalink to jdk.internal.module of java.base module
sundar
parents: 38491
diff changeset
   158
        return Lookup.unreflect(lookup, m);
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   159
    }
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   160
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   161
    private static MethodHandle unreflectConstructor(final MethodHandles.Lookup lookup, final Constructor<?> c) {
41502
5772044e1a21 8167614: Avoid module dependency from jdk.dynalink to jdk.internal.module of java.base module
sundar
parents: 38491
diff changeset
   162
        return Lookup.unreflectConstructor(lookup, c);
38491
777ad2adf246 8157310: jdk.dynalink.linker.support.Lookup should have more checks before adding module read link
sundar
parents: 36692
diff changeset
   163
    }
18841
9bbc4b8832b2 8010946: AccessControl.doPrivileged is broken when called from js script
attila
parents:
diff changeset
   164
}