JDK 11 jdk.compiler.jmod - Compiler Tool

JDK 11 jdk.compiler.jmod is the JMOD file for JDK 11 Compiler tool, which can be invoked by the "javac" command.

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

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

JDK 11 Compiler source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.compiler.

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

✍: FYIcenter

com/sun/tools/sjavac/comp/PathAndPackageVerifier.java

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

package com.sun.tools.sjavac.comp;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.tools.JavaFileObject;

import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Name;
import com.sun.tools.sjavac.Log;

public class PathAndPackageVerifier implements TaskListener {

    // Stores the set of compilation units whose source file path does not
    // match the package declaration.
    Set<CompilationUnitTree> misplacedCompilationUnits = new HashSet<>();

    @Override
    @DefinedBy(Api.COMPILER_TREE)
    public void finished(TaskEvent e) {
        if (e.getKind() == TaskEvent.Kind.ANALYZE) {

            CompilationUnitTree cu = e.getCompilationUnit();
            if (cu == null)
                return;

            JavaFileObject jfo = cu.getSourceFile();
            if (jfo == null)
                return; // No source file -> package doesn't matter

            JCTree pkg = (JCTree) cu.getPackageName();
            if (pkg == null)
                return; // Default package. See JDK-8048144.

            Path dir = Paths.get(jfo.toUri()).normalize().getParent();
            if (!checkPathAndPackage(dir, pkg))
                misplacedCompilationUnits.add(cu);
        }

        if (e.getKind() == TaskEvent.Kind.COMPILATION) {
            for (CompilationUnitTree cu : misplacedCompilationUnits) {
                Log.error("Misplaced compilation unit.");
                Log.error("    Directory: " + Paths.get(cu.getSourceFile().toUri()).getParent());
                Log.error("    Package:   " + cu.getPackageName());
            }
        }
    }

    public boolean errorsDiscovered() {
        return misplacedCompilationUnits.size() > 0;
    }

    /* Returns true if dir matches pkgName.
     *
     * Examples:
     *     (a/b/c, a.b.c) gives true
     *     (i/j/k, i.x.k) gives false
     *
     * Currently (x/a/b/c, a.b.c) also gives true. See JDK-8059598.
     */
    private boolean checkPathAndPackage(Path dir, JCTree pkgName) {
        Iterator<String> pathIter = new ParentIterator(dir);
        Iterator<String> pkgIter = new EnclosingPkgIterator(pkgName);
        while (pathIter.hasNext() && pkgIter.hasNext()) {
            if (!pathIter.next().equals(pkgIter.next()))
                return false;
        }
        return !pkgIter.hasNext(); /*&& !pathIter.hasNext() See JDK-8059598 */
    }

    /* Iterates over the names of the parents of the given path:
     * Example: dir1/dir2/dir3  results in  dir3 -> dir2 -> dir1
     */
    private static class ParentIterator implements Iterator<String> {
        Path next;
        ParentIterator(Path initial) {
            next = initial;
        }
        @Override
        public boolean hasNext() {
            return next != null;
        }
        @Override
        public String next() {
            String tmp = next.getFileName().toString();
            next = next.getParent();
            return tmp;
        }
    }

    /* Iterates over the names of the enclosing packages:
     * Example: pkg1.pkg2.pkg3  results in  pkg3 -> pkg2 -> pkg1
     */
    private static class EnclosingPkgIterator implements Iterator<String> {
        JCTree next;
        EnclosingPkgIterator(JCTree initial) {
            next = initial;
        }
        @Override
        public boolean hasNext() {
            return next != null;
        }
        @Override
        public String next() {
            Name name;
            if (next instanceof JCIdent) {
                name = ((JCIdent) next).name;
                next = null;
            } else {
                JCFieldAccess fa = (JCFieldAccess) next;
                name = fa.name;
                next = fa.selected;
            }
            return name.toString();
        }
    }
}

com/sun/tools/sjavac/comp/PathAndPackageVerifier.java

 

Or download all of them as a single archive file:

File name: jdk.compiler-11.0.1-src.zip
File size: 1347269 bytes
Release date: 2018-11-04
Download 

 

JDK 11 jdk.crypto.cryptoki.jmod - Crypto KI Module

JDK 11 jdk.charsets.jmod - Charsets Module

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-08-13, 93540👍, 0💬