Path: blob/master/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java
41161 views
/*1* Copyright (c) 2015, 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*/2425package jdk.dynalink.beans;2627import java.lang.invoke.MethodHandle;28import java.lang.invoke.MethodType;29import java.util.function.Supplier;30import jdk.dynalink.SecureLookupSupplier;31import jdk.dynalink.linker.ConversionComparator.Comparison;32import jdk.dynalink.linker.GuardedInvocation;33import jdk.dynalink.linker.LinkRequest;34import jdk.dynalink.linker.LinkerServices;3536final class LinkerServicesWithMissingMemberHandlerFactory implements LinkerServices {37final LinkerServices linkerServices;38final MissingMemberHandlerFactory missingMemberHandlerFactory;3940static LinkerServices get(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) {41if (missingMemberHandlerFactory == null) {42return linkerServices;43}44return new LinkerServicesWithMissingMemberHandlerFactory(linkerServices, missingMemberHandlerFactory);45}4647private LinkerServicesWithMissingMemberHandlerFactory(final LinkerServices linkerServices, final MissingMemberHandlerFactory missingMemberHandlerFactory) {48this.linkerServices = linkerServices;49this.missingMemberHandlerFactory = missingMemberHandlerFactory;50}5152@Override53public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {54return linkerServices.asType(handle, fromType);55}5657@Override58public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {59return linkerServices.getTypeConverter(sourceType, targetType);60}6162@Override63public boolean canConvert(final Class<?> from, final Class<?> to) {64return linkerServices.canConvert(from, to);65}6667@Override68public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest) throws Exception {69return linkerServices.getGuardedInvocation(linkRequest);70}7172@Override73public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {74return linkerServices.compareConversion(sourceType, targetType1, targetType2);75}7677@Override78public MethodHandle filterInternalObjects(final MethodHandle target) {79return linkerServices.filterInternalObjects(target);80}8182@Override83public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {84return linkerServices.getWithLookup(operation, lookupSupplier);85}86}878889