jdk.internal.dynalink.linker.GuardingDynamicLinker Java Examples

The following examples show how to use jdk.internal.dynalink.linker.GuardingDynamicLinker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void addTypeBased(final List<GuardingDynamicLinker> llinkers,
        final List<TypeBasedGuardingDynamicLinker> tblinkers) {
    switch(tblinkers.size()) {
        case 0: {
            break;
        }
        case 1: {
            llinkers.addAll(tblinkers);
            tblinkers.clear();
            break;
        }
        default: {
            llinkers.add(new CompositeTypeBasedGuardingDynamicLinker(tblinkers));
            tblinkers.clear();
            break;
        }
    }
}
 
Example #2
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void addTypeBased(final List<GuardingDynamicLinker> llinkers,
        final List<TypeBasedGuardingDynamicLinker> tblinkers) {
    switch(tblinkers.size()) {
        case 0: {
            break;
        }
        case 1: {
            llinkers.addAll(tblinkers);
            tblinkers.clear();
            break;
        }
        default: {
            llinkers.add(new CompositeTypeBasedGuardingDynamicLinker(tblinkers));
            tblinkers.clear();
            break;
        }
    }
}
 
Example #3
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private static void addTypeBased(final List<GuardingDynamicLinker> llinkers,
        final List<TypeBasedGuardingDynamicLinker> tblinkers) {
    switch(tblinkers.size()) {
        case 0: {
            break;
        }
        case 1: {
            llinkers.addAll(tblinkers);
            tblinkers.clear();
            break;
        }
        default: {
            llinkers.add(new CompositeTypeBasedGuardingDynamicLinker(tblinkers));
            tblinkers.clear();
            break;
        }
    }
}
 
Example #4
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void addTypeBased(List<GuardingDynamicLinker> llinkers,
        List<TypeBasedGuardingDynamicLinker> tblinkers) {
    switch(tblinkers.size()) {
        case 0: {
            break;
        }
        case 1: {
            llinkers.addAll(tblinkers);
            tblinkers.clear();
            break;
        }
        default: {
            llinkers.add(new CompositeTypeBasedGuardingDynamicLinker(tblinkers));
            tblinkers.clear();
            break;
        }
    }
}
 
Example #5
Source File: NativeObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoints() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #6
Source File: CompositeGuardingDynamicLinker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #7
Source File: CompositeGuardingDynamicLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #8
Source File: NativeObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoint() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #9
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement
 * {@link TypeBasedGuardingDynamicLinker}, they will be replaced with a single instance of
 * {@link CompositeTypeBasedGuardingDynamicLinker} that contains them.
 *
 * @param linkers the list of linkers to optimize
 * @return the optimized list
 */
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
    final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        if(linker instanceof TypeBasedGuardingDynamicLinker) {
            tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
        } else {
            addTypeBased(llinkers, tblinkers);
            llinkers.add(linker);
        }
    }
    addTypeBased(llinkers, tblinkers);
    return llinkers;
}
 
Example #10
Source File: CompositeGuardingDynamicLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #11
Source File: NativeObject.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoint() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #12
Source File: CompositeGuardingDynamicLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #13
Source File: NativeObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoints() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #14
Source File: CompositeGuardingDynamicLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #15
Source File: CompositeGuardingDynamicLinker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #16
Source File: CompositeGuardingDynamicLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #17
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement
 * {@link TypeBasedGuardingDynamicLinker}, they will be replaced with a single instance of
 * {@link CompositeTypeBasedGuardingDynamicLinker} that contains them.
 *
 * @param linkers the list of linkers to optimize
 * @return the optimized list
 */
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
    final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        if(linker instanceof TypeBasedGuardingDynamicLinker) {
            tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
        } else {
            addTypeBased(llinkers, tblinkers);
            llinkers.add(linker);
        }
    }
    addTypeBased(llinkers, tblinkers);
    return llinkers;
}
 
Example #18
Source File: CompositeGuardingDynamicLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #19
Source File: CompositeGuardingDynamicLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #20
Source File: CompositeGuardingDynamicLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #21
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement
 * {@link TypeBasedGuardingDynamicLinker}, they will be replaced with a single instance of
 * {@link CompositeTypeBasedGuardingDynamicLinker} that contains them.
 *
 * @param linkers the list of linkers to optimize
 * @return the optimized list
 */
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
    final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        if(linker instanceof TypeBasedGuardingDynamicLinker) {
            tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
        } else {
            addTypeBased(llinkers, tblinkers);
            llinkers.add(linker);
        }
    }
    addTypeBased(llinkers, tblinkers);
    return llinkers;
}
 
Example #22
Source File: CompositeGuardingDynamicLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #23
Source File: NativeObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoints() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #24
Source File: NativeObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoints() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #25
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement
 * {@link TypeBasedGuardingDynamicLinker}, they will be replaced with a single instance of
 * {@link CompositeTypeBasedGuardingDynamicLinker} that contains them.
 *
 * @param linkers the list of linkers to optimize
 * @return the optimized list
 */
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
    final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        if(linker instanceof TypeBasedGuardingDynamicLinker) {
            tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
        } else {
            addTypeBased(llinkers, tblinkers);
            llinkers.add(linker);
        }
    }
    addTypeBased(llinkers, tblinkers);
    return llinkers;
}
 
Example #26
Source File: CompositeGuardingDynamicLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new composite linker.
 *
 * @param linkers a list of component linkers.
 */
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> l = new LinkedList<>();
    for(final GuardingDynamicLinker linker: linkers) {
        l.add(linker);
    }
    this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
 
Example #27
Source File: CompositeGuardingDynamicLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #28
Source File: CompositeTypeBasedGuardingDynamicLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Optimizes a list of type-based linkers. If a group of adjacent linkers in the list all implement
 * {@link TypeBasedGuardingDynamicLinker}, they will be replaced with a single instance of
 * {@link CompositeTypeBasedGuardingDynamicLinker} that contains them.
 *
 * @param linkers the list of linkers to optimize
 * @return the optimized list
 */
public static List<GuardingDynamicLinker> optimize(Iterable<? extends GuardingDynamicLinker> linkers) {
    final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
    final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
    for(GuardingDynamicLinker linker: linkers) {
        if(linker instanceof TypeBasedGuardingDynamicLinker) {
            tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
        } else {
            addTypeBased(llinkers, tblinkers);
            llinkers.add(linker);
        }
    }
    addTypeBased(llinkers, tblinkers);
    return llinkers;
}
 
Example #29
Source File: NativeObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle getBeanOperation(final GuardingDynamicLinker linker, final String operation,
        final MethodType methodType, final Object source) {
    final GuardedInvocation inv;
    try {
        inv = NashornBeansLinker.getGuardedInvocation(linker, createLinkRequest(operation, methodType, source), Bootstrap.getLinkerServices());
        assert passesGuard(source, inv.getGuard());
    } catch(RuntimeException|Error e) {
        throw e;
    } catch(final Throwable t) {
        throw new RuntimeException(t);
    }
    assert inv.getSwitchPoints() == null; // Linkers in Dynalink's beans package don't use switchpoints.
    // We discard the guard, as all method handles will be bound to a specific object.
    return inv.getInvocation();
}
 
Example #30
Source File: CompositeGuardingDynamicLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}