Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 11 jdk.scripting.nashorn.jmod - Scripting Nashorn Module
JDK 11 jdk.scripting.nashorn.jmod is the JMOD file for JDK 11 Scripting Nashorn module.
JDK 11 Scripting Nashorn module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.scripting.nashorn.jmod.
JDK 11 Scripting Nashorn module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.
JDK 11 Scripting Nashorn module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.scripting.nashorn.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java
/* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package jdk.nashorn.internal.runtime.linker; import static jdk.nashorn.internal.runtime.JSType.isString; import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_CALL; import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETMEMBER; import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETSLOT; import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETMEMBER; import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETSLOT; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.linker.GuardedInvocation; import jdk.dynalink.linker.LinkRequest; import jdk.dynalink.linker.LinkerServices; import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker; import jdk.nashorn.internal.lookup.MethodHandleFactory; import jdk.nashorn.internal.lookup.MethodHandleFunctionality; import jdk.nashorn.internal.runtime.JSType; /** * A Dynalink linker to handle web browser built-in JS (DOM etc.) objects. */ final class BrowserJSObjectLinker implements TypeBasedGuardingDynamicLinker { private static final String JSOBJECT_CLASS = "netscape.javascript.JSObject"; private static final Class<?> jsObjectClass = findBrowserJSObjectClass(); private final NashornBeansLinker nashornBeansLinker; BrowserJSObjectLinker(final NashornBeansLinker nashornBeansLinker) { this.nashornBeansLinker = nashornBeansLinker; } @Override public boolean canLinkType(final Class<?> type) { return canLinkTypeStatic(type); } static boolean canLinkTypeStatic(final Class<?> type) { return jsObjectClass != null && jsObjectClass.isAssignableFrom(type); } private static void checkJSObjectClass() { assert jsObjectClass != null : JSOBJECT_CLASS + " not found!"; } @Override public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception { final Object self = request.getReceiver(); final CallSiteDescriptor desc = request.getCallSiteDescriptor(); checkJSObjectClass(); assert jsObjectClass.isInstance(self); GuardedInvocation inv = lookup(desc, request, linkerServices); inv = inv.replaceMethods(linkerServices.filterInternalObjects(inv.getInvocation()), inv.getGuard()); return Bootstrap.asTypeSafeReturn(inv, linkerServices, desc); } private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception { GuardedInvocation inv; try { inv = nashornBeansLinker.getGuardedInvocation(request, linkerServices); } catch (final Throwable th) { inv = null; } final String name = NashornCallSiteDescriptor.getOperand(desc); switch (NashornCallSiteDescriptor.getStandardOperation(desc)) { case GET: return name != null ? findGetMethod(name, inv) : findGetIndexMethod(inv); case SET: return name != null ? findSetMethod(name, inv) : findSetIndexMethod(); case CALL: return findCallMethod(desc); default: return null; } } private static GuardedInvocation findGetMethod(final String name, final GuardedInvocation inv) { if (inv != null) { return inv; } final MethodHandle getter = MH.insertArguments(JSOBJECT_GETMEMBER, 1, name); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); } private static GuardedInvocation findGetIndexMethod(final GuardedInvocation inv) { final MethodHandle getter = MH.insertArguments(JSOBJECTLINKER_GET, 0, inv.getInvocation()); return inv.replaceMethods(getter, inv.getGuard()); } private static GuardedInvocation findSetMethod(final String name, final GuardedInvocation inv) { if (inv != null) { return inv; } final MethodHandle getter = MH.insertArguments(JSOBJECT_SETMEMBER, 1, name); return new GuardedInvocation(getter, IS_JSOBJECT_GUARD); } private static GuardedInvocation findSetIndexMethod() { return new GuardedInvocation(JSOBJECTLINKER_PUT, IS_JSOBJECT_GUARD); } private static GuardedInvocation findCallMethod(final CallSiteDescriptor desc) { final MethodHandle call = MH.insertArguments(JSOBJECT_CALL, 1, "call"); return new GuardedInvocation(MH.asCollector(call, Object[].class, desc.getMethodType().parameterCount() - 1), IS_JSOBJECT_GUARD); } @SuppressWarnings("unused") private static boolean isJSObject(final Object self) { return jsObjectClass.isInstance(self); } @SuppressWarnings("unused") private static Object get(final MethodHandle fallback, final Object jsobj, final Object key) throws Throwable { if (key instanceof Integer) { return JSOBJECT_GETSLOT.invokeExact(jsobj, (int)key); } else if (key instanceof Number) { final int index = getIndex((Number)key); if (index > -1) { return JSOBJECT_GETSLOT.invokeExact(jsobj, index); } } else if (isString(key)) { final String name = key.toString(); if (name.indexOf('(') != -1) { return fallback.invokeExact(jsobj, (Object) name); } return JSOBJECT_GETMEMBER.invokeExact(jsobj, name); } return null; } @SuppressWarnings("unused") private static void put(final Object jsobj, final Object key, final Object value) throws Throwable { if (key instanceof Integer) { JSOBJECT_SETSLOT.invokeExact(jsobj, (int)key, value); } else if (key instanceof Number) { JSOBJECT_SETSLOT.invokeExact(jsobj, getIndex((Number)key), value); } else if (isString(key)) { JSOBJECT_SETMEMBER.invokeExact(jsobj, key.toString(), value); } } private static int getIndex(final Number n) { final double value = n.doubleValue(); return JSType.isRepresentableAsInt(value) ? (int)value : -1; } private static final MethodHandleFunctionality MH = MethodHandleFactory.getFunctionality(); // method handles of the current class private static final MethodHandle IS_JSOBJECT_GUARD = findOwnMH_S("isJSObject", boolean.class, Object.class); private static final MethodHandle JSOBJECTLINKER_GET = findOwnMH_S("get", Object.class, MethodHandle.class, Object.class, Object.class); private static final MethodHandle JSOBJECTLINKER_PUT = findOwnMH_S("put", Void.TYPE, Object.class, Object.class, Object.class); private static MethodHandle findOwnMH_S(final String name, final Class<?> rtype, final Class<?>... types) { return MH.findStatic(MethodHandles.lookup(), BrowserJSObjectLinker.class, name, MH.type(rtype, types)); } // method handles of netscape.javascript.JSObject class // These are in separate class as we lazily initialize these // method handles when we hit a subclass of JSObject first time. static class JSObjectHandles { // method handles of JSObject class static final MethodHandle JSOBJECT_GETMEMBER = findJSObjectMH_V("getMember", Object.class, String.class).asType(MH.type(Object.class, Object.class, String.class)); static final MethodHandle JSOBJECT_GETSLOT = findJSObjectMH_V("getSlot", Object.class, int.class).asType(MH.type(Object.class, Object.class, int.class)); static final MethodHandle JSOBJECT_SETMEMBER = findJSObjectMH_V("setMember", Void.TYPE, String.class, Object.class).asType(MH.type(Void.TYPE, Object.class, String.class, Object.class)); static final MethodHandle JSOBJECT_SETSLOT = findJSObjectMH_V("setSlot", Void.TYPE, int.class, Object.class).asType(MH.type(Void.TYPE, Object.class, int.class, Object.class)); static final MethodHandle JSOBJECT_CALL = findJSObjectMH_V("call", Object.class, String.class, Object[].class).asType(MH.type(Object.class, Object.class, String.class, Object[].class)); private static MethodHandle findJSObjectMH_V(final String name, final Class<?> rtype, final Class<?>... types) { checkJSObjectClass(); return MH.findVirtual(MethodHandles.publicLookup(), jsObjectClass, name, MH.type(rtype, types)); } } private static Class<?> findBrowserJSObjectClass() { ClassLoader extLoader; extLoader = BrowserJSObjectLinker.class.getClassLoader(); // in case nashorn is loaded as bootstrap! if (extLoader == null) { extLoader = ClassLoader.getSystemClassLoader().getParent(); } try { return Class.forName(JSOBJECT_CLASS, false, extLoader); } catch (final ClassNotFoundException e) { return null; } } }
⏎ jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java
Or download all of them as a single archive file:
File name: jdk.scripting.nashorn-11.0.1-src.zip File size: 1390965 bytes Release date: 2018-11-04 Download
⇒ JDK 11 jdk.scripting.nashorn.shell.jmod - Scripting Nashorn Shell Module
2020-04-25, 109765👍, 0💬
Popular Posts:
XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with ...
JDK 11 jdk.localedata.jmod is the JMOD file for JDK 11 Localedata module. JDK 11 Locale Data module ...
JDK 7 tools.jar is the JAR file for JDK 7 tools. It contains Java classes to support different JDK t...
commons-fileupload-1.3.3 -sources.jaris the source JAR file for Apache Commons FileUpload 1.3., whic...
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time. Her...