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 17 jdk.jshell.jmod - JShell Tool
JDK 17 jdk.jshell.jmod is the JMOD file for JDK 17 JShell tool, which can be invoked by the "jshell" command.
JDK 17 JShell tool compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.jshell.jmod.
JDK 17 JShell tool compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 JShell tool source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.jshell.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/jshell/execution/DefaultLoaderDelegate.java
/* * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package jdk.jshell.execution; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; import java.net.URLStreamHandler; import java.security.CodeSource; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import jdk.jshell.spi.ExecutionControl.ClassBytecodes; import jdk.jshell.spi.ExecutionControl.ClassInstallException; import jdk.jshell.spi.ExecutionControl.EngineTerminationException; import jdk.jshell.spi.ExecutionControl.InternalException; /** * The standard implementation of {@link LoaderDelegate} using * a {@link URLClassLoader}. * * @author Robert Field */ class DefaultLoaderDelegate implements LoaderDelegate { private final RemoteClassLoader loader; private final Map<String, Class<?>> klasses = new HashMap<>(); private static class RemoteClassLoader extends URLClassLoader { private final Map<String, ClassFile> classFiles = new HashMap<>(); RemoteClassLoader() { super(new URL[0]); } private class ResourceURLStreamHandler extends URLStreamHandler { private final String name; ResourceURLStreamHandler(String name) { this.name = name; } @Override protected URLConnection openConnection(URL u) throws IOException { return new URLConnection(u) { private InputStream in; private Map<String, List<String>> fields; private List<String> fieldNames; @Override public void connect() { if (connected) { return; } connected = true; ClassFile file = classFiles.get(name); in = new ByteArrayInputStream(file.data); fields = new LinkedHashMap<>(); fields.put("content-length", List.of(Integer.toString(file.data.length))); Instant instant = new Date(file.timestamp).toInstant(); ZonedDateTime time = ZonedDateTime.ofInstant(instant, ZoneId.of("GMT")); String timeStamp = DateTimeFormatter.RFC_1123_DATE_TIME.format(time); fields.put("date", List.of(timeStamp)); fields.put("last-modified", List.of(timeStamp)); fieldNames = new ArrayList<>(fields.keySet()); } @Override public InputStream getInputStream() throws IOException { connect(); return in; } @Override public String getHeaderField(String name) { connect(); return fields.getOrDefault(name, List.of()) .stream() .findFirst() .orElse(null); } @Override public Map<String, List<String>> getHeaderFields() { connect(); return fields; } @Override public String getHeaderFieldKey(int n) { return n < fieldNames.size() ? fieldNames.get(n) : null; } @Override public String getHeaderField(int n) { String name = getHeaderFieldKey(n); return name != null ? getHeaderField(name) : null; } }; } } void declare(String name, byte[] bytes) { classFiles.put(toResourceString(name), new ClassFile(bytes, System.currentTimeMillis())); } @Override protected Class<?> findClass(String name) throws ClassNotFoundException { ClassFile file = classFiles.get(toResourceString(name)); if (file == null) { return super.findClass(name); } return super.defineClass(name, file.data, 0, file.data.length, (CodeSource) null); } @Override public URL findResource(String name) { URL u = doFindResource(name); return u != null ? u : super.findResource(name); } @Override public Enumeration<URL> findResources(String name) throws IOException { URL u = doFindResource(name); Enumeration<URL> sup = super.findResources(name); if (u == null) { return sup; } List<URL> result = new ArrayList<>(); while (sup.hasMoreElements()) { result.add(sup.nextElement()); } result.add(u); return Collections.enumeration(result); } private URL doFindResource(String name) { if (classFiles.containsKey(name)) { try { return new URL(null, new URI("jshell", null, "/" + name, null).toString(), new ResourceURLStreamHandler(name)); } catch (MalformedURLException | URISyntaxException ex) { throw new InternalError(ex); } } return null; } private String toResourceString(String className) { return className.replace('.', '/') + ".class"; } @Override public void addURL(URL url) { super.addURL(url); } private static class ClassFile { public final byte[] data; public final long timestamp; ClassFile(byte[] data, long timestamp) { this.data = data; this.timestamp = timestamp; } } } public DefaultLoaderDelegate() { this.loader = new RemoteClassLoader(); Thread.currentThread().setContextClassLoader(loader); } @Override public void load(ClassBytecodes[] cbcs) throws ClassInstallException, EngineTerminationException { boolean[] loaded = new boolean[cbcs.length]; try { for (ClassBytecodes cbc : cbcs) { loader.declare(cbc.name(), cbc.bytecodes()); } for (int i = 0; i < cbcs.length; ++i) { ClassBytecodes cbc = cbcs[i]; Class<?> klass = loader.loadClass(cbc.name()); klasses.put(cbc.name(), klass); loaded[i] = true; // Get class loaded to the point of, at least, preparation klass.getDeclaredMethods(); } } catch (Throwable ex) { throw new ClassInstallException("load: " + ex.getMessage(), loaded); } } @Override public void classesRedefined(ClassBytecodes[] cbcs) { for (ClassBytecodes cbc : cbcs) { loader.declare(cbc.name(), cbc.bytecodes()); } } @Override public void addToClasspath(String cp) throws EngineTerminationException, InternalException { try { for (String path : cp.split(File.pathSeparator)) { loader.addURL(new File(path).toURI().toURL()); } } catch (Exception ex) { throw new InternalException(ex.toString()); } } @Override public Class<?> findClass(String name) throws ClassNotFoundException { Class<?> klass = klasses.get(name); if (klass == null) { throw new ClassNotFoundException(name + " not found"); } else { return klass; } } }
⏎ jdk/jshell/execution/DefaultLoaderDelegate.java
Or download all of them as a single archive file:
File name: jdk.jshell-17.0.5-src.zip File size: 302589 bytes Release date: 2022-09-13 Download
⇒ JDK 17 jdk.jsobject.jmod - JS Object Module
2023-08-03, 5906👍, 0💬
Popular Posts:
JDK 11 jdk.aot.jmod is the JMOD file for JDK 11 Ahead-of-Time (AOT) Compiler module. JDK 11 AOT Comp...
itextpdf.jar is a component in iText 5 Java library to provide core functionalities. iText Java libr...
JDK 6 tools.jar is the JAR file for JDK 6 tools. It contains Java classes to support different JDK t...
What Is javamail1_1_3.zip? javamail1_1_3.zip is the binary package of JavaMail API 1.1.3 in ZIP form...
JDOM provides a solution for using XML from Java that is as simple as Java itself. There is no compe...