JDK 11 jdk.jdeps.jmod - JDeps Tool

JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" command.

JDK 11 JDeps tool compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.jdeps.jmod.

JDK 11 JDeps tool compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 JDeps tool source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.jdeps.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

com/sun/tools/jdeps/Module.java

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

package com.sun.tools.jdeps;

import java.lang.module.ModuleDescriptor;
import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * Jdeps internal representation of module for dependency analysis.
 */
class Module extends Archive {
    static final Module UNNAMED_MODULE = new UnnamedModule();
    static final String JDK_UNSUPPORTED = "jdk.unsupported";

    static final boolean DEBUG = Boolean.getBoolean("jdeps.debug");
    static void trace(String fmt, Object... args) {
        trace(DEBUG, fmt, args);
    }

    static void trace(boolean traceOn, String fmt, Object... args) {
        if (traceOn) {
            System.err.format(fmt, args);
        }
    }

    private final ModuleDescriptor descriptor;
    private final Map<String, Set<String>> exports;
    private final Map<String, Set<String>> opens;
    private final boolean isSystem;
    private final URI location;

    protected Module(String name) {
        super(name);
        this.descriptor = null;
        this.location = null;
        this.exports = Collections.emptyMap();
        this.opens = Collections.emptyMap();
        this.isSystem = true;
    }

    private Module(String name,
                   URI location,
                   ModuleDescriptor descriptor,
                   Map<String, Set<String>> exports,
                   Map<String, Set<String>> opens,
                   boolean isSystem,
                   ClassFileReader reader) {
        super(name, location, reader);
        this.descriptor = descriptor;
        this.location = location;
        this.exports = Collections.unmodifiableMap(exports);
        this.opens = Collections.unmodifiableMap(opens);
        this.isSystem = isSystem;
    }

    /**
     * Returns module name
     */
    public String name() {
        return descriptor != null ? descriptor.name() : getName();
    }

    public boolean isNamed() {
        return true;
    }

    public boolean isAutomatic() {
        return descriptor.isAutomatic();
    }

    public Module getModule() {
        return this;
    }

    public ModuleDescriptor descriptor() {
        return descriptor;
    }

    public URI location() {
        return location;
    }

    public boolean isJDK() {
        String mn = name();
        return isSystem &&
            (mn.startsWith("java.") || mn.startsWith("jdk.") || mn.startsWith("javafx."));
    }

    public boolean isSystem() {
        return isSystem;
    }

    public Map<String, Set<String>> exports() {
        return exports;
    }

    public Set<String> packages() {
        return descriptor.packages();
    }

    public boolean isJDKUnsupported() {
        return JDK_UNSUPPORTED.equals(this.name());
    }

    /**
     * Converts this module to a normal module with the given dependences
     *
     * @throws IllegalArgumentException if this module is not an automatic module
     */
    public Module toNormalModule(Map<String, Boolean> requires) {
        if (!isAutomatic()) {
            throw new IllegalArgumentException(name() + " not an automatic module");
        }
        return new NormalModule(this, requires);
    }

    /**
     * Tests if the package of the given name is exported.
     */
    public boolean isExported(String pn) {
        return exports.containsKey(pn) && exports.get(pn).isEmpty();
    }

    /**
     * Tests if the package of the given name is exported to the target
     * in a qualified fashion.
     */
    public boolean isExported(String pn, String target) {
        return isExported(pn)
                || exports.containsKey(pn) && exports.get(pn).contains(target);
    }

    /**
     * Tests if the package of the given name is open.
     */
    public boolean isOpen(String pn) {
        return opens.containsKey(pn) && opens.get(pn).isEmpty();
    }

    /**
     * Tests if the package of the given name is open to the target
     * in a qualified fashion.
     */
    public boolean isOpen(String pn, String target) {
        return isOpen(pn)
            || opens.containsKey(pn) && opens.get(pn).contains(target);
    }

    @Override
    public String toString() {
        return name();
    }

    public final static class Builder {
        final String name;
        final ModuleDescriptor descriptor;
        final boolean isSystem;
        ClassFileReader reader;
        URI location;

        public Builder(ModuleDescriptor md) {
            this(md, false);
        }

        public Builder(ModuleDescriptor md, boolean isSystem) {
            this.name = md.name();
            this.descriptor = md;
            this.isSystem = isSystem;
        }

        public Builder location(URI location) {
            this.location = location;
            return this;
        }

        public Builder classes(ClassFileReader reader) {
            this.reader = reader;
            return this;
        }

        public Module build() {
            if (descriptor.isAutomatic() && isSystem) {
                throw new InternalError("JDK module: " + name + " can't be automatic module");
            }

            Map<String, Set<String>> exports = new HashMap<>();
            Map<String, Set<String>> opens = new HashMap<>();

            if (descriptor.isAutomatic()) {
                // ModuleDescriptor::exports and opens returns an empty set
                descriptor.packages().forEach(pn -> exports.put(pn, Collections.emptySet()));
                descriptor.packages().forEach(pn -> opens.put(pn, Collections.emptySet()));
            } else {
                descriptor.exports().stream()
                          .forEach(exp -> exports.computeIfAbsent(exp.source(), _k -> new HashSet<>())
                                                 .addAll(exp.targets()));
                descriptor.opens().stream()
                    .forEach(exp -> opens.computeIfAbsent(exp.source(), _k -> new HashSet<>())
                        .addAll(exp.targets()));
            }
            return new Module(name, location, descriptor, exports, opens, isSystem, reader);
        }
    }

    private static class UnnamedModule extends Module {
        private UnnamedModule() {
            super("unnamed", null, null,
                  Collections.emptyMap(), Collections.emptyMap(),
                  false, null);
        }

        @Override
        public String name() {
            return "unnamed";
        }

        @Override
        public boolean isNamed() {
            return false;
        }

        @Override
        public boolean isAutomatic() {
            return false;
        }

        @Override
        public boolean isExported(String pn) {
            return true;
        }
    }

    /**
     * A normal module has a module-info.class
     */
    private static class NormalModule extends Module {
        private final ModuleDescriptor md;

        /**
         * Converts the given automatic module to a normal module.
         *
         * Replace this module's dependences with the given requires and also
         * declare service providers, if specified in META-INF/services configuration file
         */
        private NormalModule(Module m, Map<String, Boolean> requires) {
            super(m.name(), m.location, m.descriptor, m.exports, m.opens, m.isSystem, m.reader());

            ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(m.name());
            requires.keySet().forEach(mn -> {
                if (requires.get(mn).equals(Boolean.TRUE)) {
                    builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.TRANSITIVE), mn);
                } else {
                    builder.requires(mn);
                }
            });
            // exports all packages
            m.descriptor.packages().forEach(builder::exports);
            m.descriptor.uses().forEach(builder::uses);
            m.descriptor.provides().forEach(builder::provides);
            this.md = builder.build();
        }

        @Override
        public ModuleDescriptor descriptor() {
            return md;
        }
    }
}

com/sun/tools/jdeps/Module.java

 

JDK 11 jdk.jdi.jmod - JDI Tool

JDK 11 jdk.jconsole.jmod - JConsole Tool

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-07-07, 5224👍, 0💬