Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 8254072-fix-windo…
Browse files Browse the repository at this point in the history
…ws-arm64-warnings
  • Loading branch information
lewurm committed Oct 8, 2020
2 parents b136018 + 5351ba6 commit a081dfb
Show file tree
Hide file tree
Showing 303 changed files with 8,772 additions and 6,610 deletions.
92 changes: 40 additions & 52 deletions .github/workflows/submit.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion make/CompileInterimLangtools.gmk
Expand Up @@ -74,7 +74,7 @@ define SetupInterimModule
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
Standard.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
COPY := .gif .png .xml .css .js .txt javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
DISABLED_WARNINGS := module options, \
JAVAC_FLAGS := \
Expand Down
2 changes: 1 addition & 1 deletion make/CompileJavaModules.gmk
Expand Up @@ -348,7 +348,7 @@ jdk.dynalink_CLEAN += .properties

################################################################################

jdk.javadoc_COPY += .xml .css .js .png
jdk.javadoc_COPY += .xml .css .js .png .txt

################################################################################

Expand Down
6 changes: 0 additions & 6 deletions make/Main.gmk
Expand Up @@ -112,7 +112,6 @@ $(eval $(call SetupTarget, generate-exported-symbols, \
$(eval $(call DeclareRecipesForPhase, GENSRC, \
TARGET_SUFFIX := gensrc-src, \
FILE_PREFIX := Gensrc, \
MAKE_SUBDIR := gensrc, \
CHECK_MODULES := $(ALL_MODULES), \
))

Expand Down Expand Up @@ -150,7 +149,6 @@ ALL_TARGETS += $(GENSRC_TARGETS)
$(eval $(call DeclareRecipesForPhase, GENDATA, \
TARGET_SUFFIX := gendata, \
FILE_PREFIX := Gendata, \
MAKE_SUBDIR := gendata, \
CHECK_MODULES := $(ALL_MODULES), \
))

Expand All @@ -161,7 +159,6 @@ ALL_TARGETS += $(GENDATA_TARGETS)
$(eval $(call DeclareRecipesForPhase, COPY, \
TARGET_SUFFIX := copy, \
FILE_PREFIX := Copy, \
MAKE_SUBDIR := copy, \
CHECK_MODULES := $(ALL_MODULES), \
))

Expand Down Expand Up @@ -203,7 +200,6 @@ ALL_TARGETS += $(JAVA_TARGETS)
$(eval $(call DeclareRecipesForPhase, LIBS, \
TARGET_SUFFIX := libs, \
FILE_PREFIX := Lib, \
MAKE_SUBDIR := lib, \
CHECK_MODULES := $(ALL_MODULES), \
))

Expand All @@ -216,7 +212,6 @@ ALL_TARGETS += $(LIBS_TARGETS)
$(eval $(call DeclareRecipesForPhase, STATIC_LIBS, \
TARGET_SUFFIX := static-libs, \
FILE_PREFIX := Lib, \
MAKE_SUBDIR := lib, \
CHECK_MODULES := $(ALL_MODULES), \
EXTRA_ARGS := STATIC_LIBS=true, \
))
Expand All @@ -228,7 +223,6 @@ ALL_TARGETS += $(STATIC_LIBS_TARGETS)
$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
TARGET_SUFFIX := launchers, \
FILE_PREFIX := Launcher, \
MAKE_SUBDIR := launcher, \
CHECK_MODULES := $(ALL_MODULES), \
))

Expand Down
1 change: 0 additions & 1 deletion make/MainSupport.gmk
Expand Up @@ -185,7 +185,6 @@ endef
# Param 1: Name of list to add targets to
# Named params:
# TARGET_SUFFIX : Suffix of target to create for recipe
# MAKE_SUBDIR : Subdir for this build phase
# FILE_PREFIX : File prefix for this build phase
# CHECK_MODULES : List of modules to try
# MULTIPLE_MAKEFILES : Set to true to handle makefiles for the same module and
Expand Down
Expand Up @@ -143,6 +143,7 @@
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Pair;
import java.util.Optional;

/**
* A tool for processing the .sym.txt files.
Expand Down Expand Up @@ -3820,6 +3821,47 @@ private static AnnotationDescription parseAnnotation(String value, int[] valuePo
}
//</editor-fold>

/**Create sig files for ct.sym reading the classes description from the directory that contains
* {@code ctDescriptionFile}, using the file as a recipe to create the sigfiles.
*/
@SuppressWarnings("unchecked")
public void createJavadocData(String ctDescriptionFileExtra, String ctDescriptionFile,
String targetDir, int startVersion) throws IOException {
LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra)
: null,
Paths.get(ctDescriptionFile));

Path target = Paths.get(targetDir);

for (PlatformInput version : data.versions) {
int versionNumber = Integer.parseInt(version.version, Character.MAX_RADIX);
if (versionNumber < startVersion) {
continue;
}
Path outputFile = target.resolve("element-list-" + versionNumber + ".txt");
Files.createDirectories(outputFile.getParent());
try (Writer w = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) {
Set<ModuleDescription> modules = new TreeSet<>((m1, m2) -> m1.name.compareTo(m2.name));
modules.addAll(data.modules.values());
for (ModuleDescription module : modules) {
if ("jdk.unsupported".equals(module.name)) {
continue;
}
Optional<ModuleHeaderDescription> header = module.header.stream().filter(h -> h.versions.contains(version.version)).findAny();
if (header.isEmpty()) {
continue;
}
w.write("module:" + module.name);
w.write("\n");
for (String pack : header.get().exports) {
w.write(pack.replace('/', '.'));
w.write("\n");
}
}
}
}
}

private static void help() {
System.err.println("Help...");
}
Expand Down Expand Up @@ -3900,7 +3942,7 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
new CreateSymbols().createIncrementalBaseLine(args[1], args[2], args);
break;
}
case "build-ctsym":
case "build-ctsym": {
String ctDescriptionFileExtra;
String ctDescriptionFile;
String ctSymLocation;
Expand Down Expand Up @@ -3939,6 +3981,39 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
currentVersion,
systemModules);
break;
}
case "build-javadoc-data": {
String ctDescriptionFileExtra;
String ctDescriptionFile;
String targetDir;
int startVersion;

if (args.length == 4) {
ctDescriptionFileExtra = null;
ctDescriptionFile = args[1];
targetDir = args[2];
startVersion = Integer.parseInt(args[3]);
} else if (args.length == 5) {
ctDescriptionFileExtra = args[1];
ctDescriptionFile = args[2];
targetDir = args[3];
startVersion = Integer.parseInt(args[4]);
} else {
help();
return ;
}

if (startVersion < 9) {
System.err.println("The start version must be at least 9!");
return ;
}

new CreateSymbols().createJavadocData(ctDescriptionFileExtra,
ctDescriptionFile,
targetDir,
startVersion);
break;
}
}
}

Expand Down
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package build.tools.symbolgenerator;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import javax.lang.model.element.ModuleElement.ExportsDirective;
import javax.lang.model.util.Elements;
import javax.tools.JavaCompiler;

import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
import com.sun.tools.javac.jvm.Target;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.lang.model.element.ModuleElement;

/**
* Generate list of modules and packages in the current release.
* Used by the javadoc tool.
*/
public class JavadocElementList {

private static void help() {
System.err.println("java JavadocElementList <target-file> <module-source-path> <root-modules>");
}

public static void main(String... args) throws IOException {
if (args.length < 2) {
help();
return ;
}

JavaCompiler compiler = JavacTool.create();
List<String> options = List.of("-source", Source.DEFAULT.name,
"-target", Target.DEFAULT.name,
"-proc:only",
"--system", "none",
"--module-source-path", args[1],
"--add-modules", Arrays.stream(args)
.skip(2)
.collect(Collectors.joining(",")));
List<String> jlObjectList = List.of("java.lang.Object");
JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, options, jlObjectList, null);
task.enter();
Elements elements = task.getElements();
Deque<String> todo = new ArrayDeque<>();
Arrays.stream(args).skip(2).forEach(todo::add);

todo.add("java.base");

Map<String, Set<String>> modulesAndExports = new TreeMap<>();

while (!todo.isEmpty()) {
String current = todo.removeFirst();

if (modulesAndExports.containsKey(current))
continue;

ModuleSymbol mod = (ModuleSymbol) elements.getModuleElement(current);

if (mod == null) {
throw new IllegalStateException("Missing: " + current);
}

//use the internal structure to avoid unnecesarily completing the symbol using the UsesProvidesVisitor:
modulesAndExports.put(mod.getQualifiedName().toString(),
mod.exports
.stream()
.filter((ExportsDirective ed) -> ed.getTargetModules() == null)
.map((ExportsDirective ed) -> ed.getPackage().getQualifiedName().toString())
.collect(Collectors.toCollection(() -> new TreeSet<>()))
);
for (ModuleElement.RequiresDirective rd : mod.requires) {
if (rd.isTransitive()) {
todo.offerLast(rd.getDependency().getQualifiedName().toString());
}
}
}

Path targetFile = Paths.get(args[0]);

Files.createDirectories(targetFile.getParent());

try (Writer w = Files.newBufferedWriter(targetFile);
PrintWriter out = new PrintWriter(w)) {
for (Entry<String, Set<String>> moduleAndExports : modulesAndExports.entrySet()) {
out.write("module:" + moduleAndExports.getKey());
out.write("\n");
for (String pack : moduleAndExports.getValue()) {
out.write(pack);
out.write("\n");
}
}
}
}

}

0 comments on commit a081dfb

Please sign in to comment.