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/ClassTracker.java

/*
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package jdk.jshell;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import jdk.jshell.spi.ExecutionControl.ClassBytecodes;

/**
 * Tracks the state of a class.
 */
class ClassTracker {

    private final HashMap<String, ClassInfo> map;

    ClassTracker() {
        this.map = new HashMap<>();
    }

    /**
     * Associates a class name, class bytes (current and loaded).
     */
    class ClassInfo {

        // The name of the class
        private final String className;

        // The corresponding compiled class bytes when a load or redefine
        // is started.  May not be the loaded bytes.  May be null.
        private byte[] currentBytes;

        // The class bytes successfully loaded/redefined into the remote VM.
        private byte[] loadedBytes;

        private ClassInfo(String className) {
            this.className = className;
        }

        String getClassName() {
            return className;
        }

        byte[] getLoadedBytes() {
            return loadedBytes;
        }

        byte[] getCurrentBytes() {
            return currentBytes;
        }

        void setCurrentBytes(byte[] bytes) {
            this.currentBytes = bytes;
        }

        void setLoadedBytes(byte[] bytes) {
            this.loadedBytes = bytes;
        }

        boolean isLoaded() {
            return loadedBytes != null;
        }

        boolean isCurrent() {
            return Arrays.equals(currentBytes, loadedBytes);
        }

        ClassBytecodes toClassBytecodes() {
            return new ClassBytecodes(className, currentBytes);
        }

            @Override
        public boolean equals(Object o) {
            return o instanceof ClassInfo
                    && ((ClassInfo) o).className.equals(className);
        }

        @Override
        public int hashCode() {
            return Objects.hashCode(this.className);
        }
    }

    void markLoaded(ClassBytecodes[] cbcs) {
        for (ClassBytecodes cbc : cbcs) {
            get(cbc.name()).setLoadedBytes(cbc.bytecodes());
        }
    }

    void markLoaded(ClassBytecodes[] cbcs, boolean[] isLoaded) {
        for (int i = 0; i < cbcs.length; ++i) {
            if (isLoaded[i]) {
                ClassBytecodes cbc = cbcs[i];
                get(cbc.name()).setLoadedBytes(cbc.bytecodes());
            }
        }
    }

    // Map a class name to the current compiled class bytes.
    void setCurrentBytes(String className, byte[] bytes) {
        ClassInfo ci = get(className);
        ci.setCurrentBytes(bytes);
    }

    // Lookup the ClassInfo by class name, create if it does not exist.
    ClassInfo get(String className) {
        return map.computeIfAbsent(className, ClassInfo::new);
    }
}

jdk/jshell/ClassTracker.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

JDK 17 jdk.jpackage.jmod - JPackage Tool

JDK 17 JMod/Module Files

⇑⇑ FAQ for JDK (Java Development Kit) 17

2023-08-03, 5910👍, 0💬