jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker Java Examples
The following examples show how to use
jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker.
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 |
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 hottub with GNU General Public License v2.0 | 6 votes |
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 openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override protected List<TypeBasedGuardingDynamicLinker> computeValue(Class<?> clazz) { List<TypeBasedGuardingDynamicLinker> list = NO_LINKER; for(int i = 0; i < linkers.length; ++i) { final TypeBasedGuardingDynamicLinker linker = linkers[i]; if(linker.canLinkType(clazz)) { switch(list.size()) { case 0: { list = singletonLinkers[i]; break; } case 1: { list = new LinkedList<>(list); } //$FALL-THROUGH$ default: { list.add(linker); } } } } return list; }
Example #4
Source File: CompositeTypeBasedGuardingDynamicLinker.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("fallthrough") @Override protected List<TypeBasedGuardingDynamicLinker> computeValue(final Class<?> clazz) { List<TypeBasedGuardingDynamicLinker> list = NO_LINKER; for(int i = 0; i < linkers.length; ++i) { final TypeBasedGuardingDynamicLinker linker = linkers[i]; if(linker.canLinkType(clazz)) { switch(list.size()) { case 0: { list = singletonLinkers[i]; break; } case 1: { list = new LinkedList<>(list); } default: { list.add(linker); } } } } return list; }
Example #5
Source File: CompositeTypeBasedGuardingDynamicLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: CompositeTypeBasedGuardingDynamicLinker.java From hottub with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("fallthrough") @Override protected List<TypeBasedGuardingDynamicLinker> computeValue(final Class<?> clazz) { List<TypeBasedGuardingDynamicLinker> list = NO_LINKER; for(int i = 0; i < linkers.length; ++i) { final TypeBasedGuardingDynamicLinker linker = linkers[i]; if(linker.canLinkType(clazz)) { switch(list.size()) { case 0: { list = singletonLinkers[i]; break; } case 1: { list = new LinkedList<>(list); } default: { list.add(linker); } } } } return list; }
Example #7
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: CompositeTypeBasedGuardingDynamicLinker.java From nashorn with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override protected List<TypeBasedGuardingDynamicLinker> computeValue(Class<?> clazz) { List<TypeBasedGuardingDynamicLinker> list = NO_LINKER; for(int i = 0; i < linkers.length; ++i) { final TypeBasedGuardingDynamicLinker linker = linkers[i]; if(linker.canLinkType(clazz)) { switch(list.size()) { case 0: { list = singletonLinkers[i]; break; } case 1: { list = new LinkedList<>(list); } //$FALL-THROUGH$ default: { list.add(linker); } } } } return list; }
Example #10
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 #12
Source File: CompositeTypeBasedGuardingDynamicLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("fallthrough") @Override protected List<TypeBasedGuardingDynamicLinker> computeValue(final Class<?> clazz) { List<TypeBasedGuardingDynamicLinker> list = NO_LINKER; for(int i = 0; i < linkers.length; ++i) { final TypeBasedGuardingDynamicLinker linker = linkers[i]; if(linker.canLinkType(clazz)) { switch(list.size()) { case 0: { list = singletonLinkers[i]; break; } case 1: { list = new LinkedList<>(list); } default: { list.add(linker); } } } } return list; }
Example #13
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") ClassToLinker(TypeBasedGuardingDynamicLinker[] linkers) { this.linkers = linkers; singletonLinkers = new List[linkers.length]; for(int i = 0; i < linkers.length; ++i) { singletonLinkers[i] = Collections.singletonList(linkers[i]); } }
Example #14
Source File: BeansLinker.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all instance methods of a class. * @param clazz the class * @return a collection of names of all instance methods of a class. */ public static Collection<String> getInstanceMethodNames(Class<?> clazz) { TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getMethodNames(); } return Collections.emptySet(); }
Example #15
Source File: BeansLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all readable instance properties of a class. * @param clazz the class * @return a collection of names of all readable instance properties of a class. */ public static Collection<String> getReadableInstancePropertyNames(final Class<?> clazz) { final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getReadablePropertyNames(); } return Collections.emptySet(); }
Example #16
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final Object obj = linkRequest.getReceiver(); if(obj == null) { return null; } for(TypeBasedGuardingDynamicLinker linker: classToLinker.get(obj.getClass())) { final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices); if(invocation != null) { return invocation; } } return null; }
Example #17
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a new composite type-based linker. * * @param linkers the component linkers */ public CompositeTypeBasedGuardingDynamicLinker(Iterable<? extends TypeBasedGuardingDynamicLinker> linkers) { final List<TypeBasedGuardingDynamicLinker> l = new LinkedList<>(); for(TypeBasedGuardingDynamicLinker linker: linkers) { l.add(linker); } this.classToLinker = new ClassToLinker(l.toArray(new TypeBasedGuardingDynamicLinker[l.size()])); }
Example #18
Source File: CompositeTypeBasedGuardingDynamicLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers) { this.linkers = linkers; singletonLinkers = new List[linkers.length]; for(int i = 0; i < linkers.length; ++i) { singletonLinkers[i] = Collections.singletonList(linkers[i]); } }
Example #19
Source File: BeansLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected TypeBasedGuardingDynamicLinker computeValue(final Class<?> clazz) { // If ClassValue.put() were public, we could just pre-populate with these known mappings... return clazz == Class.class ? new ClassLinker() : clazz == StaticClass.class ? new StaticClassLinker() : DynamicMethod.class.isAssignableFrom(clazz) ? new DynamicMethodLinker() : new BeanLinker(clazz); }
Example #20
Source File: BeansLinker.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all instance methods of a class. * @param clazz the class * @return a collection of names of all instance methods of a class. */ public static Collection<String> getInstanceMethodNames(Class<?> clazz) { TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getMethodNames(); } return Collections.emptySet(); }
Example #21
Source File: CompositeTypeBasedGuardingDynamicLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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: CompositeTypeBasedGuardingDynamicLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final Object obj = linkRequest.getReceiver(); if(obj == null) { return null; } for(final TypeBasedGuardingDynamicLinker linker: classToLinker.get(obj.getClass())) { final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices); if(invocation != null) { return invocation; } } return null; }
Example #23
Source File: CompositeTypeBasedGuardingDynamicLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Creates a new composite type-based linker. * * @param linkers the component linkers */ public CompositeTypeBasedGuardingDynamicLinker(final Iterable<? extends TypeBasedGuardingDynamicLinker> linkers) { final List<TypeBasedGuardingDynamicLinker> l = new LinkedList<>(); for(final TypeBasedGuardingDynamicLinker linker: linkers) { l.add(linker); } this.classToLinker = new ClassToLinker(l.toArray(new TypeBasedGuardingDynamicLinker[l.size()])); }
Example #24
Source File: CompositeTypeBasedGuardingDynamicLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers) { this.linkers = linkers; singletonLinkers = new List[linkers.length]; for(int i = 0; i < linkers.length; ++i) { singletonLinkers[i] = Collections.singletonList(linkers[i]); } }
Example #25
Source File: BeansLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all instance methods of a class. * @param clazz the class * @return a collection of names of all instance methods of a class. */ public static Collection<String> getInstanceMethodNames(final Class<?> clazz) { final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getMethodNames(); } return Collections.emptySet(); }
Example #26
Source File: BeansLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all writable instance properties of a class. * @param clazz the class * @return a collection of names of all writable instance properties of a class. */ public static Collection<String> getWritableInstancePropertyNames(final Class<?> clazz) { final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getWritablePropertyNames(); } return Collections.emptySet(); }
Example #27
Source File: BeansLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of names of all readable instance properties of a class. * @param clazz the class * @return a collection of names of all readable instance properties of a class. */ public static Collection<String> getReadableInstancePropertyNames(final Class<?> clazz) { final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz); if(linker instanceof BeanLinker) { return ((BeanLinker)linker).getReadablePropertyNames(); } return Collections.emptySet(); }
Example #28
Source File: BeansLinker.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override protected TypeBasedGuardingDynamicLinker computeValue(final Class<?> clazz) { // If ClassValue.put() were public, we could just pre-populate with these known mappings... return clazz == Class.class ? new ClassLinker() : clazz == StaticClass.class ? new StaticClassLinker() : DynamicMethod.class.isAssignableFrom(clazz) ? new DynamicMethodLinker() : new BeanLinker(clazz); }
Example #29
Source File: BeansLinker.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected TypeBasedGuardingDynamicLinker computeValue(Class<?> clazz) { // If ClassValue.put() were public, we could just pre-populate with these known mappings... return clazz == Class.class ? new ClassLinker() : clazz == StaticClass.class ? new StaticClassLinker() : DynamicMethod.class.isAssignableFrom(clazz) ? new DynamicMethodLinker() : new BeanLinker(clazz); }
Example #30
Source File: CompositeTypeBasedGuardingDynamicLinker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final Object obj = linkRequest.getReceiver(); if(obj == null) { return null; } for(final TypeBasedGuardingDynamicLinker linker: classToLinker.get(obj.getClass())) { final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices); if(invocation != null) { return invocation; } } return null; }