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/codegen/DumpBytecode.java

/*
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package jdk.nashorn.internal.codegen;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import jdk.nashorn.internal.runtime.ECMAErrors;
import jdk.nashorn.internal.runtime.ScriptEnvironment;
import jdk.nashorn.internal.runtime.logging.DebugLogger;

/**
 * Class that facilitates printing bytecode and dumping it to disk.
 */
public final class DumpBytecode {
    /**
     * Dump bytecode to console and potentially disk.
     * @param env the script environment defining options for printing bytecode
     * @param logger a logger used to write diagnostics about bytecode dumping
     * @param bytecode the actual code to dump
     * @param className the name of the class being dumped
     */
    public static void dumpBytecode(final ScriptEnvironment env, final DebugLogger logger, final byte[] bytecode, final String className) {
        File dir = null;
        try {
            // should could be printed to stderr for generate class?
            if (env._print_code) {

                final StringBuilder sb = new StringBuilder();
                sb.append("class: ").append(className).
                    append('\n').
                    append(ClassEmitter.disassemble(bytecode)).
                    append("=====");

                if (env._print_code_dir != null) {

                    String name = className;
                    final int dollar = name.lastIndexOf('$');
                    if (dollar != -1) {
                        name = name.substring(dollar + 1);
                    }

                    dir = new File(env._print_code_dir);
                    if (!dir.exists() && !dir.mkdirs()) {
                        throw new IOException(dir.toString());
                    }

                    File file;
                    String fileName;
                    int uniqueId = 0;
                    do {
                        fileName = name + (uniqueId == 0 ? "" : "_" + uniqueId) + ".bytecode";
                        file = new File(env._print_code_dir, fileName);
                        uniqueId++;
                    } while (file.exists());

                    try (final PrintWriter pw = new PrintWriter(new FileOutputStream(file))) {
                        pw.print(sb.toString());
                        pw.flush();
                    }
                } else {
                    env.getErr().println(sb);
                }
            }


            // should code be dumped to disk
            if (env._dest_dir != null) {
                final String fileName = className.replace('.', File.separatorChar) + ".class";
                final int    index    = fileName.lastIndexOf(File.separatorChar);

                if (index != -1) {
                    dir = new File(env._dest_dir, fileName.substring(0, index));
                } else {
                    dir = new File(env._dest_dir);
                }

                if (!dir.exists() && !dir.mkdirs()) {
                    throw new IOException(dir.toString());
                }
                final File file = new File(env._dest_dir, fileName);
                try (final FileOutputStream fos = new FileOutputStream(file)) {
                    fos.write(bytecode);
                }
                logger.info("Wrote class to '" + file.getAbsolutePath() + '\'');
            }
        } catch (final IOException e) {
            logger.warning("Skipping class dump for ",
                    className,
                    ": ",
                    ECMAErrors.getMessage(
                        "io.error.cant.write",
                        dir.toString()));
        }
    }
}

jdk/nashorn/internal/codegen/DumpBytecode.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

JDK 11 jdk.rmic.jmod - RMI Compiler Tool

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-04-25, 107301👍, 0💬