nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java
author stuefe
Mon, 13 Mar 2017 21:46:37 -0400
changeset 44319 8c42183dbd04
parent 36686 a351eacd4c42
permissions -rw-r--r--
8176442: [aix] assert(_thr_current == 0L) failed: Thread::current already initialized Summary: Revert Thread::current() back to pthread library based TLS on AIX. Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34979
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     1
/*
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     4
 *
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    10
 *
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    15
 * accompanied this code).
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    16
 *
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    20
 *
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    23
 * questions.
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    24
 */
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    25
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    26
package jdk.dynalink.beans;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    27
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    28
import java.lang.invoke.MethodHandle;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    29
import java.lang.invoke.MethodType;
36686
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    30
import java.util.function.Supplier;
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    31
import jdk.dynalink.SecureLookupSupplier;
34979
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    32
import jdk.dynalink.linker.ConversionComparator.Comparison;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    33
import jdk.dynalink.linker.GuardedInvocation;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    34
import jdk.dynalink.linker.LinkRequest;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    35
import jdk.dynalink.linker.LinkerServices;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    36
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    37
final class LinkerServicesWithMissingMemberHandlerFactory implements LinkerServices {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    38
    final LinkerServices linkerServices;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    39
    final MissingMemberHandlerFactory missingMemberHandlerFactory;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    40
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    41
    static LinkerServices get(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    42
        if (missingMemberHandlerFactory == null) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    43
            return linkerServices;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    44
        }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    45
        return new LinkerServicesWithMissingMemberHandlerFactory(linkerServices, missingMemberHandlerFactory);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    46
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    47
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    48
    private LinkerServicesWithMissingMemberHandlerFactory(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    49
        this.linkerServices = linkerServices;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    50
        this.missingMemberHandlerFactory = missingMemberHandlerFactory;
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    51
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    52
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    53
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    54
    public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    55
        return linkerServices.asType(handle, fromType);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    56
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    57
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    58
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    59
    public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    60
        return linkerServices.getTypeConverter(sourceType, targetType);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    61
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    62
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    63
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    64
    public boolean canConvert(final Class<?> from, final Class<?> to) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    65
        return linkerServices.canConvert(from, to);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    66
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    67
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    68
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    69
    public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest) throws Exception {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    70
        return linkerServices.getGuardedInvocation(linkRequest);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    71
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    72
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    73
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    74
    public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    75
        return linkerServices.compareConversion(sourceType, targetType1, targetType2);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    76
    }
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    77
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    78
    @Override
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    79
    public MethodHandle filterInternalObjects(final MethodHandle target) {
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    80
        return linkerServices.filterInternalObjects(target);
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    81
    }
36686
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    82
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    83
    @Override
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    84
    public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    85
        return linkerServices.getWithLookup(operation, lookupSupplier);
a351eacd4c42 8150218: Autoconversion SAM adapters sometimes don't get privileges
attila
parents: 34979
diff changeset
    86
    }
34979
03b189baa361 8144919: Implement missing member handler for BeansLinker
attila
parents:
diff changeset
    87
}