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/DirectExecutionControl.java
/* * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package jdk.jshell.execution; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.stream.IntStream; import jdk.jshell.spi.ExecutionControl; import jdk.jshell.spi.SPIResolutionException; /** * An {@link ExecutionControl} implementation that runs in the current process. * May be used directly, or over a channel with * {@link Util#forwardExecutionControl(ExecutionControl, java.io.ObjectInput, java.io.ObjectOutput) }. * * @author Robert Field * @author Jan Lahoda * @since 9 */ public class DirectExecutionControl implements ExecutionControl { private static final String[] charRep; static { charRep = new String[256]; for (int i = 0; i < charRep.length; ++i) { charRep[i] = Character.isISOControl(i) ? String.format("\\%03o", i) : "" + (char) i; } charRep['\b'] = "\\b"; charRep['\t'] = "\\t"; charRep['\n'] = "\\n"; charRep['\f'] = "\\f"; charRep['\r'] = "\\r"; charRep['\\'] = "\\\\"; } private final LoaderDelegate loaderDelegate; /** * Creates an instance, delegating loader operations to the specified * delegate. * * @param loaderDelegate the delegate to handle loading classes */ public DirectExecutionControl(LoaderDelegate loaderDelegate) { this.loaderDelegate = loaderDelegate; } /** * Create an instance using the default class loading. */ public DirectExecutionControl() { this(new DefaultLoaderDelegate()); } @Override public void load(ClassBytecodes[] cbcs) throws ClassInstallException, NotImplementedException, EngineTerminationException { loaderDelegate.load(cbcs); } @Override public void redefine(ClassBytecodes[] cbcs) throws ClassInstallException, NotImplementedException, EngineTerminationException { throw new NotImplementedException("redefine not supported"); } /**Notify that classes have been redefined. * * @param cbcs the class name and bytecodes to redefine * @throws NotImplementedException if not implemented * @throws EngineTerminationException the execution engine has terminated */ protected void classesRedefined(ClassBytecodes[] cbcs) throws NotImplementedException, EngineTerminationException { loaderDelegate.classesRedefined(cbcs); } @Override public String invoke(String className, String methodName) throws RunException, InternalException, EngineTerminationException { Method doitMethod; try { Class<?> klass = findClass(className); doitMethod = klass.getDeclaredMethod(methodName, new Class<?>[0]); doitMethod.setAccessible(true); } catch (Throwable ex) { throw new InternalException(ex.toString()); } try { clientCodeEnter(); String result = invoke(doitMethod); System.out.flush(); return result; } catch (RunException | InternalException | EngineTerminationException ex) { throw ex; } catch (SPIResolutionException ex) { return throwConvertedInvocationException(ex); } catch (InvocationTargetException ex) { return throwConvertedInvocationException(ex.getCause()); } catch (Throwable ex) { return throwConvertedOtherException(ex); } finally { clientCodeLeave(); } } @Override public String varValue(String className, String varName) throws RunException, EngineTerminationException, InternalException { Object val; try { Class<?> klass = findClass(className); Field var = klass.getDeclaredField(varName); var.setAccessible(true); val = var.get(null); } catch (Throwable ex) { throw new InternalException(ex.toString()); } try { clientCodeEnter(); return valueString(val); } catch (Throwable ex) { return throwConvertedInvocationException(ex); } finally { clientCodeLeave(); } } @Override public void addToClasspath(String cp) throws EngineTerminationException, InternalException { loaderDelegate.addToClasspath(cp); } /** * {@inheritDoc} * <p> * Not supported. */ @Override public void stop() throws EngineTerminationException, InternalException { throw new NotImplementedException("stop: Not supported."); } @Override public Object extensionCommand(String command, Object arg) throws RunException, EngineTerminationException, InternalException { throw new NotImplementedException("Unknown command: " + command); } @Override public void close() { } /** * Finds the class with the specified binary name. * * @param name the binary name of the class * @return the Class Object * @throws ClassNotFoundException if the class could not be found */ protected Class<?> findClass(String name) throws ClassNotFoundException { return loaderDelegate.findClass(name); } /** * Invoke the specified "doit-method", a static method with no parameters. * The {@link DirectExecutionControl#invoke(java.lang.String, java.lang.String) } * in this class will call this to invoke. * * @param doitMethod the Method to invoke * @return the value or null * @throws Exception any exceptions thrown by * {@link java.lang.reflect.Method#invoke(Object, Object...) } * or any {@link ExecutionControl.ExecutionControlException} * to pass-through. */ protected String invoke(Method doitMethod) throws Exception { Object res = doitMethod.invoke(null, new Object[0]); return valueString(res); } /** * Converts the {@code Object} value from * {@link ExecutionControl#invoke(String, String) } or * {@link ExecutionControl#varValue(String, String) } to {@code String}. * * @param value the value to convert * @return the {@code String} representation */ protected static String valueString(Object value) { if (value == null) { return "null"; } else if (value instanceof String) { return "\"" + ((String) value).codePoints() .flatMap(cp -> (cp == '"') ? "\\\"".codePoints() : (cp < 256) ? charRep[cp].codePoints() : IntStream.of(cp)) .collect( StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString() + "\""; } else if (value instanceof Character) { char cp = (char) (Character) value; return "'" + ( (cp == '\'') ? "\\\'" : (cp < 256) ? charRep[cp] : String.valueOf(cp)) + "'"; } else if (value.getClass().isArray()) { int dims = 0; Class<?> t = value.getClass(); while (true) { Class<?> ct = t.getComponentType(); if (ct == null) { break; } ++dims; t = ct; } String tn = t.getTypeName(); int len = Array.getLength(value); StringBuilder sb = new StringBuilder(); sb.append(tn.substring(tn.lastIndexOf('.') + 1, tn.length())); sb.append("["); sb.append(len); sb.append("]"); for (int i = 1; i < dims; ++i) { sb.append("[]"); } sb.append(" { "); for (int i = 0; i < len; ++i) { sb.append(valueString(Array.get(value, i))); if (i < len - 1) { sb.append(", "); } } sb.append(" }"); return sb.toString(); } else { return value.toString(); } } /** * Converts incoming exceptions in user code into instances of subtypes of * {@link ExecutionControl.ExecutionControlException} and throws the * converted exception. * * @param cause the exception to convert * @return never returns as it always throws * @throws ExecutionControl.RunException for normal exception occurrences * @throws ExecutionControl.InternalException for internal problems */ protected String throwConvertedInvocationException(Throwable cause) throws RunException, InternalException { throw asRunException(cause); } private RunException asRunException(Throwable ex) { if (ex instanceof SPIResolutionException) { SPIResolutionException spire = (SPIResolutionException) ex; return new ResolutionException(spire.id(), spire.getStackTrace()); } else { UserException ue = new UserException(ex.getMessage(), ex.getClass().getName(), ex.getStackTrace()); Throwable cause = ex.getCause(); ue.initCause(cause == null ? null : asRunException(cause)); return ue; } } /** * Converts incoming exceptions in agent code into instances of subtypes of * {@link ExecutionControl.ExecutionControlException} and throws the * converted exception. * * @param ex the exception to convert * @return never returns as it always throws * @throws ExecutionControl.RunException for normal exception occurrences * @throws ExecutionControl.InternalException for internal problems */ protected String throwConvertedOtherException(Throwable ex) throws RunException, InternalException { throw new InternalException(ex.toString()); } /** * Marks entry into user code. * * @throws ExecutionControl.InternalException in unexpected failure cases */ protected void clientCodeEnter() throws InternalException { } /** * Marks departure from user code. * * @throws ExecutionControl.InternalException in unexpected failure cases */ protected void clientCodeLeave() throws InternalException { } }
⏎ jdk/jshell/execution/DirectExecutionControl.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, 5946👍, 0💬
Popular Posts:
Apache BCEL Source Code Files are inside the Apache BCEL source package file like bcel-6.6.1-src.zip...
What Is commons-codec-1.4.jar? commons-codec-1.4.jar is the JAR file for Apache Commons Codec 1.4, w...
JRE 5 sunjce_provider.jar is the JAR file for JRE 5 Sun JCE Provider, which provides implementations...
JDK 11 jdk.rmic.jmod is the JMOD file for JDK 11 RMI (Remote Method Invocation) Compiler Tool tool, ...
MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format su...