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

/*
 * Copyright (c) 2015, 2016, 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.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URI;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;

import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.main.Main;
import com.sun.tools.javac.main.Main.Result;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Dependencies;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.sjavac.Log;
import com.sun.tools.sjavac.Util;
import com.sun.tools.sjavac.comp.dependencies.NewDependencyCollector;
import com.sun.tools.sjavac.comp.dependencies.PublicApiCollector;
import com.sun.tools.sjavac.server.CompilationSubResult;
import com.sun.tools.sjavac.server.SysInfo;

/**
 *  <p><b>This is NOT part of any supported API.
 *  If you write code that depends on this, you do so at your own risk.
 *  This code and its internal interfaces are subject to change or
 *  deletion without notice.</b>
 */
public class CompilationService {

    public SysInfo getSysInfo() {
        return new SysInfo(Runtime.getRuntime().availableProcessors(),
                           Runtime.getRuntime().maxMemory());
    }

    public CompilationSubResult compile(String protocolId,
                                     String invocationId,
                                     String[] args,
                                     List<File> explicitSources,
                                     Set<URI> sourcesToCompile,
                                     Set<URI> visibleSources) {

        JavacTool compiler = (JavacTool) ToolProvider.getSystemJavaCompiler();
        try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
            SmartFileManager sfm = new SmartFileManager(fm);
            Context context = new Context();

            Dependencies.GraphDependencies.preRegister(context);

            // Now setup the actual compilation
            CompilationSubResult compilationResult = new CompilationSubResult(Result.OK);

            // First deal with explicit source files on cmdline and in at file
            ListBuffer<JavaFileObject> explicitJFOs = new ListBuffer<>();
            for (JavaFileObject jfo : fm.getJavaFileObjectsFromFiles(explicitSources)) {
                explicitJFOs.append(SmartFileManager.locWrap(jfo, StandardLocation.SOURCE_PATH));
            }
            // Now deal with sources supplied as source_to_compile
            ListBuffer<File> sourcesToCompileFiles = new ListBuffer<>();
            for (URI u : sourcesToCompile)
                sourcesToCompileFiles.append(new File(u));

            for (JavaFileObject jfo : fm.getJavaFileObjectsFromFiles(sourcesToCompileFiles))
                explicitJFOs.append(SmartFileManager.locWrap(jfo, StandardLocation.SOURCE_PATH));

            // Create a log to capture compiler output
            StringWriter stderrLog = new StringWriter();
            Result result;
            PublicApiCollector pubApiCollector = new PublicApiCollector(context, explicitJFOs);
            PathAndPackageVerifier papVerifier = new PathAndPackageVerifier();
            NewDependencyCollector depsCollector = new NewDependencyCollector(context, explicitJFOs);
            try {
                if (explicitJFOs.size() > 0) {
                    sfm.setVisibleSources(visibleSources);
                    sfm.cleanArtifacts();

                    // Do the compilation!
                    JavacTaskImpl task =
                            (JavacTaskImpl) compiler.getTask(new PrintWriter(stderrLog),
                                                             sfm,
                                                             null,
                                                             Arrays.asList(args),
                                                             null,
                                                             explicitJFOs,
                                                             context);
                    sfm.setSymbolFileEnabled(!com.sun.tools.javac.util.Options.instance(context).isSet("ignore.symbol.file"));
                    task.addTaskListener(depsCollector);
                    task.addTaskListener(pubApiCollector);
                    task.addTaskListener(papVerifier);
                    logJavacInvocation(args);
                    result = task.doCall();
                    Log.debug("javac result: " + result);
                    sfm.flush();
                } else {
                    result = Result.ERROR;
                }
            } catch (Exception e) {
                Log.error(Util.getStackTrace(e));
                stderrLog.append(Util.getStackTrace(e));
                result = Result.ERROR;
            }

            compilationResult.packageArtifacts = sfm.getPackageArtifacts();

            if (papVerifier.errorsDiscovered()) {
                result = Result.ERROR;
            }

            compilationResult.packageDependencies = depsCollector.getDependencies(false);
            compilationResult.packageCpDependencies = depsCollector.getDependencies(true);

            compilationResult.packagePubapis = pubApiCollector.getPubApis(true);
            compilationResult.dependencyPubapis = pubApiCollector.getPubApis(false);
            compilationResult.stderr = stderrLog.toString();
            compilationResult.result = result;

            return compilationResult;
        } catch (IOException e) {
            throw new Error(e);
        }
    }

    private void logJavacInvocation(String[] args) {
        Log.debug("Invoking javac with args");
        Iterator<String> argIter = Arrays.asList(args).iterator();
        while (argIter.hasNext()) {
            String arg = argIter.next();
            String line = "    " + arg;
            if (arg.matches("\\-(d|cp|classpath|sourcepath|source|target)")
                    && argIter.hasNext()) {
                line += " " + argIter.next();
            }
            Log.debug(line);
        }
    }

}

com/sun/tools/sjavac/comp/CompilationService.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, 92106👍, 0💬