From ba0558addb281ef4f3e16fd39b8567071dd7113b Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 9 Aug 2016 07:43:48 -0700 Subject: [PATCH 01/66] 8163431: probeContentType/Basic.java fails after changes for JDK-8146215 Allow multiple legal MIME type interpretations for certain extensions. Reviewed-by: chegar --- .../file/Files/probeContentType/Basic.java | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/nio/file/Files/probeContentType/Basic.java b/jdk/test/java/nio/file/Files/probeContentType/Basic.java index bb48ca71995..5e0d0c94c62 100644 --- a/jdk/test/java/nio/file/Files/probeContentType/Basic.java +++ b/jdk/test/java/nio/file/Files/probeContentType/Basic.java @@ -95,7 +95,7 @@ public class Basic { return 0; } - static int checkContentTypes(String[] extensions, String[] expectedTypes) + static int checkContentTypes(String[] extensions, String[][] expectedTypes) throws IOException { if (extensions.length != expectedTypes.length) { System.err.println("Parameter array lengths differ"); @@ -113,9 +113,24 @@ public class Basic { + " cannot be determined"); failures++; } else { - if (!type.equals(expectedTypes[i])) { - System.err.println("Content type: " + type - + "; expected: " + expectedTypes[i]); + boolean isTypeFound = false; + for (String s : expectedTypes[i]) { + if (type.equals(s)) { + isTypeFound = true; + break; + } + } + if (!isTypeFound) { + System.err.printf("Content type: %s; expected: ", type); + int j = 0; + for (String s : expectedTypes[i]) { + if (j++ == 0) { + System.err.printf("%s", s); + } else { + System.err.printf(", or %s", s); + } + } + System.err.println(); failures++; } } @@ -159,11 +174,24 @@ public class Basic { // Verify that certain media extensions are mapped to the correct type. String[] extensions = new String[]{ - "aac", "flac", "jpg", "mp3", "mp4", "pdf", "png", "webm" + "aac", + "flac", + "jpg", + "mp3", + "mp4", + "pdf", + "png", + "webm" }; - String[] expectedTypes = new String[]{ - "audio/aac", "audio/flac", "image/jpeg", "audio/mpeg", - "video/mp4", "application/pdf", "image/png", "video/webm" + String[][] expectedTypes = new String[][] { + {"audio/aac", "audio/x-aac"}, + {"audio/flac", "audio/x-flac"}, + {"image/jpeg"}, + {"audio/mpeg"}, + {"video/mp4"}, + {"application/pdf"}, + {"image/png"}, + {"video/webm"} }; failures += checkContentTypes(extensions, expectedTypes); From 911dda4ee1afddd214271b07ae879315c33aeff9 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 9 Aug 2016 07:50:26 -0700 Subject: [PATCH 02/66] 8163305: Add some print instrumentation to java/nio/channels/Selector/RacyDeregister Perform more iterations on Windows, and on all platforms if the test enters the failure branch, poll for an extra period of time to determine whether it might have succeeded with a longer timeout Reviewed-by: chegar --- .../nio/channels/Selector/RacyDeregister.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/nio/channels/Selector/RacyDeregister.java b/jdk/test/java/nio/channels/Selector/RacyDeregister.java index 5a72df18107..c0b98190fab 100644 --- a/jdk/test/java/nio/channels/Selector/RacyDeregister.java +++ b/jdk/test/java/nio/channels/Selector/RacyDeregister.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -40,6 +40,11 @@ import java.nio.channels.SocketChannel; */ public class RacyDeregister { + // FIXME: numOuterLoopIterations should be reverted to the hard-coded value + // 15 when JDK-8161083 is resolved as either a bug or a non-issue. + static final int numOuterLoopIterations = + System.getProperty("os.name").startsWith("Windows") ? 150 : 15; + static boolean notified; static final Object selectorLock = new Object(); static final Object notifyLock = new Object(); @@ -77,7 +82,7 @@ public class RacyDeregister { public void run() { try { - for (int k = 0; k < 15; k++) { + for (int k = 0; k < numOuterLoopIterations; k++) { for (int i = 0; i < 10000; i++) { synchronized (notifyLock) { synchronized (selectorLock) { @@ -94,6 +99,17 @@ public class RacyDeregister { } long endTime = System.currentTimeMillis(); if (endTime - beginTime > 5000) { + for (int j = 0; j < 60; j++) { + Thread.sleep(1000); + if (notified) { + long t = + System.currentTimeMillis(); + System.out.printf + ("Notified after %d ms%n", + t - beginTime); + break; + } + } succTermination = false; // wake up main thread doing select() sel.wakeup(); From def15478ebc213eeff8eb4da9178f8bac4c72604 Mon Sep 17 00:00:00 2001 From: Steve Drach Date: Fri, 29 Jul 2016 09:58:28 -0700 Subject: [PATCH 03/66] 8158295: Add a multi-release jar validation mechanism to jar tool Reviewed-by: ogb, psandoz --- .../java.base/share/classes/module-info.java | 1 + .../classes/sun/tools/jar/FingerPrint.java | 324 ++++++++++++++++++ .../share/classes/sun/tools/jar/Main.java | 223 +++++++----- .../classes/sun/tools/jar/Validator.java | 242 +++++++++++++ .../sun/tools/jar/resources/jar.properties | 24 ++ jdk/test/tools/jar/multiRelease/Basic.java | 264 +++++++++++++- .../data/test04/v9/version/Version.java | 14 + .../data/test05/v9/version/Extra.java | 13 + .../data/test06/v9/version/Extra.java | 13 + .../data/test10/base/version/Nested.java | 17 + .../data/test10/v9/version/Nested.java | 14 + 11 files changed, 1069 insertions(+), 80 deletions(-) create mode 100644 jdk/src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java create mode 100644 jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test05/v9/version/Extra.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test06/v9/version/Extra.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test10/base/version/Nested.java create mode 100644 jdk/test/tools/jar/multiRelease/data/test10/v9/version/Nested.java diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index a6446ac111c..044f43b2877 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -128,6 +128,7 @@ module java.base { exports jdk.internal.logger to java.logging; exports jdk.internal.org.objectweb.asm to + jdk.jartool, jdk.jlink, jdk.scripting.nashorn, jdk.vm.ci; diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java new file mode 100644 index 00000000000..5ae52909e81 --- /dev/null +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2016, 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 sun.tools.jar; + +import jdk.internal.org.objectweb.asm.*; + +import java.io.IOException; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * A FingerPrint is an abstract representation of a JarFile entry that contains + * information to determine if the entry represents a class or a + * resource, and whether two entries are identical. If the FingerPrint represents + * a class, it also contains information to (1) describe the public API; + * (2) compare the public API of this class with another class; (3) determine + * whether or not it's a nested class and, if so, the name of the associated + * top level class; and (4) for an canonically ordered set of classes determine + * if the class versions are compatible. A set of classes is canonically + * ordered if the classes in the set have the same name, and the base class + * precedes the versioned classes and if each versioned class with version + * {@code n} precedes classes with versions {@code > n} for all versions + * {@code n}. + */ +final class FingerPrint { + private static final MessageDigest MD; + + private final byte[] sha1; + private final ClassAttributes attrs; + private final boolean isClassEntry; + private final String entryName; + + static { + try { + MD = MessageDigest.getInstance("SHA-1"); + } catch (NoSuchAlgorithmException x) { + // log big problem? + throw new RuntimeException(x); + } + } + + public FingerPrint(String entryName,byte[] bytes) throws IOException { + this.entryName = entryName; + if (entryName.endsWith(".class") && isCafeBabe(bytes)) { + isClassEntry = true; + sha1 = sha1(bytes, 8); // skip magic number and major/minor version + attrs = getClassAttributes(bytes); + } else { + isClassEntry = false; + sha1 = sha1(bytes); + attrs = new ClassAttributes(); // empty class + } + } + + public boolean isClass() { + return isClassEntry; + } + + public boolean isNestedClass() { + return attrs.nestedClass; + } + + public boolean isPublicClass() { + return attrs.publicClass; + } + + public boolean isIdentical(FingerPrint that) { + if (that == null) return false; + if (this == that) return true; + return isEqual(this.sha1, that.sha1); + } + + public boolean isCompatibleVersion(FingerPrint that) { + return attrs.version >= that.attrs.version; + } + + public boolean isSameAPI(FingerPrint that) { + if (that == null) return false; + return attrs.equals(that.attrs); + } + + public String name() { + String name = attrs.name; + return name == null ? entryName : name; + } + + public String topLevelName() { + String name = attrs.topLevelName; + return name == null ? name() : name; + } + + private byte[] sha1(byte[] entry) { + MD.update(entry); + return MD.digest(); + } + + private byte[] sha1(byte[] entry, int offset) { + MD.update(entry, offset, entry.length - offset); + return MD.digest(); + } + + private boolean isEqual(byte[] sha1_1, byte[] sha1_2) { + return MessageDigest.isEqual(sha1_1, sha1_2); + } + + private static final byte[] cafeBabe = {(byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe}; + + private boolean isCafeBabe(byte[] bytes) { + if (bytes.length < 4) return false; + for (int i = 0; i < 4; i++) { + if (bytes[i] != cafeBabe[i]) { + return false; + } + } + return true; + } + + private ClassAttributes getClassAttributes(byte[] bytes) { + ClassReader rdr = new ClassReader(bytes); + ClassAttributes attrs = new ClassAttributes(); + rdr.accept(attrs, 0); + return attrs; + } + + private static final class Field { + private final int access; + private final String name; + private final String desc; + + Field(int access, String name, String desc) { + this.access = access; + this.name = name; + this.desc = desc; + } + + @Override + public boolean equals(Object that) { + if (that == null) return false; + if (this == that) return true; + if (!(that instanceof Field)) return false; + Field field = (Field)that; + return (access == field.access) && name.equals(field.name) + && desc.equals(field.desc); + } + + @Override + public int hashCode() { + int result = 17; + result = 37 * result + access; + result = 37 * result + name.hashCode(); + result = 37 * result + desc.hashCode(); + return result; + } + } + + private static final class Method { + private final int access; + private final String name; + private final String desc; + private final Set exceptions; + + Method(int access, String name, String desc, Set exceptions) { + this.access = access; + this.name = name; + this.desc = desc; + this.exceptions = exceptions; + } + + @Override + public boolean equals(Object that) { + if (that == null) return false; + if (this == that) return true; + if (!(that instanceof Method)) return false; + Method method = (Method)that; + return (access == method.access) && name.equals(method.name) + && desc.equals(method.desc) + && exceptions.equals(method.exceptions); + } + + @Override + public int hashCode() { + int result = 17; + result = 37 * result + access; + result = 37 * result + name.hashCode(); + result = 37 * result + desc.hashCode(); + result = 37 * result + exceptions.hashCode(); + return result; + } + } + + private static final class ClassAttributes extends ClassVisitor { + private String name; + private String topLevelName; + private String superName; + private int version; + private int access; + private boolean publicClass; + private boolean nestedClass; + private final Set fields = new HashSet<>(); + private final Set methods = new HashSet<>(); + + public ClassAttributes() { + super(Opcodes.ASM5); + } + + private boolean isPublic(int access) { + return ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) + || ((access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED); + } + + @Override + public void visit(int version, int access, String name, String signature, + String superName, String[] interfaces) { + this.version = version; + this.access = access; + this.name = name; + this.nestedClass = name.contains("$"); + this.superName = superName; + this.publicClass = isPublic(access); + } + + @Override + public void visitOuterClass(String owner, String name, String desc) { + if (!this.nestedClass) return; + this.topLevelName = owner; + } + + @Override + public void visitInnerClass(String name, String outerName, String innerName, + int access) { + if (!this.nestedClass) return; + if (outerName == null) return; + if (!this.name.equals(name)) return; + if (this.topLevelName == null) this.topLevelName = outerName; + } + + @Override + public FieldVisitor visitField(int access, String name, String desc, + String signature, Object value) { + if (isPublic(access)) { + fields.add(new Field(access, name, desc)); + } + return null; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, + String signature, String[] exceptions) { + if (isPublic(access)) { + Set exceptionSet = new HashSet<>(); + if (exceptions != null) { + for (String e : exceptions) { + exceptionSet.add(e); + } + } + // treat type descriptor as a proxy for signature because signature + // is usually null, need to strip off the return type though + int n; + if (desc != null && (n = desc.lastIndexOf(')')) != -1) { + desc = desc.substring(0, n + 1); + methods.add(new Method(access, name, desc, exceptionSet)); + } + } + return null; + } + + @Override + public void visitEnd() { + this.nestedClass = this.topLevelName != null; + } + + @Override + public boolean equals(Object that) { + if (that == null) return false; + if (this == that) return true; + if (!(that instanceof ClassAttributes)) return false; + ClassAttributes clsAttrs = (ClassAttributes)that; + boolean superNameOkay = superName != null + ? superName.equals(clsAttrs.superName) : true; + return access == clsAttrs.access + && superNameOkay + && fields.equals(clsAttrs.fields) + && methods.equals(clsAttrs.methods); + } + + @Override + public int hashCode() { + int result = 17; + result = 37 * result + access; + result = 37 * result + superName != null ? superName.hashCode() : 0; + result = 37 * result + fields.hashCode(); + result = 37 * result + methods.hashCode(); + return result; + } + } +} diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index f33bcf711ce..00796dee41e 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -42,6 +42,7 @@ import java.nio.ByteBuffer; import java.nio.file.Path; import java.nio.file.Files; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.*; import java.util.function.Consumer; import java.util.function.Function; @@ -278,23 +279,20 @@ class Main { } } } + if (cflag) { Manifest manifest = null; - InputStream in = null; - if (!Mflag) { if (mname != null) { - in = new FileInputStream(mname); - manifest = new Manifest(new BufferedInputStream(in)); + try (InputStream in = new FileInputStream(mname)) { + manifest = new Manifest(new BufferedInputStream(in)); + } } else { manifest = new Manifest(); } addVersion(manifest); addCreatedBy(manifest); if (isAmbiguousMainClass(manifest)) { - if (in != null) { - in.close(); - } return false; } if (ename != null) { @@ -304,11 +302,13 @@ class Main { addMultiRelease(manifest); } } + Map moduleInfoPaths = new HashMap<>(); for (int version : filesMap.keySet()) { String[] files = filesMap.get(version); expand(null, files, false, moduleInfoPaths, version); } + Map moduleInfos = new LinkedHashMap<>(); if (!moduleInfoPaths.isEmpty()) { if (!checkModuleInfos(moduleInfoPaths)) @@ -332,84 +332,61 @@ class Main { return false; } - OutputStream out; - if (fname != null) { - out = new FileOutputStream(fname); - } else { - out = new FileOutputStream(FileDescriptor.out); - if (vflag) { - // Disable verbose output so that it does not appear - // on stdout along with file data - // error("Warning: -v option ignored"); - vflag = false; - } + if (vflag && fname == null) { + // Disable verbose output so that it does not appear + // on stdout along with file data + // error("Warning: -v option ignored"); + vflag = false; } - File tmpfile = null; - final OutputStream finalout = out; + final String tmpbase = (fname == null) ? "tmpjar" : fname.substring(fname.indexOf(File.separatorChar) + 1); - if (nflag) { - tmpfile = createTemporaryFile(tmpbase, ".jar"); - out = new FileOutputStream(tmpfile); - } - create(new BufferedOutputStream(out, 4096), manifest, moduleInfos); + File tmpfile = createTemporaryFile(tmpbase, ".jar"); - if (in != null) { - in.close(); + try (OutputStream out = new FileOutputStream(tmpfile)) { + create(new BufferedOutputStream(out, 4096), manifest, moduleInfos); } - out.close(); + if (nflag) { - JarFile jarFile = null; - File packFile = null; - JarOutputStream jos = null; + File packFile = createTemporaryFile(tmpbase, ".pack"); try { Packer packer = Pack200.newPacker(); Map p = packer.properties(); p.put(Packer.EFFORT, "1"); // Minimal effort to conserve CPU - jarFile = new JarFile(tmpfile.getCanonicalPath()); - packFile = createTemporaryFile(tmpbase, ".pack"); - out = new FileOutputStream(packFile); - packer.pack(jarFile, out); - jos = new JarOutputStream(finalout); - Unpacker unpacker = Pack200.newUnpacker(); - unpacker.unpack(packFile, jos); - } catch (IOException ioe) { - fatalError(ioe); - } finally { - if (jarFile != null) { - jarFile.close(); + try ( + JarFile jarFile = new JarFile(tmpfile.getCanonicalPath()); + OutputStream pack = new FileOutputStream(packFile) + ) { + packer.pack(jarFile, pack); } - if (out != null) { - out.close(); - } - if (jos != null) { - jos.close(); - } - if (tmpfile != null && tmpfile.exists()) { + if (tmpfile.exists()) { tmpfile.delete(); } - if (packFile != null && packFile.exists()) { - packFile.delete(); + tmpfile = createTemporaryFile(tmpbase, ".jar"); + try ( + OutputStream out = new FileOutputStream(tmpfile); + JarOutputStream jos = new JarOutputStream(out) + ) { + Unpacker unpacker = Pack200.newUnpacker(); + unpacker.unpack(packFile, jos); } + } finally { + Files.deleteIfExists(packFile.toPath()); } } + + validateAndClose(tmpfile); + } else if (uflag) { File inputFile = null, tmpFile = null; - FileInputStream in; - FileOutputStream out; if (fname != null) { inputFile = new File(fname); tmpFile = createTempFileInSameDirectoryAs(inputFile); - in = new FileInputStream(inputFile); - out = new FileOutputStream(tmpFile); } else { - in = new FileInputStream(FileDescriptor.in); - out = new FileOutputStream(FileDescriptor.out); vflag = false; + tmpFile = createTemporaryFile("tmpjar", ".jar"); } - InputStream manifest = (!Mflag && (mname != null)) ? - (new FileInputStream(mname)) : null; Map moduleInfoPaths = new HashMap<>(); for (int version : filesMap.keySet()) { @@ -421,8 +398,19 @@ class Main { for (Map.Entry e : moduleInfoPaths.entrySet()) moduleInfos.put(e.getKey(), readModuleInfo(e.getValue())); - boolean updateOk = update(in, new BufferedOutputStream(out), - manifest, moduleInfos, null); + try ( + FileInputStream in = (fname != null) ? new FileInputStream(inputFile) + : new FileInputStream(FileDescriptor.in); + FileOutputStream out = new FileOutputStream(tmpFile); + InputStream manifest = (!Mflag && (mname != null)) ? + (new FileInputStream(mname)) : null; + ) { + boolean updateOk = update(in, new BufferedOutputStream(out), + manifest, moduleInfos, null); + if (ok) { + ok = updateOk; + } + } // Consistency checks for modular jars. if (!moduleInfos.isEmpty()) { @@ -430,23 +418,8 @@ class Main { return false; } - if (ok) { - ok = updateOk; - } - in.close(); - out.close(); - if (manifest != null) { - manifest.close(); - } - if (ok && fname != null) { - // on Win32, we need this delete - inputFile.delete(); - if (!tmpFile.renameTo(inputFile)) { - tmpFile.delete(); - throw new IOException(getMsg("error.write.file")); - } - tmpFile.delete(); - } + validateAndClose(tmpFile); + } else if (tflag) { replaceFSC(filesMap); // For the "list table contents" action, access using the @@ -520,6 +493,28 @@ class Main { return ok; } + private void validateAndClose(File tmpfile) throws IOException { + if (ok && isMultiRelease) { + ok = validate(tmpfile.getCanonicalPath()); + if (!ok) { + error(formatMsg("error.validator.jarfile.invalid", fname)); + } + } + + Path path = tmpfile.toPath(); + try { + if (ok) { + if (fname != null) { + Files.move(path, Paths.get(fname), StandardCopyOption.REPLACE_EXISTING); + } else { + Files.copy(path, new FileOutputStream(FileDescriptor.out)); + } + } + } finally { + Files.deleteIfExists(path); + } + } + private String[] filesMapToFiles(Map filesMap) { if (filesMap.isEmpty()) return null; return filesMap.entrySet() @@ -534,6 +529,76 @@ class Main { .map(f -> (new EntryName(f, version)).entryName); } + // sort base entries before versioned entries, and sort entry classes with + // nested classes so that the top level class appears before the associated + // nested class + private Comparator entryComparator = (je1, je2) -> { + String s1 = je1.getName(); + String s2 = je2.getName(); + if (s1.equals(s2)) return 0; + boolean b1 = s1.startsWith(VERSIONS_DIR); + boolean b2 = s2.startsWith(VERSIONS_DIR); + if (b1 && !b2) return 1; + if (!b1 && b2) return -1; + int n = 0; // starting char for String compare + if (b1 && b2) { + // normally strings would be sorted so "10" goes before "9", but + // version number strings need to be sorted numerically + n = VERSIONS_DIR.length(); // skip the common prefix + int i1 = s1.indexOf('/', n); + int i2 = s1.indexOf('/', n); + if (i1 == -1) throw new InvalidJarException(s1); + if (i2 == -1) throw new InvalidJarException(s2); + // shorter version numbers go first + if (i1 != i2) return i1 - i2; + // otherwise, handle equal length numbers below + } + int l1 = s1.length(); + int l2 = s2.length(); + int lim = Math.min(l1, l2); + for (int k = n; k < lim; k++) { + char c1 = s1.charAt(k); + char c2 = s2.charAt(k); + if (c1 != c2) { + // change natural ordering so '.' comes before '$' + // i.e. top level classes come before nested classes + if (c1 == '$' && c2 == '.') return 1; + if (c1 == '.' && c2 == '$') return -1; + return c1 - c2; + } + } + return l1 - l2; + }; + + private boolean validate(String fname) { + boolean valid; + + try (JarFile jf = new JarFile(fname)) { + Validator validator = new Validator(this, jf); + jf.stream() + .filter(e -> !e.isDirectory()) + .filter(e -> !e.getName().equals(MANIFEST_NAME)) + .filter(e -> !e.getName().endsWith(MODULE_INFO)) + .sorted(entryComparator) + .forEachOrdered(validator); + valid = validator.isValid(); + } catch (IOException e) { + error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage())); + valid = false; + } catch (InvalidJarException e) { + error(formatMsg("error.validator.bad.entry.name", e.getMessage())); + valid = false; + } + return valid; + } + + private static class InvalidJarException extends RuntimeException { + private static final long serialVersionUID = -3642329147299217726L; + InvalidJarException(String msg) { + super(msg); + } + } + /** * Parses command line arguments. */ diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java new file mode 100644 index 00000000000..bf4fa8bf702 --- /dev/null +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2016, 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 sun.tools.jar; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +final class Validator implements Consumer { + private final static boolean DEBUG = Boolean.getBoolean("jar.debug"); + private final Map fps = new HashMap<>(); + private final int vdlen = Main.VERSIONS_DIR.length(); + private final Main main; + private final JarFile jf; + private int oldVersion = -1; + private String currentTopLevelName; + private boolean isValid = true; + + Validator(Main main, JarFile jf) { + this.main = main; + this.jf = jf; + } + + boolean isValid() { + return isValid; + } + + /* + * Validator has state and assumes entries provided to accept are ordered + * from base entries first and then through the versioned entries in + * ascending version order. Also, to find isolated nested classes, + * classes must be ordered so that the top level class is before the associated + * nested class(es). + */ + public void accept(JarEntry je) { + String entryName = je.getName(); + + // directories are always accepted + if (entryName.endsWith("/")) { + debug("%s is a directory", entryName); + return; + } + + // figure out the version and basename from the JarEntry + int version; + String basename; + if (entryName.startsWith(Main.VERSIONS_DIR)) { + int n = entryName.indexOf("/", vdlen); + if (n == -1) { + main.error(Main.formatMsg("error.validator.version.notnumber", entryName)); + isValid = false; + return; + } + String v = entryName.substring(vdlen, n); + try { + version = Integer.parseInt(v); + } catch (NumberFormatException x) { + main.error(Main.formatMsg("error.validator.version.notnumber", entryName)); + isValid = false; + return; + } + if (n == entryName.length()) { + main.error(Main.formatMsg("error.validator.entryname.tooshort", entryName)); + isValid = false; + return; + } + basename = entryName.substring(n + 1); + } else { + version = 0; + basename = entryName; + } + debug("\n===================\nversion %d %s", version, entryName); + + if (oldVersion != version) { + oldVersion = version; + currentTopLevelName = null; + } + + // analyze the entry, keeping key attributes + FingerPrint fp; + try (InputStream is = jf.getInputStream(je)) { + fp = new FingerPrint(basename, is.readAllBytes()); + } catch (IOException x) { + main.error(x.getMessage()); + isValid = false; + return; + } + String internalName = fp.name(); + + // process a base entry paying attention to nested classes + if (version == 0) { + debug("base entry found"); + if (fp.isNestedClass()) { + debug("nested class found"); + if (fp.topLevelName().equals(currentTopLevelName)) { + fps.put(internalName, fp); + return; + } + main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName)); + isValid = false; + return; + } + // top level class or resource entry + if (fp.isClass()) { + currentTopLevelName = fp.topLevelName(); + if (!checkInternalName(entryName, basename, internalName)) { + isValid = false; + return; + } + } + fps.put(internalName, fp); + return; + } + + // process a versioned entry, look for previous entry with same name + FingerPrint matchFp = fps.get(internalName); + debug("looking for match"); + if (matchFp == null) { + debug("no match found"); + if (fp.isClass()) { + if (fp.isNestedClass()) { + if (!checkNestedClass(version, entryName, internalName, fp)) { + isValid = false; + } + return; + } + if (fp.isPublicClass()) { + main.error(Main.formatMsg("error.validator.new.public.class", entryName)); + isValid = false; + return; + } + debug("%s is a non-public class entry", entryName); + fps.put(internalName, fp); + currentTopLevelName = fp.topLevelName(); + return; + } + debug("%s is a resource entry"); + fps.put(internalName, fp); + return; + } + debug("match found"); + + // are the two classes/resources identical? + if (fp.isIdentical(matchFp)) { + main.error(Main.formatMsg("error.validator.identical.entry", entryName)); + return; // it's okay, just takes up room + } + debug("sha1 not equal -- different bytes"); + + // ok, not identical, check for compatible class version and api + if (fp.isClass()) { + if (fp.isNestedClass()) { + if (!checkNestedClass(version, entryName, internalName, fp)) { + isValid = false; + } + return; + } + debug("%s is a class entry", entryName); + if (!fp.isCompatibleVersion(matchFp)) { + main.error(Main.formatMsg("error.validator.incompatible.class.version", entryName)); + isValid = false; + return; + } + if (!fp.isSameAPI(matchFp)) { + main.error(Main.formatMsg("error.validator.different.api", entryName)); + isValid = false; + return; + } + if (!checkInternalName(entryName, basename, internalName)) { + isValid = false; + return; + } + debug("fingerprints same -- same api"); + fps.put(internalName, fp); + currentTopLevelName = fp.topLevelName(); + return; + } + debug("%s is a resource", entryName); + + main.error(Main.formatMsg("error.validator.resources.with.same.name", entryName)); + fps.put(internalName, fp); + return; + } + + private boolean checkInternalName(String entryName, String basename, String internalName) { + String className = className(basename); + if (internalName.equals(className)) { + return true; + } + main.error(Main.formatMsg2("error.validator.names.mismatch", + entryName, internalName.replace("/", "."))); + return false; + } + + private boolean checkNestedClass(int version, String entryName, String internalName, FingerPrint fp) { + debug("%s is a nested class entry in top level class %s", entryName, fp.topLevelName()); + if (fp.topLevelName().equals(currentTopLevelName)) { + debug("%s (top level class) was accepted", fp.topLevelName()); + fps.put(internalName, fp); + return true; + } + debug("top level class was not accepted"); + main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName)); + return false; + } + + private String className(String entryName) { + return entryName.endsWith(".class") ? entryName.substring(0, entryName.length() - 6) : null; + } + + private void debug(String fmt, Object... args) { + if (DEBUG) System.err.format(fmt, args); + } +} + diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties index e00ee76610d..9c570c7ded8 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties @@ -85,6 +85,30 @@ error.release.value.notnumber=\ release {0} not valid error.release.value.toosmall=\ release {0} not valid, must be >= 9 +error.validator.jarfile.exception=\ + can not validate {0}: {1} +error.validator.jarfile.invalid=\ + invalid multi-release jar file {0} deleted +error.validator.bad.entry.name=\ + entry name malformed, {0} +error.validator.version.notnumber=\ + entry name: {0}, does not have a version number +error.validator.entryname.tooshort=\ + entry name: {0}, too short, not a directory +error.validator.isolated.nested.class=\ + entry: {0}, is an isolated nested class +error.validator.new.public.class=\ + entry: {0}, contains a new public class not found in base entries +error.validator.identical.entry=\ + warning - entry: {0} contains a class that is identical to an entry already in the jar +error.validator.incompatible.class.version=\ + entry: {0}, has a class version incompatible with an earlier version +error.validator.different.api=\ + entry: {0}, contains a class with different api from earlier version +error.validator.resources.with.same.name=\ + warning - entry: {0}, multiple resources with same name +error.validator.names.mismatch=\ + entry: {0}, contains a class with internal name {1}, names do not match out.added.manifest=\ added manifest out.added.module-info=\ diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java index cd5c195a169..589615ad1e9 100644 --- a/jdk/test/tools/jar/multiRelease/Basic.java +++ b/jdk/test/tools/jar/multiRelease/Basic.java @@ -43,6 +43,7 @@ import java.util.stream.Stream; import java.util.zip.*; import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; import static java.lang.String.format; import static java.lang.System.out; @@ -198,6 +199,262 @@ public class Basic { deleteDir(Paths.get(usr, "classes")); } + /* + * The following tests exercise the jar validator + */ + + @Test + // META-INF/versions/9 class has different api than base class + public void test04() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // replace the v9 class + Path source = Paths.get(src, "data", "test04", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Version.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertFailure() + .resultChecker(r -> + assertTrue(r.output.contains("different api from earlier"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // META-INF/versions/9 contains an extra public class + public void test05() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add the new v9 class + Path source = Paths.get(src, "data", "test05", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Extra.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertFailure() + .resultChecker(r -> + assertTrue(r.output.contains("contains a new public class"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // META-INF/versions/9 contains an extra package private class -- this is okay + public void test06() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add the new v9 class + Path source = Paths.get(src, "data", "test06", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Extra.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // META-INF/versions/9 contains an identical class to base entry class + // this is okay but produces warning + public void test07() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add the new v9 class + Path source = Paths.get(src, "data", "test01", "base", "version"); + javac(classes.resolve("v9"), source.resolve("Version.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess() + .resultChecker(r -> + assertTrue(r.output.contains("contains a class that is identical"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // resources with same name in different versions + // this is okay but produces warning + public void test08() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add a resource to the base + Path source = Paths.get(src, "data", "test01", "base", "version"); + Files.copy(source.resolve("Version.java"), classes.resolve("base") + .resolve("version").resolve("Version.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess() + .resultChecker(r -> + assertTrue(r.output.isEmpty(), r.output) + ); + + // now add a different resource with same name to META-INF/version/9 + Files.copy(source.resolve("Main.java"), classes.resolve("v9") + .resolve("version").resolve("Version.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess() + .resultChecker(r -> + assertTrue(r.output.contains("multiple resources with same name"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // a class with an internal name different from the external name + public void test09() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + Path base = classes.resolve("base").resolve("version"); + + Files.copy(base.resolve("Main.class"), base.resolve("Foo.class")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertFailure() + .resultChecker(r -> + assertTrue(r.output.contains("names do not match"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // assure that basic nested classes are acceptable + public void test10() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add a base class with a nested class + Path source = Paths.get(src, "data", "test10", "base", "version"); + javac(classes.resolve("base"), source.resolve("Nested.java")); + + // add a versioned class with a nested class + source = Paths.get(src, "data", "test10", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Nested.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertSuccess(); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // a base entry contains a nested class that doesn't have a matching top level class + public void test11() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add a base class with a nested class + Path source = Paths.get(src, "data", "test10", "base", "version"); + javac(classes.resolve("base"), source.resolve("Nested.java")); + + // remove the top level class, thus isolating the nested class + Files.delete(classes.resolve("base").resolve("version").resolve("Nested.class")); + + // add a versioned class with a nested class + source = Paths.get(src, "data", "test10", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Nested.java")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertFailure() + .resultChecker(r -> { + String[] msg = r.output.split("\\R"); + // There should be 3 error messages, cascading from the first. Once we + // remove the base top level class, the base nested class becomes isolated, + // also the versioned top level class becomes a new public class, thus ignored + // for subsequent checks, leading to the associated versioned nested class + // becoming an isolated nested class + assertTrue(msg.length == 4); + assertTrue(msg[0].contains("an isolated nested class"), msg[0]); + assertTrue(msg[1].contains("contains a new public class"), msg[1]); + assertTrue(msg[2].contains("an isolated nested class"), msg[2]); + assertTrue(msg[3].contains("invalid multi-release jar file"), msg[3]); + }); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + + @Test + // a versioned entry contains a nested class that doesn't have a matching top level class + public void test12() throws IOException { + String jarfile = "test.jar"; + + compile("test01"); //use same data as test01 + + Path classes = Paths.get("classes"); + + // add a base class with a nested class + Path source = Paths.get(src, "data", "test10", "base", "version"); + javac(classes.resolve("base"), source.resolve("Nested.java")); + + // add a versioned class with a nested class + source = Paths.get(src, "data", "test10", "v9", "version"); + javac(classes.resolve("v9"), source.resolve("Nested.java")); + + // remove the top level class, thus isolating the nested class + Files.delete(classes.resolve("v9").resolve("version").resolve("Nested.class")); + + jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".", + "--release", "9", "-C", classes.resolve("v9").toString(), ".") + .assertFailure() + .resultChecker(r -> + assertTrue(r.output.contains("an isolated nested class"), r.output) + ); + + delete(jarfile); + deleteDir(Paths.get(usr, "classes")); + } + /* * Test Infrastructure */ @@ -243,7 +500,7 @@ public class Basic { } private void delete(String name) throws IOException { - Files.delete(Paths.get(usr, name)); + Files.deleteIfExists(Paths.get(usr, name)); } private void deleteDir(Path dir) throws IOException { @@ -271,6 +528,10 @@ public class Basic { List commands = new ArrayList<>(); commands.add(javac); + String opts = System.getProperty("test.compiler.opts"); + if (!opts.isEmpty()) { + commands.addAll(Arrays.asList(opts.split(" +"))); + } commands.add("-d"); commands.add(dest.toString()); Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); @@ -282,6 +543,7 @@ public class Basic { String jar = JDKToolFinder.getJDKTool("jar"); List commands = new ArrayList<>(); commands.add(jar); + commands.addAll(Utils.getForwardVmOptions()); Stream.of(args).forEach(x -> commands.add(x)); ProcessBuilder p = new ProcessBuilder(commands); if (stdinSource != null) diff --git a/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java b/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java new file mode 100644 index 00000000000..c4731163178 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test04/v9/version/Version.java @@ -0,0 +1,14 @@ +package version; + +public class Version { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + // extra publc method + public void anyName() { + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test05/v9/version/Extra.java b/jdk/test/tools/jar/multiRelease/data/test05/v9/version/Extra.java new file mode 100644 index 00000000000..83ef985c410 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test05/v9/version/Extra.java @@ -0,0 +1,13 @@ +package version; + +public class Extra { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + private void anyName() { + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test06/v9/version/Extra.java b/jdk/test/tools/jar/multiRelease/data/test06/v9/version/Extra.java new file mode 100644 index 00000000000..f2d7862aad3 --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test06/v9/version/Extra.java @@ -0,0 +1,13 @@ +package version; + +class Extra { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + private void anyName() { + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test10/base/version/Nested.java b/jdk/test/tools/jar/multiRelease/data/test10/base/version/Nested.java new file mode 100644 index 00000000000..88f3d93d19c --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test10/base/version/Nested.java @@ -0,0 +1,17 @@ +package version; + +public class Nested { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + private void anyName() { + } + + class nested { + int save; + } +} diff --git a/jdk/test/tools/jar/multiRelease/data/test10/v9/version/Nested.java b/jdk/test/tools/jar/multiRelease/data/test10/v9/version/Nested.java new file mode 100644 index 00000000000..7e3d0c6b16e --- /dev/null +++ b/jdk/test/tools/jar/multiRelease/data/test10/v9/version/Nested.java @@ -0,0 +1,14 @@ +package version; + +public class Nested { + public int getVersion() { + return 9; + } + + protected void doNothing() { + } + + class nested { + int save = getVersion(); + } +} From d0c3112a73a1dd2a488ad9ad2efbda0c2bd4a8c7 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Thu, 4 Aug 2016 13:58:06 +0800 Subject: [PATCH 04/66] 8163145: Remove two null line in the end of message.properties Reviewed-by: joehw, rriggs --- .../apache/xerces/internal/impl/xpath/regex/message.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties index 01f475b6ed8..48e15b05488 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties @@ -37,5 +37,3 @@ parser.quantifier.2=Invalid quantifier. Invalid quantity or a '}' is missing. parser.quantifier.3=Invalid quantifier. A digit or '}' is expected. parser.quantifier.4=Invalid quantifier. A min quantity must be <= a max quantity. parser.quantifier.5=Invalid quantifier. A quantity value overflow. -null -null From cd9b88b93dab89d58dbd1a3695cc6307c7c4d425 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 9 Aug 2016 07:31:16 -0700 Subject: [PATCH 05/66] 8075529: Documentation in DocumentationTool.getTask(...) should mention about "null" parameter for doclet Reviewed-by: jjg --- .../share/classes/javax/tools/DocumentationTool.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java b/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java index 163c2a56fc3..aeb7b98f9d7 100644 --- a/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java +++ b/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -57,7 +57,7 @@ public interface DocumentationTool extends Tool, OptionChecker { * use the tool's default method for reporting diagnostics * * @param docletClass a class providing the necessary methods required - * of a doclet + * of a doclet; a value of {@code null} means to use the standard doclet. * * @param options documentation tool options and doclet options, * {@code null} means no options From 39de28475b594f63ef908e057c96073b66220c08 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 9 Aug 2016 20:27:06 +0200 Subject: [PATCH 06/66] 8143048: Re-examine dependency on property sun.boot.class.path Removing obsolete references to sun.boot.class.path Reviewed-by: jjg --- .../com/sun/tools/javac/file/Locations.java | 24 ++----------------- .../processing/messager/MessagerDiags.java | 1 - 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index 2ec0256463f..fd543bba91f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -773,14 +773,14 @@ public class Locations { private Collection systemClasses() throws IOException { // Return "modules" jimage file if available if (Files.isRegularFile(thisSystemModules)) { - return addAdditionalBootEntries(Collections.singleton(thisSystemModules)); + return Collections.singleton(thisSystemModules); } // Exploded module image Path modules = javaHome.resolve("modules"); if (Files.isDirectory(modules.resolve("java.base"))) { try (Stream listedModules = Files.list(modules)) { - return addAdditionalBootEntries(listedModules.collect(Collectors.toList())); + return listedModules.collect(Collectors.toList()); } } @@ -788,26 +788,6 @@ public class Locations { return null; } - //ensure bootclasspath prepends/appends are reflected in the systemClasses - private Collection addAdditionalBootEntries(Collection modules) throws IOException { - String files = System.getProperty("sun.boot.class.path"); - if (files == null) - return modules; - - Set paths = new LinkedHashSet<>(); - - // The JVM no longer supports -Xbootclasspath/p:, so any interesting - // entries should be appended to the set of modules. - - paths.addAll(modules); - - for (String s : files.split(Pattern.quote(File.pathSeparator))) { - paths.add(getPath(s)); - } - - return paths; - } - private void lazy() { if (searchPath == null) { try { diff --git a/langtools/test/tools/javac/processing/messager/MessagerDiags.java b/langtools/test/tools/javac/processing/messager/MessagerDiags.java index 64c2a3ac9dd..41d34240af2 100644 --- a/langtools/test/tools/javac/processing/messager/MessagerDiags.java +++ b/langtools/test/tools/javac/processing/messager/MessagerDiags.java @@ -80,7 +80,6 @@ public class MessagerDiags extends AbstractProcessor { } public static void main(String... args) throws IOException { - final String bootPath = System.getProperty("sun.boot.class.path"); final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); assert tool != null; From 719eeed2d23b10d225810c09de0620ed6ea45bdb Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 9 Aug 2016 13:22:57 -0700 Subject: [PATCH 07/66] 8160697: HTMLWriter needs perf cleanup Reviewed-by: ksrini, bpatel --- .../html/AbstractExecutableMemberWriter.java | 8 +- .../formats/html/AbstractIndexWriter.java | 27 +- .../formats/html/AbstractMemberWriter.java | 23 +- .../html/AbstractModuleIndexWriter.java | 4 +- .../html/AbstractPackageIndexWriter.java | 6 +- .../formats/html/AbstractTreeWriter.java | 9 +- .../formats/html/AllClassesFrameWriter.java | 12 +- .../html/AnnotationTypeFieldWriterImpl.java | 23 +- ...nnotationTypeOptionalMemberWriterImpl.java | 25 +- ...nnotationTypeRequiredMemberWriterImpl.java | 23 +- .../html/AnnotationTypeWriterImpl.java | 36 +- .../doclets/formats/html/ClassUseWriter.java | 76 ++-- .../doclets/formats/html/ClassWriterImpl.java | 68 ++- .../formats/html/ConfigurationImpl.java | 102 ++++- .../html/ConstantsSummaryWriterImpl.java | 15 +- .../formats/html/ConstructorWriterImpl.java | 38 +- .../doclets/formats/html/Contents.java | 369 +++++++++++++++++ .../formats/html/DeprecatedListWriter.java | 14 +- .../formats/html/EnumConstantWriterImpl.java | 30 +- .../doclets/formats/html/FieldWriterImpl.java | 38 +- .../formats/html/FrameOutputWriter.java | 8 +- .../doclets/formats/html/HelpWriter.java | 147 ++++--- .../doclets/formats/html/HtmlDoclet.java | 13 +- .../formats/html/HtmlDocletWriter.java | 103 ++--- .../formats/html/MethodWriterImpl.java | 70 ++-- .../formats/html/ModuleFrameWriter.java | 17 +- .../formats/html/ModuleIndexFrameWriter.java | 16 +- .../formats/html/ModuleIndexWriter.java | 11 +- .../html/ModulePackageIndexFrameWriter.java | 26 +- .../formats/html/ModuleWriterImpl.java | 49 ++- .../formats/html/NestedClassWriterImpl.java | 26 +- .../formats/html/PackageFrameWriter.java | 33 +- .../formats/html/PackageIndexFrameWriter.java | 16 +- .../formats/html/PackageIndexWriter.java | 16 +- .../formats/html/PackageTreeWriter.java | 14 +- .../formats/html/PackageUseWriter.java | 25 +- .../formats/html/PackageWriterImpl.java | 37 +- .../formats/html/PropertyWriterImpl.java | 38 +- .../html/SerializedFormWriterImpl.java | 8 +- .../formats/html/SingleIndexWriter.java | 10 +- .../formats/html/SourceToHTMLConverter.java | 5 +- .../formats/html/SplitIndexWriter.java | 15 +- .../formats/html/SubWriterHolderWriter.java | 18 +- .../formats/html/TagletWriterImpl.java | 11 +- .../doclets/formats/html/TreeWriter.java | 12 +- .../html/markup/FixedStringContent.java | 138 +++++++ .../formats/html/markup/HtmlDocWriter.java | 11 +- .../formats/html/markup/HtmlWriter.java | 391 +++++------------- .../doclets/formats/html/markup/RawHtml.java | 2 +- .../doclets/toolkit/AbstractDoclet.java | 15 +- .../toolkit/AnnotationTypeFieldWriter.java | 5 - .../AnnotationTypeRequiredMemberWriter.java | 5 - .../doclets/toolkit/AnnotationTypeWriter.java | 5 - .../internal/doclets/toolkit/ClassWriter.java | 5 - .../doclets/toolkit/Configuration.java | 159 +++---- .../toolkit/ConstantsSummaryWriter.java | 5 - .../doclets/toolkit/ConstructorWriter.java | 5 - .../doclets/toolkit/EnumConstantWriter.java | 5 - .../internal/doclets/toolkit/FieldWriter.java | 5 - .../doclets/toolkit/MemberSummaryWriter.java | 5 - .../internal/doclets/toolkit/Messages.java | 164 ++++++++ .../doclets/toolkit/MethodWriter.java | 5 - .../doclets/toolkit/ModuleSummaryWriter.java | 6 - .../doclets/toolkit/NestedClassWriter.java | 5 - .../doclets/toolkit/PackageSummaryWriter.java | 5 - .../doclets/toolkit/PropertyWriter.java | 5 - .../internal/doclets/toolkit/Resources.java | 116 ++++++ .../doclets/toolkit/SerializedFormWriter.java | 5 - .../toolkit/builders/AbstractBuilder.java | 14 +- .../builders/AnnotationTypeBuilder.java | 1 - .../toolkit/builders/ClassBuilder.java | 1 - .../builders/ConstantsSummaryBuilder.java | 1 - .../builders/ModuleSummaryBuilder.java | 1 - .../builders/PackageSummaryBuilder.java | 1 - .../builders/SerializedFormBuilder.java | 6 +- .../toolkit/taglets/InheritDocTaglet.java | 6 +- .../doclets/toolkit/taglets/ParamTaglet.java | 24 +- .../doclets/toolkit/taglets/ReturnTaglet.java | 4 +- .../toolkit/taglets/TagletManager.java | 44 +- .../doclets/toolkit/taglets/TagletWriter.java | 8 - .../doclets/toolkit/taglets/ValueTaglet.java | 8 +- .../doclets/toolkit/util/ClassTree.java | 6 +- .../internal/doclets/toolkit/util/Group.java | 24 +- .../doclets/toolkit/util/IndexBuilder.java | 8 +- .../toolkit/util/MessageRetriever.java | 280 ------------- .../toolkit/util/PackageListWriter.java | 4 +- .../internal/doclets/toolkit/util/Utils.java | 15 +- .../toolkit/util/VisibleMemberMap.java | 5 +- 88 files changed, 1704 insertions(+), 1519 deletions(-) create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java delete mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java index 44977bfb71a..bb363d19ade 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -80,7 +80,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite Content typeParameters = getTypeParameters(member); if (!typeParameters.isEmpty()) { htmltree.addContent(typeParameters); - htmltree.addContent(writer.getSpace()); + htmltree.addContent(Contents.SPACE); } } @@ -157,7 +157,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite param.asType()).varargs(isVarArg)); tree.addContent(link); if(name(param).length() > 0) { - tree.addContent(writer.getSpace()); + tree.addContent(Contents.SPACE); tree.addContent(name(param)); } } @@ -173,11 +173,11 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType, List annotationMirrors, Content tree) { writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree); - tree.addContent(writer.getSpace()); + tree.addContent(Contents.SPACE); tree.addContent(utils.getTypeName(rcvrType, false)); LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType); tree.addContent(writer.getTypeParameterLinks(linkInfo)); - tree.addContent(writer.getSpace()); + tree.addContent(Contents.SPACE); tree.addContent("this"); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java index b9d4d36c2a5..66e41b7bfc2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java @@ -82,8 +82,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { */ protected AbstractIndexWriter(ConfigurationImpl configuration, DocPath path, - IndexBuilder indexbuilder) - throws IOException { + IndexBuilder indexbuilder) { super(configuration, path); this.indexbuilder = indexbuilder; } @@ -94,7 +93,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * @return a content tree for the tree label */ protected Content getNavLinkIndex() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.indexLabel); return li; } @@ -216,10 +215,10 @@ public class AbstractIndexWriter extends HtmlDocletWriter { protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) { Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); si.setLabel(utils.getPackageName(pkg)); - si.setCategory(getResource("doclet.Packages").toString()); + si.setCategory(resources.getText("doclet.Packages")); Content dt = HtmlTree.DT(link); dt.addContent(" - "); - dt.addContent(getResource("doclet.package")); + dt.addContent(contents.package_); dt.addContent(" " + utils.getPackageName(pkg)); dlTree.addContent(dt); Content dd = new HtmlTree(HtmlTag.DD); @@ -238,7 +237,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { LinkInfoImpl.Kind.INDEX, typeElement).strong(true)); si.setContainingPackage(utils.getPackageName(utils.containingPackage(typeElement))); si.setLabel(utils.getSimpleName(typeElement)); - si.setCategory(getResource("doclet.Types").toString()); + si.setCategory(resources.getText("doclet.Types")); Content dt = HtmlTree.DT(link); dt.addContent(" - "); addClassInfo(typeElement, dt); @@ -256,7 +255,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * @param contentTree the content tree to which the class info will be added */ protected void addClassInfo(TypeElement te, Content contentTree) { - contentTree.addContent(getResource("doclet.in", + contentTree.addContent(contents.getContent("doclet.in", utils.getTypeElementName(te, false), getPackageLink(utils.containingPackage(te), utils.getPackageName(utils.containingPackage(te))) @@ -286,7 +285,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { } else { si.setLabel(name); } - si.setCategory(getResource("doclet.Members").toString()); + si.setCategory(resources.getText("doclet.Members")); Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink, getDocLink(LinkInfoImpl.Kind.INDEX, member, name)); Content dt = HtmlTree.DT(span); @@ -304,11 +303,11 @@ public class AbstractIndexWriter extends HtmlDocletWriter { HtmlTree labelLink = HtmlTree.A(path, new StringContent(sii.getLabel())); Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink)); dt.addContent(" - "); - dt.addContent(getResource("doclet.Search_tag_in", sii.getHolder())); + dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder())); dlTree.addContent(dt); Content dd = new HtmlTree(HtmlTag.DD); if (sii.getDescription().isEmpty()) { - dd.addContent(getSpace()); + dd.addContent(Contents.SPACE); } else { dd.addContent(sii.getDescription()); } @@ -326,7 +325,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { */ protected void addComment(Element element, Content contentTree) { List tags; - Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.block); if (utils.isDeprecated(element)) { @@ -360,15 +359,15 @@ public class AbstractIndexWriter extends HtmlDocletWriter { TypeElement containing = utils.getEnclosingTypeElement(member); String classdesc = utils.getTypeElementName(containing, true) + " "; if (utils.isField(member)) { - Content resource = getResource(utils.isStatic(member) + Content resource = contents.getContent(utils.isStatic(member) ? "doclet.Static_variable_in" : "doclet.Variable_in", classdesc); contentTree.addContent(resource); } else if (utils.isConstructor(member)) { contentTree.addContent( - getResource("doclet.Constructor_for", classdesc)); + contents.getContent("doclet.Constructor_for", classdesc)); } else if (utils.isMethod(member)) { - Content resource = getResource(utils.isStatic(member) + Content resource = contents.getContent(utils.isStatic(member) ? "doclet.Static_method_in" : "doclet.Method_in", classdesc); contentTree.addContent(resource); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java index 50f4c099807..595d5b45af9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java @@ -33,13 +33,9 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeParameterElement; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.SimpleElementVisitor9; import com.sun.source.doctree.DocTree; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; @@ -48,6 +44,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.taglets.DeprecatedTaglet; import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes; import jdk.javadoc.internal.doclets.toolkit.util.Utils; @@ -73,6 +70,9 @@ public abstract class AbstractMemberWriter { protected final ConfigurationImpl configuration; protected final Utils utils; protected final SubWriterHolderWriter writer; + protected final Contents contents; + protected final Resources resources; + protected final TypeElement typeElement; protected Map typeMap = new LinkedHashMap<>(); protected Set methodTypes = EnumSet.noneOf(MethodTypes.class); @@ -86,7 +86,9 @@ public abstract class AbstractMemberWriter { this.writer = writer; this.nodepr = configuration.nodeprecated; this.typeElement = typeElement; - this.utils = writer.configuration.utils; + this.utils = configuration.utils; + this.contents = configuration.contents; + this.resources = configuration.resources; } public AbstractMemberWriter(SubWriterHolderWriter writer) { @@ -258,7 +260,7 @@ public abstract class AbstractMemberWriter { if (!set.isEmpty()) { String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" ")); htmltree.addContent(mods); - htmltree.addContent(writer.getSpace()); + htmltree.addContent(Contents.SPACE); } } @@ -286,7 +288,7 @@ public abstract class AbstractMemberWriter { addModifier(member, code); if (type == null) { code.addContent(utils.isClass(member) ? "class" : "interface"); - code.addContent(writer.getSpace()); + code.addContent(Contents.SPACE); } else { List list = utils.isExecutableElement(member) ? ((ExecutableElement)member).getTypeParameters() @@ -299,7 +301,7 @@ public abstract class AbstractMemberWriter { if (typeParameters.charCount() > 10) { code.addContent(new HtmlTree(HtmlTag.BR)); } else { - code.addContent(writer.getSpace()); + code.addContent(Contents.SPACE); } code.addContent( writer.getLink(new LinkInfoImpl(configuration, @@ -394,6 +396,7 @@ public abstract class AbstractMemberWriter { * @param ped The ProgramElement being checked. * return true if the ProgramElement is being inherited and * false otherwise. + *@return true if inherited */ protected boolean isInherited(Element ped){ return (!utils.isPrivate(ped) && @@ -413,7 +416,7 @@ public abstract class AbstractMemberWriter { protected void addDeprecatedAPI(Collection deprmembers, String headingKey, String tableSummary, List tableHeader, Content contentTree) { if (deprmembers.size() > 0) { - Content caption = writer.getTableCaption(configuration.getResource(headingKey)); + Content caption = writer.getTableCaption(configuration.getContent(headingKey)); Content table = (configuration.isOutputHtml5()) ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption) : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption); @@ -536,7 +539,7 @@ public abstract class AbstractMemberWriter { protected void serialWarning(Element e, String key, String a1, String a2) { if (configuration.serialwarn) { - configuration.getDocletSpecificMsg().warning(e, key, a1, a2); + configuration.messages.warning(e, key, a1, a2); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java index 457fe161fd1..f0965f6bb4e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java @@ -66,7 +66,7 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * @param filename Name of the module index file to be generated. */ public AbstractModuleIndexWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + DocPath filename) { super(configuration, filename); modules = configuration.modulePackages; } @@ -259,7 +259,7 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * @return a Content object to be added to the documentation tree */ protected Content getNavLinkContents() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel); return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java index 62a10745ce9..9066b515da1 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -65,7 +65,7 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { * @param filename Name of the package index file to be generated. */ public AbstractPackageIndexWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + DocPath filename) { super(configuration, filename); packages = configuration.packages; } @@ -191,7 +191,7 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { * @return a Content object to be added to the documentation tree */ protected Content getNavLinkContents() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel); return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java index 68ede24c0cf..b8606b483af 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java @@ -71,8 +71,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { * @throws DocletAbortException */ protected AbstractTreeWriter(ConfigurationImpl configuration, - DocPath filename, ClassTree classtree) - throws IOException { + DocPath filename, ClassTree classtree) { super(configuration, filename); this.classtree = classtree; } @@ -121,7 +120,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { HtmlTree div, boolean isEnums) { if (!sset.isEmpty()) { TypeElement firstTypeElement = sset.first(); - Content headingContent = getResource(heading); + Content headingContent = contents.getContent(heading); Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent); HtmlTree htmlTree; @@ -162,7 +161,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { isFirst = false; if (utils.isInterface(typeElement)) { contentTree.addContent(" ("); - contentTree.addContent(getResource("doclet.also")); + contentTree.addContent(contents.also); contentTree.addContent(" extends "); } else { contentTree.addContent(" (implements "); @@ -196,7 +195,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { * @return a content tree for the tree label */ protected Content getNavLinkTree() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.treeLabel); return li; } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java index 6ba6f0afc4c..9091fb27a5a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java @@ -35,6 +35,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -78,8 +79,7 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { * @throws DocletAbortException */ public AllClassesFrameWriter(ConfigurationImpl configuration, - DocPath filename, IndexBuilder indexbuilder) - throws IOException { + DocPath filename, IndexBuilder indexbuilder) { super(configuration, filename); this.indexbuilder = indexbuilder; } @@ -100,15 +100,13 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { allclassgen = new AllClassesFrameWriter(configuration, filename, indexbuilder); allclassgen.buildAllClassesFile(true); - allclassgen.close(); filename = DocPaths.ALLCLASSES_NOFRAME; allclassgen = new AllClassesFrameWriter(configuration, filename, indexbuilder); allclassgen.buildAllClassesFile(false); - allclassgen.close(); } catch (IOException exc) { - configuration.standardmessage. - error("doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -122,7 +120,7 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { String label = configuration.getText("doclet.All_Classes"); Content body = getBody(false, getWindowTitle(label)); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, - HtmlStyle.bar, allclassesLabel); + HtmlStyle.bar, contents.allClassesLabel); body.addContent(heading); Content ul = new HtmlTree(HtmlTag.UL); // Generate the class links and add it to the tdFont tree. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java index 0bb63a68f93..f0392bcc1db 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java @@ -111,7 +111,7 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter memberDetailsTree.addContent(writer.getMarkerAnchor( SectionName.ANNOTATION_TYPE_FIELD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.fieldDetailsLabel); + contents.fieldDetailsLabel); memberDetailsTree.addContent(heading); writer.printedAnnotationFieldHeading = true; } @@ -142,7 +142,7 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, getType(member))); pre.addContent(link); - pre.addContent(writer.getSpace()); + pre.addContent(Contents.SPACE); if (configuration.linksource) { Content memberName = new StringContent(name(member)); writer.addSrcLink(member, memberName, pre); @@ -192,19 +192,12 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter return getMemberTree(annotationDocTree, isLastContent); } - /** - * Close the writer. - */ - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Field_Summary")); + contents.fieldSummaryLabel); memberTree.addContent(label); } @@ -221,7 +214,7 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public Content getCaption() { - return configuration.getResource("doclet.Fields"); + return configuration.getContent("doclet.Fields"); } /** @@ -296,9 +289,9 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter if (link) { return writer.getHyperLink( SectionName.ANNOTATION_TYPE_FIELD_SUMMARY, - writer.getResource("doclet.navField")); + contents.navField); } else { - return writer.getResource("doclet.navField"); + return contents.navField; } } @@ -309,9 +302,9 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.ANNOTATION_TYPE_FIELD_DETAIL, - writer.getResource("doclet.navField"))); + contents.navField)); } else { - liNav.addContent(writer.getResource("doclet.navField")); + liNav.addContent(contents.navField); } } private TypeMirror getType(Element member) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java index 221e467101b..2d493090872 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java @@ -25,8 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; - import java.util.Arrays; import java.util.List; @@ -96,7 +94,7 @@ public class AnnotationTypeOptionalMemberWriterImpl extends ExecutableElement ee = (ExecutableElement)member; AnnotationValue value = ee.getDefaultValue(); if (value != null) { - Content dt = HtmlTree.DT(writer.getResource("doclet.Default")); + Content dt = HtmlTree.DT(contents.default_); Content dl = HtmlTree.DL(dt); Content dd = HtmlTree.DD(new StringContent(value.toString())); dl.addContent(dd); @@ -105,19 +103,12 @@ public class AnnotationTypeOptionalMemberWriterImpl extends } } - /** - * {@inheritDoc} - */ - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Annotation_Type_Optional_Member_Summary")); + contents.annotateTypeOptionalMemberSummaryLabel); memberTree.addContent(label); } @@ -125,16 +116,16 @@ public class AnnotationTypeOptionalMemberWriterImpl extends * {@inheritDoc} */ public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"), - configuration.getText("doclet.annotation_type_optional_members")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Annotation_Type_Optional_Member_Summary"), + resources.getText("doclet.annotation_type_optional_members")); } /** * {@inheritDoc} */ public Content getCaption() { - return configuration.getResource("doclet.Annotation_Type_Optional_Members"); + return configuration.getContent("doclet.Annotation_Type_Optional_Members"); } /** @@ -163,9 +154,9 @@ public class AnnotationTypeOptionalMemberWriterImpl extends if (link) { return writer.getHyperLink( SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY, - writer.getResource("doclet.navAnnotationTypeOptionalMember")); + contents.navAnnotationTypeOptionalMember); } else { - return writer.getResource("doclet.navAnnotationTypeOptionalMember"); + return contents.navAnnotationTypeOptionalMember; } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java index 531d0a033f5..767a6660a83 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java @@ -111,7 +111,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter memberDetailsTree.addContent(writer.getMarkerAnchor( SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.annotationTypeDetailsLabel); + contents.annotationTypeDetailsLabel); memberDetailsTree.addContent(heading); writer.printedAnnotationHeading = true; } @@ -143,7 +143,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, getType(member))); pre.addContent(link); - pre.addContent(writer.getSpace()); + pre.addContent(Contents.SPACE); if (configuration.linksource) { Content memberName = new StringContent(name(member)); writer.addSrcLink(member, memberName, pre); @@ -193,19 +193,12 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter return getMemberTree(annotationDocTree, isLastContent); } - /** - * Close the writer. - */ - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Annotation_Type_Required_Member_Summary")); + contents.annotateTypeRequiredMemberSummaryLabel); memberTree.addContent(label); } @@ -222,7 +215,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter * {@inheritDoc} */ public Content getCaption() { - return configuration.getResource("doclet.Annotation_Type_Required_Members"); + return configuration.getContent("doclet.Annotation_Type_Required_Members"); } /** @@ -297,9 +290,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter if (link) { return writer.getHyperLink( SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY, - writer.getResource("doclet.navAnnotationTypeRequiredMember")); + contents.navAnnotationTypeRequiredMember); } else { - return writer.getResource("doclet.navAnnotationTypeRequiredMember"); + return contents.navAnnotationTypeRequiredMember; } } @@ -310,9 +303,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL, - writer.getResource("doclet.navAnnotationTypeMember"))); + contents.navAnnotationTypeMember)); } else { - liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember")); + liNav.addContent(contents.navAnnotationTypeMember); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java index efb0612f22b..9ff7d7b8ba6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java @@ -98,7 +98,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -111,7 +111,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter @Override protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, - packageLabel); + contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -123,7 +123,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter */ @Override protected Content getNavLinkClass() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel); return li; } @@ -134,7 +134,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter */ @Override protected Content getNavLinkClassUse() { - Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel); + Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -150,11 +150,11 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter if (prev != null) { Content prevLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, utils.asTypeElement(prev)) - .label(prevclassLabel).strong(true)); + .label(contents.prevClassLabel).strong(true)); li = HtmlTree.LI(prevLink); } else - li = HtmlTree.LI(prevclassLabel); + li = HtmlTree.LI(contents.prevClassLabel); return li; } @@ -169,11 +169,11 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter if (next != null) { Content nextLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, utils.asTypeElement(next)) - .label(nextclassLabel).strong(true)); + .label(contents.nextClassLabel).strong(true)); li = HtmlTree.LI(nextLink); } else - li = HtmlTree.LI(nextclassLabel); + li = HtmlTree.LI(contents.nextClassLabel); return li; } @@ -320,13 +320,13 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter List deprs = utils.getBlockTags(annotationType, DocTree.Kind.DEPRECATED); if (utils.isDeprecated(annotationType)) { CommentHelper ch = utils.getCommentHelper(annotationType); - Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (!deprs.isEmpty()) { List commentTags = ch.getDescription(configuration, deprs.get(0)); if (!commentTags.isEmpty()) { - div.addContent(getSpace()); + div.addContent(Contents.SPACE); addInlineDeprecatedComment(annotationType, deprs.get(0), div); } } @@ -340,7 +340,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter @Override protected Content getNavLinkTree() { Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE, - treeLabel, "", ""); + contents.treeLabel, "", ""); Content li = HtmlTree.LI(treeLinkContent); return li; } @@ -368,8 +368,8 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * @throws java.lang.Exception */ protected Content getNavSummaryLinks() throws Exception { - Content li = HtmlTree.LI(summaryLabel); - li.addContent(getSpace()); + Content li = HtmlTree.LI(contents.summaryLabel); + li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); @@ -406,7 +406,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter AbstractMemberWriter writer = ((AbstractMemberWriter) builder. getMemberSummaryWriter(type)); if (writer == null) { - liNav.addContent(getResource(label)); + liNav.addContent(contents.getContent(label)); } else { liNav.addContent(writer.getNavSummaryLink(null, ! builder.getVisibleMemberMap(type).noVisibleMembers())); @@ -420,8 +420,8 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * @throws java.lang.Exception */ protected Content getNavDetailLinks() throws Exception { - Content li = HtmlTree.LI(detailLabel); - li.addContent(getSpace()); + Content li = HtmlTree.LI(contents.detailLabel); + li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); @@ -438,7 +438,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter if (writerField != null) { writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField); } else { - liNavField.addContent(getResource("doclet.navField")); + liNavField.addContent(contents.navField); } addNavGap(liNavField); ulNav.addContent(liNavField); @@ -451,7 +451,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq); ulNav.addContent(liNavReq); } else { - Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember")); + Content liNav = HtmlTree.LI(contents.navAnnotationTypeMember); ulNav.addContent(liNav); } return ulNav; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index 061a21543ce..1ec0e5bfe2c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -47,6 +47,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; @@ -226,11 +227,10 @@ public class ClassUseWriter extends SubWriterHolderWriter { try { clsgen = new ClassUseWriter(configuration, mapper, path, typeElement); clsgen.generateClassUseFile(); - clsgen.close(); } catch (IOException exc) { - configuration.standardmessage. - error("doclet.exception_encountered", - exc.toString(), path.getPath()); + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", + exc.toString(), path.getPath()); throw new DocletAbortException(exc); } } @@ -245,7 +245,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { if (pkgSet.size() > 0) { addClassUse(div); } else { - div.addContent(getResource("doclet.ClassUse_No.usage.of.0", + div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getFullyQualifiedName(typeElement))); } if (configuration.allowTag(HtmlTag.MAIN)) { @@ -287,7 +287,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { * @param contentTree the content tree to which the packages elements will be added */ protected void addPackageList(Content contentTree) throws IOException { - Content caption = getTableCaption(configuration.getResource( + Content caption = getTableCaption(configuration.getContent( "doclet.ClassUse_Packages.that.use.0", getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); @@ -320,7 +320,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { pkgToPackageAnnotations.isEmpty()) { return; } - Content caption = getTableCaption(configuration.getResource( + Content caption = getTableCaption(configuration.getContent( "doclet.ClassUse_PackageAnnotation", getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)))); @@ -360,10 +360,10 @@ public class ClassUseWriter extends SubWriterHolderWriter { HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(markerAnchor) : HtmlTree.LI(HtmlStyle.blockList, markerAnchor); - Content link = getResource("doclet.ClassUse_Uses.of.0.in.1", - getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, - typeElement)), - getPackageLink(pkg, utils.getPackageName(pkg))); + Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1", + getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, + typeElement)), + getPackageLink(pkg, utils.getPackageName(pkg))); Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); htmlTree.addContent(heading); addClassUse(pkg, htmlTree); @@ -404,67 +404,67 @@ public class ClassUseWriter extends SubWriterHolderWriter { LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)); Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg)); classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_Annotation", classLink, + configuration.getContent("doclet.ClassUse_Annotation", classLink, pkgLink), classUseTableSummary, contentTree); classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_TypeParameter", classLink, + configuration.getContent("doclet.ClassUse_TypeParameter", classLink, pkgLink), classUseTableSummary, contentTree); classSubWriter.addUseInfo(pkgToSubclass.get(pkg), - configuration.getResource("doclet.ClassUse_Subclass", classLink, + configuration.getContent("doclet.ClassUse_Subclass", classLink, pkgLink), subclassUseTableSummary, contentTree); classSubWriter.addUseInfo(pkgToSubinterface.get(pkg), - configuration.getResource("doclet.ClassUse_Subinterface", classLink, + configuration.getContent("doclet.ClassUse_Subinterface", classLink, pkgLink), subinterfaceUseTableSummary, contentTree); classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg), - configuration.getResource("doclet.ClassUse_ImplementingClass", classLink, + configuration.getContent("doclet.ClassUse_ImplementingClass", classLink, pkgLink), classUseTableSummary, contentTree); fieldSubWriter.addUseInfo(pkgToField.get(pkg), - configuration.getResource("doclet.ClassUse_Field", classLink, + configuration.getContent("doclet.ClassUse_Field", classLink, pkgLink), fieldUseTableSummary, contentTree); fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink, + configuration.getContent("doclet.ClassUse_FieldAnnotations", classLink, pkgLink), fieldUseTableSummary, contentTree); fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink, + configuration.getContent("doclet.ClassUse_FieldTypeParameter", classLink, pkgLink), fieldUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink, + configuration.getContent("doclet.ClassUse_MethodAnnotations", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink, + configuration.getContent("doclet.ClassUse_MethodParameterAnnotations", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink, + configuration.getContent("doclet.ClassUse_MethodTypeParameter", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg), - configuration.getResource("doclet.ClassUse_MethodReturn", classLink, + configuration.getContent("doclet.ClassUse_MethodReturn", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink, + configuration.getContent("doclet.ClassUse_MethodReturnTypeParameter", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg), - configuration.getResource("doclet.ClassUse_MethodArgs", classLink, + configuration.getContent("doclet.ClassUse_MethodArgs", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink, + configuration.getContent("doclet.ClassUse_MethodArgsTypeParameters", classLink, pkgLink), methodUseTableSummary, contentTree); methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg), - configuration.getResource("doclet.ClassUse_MethodThrows", classLink, + configuration.getContent("doclet.ClassUse_MethodThrows", classLink, pkgLink), methodUseTableSummary, contentTree); constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink, + configuration.getContent("doclet.ClassUse_ConstructorAnnotations", classLink, pkgLink), constructorUseTableSummary, contentTree); constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg), - configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink, + configuration.getContent("doclet.ClassUse_ConstructorParameterAnnotations", classLink, pkgLink), constructorUseTableSummary, contentTree); constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg), - configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink, + configuration.getContent("doclet.ClassUse_ConstructorArgs", classLink, pkgLink), constructorUseTableSummary, contentTree); constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg), - configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink, + configuration.getContent("doclet.ClassUse_ConstructorArgsTypeParameters", classLink, pkgLink), constructorUseTableSummary, contentTree); constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg), - configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink, + configuration.getContent("doclet.ClassUse_ConstructorThrows", classLink, pkgLink), constructorUseTableSummary, contentTree); } @@ -490,7 +490,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { bodyTree.addContent(htmlTree); } ContentBuilder headContent = new ContentBuilder(); - headContent.addContent(getResource("doclet.ClassUse_Title", cltype)); + headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(clname); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, @@ -512,7 +512,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -524,7 +524,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { */ protected Content getNavLinkPackage() { Content linkContent = - getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel); + getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -548,7 +548,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { * @return a content tree for the use link */ protected Content getNavLinkClassUse() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); return li; } @@ -559,8 +559,8 @@ public class ClassUseWriter extends SubWriterHolderWriter { */ protected Content getNavLinkTree() { Content linkContent = utils.isEnclosingPackageIncluded(typeElement) - ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel) - : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel); + ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel) + : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel); Content li = HtmlTree.LI(linkContent); return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java index 0356b0a8c78..f9a5fb4af9f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java @@ -112,7 +112,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -125,7 +125,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite @Override protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, - packageLabel); + contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -137,7 +137,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite */ @Override protected Content getNavLinkClass() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel); return li; } @@ -148,7 +148,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite */ @Override protected Content getNavLinkClassUse() { - Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel); + Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -164,11 +164,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite if (prev != null) { Content prevLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, prev) - .label(prevclassLabel).strong(true)); + .label(contents.prevClassLabel).strong(true)); li = HtmlTree.LI(prevLink); } else - li = HtmlTree.LI(prevclassLabel); + li = HtmlTree.LI(contents.prevClassLabel); return li; } @@ -183,11 +183,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite if (next != null) { Content nextLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, next) - .label(nextclassLabel).strong(true)); + .label(contents.nextClassLabel).strong(true)); li = HtmlTree.LI(nextLink); } else - li = HtmlTree.LI(nextclassLabel); + li = HtmlTree.LI(contents.nextClassLabel); return li; } @@ -210,18 +210,18 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite div.addStyle(HtmlStyle.header); ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(typeElement); if (mdle != null && !mdle.isUnnamed()) { - Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, moduleLabel); + Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); - moduleNameDiv.addContent(getSpace()); + moduleNameDiv.addContent(Contents.SPACE); moduleNameDiv.addContent(getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()))); div.addContent(moduleNameDiv); } PackageElement pkg = utils.containingPackage(typeElement); if (!pkg.isUnnamed()) { - Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInClass, packageLabel); + Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInClass, contents.packageLabel); Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classPackageLabel); - pkgNameDiv.addContent(getSpace()); + pkgNameDiv.addContent(Contents.SPACE); Content pkgNameContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); pkgNameDiv.addContent(pkgNameContent); @@ -469,8 +469,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite } Set subclasses = classtree.directSubClasses(typeElement, false); if (!subclasses.isEmpty()) { - Content label = getResource( - "doclet.Subclasses"); + Content label = contents.subclassesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES, @@ -488,8 +487,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite if (utils.isInterface(typeElement)) { Set subInterfaces = classtree.allSubClasses(typeElement, false); if (!subInterfaces.isEmpty()) { - Content label = getResource( - "doclet.Subinterfaces"); + Content label = contents.subinterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES, @@ -513,8 +511,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite } Set implcl = classtree.implementingClasses(typeElement); if (!implcl.isEmpty()) { - Content label = getResource( - "doclet.Implementing_Classes"); + Content label = contents.implementingClassesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES, @@ -531,8 +528,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite SortedSet interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator()); interfaces.addAll(utils.getAllInterfaces(typeElement)); if (utils.isClass(typeElement) && !interfaces.isEmpty()) { - Content label = getResource( - "doclet.All_Implemented_Interfaces"); + Content label = contents.allImplementedInterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces)); @@ -550,7 +546,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite interfaces.addAll(utils.getAllInterfaces(typeElement)); if (utils.isInterface(typeElement) && !interfaces.isEmpty()) { - Content label = getResource("doclet.All_Superinterfaces"); + Content label = contents.allSuperinterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces)); @@ -569,10 +565,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite new SimpleElementVisitor8() { @Override @DefinedBy(Api.LANGUAGE_MODEL) public Void visitType(TypeElement e, Void p) { - String label = utils.isInterface(e) - ? "doclet.Enclosing_Interface" - : "doclet.Enclosing_Class"; - Content dt = HtmlTree.DT(getResource(label)); + Content label = utils.isInterface(e) + ? contents.enclosingInterfaceLabel + : contents.enclosingClassLabel; + Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); dd.addContent(getLink(new LinkInfoImpl(configuration, @@ -590,10 +586,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite @Override public void addFunctionalInterfaceInfo (Content classInfoTree) { if (isFunctionalInterface()) { - Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface")); + Content dt = HtmlTree.DT(contents.functionalInterface); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); - dd.addContent(getResource("doclet.Functional_Interface_Message")); + dd.addContent(contents.functionalInterfaceMessage); dl.addContent(dd); classInfoTree.addContent(dl); } @@ -619,14 +615,14 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite classInfoTree.addContent(hr); List deprs = utils.getBlockTags(typeElement, DocTree.Kind.DEPRECATED); if (utils.isDeprecated(typeElement)) { - Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (!deprs.isEmpty()) { CommentHelper ch = utils.getCommentHelper(typeElement); DocTree dt = deprs.get(0); List commentTags = ch.getBody(configuration, dt); if (!commentTags.isEmpty()) { - div.addContent(getSpace()); + div.addContent(Contents.SPACE); addInlineDeprecatedComment(typeElement, deprs.get(0), div); } } @@ -671,7 +667,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite @Override protected Content getNavLinkTree() { Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE, - treeLabel, "", ""); + contents.treeLabel, "", ""); Content li = HtmlTree.LI(treeLinkContent); return li; } @@ -697,8 +693,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * @return the content tree for the navigation summary links */ protected Content getNavSummaryLinks() throws Exception { - Content li = HtmlTree.LI(summaryLabel); - li.addContent(getSpace()); + Content li = HtmlTree.LI(contents.summaryLabel); + li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); @@ -713,7 +709,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite AbstractMemberWriter writer = ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind)); if (writer == null) { - liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind))); + liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind))); } else { writer.addNavSummaryLink( memberSummaryBuilder.members(kind), @@ -734,8 +730,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * @throws java.lang.Exception */ protected Content getNavDetailLinks() throws Exception { - Content li = HtmlTree.LI(detailLabel); - li.addContent(getSpace()); + Content li = HtmlTree.LI(contents.detailLabel); + li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); @@ -751,7 +747,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite continue; } if (writer == null) { - liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind))); + liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind))); } else { writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java index e56f25a8c33..ac03bdb9c3e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java @@ -40,23 +40,22 @@ import javax.tools.StandardLocation; import com.sun.source.util.DocTreePath; import com.sun.tools.doclint.DocLint; -import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.ModuleSymbol; import com.sun.tools.javac.code.Symbol.PackageSymbol; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.DocletEnvironment; -import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.WriterFactory; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; -import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.Diagnostic.Kind.*; @@ -208,10 +207,7 @@ public class ConfigurationImpl extends Configuration { */ public Map doclintOpts = new LinkedHashMap<>(); - /** - * Unique Resource Handler for this package. - */ - public final MessageRetriever standardmessage; + public final Resources resources; /** * First file to appear in the right-hand frame in the generated @@ -236,13 +232,21 @@ public class ConfigurationImpl extends Configuration { protected Set tagSearchIndexKeys; + protected Contents contents; + + protected Messages messages; + /** * Constructor. Initializes resource for the * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. */ public ConfigurationImpl() { - standardmessage = new MessageRetriever(this, - "jdk.javadoc.internal.doclets.formats.html.resources.standard"); + resources = new Resources(this, + Configuration.sharedResourceBundleName, + "jdk.javadoc.internal.doclets.formats.html.resources.standard"); + + messages = new Messages(this); + contents = new Contents(this); } private final String versionRBName = "jdk.javadoc.internal.tool.resources.version"; @@ -269,6 +273,16 @@ public class ConfigurationImpl extends Configuration { } } + @Override + public Resources getResources() { + return resources; + } + + @Override + public Messages getMessages() { + return messages; + } + protected boolean validateOptions() { // check shared options if (!generalValidOptions()) { @@ -392,14 +406,6 @@ public class ConfigurationImpl extends Configuration { return htmlTag.allowTag(this.htmlVersion); } - /** - * {@inheritDoc} - */ - @Override - public MessageRetriever getDocletSpecificMsg() { - return standardmessage; - } - /** * Decide the page which will appear first in the right-hand frame. It will * be "overview-summary.html" if "-overview" option is used or no @@ -479,10 +485,11 @@ public class ConfigurationImpl extends Configuration { } /** - * Return the path of the overview file and null if it does not exist. + * Return the path of the overview file or null if it does not exist. * - * @return the path of the overview file and null if it does not exist. + * @return the path of the overview file or null if it does not exist. */ + @Override public JavaFileObject getOverviewPath() { if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) { StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager(); @@ -510,10 +517,63 @@ public class ConfigurationImpl extends Configuration { } @Override - public Content newContent() { - return new ContentBuilder(); + public String getText(String key) { + return resources.getText(key); } + @Override + public String getText(String key, String... args) { + return resources.getText(key, (Object[]) args); + } + + /** + * {@inheritdoc} + */ + @Override + public Content getContent(String key) { + return contents.getContent(key); + } + + /** + * Get the configuration string as a content. + * + * @param key the key to look for in the configuration file + * @param o string or content argument added to configuration text + * @return a content tree for the text + */ + @Override + public Content getContent(String key, Object o) { + return contents.getContent(key, o); + } + + /** + * Get the configuration string as a content. + * + * @param key the key to look for in the configuration file + * @param o1 resource argument + * @param o2 resource argument + * @return a content tree for the text + */ + @Override + public Content getContent(String key, Object o1, Object o2) { + return contents.getContent(key, o1, o2); + } + + /** + * Get the configuration string as a content. + * + * @param key the key to look for in the configuration file + * @param o0 string or content argument added to configuration text + * @param o1 string or content argument added to configuration text + * @param o2 string or content argument added to configuration text + * @return a content tree for the text + */ + @Override + public Content getContent(String key, Object o0, Object o1, Object o2) { + return contents.getContent(key, o0, o1, o2); + } + + @Override public Location getLocationForPackage(PackageElement pd) { JavaFileManager fm = getFileManager(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java index bfa30606ba4..c4778bc09e5 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -87,8 +87,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons * @param configuration the configuration used in this run * of the standard doclet. */ - public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) - throws IOException { + public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) { super(configuration, DocPaths.CONSTANT_VALUES); this.configuration = configuration; constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary", @@ -133,7 +132,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons if (pkg.isUnnamed()) { link = getHyperLink(getDocLink( SectionName.UNNAMED_PACKAGE_ANCHOR), - defaultPackageLabel, "", ""); + contents.defaultPackageLabel, "", ""); } else { String parsedPackageName = utils.parsePackageName(pkg); Content packageNameContent = getPackageLabel(parsedPackageName); @@ -150,13 +149,11 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons * {@inheritDoc} */ public void addContentsList(Content contentTree, Content contentListTree) { - Content titleContent = getResource( - "doclet.Constants_Summary"); + Content titleContent = contents.constantsSummaryTitle; Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, titleContent); Content div = HtmlTree.DIV(HtmlStyle.header, pHeading); - Content headingContent = getResource( - "doclet.Contents"); + Content headingContent = contents.contentsHeading; Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -191,7 +188,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons if (pkg.isUnnamed()) { summariesTree.addContent(getMarkerAnchor( SectionName.UNNAMED_PACKAGE_ANCHOR)); - pkgNameContent = defaultPackageLabel; + pkgNameContent = contents.defaultPackageLabel; } else { String parsedPackageName = utils.parsePackageName(pkg); summariesTree.addContent(getMarkerAnchor(parsedPackageName)); @@ -315,7 +312,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons for (Modifier mod : member.getModifiers()) { Content modifier = new StringContent(mod.toString()); code.addContent(modifier); - code.addContent(getSpace()); + code.addContent(Contents.SPACE); } Content type = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.asType())); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java index c3f3a41e163..f5bfb4a39bf 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java @@ -119,7 +119,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter constructorDetailsTree.addContent(writer.getMarkerAnchor( SectionName.CONSTRUCTOR_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.constructorDetailsLabel); + contents.constructorDetailsLabel); constructorDetailsTree.addContent(heading); return constructorDetailsTree; } @@ -220,14 +220,6 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter return getMemberTree(constructorDocTree, isLastContent); } - /** - * Close the writer. - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * Let the writer know whether a non public constructor was found. * @@ -244,7 +236,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Constructor_Summary")); + contents.constructorSummaryLabel); memberTree.addContent(label); } @@ -253,9 +245,9 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Constructor_Summary"), - configuration.getText("doclet.constructors")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Constructor_Summary"), + resources.getText("doclet.constructors")); } /** @@ -263,7 +255,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Constructors"); + return contents.constructors; } /** @@ -273,11 +265,11 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter public List getSummaryTableHeader(Element member) { List header = new ArrayList<>(); if (foundNonPubConstructor) { - header.add(configuration.getText("doclet.Modifier")); + header.add(resources.getText("doclet.Modifier")); } - header.add(configuration.getText("doclet.0_and_1", - configuration.getText("doclet.Constructor"), - configuration.getText("doclet.Description"))); + header.add(resources.getText("doclet.0_and_1", + resources.getText("doclet.Constructor"), + resources.getText("doclet.Description"))); return header; } @@ -311,9 +303,9 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter protected Content getNavSummaryLink(TypeElement typeElement, boolean link) { if (link) { return writer.getHyperLink(SectionName.CONSTRUCTOR_SUMMARY, - writer.getResource("doclet.navConstructor")); + contents.navConstructor); } else { - return writer.getResource("doclet.navConstructor"); + return contents.navConstructor; } } @@ -325,9 +317,9 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.CONSTRUCTOR_DETAIL, - writer.getResource("doclet.navConstructor"))); + contents.navConstructor)); } else { - liNav.addContent(writer.getResource("doclet.navConstructor")); + liNav.addContent(contents.navConstructor); } } @@ -343,7 +335,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter } else if (utils.isPrivate(member)) { code.addContent("private "); } else if (utils.isPublic(member)) { - code.addContent(writer.getSpace()); + code.addContent(Contents.SPACE); } else { code.addContent( configuration.getText("doclet.Package_private")); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java new file mode 100644 index 00000000000..df9e19fa81f --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java @@ -0,0 +1,369 @@ +/* + * Copyright (c) 1998, 2016, 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 jdk.javadoc.internal.doclets.formats.html; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; +import jdk.javadoc.internal.doclets.formats.html.markup.FixedStringContent; +import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; +import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; +import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Resources; +import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; + +/** + * Constants and factory methods for common fragments of content + * used by HtmlDoclet. The string content of these fragments is + * generally obtained from the {@link Resources resources} found + * in the doclet's configuration. + * + * @implNote + * Many constants are made available in this class, so that they are + * only created once per doclet-instance, instead of once per generated page. + */ +public class Contents { + public static final Content SPACE = RawHtml.nbsp; + + public final Content allClassesLabel; + public final Content allImplementedInterfacesLabel; + public final Content allModulesLabel; + public final Content allPackagesLabel; + public final Content allSuperinterfacesLabel; + public final Content also; + public final Content annotateTypeOptionalMemberSummaryLabel; + public final Content annotateTypeRequiredMemberSummaryLabel; + public final Content annotationType; + public final Content annotationTypeDetailsLabel; + public final Content annotationTypeMemberDetail; + public final Content annotationTypes; + public final Content classLabel; + public final Content classes; + public final Content constantsSummaryTitle; + public final Content constructorDetailsLabel; + public final Content constructorSummaryLabel; + public final Content constructors; + public final Content contentsHeading; + public final Content defaultPackageLabel; + public final Content default_; + public final Content deprecatedAPI; + public final Content deprecatedLabel; + public final Content deprecatedPhrase; + public final Content descfrmClassLabel; + public final Content descfrmInterfaceLabel; + public final Content descriptionLabel; + public final Content detailLabel; + public final Content enclosingClassLabel; + public final Content enclosingInterfaceLabel; + public final Content enumConstantDetailLabel; + public final Content enumConstantSummary; + public final Content enum_; + public final Content enums; + public final Content errors; + public final Content exceptions; + public final Content fieldDetailsLabel; + public final Content fieldSummaryLabel; + public final Content fields; + public final Content framesLabel; + public final Content functionalInterface; + public final Content functionalInterfaceMessage; + public final Content helpLabel; + public final Content hierarchyForAllPackages; + public final Content implementation; + public final Content implementingClassesLabel; + public final Content inClass; + public final Content inInterface; + public final Content indexLabel; + public final Content interfaces; + public final Content interfacesItalic; + public final Content methodDetailLabel; + public final Content methodSummary; + public final Content methods; + public final Content moduleLabel; + public final Content moduleSubNavLabel; + public final Content modulesLabel; + public final Content navAnnotationTypeMember; + public final Content navAnnotationTypeOptionalMember; + public final Content navAnnotationTypeRequiredMember; + public final Content navConstructor; + public final Content navEnum; + public final Content navField; + public final Content navMethod; + public final Content navModuleDescription; + public final Content navModules; + public final Content navNested; + public final Content navPackages; + public final Content navProperty; + public final Content navServices; + public final Content nestedClassSummary; + public final Content nextClassLabel; + public final Content nextLabel; + public final Content nextLetter; + public final Content nextModuleLabel; + public final Content nextPackageLabel; + public final Content noFramesLabel; + public final Content noScriptMessage; + public final Content overridesLabel; + public final Content overviewLabel; + public final Content packageHierarchies; + public final Content packageLabel; + public final Content package_; + public final Content packagesLabel; + public final Content prevClassLabel; + public final Content prevLabel; + public final Content prevLetter; + public final Content prevModuleLabel; + public final Content prevPackageLabel; + public final Content properties; + public final Content propertyDetailsLabel; + public final Content propertySummary; + public final Content seeLabel; + public final Content serializedForm; + public final Content specifiedByLabel; + public final Content subclassesLabel; + public final Content subinterfacesLabel; + public final Content summaryLabel; + public final Content treeLabel; + public final Content useLabel; + + private final Resources resources; + + /** + * Creates a {@code Contents} object. + * + * @param configuration the configuration in which to find the + * resources used to look up resource keys, and other details. + */ + Contents(ConfigurationImpl configuration) { + this.resources = configuration.getResources(); + + allClassesLabel = getNonBreakContent("doclet.All_Classes"); + allImplementedInterfacesLabel = getContent("doclet.All_Implemented_Interfaces"); + allModulesLabel = getNonBreakContent("doclet.All_Modules"); + allPackagesLabel = getNonBreakContent("doclet.All_Packages"); + allSuperinterfacesLabel = getContent("doclet.All_Superinterfaces"); + also = getContent("doclet.also"); + annotateTypeOptionalMemberSummaryLabel = getContent("doclet.Annotation_Type_Optional_Member_Summary"); + annotateTypeRequiredMemberSummaryLabel = getContent("doclet.Annotation_Type_Required_Member_Summary"); + annotationType = getContent("doclet.AnnotationType"); + annotationTypeDetailsLabel = getContent("doclet.Annotation_Type_Member_Detail"); + annotationTypeMemberDetail = getContent("doclet.Annotation_Type_Member_Detail"); + annotationTypes = getContent("doclet.AnnotationTypes"); + classLabel = getContent("doclet.Class"); + classes = getContent("doclet.Classes"); + constantsSummaryTitle = getContent("doclet.Constants_Summary"); + constructorDetailsLabel = getContent("doclet.Constructor_Detail"); + constructorSummaryLabel = getContent("doclet.Constructor_Summary"); + constructors = getContent("doclet.Constructors"); + contentsHeading = getContent("doclet.Contents"); + defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME); + default_ = getContent("doclet.Default"); + deprecatedAPI = getContent("doclet.Deprecated_API"); + deprecatedLabel = getContent("doclet.navDeprecated"); + deprecatedPhrase = getContent("doclet.Deprecated"); + descfrmClassLabel = getContent("doclet.Description_From_Class"); + descfrmInterfaceLabel = getContent("doclet.Description_From_Interface"); + descriptionLabel = getContent("doclet.Description"); + detailLabel = getContent("doclet.Detail"); + enclosingClassLabel = getContent("doclet.Enclosing_Class"); + enclosingInterfaceLabel = getContent("doclet.Enclosing_Interface"); + enumConstantDetailLabel = getContent("doclet.Enum_Constant_Detail"); + enumConstantSummary = getContent("doclet.Enum_Constant_Summary"); + enum_ = getContent("doclet.Enum"); + enums = getContent("doclet.Enums"); + errors = getContent("doclet.Errors"); + exceptions = getContent("doclet.Exceptions"); + fieldDetailsLabel = getContent("doclet.Field_Detail"); + fieldSummaryLabel = getContent("doclet.Field_Summary"); + fields = getContent("doclet.Fields"); + framesLabel = getContent("doclet.Frames"); + functionalInterface = getContent("doclet.Functional_Interface"); + functionalInterfaceMessage = getContent("doclet.Functional_Interface_Message"); + helpLabel = getContent("doclet.Help"); + hierarchyForAllPackages = getContent("doclet.Hierarchy_For_All_Packages"); + implementation = getContent("doclet.Implementation"); + implementingClassesLabel = getContent("doclet.Implementing_Classes"); + inClass = getContent("doclet.in_class"); + inInterface = getContent("doclet.in_interface"); + indexLabel = getContent("doclet.Index"); + interfaces = getContent("doclet.Interfaces"); + interfacesItalic = getContent("doclet.Interfaces_Italic"); + methodDetailLabel = getContent("doclet.Method_Detail"); + methodSummary = getContent("doclet.Method_Summary"); + methods = getContent("doclet.Methods"); + moduleLabel = getContent("doclet.Module"); + moduleSubNavLabel = getContent("doclet.Module_Sub_Nav"); + modulesLabel = getContent("doclet.Modules"); + navAnnotationTypeMember = getContent("doclet.navAnnotationTypeMember"); + navAnnotationTypeOptionalMember = getContent("doclet.navAnnotationTypeOptionalMember"); + navAnnotationTypeRequiredMember = getContent("doclet.navAnnotationTypeRequiredMember"); + navConstructor = getContent("doclet.navConstructor"); + navEnum = getContent("doclet.navEnum"); + navField = getContent("doclet.navField"); + navMethod = getContent("doclet.navMethod"); + navModuleDescription = getContent("doclet.navModuleDescription"); + navModules = getContent("doclet.navModules"); + navNested = getContent("doclet.navNested"); + navPackages = getContent("doclet.navPackages"); + navProperty = getContent("doclet.navProperty"); + navServices = getContent("doclet.navServices"); + nestedClassSummary = getContent("doclet.Nested_Class_Summary"); + nextClassLabel = getNonBreakContent("doclet.Next_Class"); + nextLabel = getNonBreakContent("doclet.Next"); + nextLetter = getContent("doclet.Next_Letter"); + nextModuleLabel = getNonBreakContent("doclet.Next_Module"); + nextPackageLabel = getNonBreakContent("doclet.Next_Package"); + noFramesLabel = getNonBreakContent("doclet.No_Frames"); + noScriptMessage = getContent("doclet.No_Script_Message"); + overridesLabel = getContent("doclet.Overrides"); + overviewLabel = getContent("doclet.Overview"); + packageHierarchies = getContent("doclet.Package_Hierarchies"); + packageLabel = getContent("doclet.Package"); + package_ = getContent("doclet.package"); + packagesLabel = getContent("doclet.Packages"); + prevClassLabel = getNonBreakContent("doclet.Prev_Class"); + prevLabel = getContent("doclet.Prev"); + prevLetter = getContent("doclet.Prev_Letter"); + prevModuleLabel = getNonBreakContent("doclet.Prev_Module"); + prevPackageLabel = getNonBreakContent("doclet.Prev_Package"); + properties = getContent("doclet.Properties"); + propertyDetailsLabel = getContent("doclet.Property_Detail"); + propertySummary = getContent("doclet.Property_Summary"); + seeLabel = getContent("doclet.See"); + serializedForm = getContent("doclet.Serialized_Form"); + specifiedByLabel = getContent("doclet.Specified_By"); + subclassesLabel = getContent("doclet.Subclasses"); + subinterfacesLabel = getContent("doclet.Subinterfaces"); + summaryLabel = getContent("doclet.Summary"); + treeLabel = getContent("doclet.Tree"); + useLabel = getContent("doclet.navClassUse"); + } + + /** + * Gets a {@code Content} object, containing the string for + * a given key in the doclet's resources. + * + * @param key the key for the desired string + * @return a content tree for the string + */ + public Content getContent(String key) { + return new FixedStringContent(resources.getText(key)); + } + + /** + * Gets a {@code Content} object, containing the string for + * a given key in the doclet's resources, formatted with + * given arguments. + * + * @param key the key to look for in the configuration fil + * @param key the key for the desired string + * @param o0 string or content argument to be formatted into the result + * @return a content tree for the text + */ + public Content getContent(String key, Object o0) { + return getContent(key, o0, null, null); + } + + /** + * Gets a {@code Content} object, containing the string for + * a given key in the doclet's resources, formatted with + * given arguments. + + * @param key the key for the desired string + * @param o0 string or content argument to be formatted into the result + * @param o1 string or content argument to be formatted into the result + * @return a content tree for the text + */ + public Content getContent(String key, Object o0, Object o1) { + return getContent(key, o0, o1, null); + } + + /** + * Gets a {@code Content} object, containing the string for + * a given key in the doclet's resources, formatted with + * given arguments. + * + * @param key the key for the desired string + * @param o0 string or content argument to be formatted into the result + * @param o1 string or content argument to be formatted into the result + * @param o2 string or content argument to be formatted into the result + * @return a content tree for the text + */ + public Content getContent(String key, Object o0, Object o1, Object o2) { + Content c = new ContentBuilder(); + Pattern p = Pattern.compile("\\{([012])\\}"); + String text = resources.getText(key); // TODO: cache + Matcher m = p.matcher(text); + int start = 0; + while (m.find(start)) { + c.addContent(text.substring(start, m.start())); + + Object o = null; + switch (m.group(1).charAt(0)) { + case '0': o = o0; break; + case '1': o = o1; break; + case '2': o = o2; break; + } + + if (o == null) { + c.addContent("{" + m.group(1) + "}"); + } else if (o instanceof String) { + c.addContent((String) o); + } else if (o instanceof Content) { + c.addContent((Content) o); + } + + start = m.end(); + } + + c.addContent(text.substring(start)); + return c; + } + + /** + * Gets a {@code Content} object, containing the string for + * a given key in the doclet's resources, substituting + *   for any space characters found in + * the named resource string. + * + * @param key the key for the desired string + * @return a content tree for the string + */ + private Content getNonBreakContent(String key) { + String text = resources.getText(key); // TODO: cache + Content c = new ContentBuilder(); + int start = 0; + int p; + while ((p = text.indexOf(" ", start)) != -1) { + c.addContent(text.substring(start, p)); + c.addContent(RawHtml.nbsp); + start = p + 1; + } + c.addContent(text.substring(start)); + return c; // TODO: should be made immutable + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java index 6defcd7614d..7280544b599 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java @@ -35,6 +35,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -243,10 +244,9 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { new DeprecatedListWriter(configuration, filename); depr.generateDeprecatedListFile( new DeprecatedAPIListBuilder(configuration)); - depr.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -314,7 +314,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { DeprElementKind kind, Content contentTree) { if (builder.hasDocumentation(kind)) { Content li = HtmlTree.LI(getHyperLink(getAnchorName(kind), - getResource(getHeadingKey(kind)))); + contents.getContent(getHeadingKey(kind)))); contentTree.addContent(li); } } @@ -326,11 +326,11 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * @return a content tree for the contents list */ public Content getContentsList(DeprecatedAPIListBuilder deprapi) { - Content headContent = getResource("doclet.Deprecated_API"); + Content headContent = contents.deprecatedAPI; Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); - Content headingContent = getResource("doclet.Contents"); + Content headingContent = contents.contentsHeading; div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent)); Content ul = new HtmlTree(HtmlTag.UL); @@ -379,7 +379,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * @return a content tree for the deprecated label */ protected Content getNavLinkDeprecated() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel); return li; } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java index fc8bf385bb6..b4f6ccedb99 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java @@ -95,7 +95,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter enumConstantsDetailsTree.addContent(writer.getMarkerAnchor( SectionName.ENUM_CONSTANT_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.enumConstantsDetailsLabel); + contents.enumConstantDetailLabel); enumConstantsDetailsTree.addContent(heading); return enumConstantsDetailsTree; } @@ -181,21 +181,13 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter return getMemberTree(enumConstantsTree, isLastContent); } - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Enum_Constant_Summary")); + contents.enumConstantSummary); memberTree.addContent(label); } @@ -204,9 +196,9 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Enum_Constant_Summary"), - configuration.getText("doclet.enum_constants")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Enum_Constant_Summary"), + resources.getText("doclet.enum_constants")); } /** @@ -214,7 +206,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Enum_Constants"); + return configuration.getContent("doclet.Enum_Constants"); } /** @@ -303,14 +295,14 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter if (link) { if (typeElement == null) { return writer.getHyperLink(SectionName.ENUM_CONSTANT_SUMMARY, - writer.getResource("doclet.navEnum")); + contents.navEnum); } else { return writer.getHyperLink( SectionName.ENUM_CONSTANTS_INHERITANCE, - configuration.getClassName(typeElement), writer.getResource("doclet.navEnum")); + configuration.getClassName(typeElement), contents.navEnum); } } else { - return writer.getResource("doclet.navEnum"); + return contents.navEnum; } } @@ -322,9 +314,9 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.ENUM_CONSTANT_DETAIL, - writer.getResource("doclet.navEnum"))); + contents.navEnum)); } else { - liNav.addContent(writer.getResource("doclet.navEnum")); + liNav.addContent(contents.navEnum); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java index b5e6c03b5f1..9afabb7aa7b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java @@ -95,7 +95,7 @@ public class FieldWriterImpl extends AbstractMemberWriter fieldDetailsTree.addContent(writer.getMarkerAnchor( SectionName.FIELD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.fieldDetailsLabel); + contents.fieldDetailsLabel); fieldDetailsTree.addContent(heading); return fieldDetailsTree; } @@ -181,21 +181,13 @@ public class FieldWriterImpl extends AbstractMemberWriter return getMemberTree(fieldTree, isLastContent); } - /** - * Close the writer. - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Field_Summary")); + contents.fieldSummaryLabel); memberTree.addContent(label); } @@ -204,9 +196,9 @@ public class FieldWriterImpl extends AbstractMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Field_Summary"), - configuration.getText("doclet.fields")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Field_Summary"), + resources.getText("doclet.fields")); } /** @@ -214,7 +206,7 @@ public class FieldWriterImpl extends AbstractMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Fields"); + return contents.fields; } /** @@ -223,9 +215,9 @@ public class FieldWriterImpl extends AbstractMemberWriter @Override public List getSummaryTableHeader(Element member) { List header = Arrays.asList(writer.getModifierTypeHeader(), - configuration.getText("doclet.0_and_1", - configuration.getText("doclet.Field"), - configuration.getText("doclet.Description"))); + resources.getText("doclet.0_and_1", + resources.getText("doclet.Field"), + resources.getText("doclet.Description"))); return header; } @@ -259,7 +251,7 @@ public class FieldWriterImpl extends AbstractMemberWriter : configuration.getText("doclet.Fields_Inherited_From_Interface")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(writer.getSpace()); + labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); inheritedTree.addContent(labelHeading); } @@ -312,14 +304,14 @@ public class FieldWriterImpl extends AbstractMemberWriter if (typeElement == null) { return writer.getHyperLink( SectionName.FIELD_SUMMARY, - writer.getResource("doclet.navField")); + contents.navField); } else { return writer.getHyperLink( SectionName.FIELDS_INHERITANCE, - configuration.getClassName(typeElement), writer.getResource("doclet.navField")); + configuration.getClassName(typeElement), contents.navField); } } else { - return writer.getResource("doclet.navField"); + return contents.navField; } } @@ -331,9 +323,9 @@ public class FieldWriterImpl extends AbstractMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.FIELD_DETAIL, - writer.getResource("doclet.navField"))); + contents.navField)); } else { - liNav.addContent(writer.getResource("doclet.navField")); + liNav.addContent(contents.navField); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java index fa8e8ee3d92..6093824917e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java @@ -32,6 +32,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -68,7 +69,7 @@ public class FrameOutputWriter extends HtmlDocletWriter { * @param filename File to be generated. * @throws java.io.IOException */ - public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) throws IOException { + public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); noOfPackages = configuration.packages.size(); } @@ -87,10 +88,9 @@ public class FrameOutputWriter extends HtmlDocletWriter { filename = DocPaths.INDEX; framegen = new FrameOutputWriter(configuration, filename); framegen.generateFrameFile(); - framegen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index 784cabd3bc9..7bc6887929f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -33,6 +33,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -58,7 +59,7 @@ public class HelpWriter extends HtmlDocletWriter { * @param filename File to be generated. */ public HelpWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + DocPath filename) { super(configuration, filename); } @@ -76,10 +77,9 @@ public class HelpWriter extends HtmlDocletWriter { filename = DocPaths.HELP_DOC; helpgen = new HelpWriter(configuration, filename); helpgen.generateHelpFile(); - helpgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -121,10 +121,10 @@ public class HelpWriter extends HtmlDocletWriter { */ protected void addHelpFileContents(Content contentTree) { Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, - getResource("doclet.Help_line_1")); + contents.getContent("doclet.Help_line_1")); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content line2 = HtmlTree.DIV(HtmlStyle.subTitle, - getResource("doclet.Help_line_2")); + contents.getContent("doclet.Help_line_2")); div.addContent(line2); if (configuration.allowTag(HtmlTag.MAIN)) { mainTree.addContent(div); @@ -136,11 +136,11 @@ public class HelpWriter extends HtmlDocletWriter { ul.addStyle(HtmlStyle.blockList); if (configuration.createoverview) { Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Overview")); + contents.overviewLabel); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(overviewHeading) : HtmlTree.LI(HtmlStyle.blockList, overviewHeading); - Content line3 = getResource("doclet.Help_line_3", + Content line3 = contents.getContent("doclet.Help_line_3", getHyperLink(DocPaths.OVERVIEW_SUMMARY, configuration.getText("doclet.Overview"))); Content overviewPara = HtmlTree.P(line3); @@ -152,26 +152,26 @@ public class HelpWriter extends HtmlDocletWriter { } } Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Package")); + contents.packageLabel); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(packageHead) : HtmlTree.LI(HtmlStyle.blockList, packageHead); - Content line4 = getResource("doclet.Help_line_4"); + Content line4 = contents.getContent("doclet.Help_line_4"); Content packagePara = HtmlTree.P(line4); htmlTree.addContent(packagePara); HtmlTree ulPackage = new HtmlTree(HtmlTag.UL); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.Interfaces_Italic"))); + contents.interfacesItalic)); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.Classes"))); + contents.classes)); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.Enums"))); + contents.enums)); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.Exceptions"))); + contents.exceptions)); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.Errors"))); + contents.errors)); ulPackage.addContent(HtmlTree.LI( - getResource("doclet.AnnotationTypes"))); + contents.annotationTypes)); htmlTree.addContent(ulPackage); if (configuration.allowTag(HtmlTag.SECTION)) { ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); @@ -179,46 +179,39 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_5")); + contents.getContent("doclet.Help_line_5")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(classHead) : HtmlTree.LI(HtmlStyle.blockList, classHead); - Content line6 = getResource("doclet.Help_line_6"); + Content line6 = contents.getContent("doclet.Help_line_6"); Content classPara = HtmlTree.P(line6); htmlTree.addContent(classPara); HtmlTree ul1 = new HtmlTree(HtmlTag.UL); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_7"))); + contents.getContent("doclet.Help_line_7"))); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_8"))); + contents.getContent("doclet.Help_line_8"))); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_9"))); + contents.getContent("doclet.Help_line_9"))); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_10"))); + contents.getContent("doclet.Help_line_10"))); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_11"))); + contents.getContent("doclet.Help_line_11"))); ul1.addContent(HtmlTree.LI( - getResource("doclet.Help_line_12"))); + contents.getContent("doclet.Help_line_12"))); htmlTree.addContent(ul1); HtmlTree ul2 = new HtmlTree(HtmlTag.UL); - ul2.addContent(HtmlTree.LI( - getResource("doclet.Nested_Class_Summary"))); - ul2.addContent(HtmlTree.LI( - getResource("doclet.Field_Summary"))); - ul2.addContent(HtmlTree.LI( - getResource("doclet.Constructor_Summary"))); - ul2.addContent(HtmlTree.LI( - getResource("doclet.Method_Summary"))); + ul2.addContent(HtmlTree.LI(contents.nestedClassSummary)); + ul2.addContent(HtmlTree.LI(contents.fieldSummaryLabel)); + ul2.addContent(HtmlTree.LI(contents.constructorSummaryLabel)); + ul2.addContent(HtmlTree.LI(contents.methodSummary)); htmlTree.addContent(ul2); HtmlTree ul3 = new HtmlTree(HtmlTag.UL); - ul3.addContent(HtmlTree.LI( - getResource("doclet.Field_Detail"))); - ul3.addContent(HtmlTree.LI( - getResource("doclet.Constructor_Detail"))); - ul3.addContent(HtmlTree.LI( - getResource("doclet.Method_Detail"))); + ul3.addContent(HtmlTree.LI(contents.fieldDetailsLabel)); + ul3.addContent(HtmlTree.LI(contents.constructorDetailsLabel)); + ul3.addContent(HtmlTree.LI(contents.methodDetailLabel)); htmlTree.addContent(ul3); - Content line13 = getResource("doclet.Help_line_13"); + Content line13 = contents.getContent("doclet.Help_line_13"); Content para = HtmlTree.P(line13); htmlTree.addContent(para); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -228,24 +221,24 @@ public class HelpWriter extends HtmlDocletWriter { } //Annotation Types Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.AnnotationType")); + contents.annotationType); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(aHead) : HtmlTree.LI(HtmlStyle.blockList, aHead); - Content aline1 = getResource("doclet.Help_annotation_type_line_1"); + Content aline1 = contents.getContent("doclet.Help_annotation_type_line_1"); Content aPara = HtmlTree.P(aline1); htmlTree.addContent(aPara); HtmlTree aul = new HtmlTree(HtmlTag.UL); aul.addContent(HtmlTree.LI( - getResource("doclet.Help_annotation_type_line_2"))); + contents.getContent("doclet.Help_annotation_type_line_2"))); aul.addContent(HtmlTree.LI( - getResource("doclet.Help_annotation_type_line_3"))); + contents.getContent("doclet.Help_annotation_type_line_3"))); aul.addContent(HtmlTree.LI( - getResource("doclet.Annotation_Type_Required_Member_Summary"))); + contents.annotateTypeRequiredMemberSummaryLabel)); aul.addContent(HtmlTree.LI( - getResource("doclet.Annotation_Type_Optional_Member_Summary"))); + contents.annotateTypeOptionalMemberSummaryLabel)); aul.addContent(HtmlTree.LI( - getResource("doclet.Annotation_Type_Member_Detail"))); + contents.annotationTypeMemberDetail)); htmlTree.addContent(aul); if (configuration.allowTag(HtmlTag.SECTION)) { ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); @@ -254,22 +247,22 @@ public class HelpWriter extends HtmlDocletWriter { } //Enums Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Enum")); + contents.enum_); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(enumHead) : HtmlTree.LI(HtmlStyle.blockList, enumHead); - Content eline1 = getResource("doclet.Help_enum_line_1"); + Content eline1 = contents.getContent("doclet.Help_enum_line_1"); Content enumPara = HtmlTree.P(eline1); htmlTree.addContent(enumPara); HtmlTree eul = new HtmlTree(HtmlTag.UL); eul.addContent(HtmlTree.LI( - getResource("doclet.Help_enum_line_2"))); + contents.getContent("doclet.Help_enum_line_2"))); eul.addContent(HtmlTree.LI( - getResource("doclet.Help_enum_line_3"))); + contents.getContent("doclet.Help_enum_line_3"))); eul.addContent(HtmlTree.LI( - getResource("doclet.Enum_Constant_Summary"))); + contents.enumConstantSummary)); eul.addContent(HtmlTree.LI( - getResource("doclet.Enum_Constant_Detail"))); + contents.enumConstantDetailLabel)); htmlTree.addContent(eul); if (configuration.allowTag(HtmlTag.SECTION)) { ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); @@ -278,11 +271,11 @@ public class HelpWriter extends HtmlDocletWriter { } if (configuration.classuse) { Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_14")); + contents.getContent("doclet.Help_line_14")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(useHead) : HtmlTree.LI(HtmlStyle.blockList, useHead); - Content line15 = getResource("doclet.Help_line_15"); + Content line15 = contents.getContent("doclet.Help_line_15"); Content usePara = HtmlTree.P(line15); htmlTree.addContent(usePara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -293,11 +286,11 @@ public class HelpWriter extends HtmlDocletWriter { } if (configuration.createtree) { Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_16")); + contents.getContent("doclet.Help_line_16")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(treeHead) : HtmlTree.LI(HtmlStyle.blockList, treeHead); - Content line17 = getResource("doclet.Help_line_17_with_tree_link", + Content line17 = contents.getContent("doclet.Help_line_17_with_tree_link", getHyperLink(DocPaths.OVERVIEW_TREE, configuration.getText("doclet.Class_Hierarchy")), HtmlTree.CODE(new StringContent("java.lang.Object"))); @@ -305,9 +298,9 @@ public class HelpWriter extends HtmlDocletWriter { htmlTree.addContent(treePara); HtmlTree tul = new HtmlTree(HtmlTag.UL); tul.addContent(HtmlTree.LI( - getResource("doclet.Help_line_18"))); + contents.getContent("doclet.Help_line_18"))); tul.addContent(HtmlTree.LI( - getResource("doclet.Help_line_19"))); + contents.getContent("doclet.Help_line_19"))); htmlTree.addContent(tul); if (configuration.allowTag(HtmlTag.SECTION)) { ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); @@ -318,11 +311,11 @@ public class HelpWriter extends HtmlDocletWriter { if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) { Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Deprecated_API")); + contents.deprecatedAPI); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(dHead) : HtmlTree.LI(HtmlStyle.blockList, dHead); - Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link", + Content line20 = contents.getContent("doclet.Help_line_20_with_deprecated_api_link", getHyperLink(DocPaths.DEPRECATED_LIST, configuration.getText("doclet.Deprecated_API"))); Content dPara = HtmlTree.P(line20); @@ -343,11 +336,11 @@ public class HelpWriter extends HtmlDocletWriter { configuration.getText("doclet.Index")); } Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_21")); + contents.getContent("doclet.Help_line_21")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(indexHead) : HtmlTree.LI(HtmlStyle.blockList, indexHead); - Content line22 = getResource("doclet.Help_line_22", indexlink); + Content line22 = contents.getContent("doclet.Help_line_22", indexlink); Content indexPara = HtmlTree.P(line22); htmlTree.addContent(indexPara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -357,11 +350,11 @@ public class HelpWriter extends HtmlDocletWriter { } } Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_23")); + contents.getContent("doclet.Help_line_23")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(prevHead) : HtmlTree.LI(HtmlStyle.blockList, prevHead); - Content line24 = getResource("doclet.Help_line_24"); + Content line24 = contents.getContent("doclet.Help_line_24"); Content prevPara = HtmlTree.P(line24); htmlTree.addContent(prevPara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -370,11 +363,11 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Help_line_25")); + contents.getContent("doclet.Help_line_25")); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(frameHead) : HtmlTree.LI(HtmlStyle.blockList, frameHead); - Content line26 = getResource("doclet.Help_line_26"); + Content line26 = contents.getContent("doclet.Help_line_26"); Content framePara = HtmlTree.P(line26); htmlTree.addContent(framePara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -383,13 +376,13 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.All_Classes")); + contents.allClassesLabel); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(allclassesHead) : HtmlTree.LI(HtmlStyle.blockList, allclassesHead); - Content line27 = getResource("doclet.Help_line_27", + Content line27 = contents.getContent("doclet.Help_line_27", getHyperLink(DocPaths.ALLCLASSES_NOFRAME, - configuration.getText("doclet.All_Classes"))); + resources.getText("doclet.All_Classes"))); Content allclassesPara = HtmlTree.P(line27); htmlTree.addContent(allclassesPara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -398,11 +391,11 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Serialized_Form")); + contents.serializedForm); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(sHead) : HtmlTree.LI(HtmlStyle.blockList, sHead); - Content line28 = getResource("doclet.Help_line_28"); + Content line28 = contents.getContent("doclet.Help_line_28"); Content serialPara = HtmlTree.P(line28); htmlTree.addContent(serialPara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -411,13 +404,13 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, - getResource("doclet.Constants_Summary")); + contents.constantsSummaryTitle); htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.SECTION(constHead) : HtmlTree.LI(HtmlStyle.blockList, constHead); - Content line29 = getResource("doclet.Help_line_29", + Content line29 = contents.getContent("doclet.Help_line_29", getHyperLink(DocPaths.CONSTANT_VALUES, - configuration.getText("doclet.Constants_Summary"))); + resources.getText("doclet.Constants_Summary"))); Content constPara = HtmlTree.P(line29); htmlTree.addContent(constPara); if (configuration.allowTag(HtmlTag.SECTION)) { @@ -426,7 +419,7 @@ public class HelpWriter extends HtmlDocletWriter { ul.addContent(htmlTree); } Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul); - Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, getResource("doclet.Help_line_30")); + Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, contents.getContent("doclet.Help_line_30")); divContent.addContent(line30); if (configuration.allowTag(HtmlTag.MAIN)) { mainTree.addContent(divContent); @@ -443,7 +436,7 @@ public class HelpWriter extends HtmlDocletWriter { */ @Override protected Content getNavLinkHelp() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.helpLabel); return li; } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java index f2251e30afc..09545fdc0bb 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java @@ -38,6 +38,7 @@ import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.Reporter; import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; @@ -68,7 +69,9 @@ public class HtmlDoclet extends AbstractDoclet { /** * The global configuration information for this run. */ - public final ConfigurationImpl configuration; + private final ConfigurationImpl configuration; + + private Messages messages; private static final DocPath DOCLET_RESOURCES = DocPath @@ -77,6 +80,7 @@ public class HtmlDoclet extends AbstractDoclet { public void init(Locale locale, Reporter reporter) { configuration.reporter = reporter; configuration.locale = locale; + messages = configuration.getMessages(); } /** @@ -118,8 +122,7 @@ public class HtmlDoclet extends AbstractDoclet { } if (configuration.topFile.isEmpty()) { - configuration.standardmessage. - error("doclet.No_Non_Deprecated_Classes_To_Document"); + messages.error("doclet.No_Non_Deprecated_Classes_To_Document"); return; } boolean nodeprecated = configuration.nodeprecated; @@ -351,11 +354,11 @@ public class HtmlDoclet extends AbstractDoclet { if (toFile.isSameFile(fromfile)) return; - configuration.message.notice("doclet.Copying_File_0_To_File_1", + messages.notice("doclet.Copying_File_0_To_File_1", fromfile.toString(), path.getPath()); toFile.copyFile(fromfile); } catch (IOException exc) { - configuration.message.error("doclet.perform_copy_exception_encountered", + messages.error("doclet.perform_copy_exception_encountered", exc.toString()); throw new DocletAbortException(exc); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 6073a6d5aff..ca30eca8ef1 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -82,7 +82,9 @@ import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter; import jdk.javadoc.internal.doclets.toolkit.ClassWriter; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter; +import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet; import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; @@ -145,6 +147,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { protected final Utils utils; + protected final Contents contents; + + protected final Messages messages; + + protected final Resources resources; + /** * To check whether annotation heading is printed or not. */ @@ -174,10 +182,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { * * @param path File to be generated. */ - public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) - throws IOException { + public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) { super(configuration, path); this.configuration = configuration; + this.contents = configuration.contents; + this.messages = configuration.messages; + this.resources = configuration.resources; this.utils = configuration.utils; this.path = path; this.pathToRoot = path.parent().invert(); @@ -249,19 +259,19 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public Content getAllClassesLinkScript(String id) { HtmlTree script = HtmlTree.SCRIPT(); - String scriptCode = "" + DocletConstants.NL; - Content scriptContent = new RawHtml(scriptCode); + String scriptCode = "\n"; + Content scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL)); script.addContent(scriptContent); Content div = HtmlTree.DIV(script); - Content div_noscript = HtmlTree.DIV(getResource("doclet.No_Script_Message")); + Content div_noscript = HtmlTree.DIV(contents.noScriptMessage); Content noScript = HtmlTree.NOSCRIPT(div_noscript); div.addContent(noScript); return div; @@ -404,7 +414,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD); tdClassDescription.addStyle(HtmlStyle.colLast); if (utils.isDeprecated(te)) { - tdClassDescription.addContent(deprecatedLabel); + tdClassDescription.addContent(contents.deprecatedLabel); List tags = utils.getDeprecatedTrees(te); if (!tags.isEmpty()) { addSummaryDeprecatedComment(te, tags.get(0), tdClassDescription); @@ -535,7 +545,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { String allClassesId = "allclasses_"; HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); fixedNavDiv.addStyle(HtmlStyle.fixedNav); - Content skipNavLinks = configuration.getResource("doclet.Skip_navigation_links"); + Content skipNavLinks = configuration.getContent("doclet.Skip_navigation_links"); if (header) { fixedNavDiv.addContent(HtmlConstants.START_OF_TOP_NAVBAR); navDiv.addStyle(HtmlStyle.topNav); @@ -617,8 +627,9 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (header && configuration.createindex) { HtmlTree inputText = HtmlTree.INPUT("text", "search"); HtmlTree inputReset = HtmlTree.INPUT("reset", "reset"); - Content searchTxt = configuration.getResource("doclet.search"); - searchTxt.addContent(getSpace()); + Content searchTxt = new ContentBuilder(); + searchTxt.addContent(configuration.getContent("doclet.search")); + searchTxt.addContent(Contents.SPACE); HtmlTree liInput = HtmlTree.LI(HtmlTree.SPAN(searchTxt)); liInput.addContent(inputText); liInput.addContent(inputReset); @@ -632,7 +643,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { fixedNavDiv.addContent(subDiv); fixedNavDiv.addContent(HtmlConstants.END_OF_TOP_NAVBAR); tree.addContent(fixedNavDiv); - HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, getSpace()); + HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE); tree.addContent(paddingDiv); } else { subDiv.addContent(getMarkerAnchor(SectionName.SKIP_NAVBAR_BOTTOM)); @@ -678,7 +689,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ protected Content getNavLinkContents() { Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY), - overviewLabel, "", ""); + contents.overviewLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -690,7 +701,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkModule(ModuleElement mdle) { - Content linkContent = getModuleLink(mdle, moduleLabel); + Content linkContent = getModuleLink(mdle, contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -701,7 +712,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkModule() { - Content li = HtmlTree.LI(moduleLabel); + Content li = HtmlTree.LI(contents.moduleLabel); return li; } @@ -712,7 +723,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkPackage(PackageElement pkg) { - Content linkContent = getPackageLink(pkg, packageLabel); + Content linkContent = getPackageLink(pkg, contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -723,7 +734,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkPackage() { - Content li = HtmlTree.LI(packageLabel); + Content li = HtmlTree.LI(contents.packageLabel); return li; } @@ -733,7 +744,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkClassUse() { - Content li = HtmlTree.LI(useLabel); + Content li = HtmlTree.LI(contents.useLabel); return li; } @@ -746,10 +757,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { public Content getNavLinkPrevious(DocPath prev) { Content li; if (prev != null) { - li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", "")); + li = HtmlTree.LI(getHyperLink(prev, contents.prevLabel, "", "")); } else - li = HtmlTree.LI(prevLabel); + li = HtmlTree.LI(contents.prevLabel); return li; } @@ -763,10 +774,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { public Content getNavLinkNext(DocPath next) { Content li; if (next != null) { - li = HtmlTree.LI(getHyperLink(next, nextLabel, "", "")); + li = HtmlTree.LI(getHyperLink(next, contents.nextLabel, "", "")); } else - li = HtmlTree.LI(nextLabel); + li = HtmlTree.LI(contents.nextLabel); return li; } @@ -778,7 +789,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ protected Content getNavShowLists(DocPath link) { DocLink dl = new DocLink(link, path.getPath(), null); - Content framesContent = getHyperLink(dl, framesLabel, "", "_top"); + Content framesContent = getHyperLink(dl, contents.framesLabel, "", "_top"); Content li = HtmlTree.LI(framesContent); return li; } @@ -799,7 +810,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavHideLists(DocPath link) { - Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top"); + Content noFramesContent = getHyperLink(link, contents.noFramesLabel, "", "_top"); Content li = HtmlTree.LI(noFramesContent); return li; } @@ -817,7 +828,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { DocPath docPath = packages.size() == 1 && utils.getSpecifiedClasses().isEmpty() ? pathString(packages.get(0), DocPaths.PACKAGE_TREE) : pathToRoot.resolve(DocPaths.OVERVIEW_TREE); - return HtmlTree.LI(getHyperLink(docPath, treeLabel, "", "")); + return HtmlTree.LI(getHyperLink(docPath, contents.treeLabel, "", "")); } /** @@ -839,7 +850,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return a content tree for the link */ protected Content getNavLinkClass() { - Content li = HtmlTree.LI(classLabel); + Content li = HtmlTree.LI(contents.classLabel); return li; } @@ -850,7 +861,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ protected Content getNavLinkDeprecated() { Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), - deprecatedLabel, "", ""); + contents.deprecatedLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -865,7 +876,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { protected Content getNavLinkClassIndex() { Content allClassesContent = getHyperLink(pathToRoot.resolve( DocPaths.ALLCLASSES_NOFRAME), - allclassesLabel, "", ""); + contents.allClassesLabel, "", ""); Content li = HtmlTree.LI(allClassesContent); return li; } @@ -880,7 +891,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { (configuration.splitindex ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)) : DocPaths.INDEX_ALL)), - indexLabel, "", ""); + contents.indexLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -902,7 +913,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { helpfilenm = DocPath.create(file.getName()); } Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm), - helpLabel, "", ""); + contents.helpLabel, "", ""); Content li = HtmlTree.LI(linkContent); return li; } @@ -913,9 +924,9 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @param liNav the content tree to which the gap will be added */ protected void addNavGap(Content liNav) { - liNav.addContent(getSpace()); + liNav.addContent(Contents.SPACE); liNav.addContent("|"); - liNav.addContent(getSpace()); + liNav.addContent(Contents.SPACE); } /** @@ -954,7 +965,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public Content getTableCaption(Content title) { Content captionSpan = HtmlTree.SPAN(title); - Content space = getSpace(); + Content space = Contents.SPACE; Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space); Content caption = HtmlTree.CAPTION(captionSpan); caption.addContent(tabSpan); @@ -1014,7 +1025,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public Content getPackageName(PackageElement packageElement) { return packageElement == null || packageElement.isUnnamed() - ? defaultPackageLabel + ? contents.defaultPackageLabel : getPackageLabel(packageElement.getQualifiedName()); } @@ -1040,7 +1051,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { protected void addPackageDeprecatedAPI(SortedSet deprPkgs, String headingKey, String tableSummary, List tableHeader, Content contentTree) { if (deprPkgs.size() > 0) { - Content caption = getTableCaption(configuration.getResource(headingKey)); + Content caption = getTableCaption(configuration.getContent(headingKey)); Content table = (configuration.isOutputHtml5()) ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption) : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption); @@ -1551,7 +1562,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return classCrossLink; } else { // No cross link found so print warning - configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(see), + messages.warning(ch.getDocTreePath(see), "doclet.see.class_or_package_not_found", "@" + tagName, seetext); @@ -1594,11 +1605,11 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (this instanceof ClassWriterImpl) { containing = ((ClassWriterImpl) this).getTypeElement(); } else if (!utils.isPublic(containing)) { - configuration.getDocletSpecificMsg().warning( + messages.warning( ch.getDocTreePath(see), "doclet.see.class_or_package_not_accessible", tagName, utils.getFullyQualifiedName(containing)); } else { - configuration.getDocletSpecificMsg().warning( + messages.warning( ch.getDocTreePath(see), "doclet.see.class_or_package_not_found", tagName, seetext); } @@ -1728,7 +1739,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { htmltree.addContent(div); } if (tags.isEmpty()) { - htmltree.addContent(getSpace()); + htmltree.addContent(Contents.SPACE); } } @@ -1917,7 +1928,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { @Override @DefinedBy(Api.COMPILER_TREE) public Boolean visitErroneous(ErroneousTree node, Content c) { - configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(node), + messages.warning(ch.getDocTreePath(node), "doclet.tag.invalid_usage", node); result.addContent(new RawHtml(node.toString())); return false; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java index 68648d4aaaa..6c94d1eb3a8 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java @@ -25,8 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; - import java.util.Arrays; import java.util.List; import java.util.SortedSet; @@ -111,7 +109,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter methodDetailsTree.addContent(writer.getMarkerAnchor( SectionName.METHOD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.methodDetailsLabel); + contents.methodDetailLabel); methodDetailsTree.addContent(heading); return methodDetailsTree; } @@ -190,9 +188,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Content codelLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, utils.isClass(holder) - ? writer.descfrmClassLabel - : writer.descfrmInterfaceLabel); - descfrmLabel.addContent(writer.getSpace()); + ? contents.descfrmClassLabel + : contents.descfrmInterfaceLabel); + descfrmLabel.addContent(Contents.SPACE); descfrmLabel.addContent(codelLink); methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(method, methodDocTree); @@ -229,21 +227,13 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter return getMemberTree(methodDocTree, isLastContent); } - /** - * Close the writer. - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Method_Summary")); + contents.methodSummary); memberTree.addContent(label); } @@ -252,9 +242,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Method_Summary"), - configuration.getText("doclet.methods")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Method_Summary"), + resources.getText("doclet.methods")); } /** @@ -262,7 +252,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Methods"); + return contents.methods; } /** @@ -271,9 +261,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter @Override public List getSummaryTableHeader(Element member) { List header = Arrays.asList(writer.getModifierTypeHeader(), - configuration.getText("doclet.0_and_1", - configuration.getText("doclet.Method"), - configuration.getText("doclet.Description"))); + resources.getText("doclet.0_and_1", + resources.getText("doclet.Method"), + resources.getText("doclet.Description"))); return header; } @@ -307,7 +297,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter : configuration.getText("doclet.Methods_Inherited_From_Interface")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(writer.getSpace()); + labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); inheritedTree.addContent(labelHeading); } @@ -329,7 +319,8 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter if (writer.configuration.nocomment) { return; } - Utils utils = writer.configuration().utils; + Utils utils = writer.utils; + Contents contents = writer.contents; TypeElement holder = utils.getEnclosingTypeElement(method); if (!(utils.isPublic(holder) || utils.isLinkable(holder))) { @@ -341,14 +332,14 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter //is not visible so don't document this. return; } - Content label = writer.overridesLabel; + Content label = contents.overridesLabel; LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES; if (method != null) { if (utils.isAbstract(holder) && utils.isAbstract(method)){ //Abstract method is implemented from abstract class, //not overridden - label = writer.specifiedByLabel; + label = contents.specifiedByLabel; context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY; } Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label)); @@ -362,9 +353,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter .where(writer.getName(writer.getAnchor(method))).label(method.getSimpleName())); Content codeMethLink = HtmlTree.CODE(methlink); Content dd = HtmlTree.DD(codeMethLink); - dd.addContent(writer.getSpace()); - dd.addContent(writer.getResource("doclet.in_class")); - dd.addContent(writer.getSpace()); + dd.addContent(Contents.SPACE); + dd.addContent(writer.contents.inClass); + dd.addContent(Contents.SPACE); dd.addContent(codeOverridenTypeLink); dl.addContent(dd); } @@ -379,6 +370,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter return; } Utils utils = writer.utils; + Contents contents = writer.contents; ImplementedMethods implementedMethodsFinder = new ImplementedMethods(method, writer.configuration); SortedSet implementedMethods = @@ -390,16 +382,16 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Content intfaclink = writer.getLink(new LinkInfoImpl( writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac)); Content codeIntfacLink = HtmlTree.CODE(intfaclink); - Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, writer.specifiedByLabel)); + Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, contents.specifiedByLabel)); dl.addContent(dt); Content methlink = writer.getDocLink( LinkInfoImpl.Kind.MEMBER, implementedMeth, implementedMeth.getSimpleName(), false); Content codeMethLink = HtmlTree.CODE(methlink); Content dd = HtmlTree.DD(codeMethLink); - dd.addContent(writer.getSpace()); - dd.addContent(writer.getResource("doclet.in_interface")); - dd.addContent(writer.getSpace()); + dd.addContent(Contents.SPACE); + dd.addContent(contents.inInterface); + dd.addContent(Contents.SPACE); dd.addContent(codeIntfacLink); dl.addContent(dd); } @@ -417,7 +409,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter Content linkContent = writer.getLink( new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type)); htmltree.addContent(linkContent); - htmltree.addContent(writer.getSpace()); + htmltree.addContent(Contents.SPACE); } } @@ -430,14 +422,14 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter if (typeElement == null) { return writer.getHyperLink( SectionName.METHOD_SUMMARY, - writer.getResource("doclet.navMethod")); + contents.navMethod); } else { return writer.getHyperLink( SectionName.METHODS_INHERITANCE, - configuration.getClassName(typeElement), writer.getResource("doclet.navMethod")); + configuration.getClassName(typeElement), contents.navMethod); } } else { - return writer.getResource("doclet.navMethod"); + return contents.navMethod; } } @@ -448,9 +440,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter protected void addNavDetailLink(boolean link, Content liNav) { if (link) { liNav.addContent(writer.getHyperLink( - SectionName.METHOD_DETAIL, writer.getResource("doclet.navMethod"))); + SectionName.METHOD_DETAIL, contents.navMethod)); } else { - liNav.addContent(writer.getResource("doclet.navMethod")); + liNav.addContent(contents.navMethod); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java index 3f25c5d334d..95a55cdafbf 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java @@ -60,7 +60,7 @@ public class ModuleFrameWriter extends HtmlDocletWriter { /** * The module being documented. */ - private ModuleElement mdle; + private final ModuleElement mdle; /** * The classes to be documented. Use this to filter out classes @@ -114,9 +114,8 @@ public class ModuleFrameWriter extends HtmlDocletWriter { } mdlgen.printHtmlDocument( configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body); - mdlgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( + configuration.messages.error( "doclet.exception_encountered", exc.toString(), DocPaths.moduleTypeFrame(moduleElement).getPath()); throw new DocletAbortException(exc); @@ -148,12 +147,12 @@ public class ModuleFrameWriter extends HtmlDocletWriter { annotationTypes.addAll(utils.getAnnotationTypes(pkg)); } } - addClassKindListing(interfaces, getResource("doclet.Interfaces"), contentTree); - addClassKindListing(classes, getResource("doclet.Classes"), contentTree); - addClassKindListing(enums, getResource("doclet.Enums"), contentTree); - addClassKindListing(exceptions, getResource("doclet.Exceptions"), contentTree); - addClassKindListing(errors, getResource("doclet.Errors"), contentTree); - addClassKindListing(annotationTypes, getResource("doclet.AnnotationTypes"), contentTree); + addClassKindListing(interfaces, contents.interfaces, contentTree); + addClassKindListing(classes, contents.classes, contentTree); + addClassKindListing(enums, contents.enums, contentTree); + addClassKindListing(exceptions, contents.exceptions, contentTree); + addClassKindListing(errors, contents.errors, contentTree); + addClassKindListing(annotationTypes, contents.annotationTypes, contentTree); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java index ce18032a117..69d8580694c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java @@ -39,6 +39,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -79,10 +80,9 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { try { modulegen = new ModuleIndexFrameWriter(configuration, filename); modulegen.buildModuleIndexFile("doclet.Window_Overview", false); - modulegen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -94,12 +94,12 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { protected void addModulesList(Map> modules, String text, String tableSummary, Content body) { Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true, - modulesLabel); + contents.modulesLabel); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) : HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); - ul.setTitle(modulesLabel); + ul.setTitle(contents.modulesLabel); for (ModuleElement mdle: modules.keySet()) { ul.addContent(getModuleLink(mdle)); } @@ -150,7 +150,7 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { */ protected void addAllClassesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, - allclassesLabel, "", "packageFrame"); + contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -163,7 +163,7 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { */ protected void addAllPackagesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, - allpackagesLabel, "", "packageListFrame"); + contents.allPackagesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -172,7 +172,7 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { * {@inheritDoc} */ protected void addNavigationBarFooter(Content body) { - Content p = HtmlTree.P(getSpace()); + Content p = HtmlTree.P(Contents.SPACE); body.addContent(p); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java index 29f0b79cdd2..1d815f90e59 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java @@ -32,12 +32,14 @@ import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -90,9 +92,9 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { try { mdlgen = new ModuleIndexWriter(configuration, filename); mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true); - mdlgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( + Messages messages = configuration.getMessages(); + messages.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); @@ -195,12 +197,13 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { subTitleDiv.addStyle(HtmlStyle.subTitle); addSummaryComment(configuration.overviewElement, subTitleDiv); Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv); - Content see = seeLabel; + Content see = new ContentBuilder(); + see.addContent(contents.seeLabel); see.addContent(" "); Content descPara = HtmlTree.P(see); Content descLink = getHyperLink(getDocLink( SectionName.OVERVIEW_DESCRIPTION), - descriptionLabel, "", ""); + contents.descriptionLabel, "", ""); descPara.addContent(descLink); div.addContent(descPara); if (configuration.allowTag(HtmlTag.MAIN)) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java index dd870800c62..accc9be7930 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java @@ -41,6 +41,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -82,10 +83,9 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { try { modpackgen = new ModulePackageIndexFrameWriter(configuration, filename); modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle); - modpackgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -99,13 +99,13 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { Content profNameContent = new StringContent(mdle.getQualifiedName().toString()); Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, getTargetModuleLink("classFrame", profNameContent, mdle)); - heading.addContent(getSpace()); - heading.addContent(packagesLabel); + heading.addContent(Contents.SPACE); + heading.addContent(contents.packagesLabel); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) : HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); - ul.setTitle(packagesLabel); + ul.setTitle(contents.packagesLabel); List packages = new ArrayList<>(modules.get(mdle)); for (PackageElement pkg : packages) { if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { @@ -124,13 +124,13 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString()); Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, getTargetModuleLink("classFrame", moduleNameContent, mdle)); - heading.addContent(getSpace()); - heading.addContent(packagesLabel); + heading.addContent(Contents.SPACE); + heading.addContent(contents.packagesLabel); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) : HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); - ul.setTitle(packagesLabel); + ul.setTitle(contents.packagesLabel); Set modulePackages = configuration.modulePackages.get(mdle); for (PackageElement pkg: modulePackages) { if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { @@ -198,7 +198,7 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { */ protected void addAllClassesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, - allclassesLabel, "", "packageFrame"); + contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -211,7 +211,7 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { */ protected void addAllPackagesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME, - allpackagesLabel, "", "packageListFrame"); + contents.allPackagesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -224,7 +224,7 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { */ protected void addAllModulesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME, - allmodulesLabel, "", "packageListFrame"); + contents.allModulesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -233,7 +233,7 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { * {@inheritDoc} */ protected void addNavigationBarFooter(Content body) { - Content p = HtmlTree.P(getSpace()); + Content p = HtmlTree.P(Contents.SPACE); body.addContent(p); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java index 4dd90f6efd1..3c52b31c44f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java @@ -102,8 +102,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW * @param nextModule Next module in the sorted array. */ public ModuleWriterImpl(ConfigurationImpl configuration, - ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) - throws IOException { + ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) { super(configuration, DocPaths.moduleSummary(mdle)); this.prevModule = prevModule; this.nextModule = nextModule; @@ -129,8 +128,8 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.header); Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.title, moduleLabel); - tHeading.addContent(getSpace()); + HtmlStyle.title, contents.moduleLabel); + tHeading.addContent(Contents.SPACE); Content moduleHead = new RawHtml(heading); tHeading.addContent(moduleHead); div.addContent(tHeading); @@ -262,7 +261,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES, - getResource("doclet.navModules"), li); + contents.navModules, li); String text = configuration.getText("doclet.Requires_Summary"); String tableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Requires_Summary"), @@ -315,7 +314,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES, - getResource("doclet.navPackages"), li); + contents.navPackages, li); String text = configuration.getText("doclet.Exported_Packages_Summary"); String tableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Exported_Packages_Summary"), @@ -385,7 +384,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, - getResource("doclet.navServices"), li); + contents.navServices, li); String text; String tableSummary; if (usesDirs != null && !usesDirs.isEmpty()) { @@ -468,9 +467,9 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW HtmlTree tdType = HtmlTree.TD(HtmlStyle.colFirst, srvLinkContent); tdType.addContent(new HtmlTree(HtmlTag.BR)); tdType.addContent("("); - HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, getResource("doclet.Implementation")); + HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, contents.implementation); tdType.addContent(implSpan); - tdType.addContent(getSpace()); + tdType.addContent(Contents.SPACE); tdType.addContent(implLinkContent); tdType.addContent(")"); HtmlTree tdDesc = new HtmlTree(HtmlTag.TD); @@ -530,25 +529,25 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW * @return the content tree for the navigation summary links */ protected Content getNavSummaryLinks() throws Exception { - Content li = HtmlTree.LI(moduleSubNavLabel); - li.addContent(getSpace()); + Content li = HtmlTree.LI(contents.moduleSubNavLabel); + li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); Content liNav = new HtmlTree(HtmlTag.LI); liNav.addContent(!utils.getBody(mdle).isEmpty() && !configuration.nocomment - ? getHyperLink(SectionName.MODULE_DESCRIPTION, getResource("doclet.navModuleDescription")) - : getResource("doclet.navModuleDescription")); + ? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription) + : contents.navModuleDescription); addNavGap(liNav); liNav.addContent(showDirectives(DirectiveKind.REQUIRES) - ? getHyperLink(SectionName.MODULES, getResource("doclet.navModules")) - : getResource("doclet.navModules")); + ? getHyperLink(SectionName.MODULES, contents.navModules) + : contents.navModules); addNavGap(liNav); liNav.addContent(showDirectives(DirectiveKind.EXPORTS) - ? getHyperLink(SectionName.PACKAGES, getResource("doclet.navPackages")) - : getResource("doclet.navPackages")); + ? getHyperLink(SectionName.PACKAGES, contents.navPackages) + : contents.navPackages); addNavGap(liNav); liNav.addContent((showDirectives(DirectiveKind.USES) || showDirectives(DirectiveKind.PROVIDES)) - ? getHyperLink(SectionName.SERVICES, getResource("doclet.navServices")) - : getResource("doclet.navServices")); + ? getHyperLink(SectionName.SERVICES, contents.navServices) + : contents.navServices); ulNav.addContent(liNav); return ulNav; } @@ -609,7 +608,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW deprs = utils.getDeprecatedTrees(pkg); HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.addStyle(HtmlStyle.deprecatedContent); - Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); deprDiv.addContent(deprPhrase); if (!deprs.isEmpty()) { CommentHelper ch = utils.getCommentHelper(pkg); @@ -629,7 +628,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW */ @Override protected Content getNavLinkModule() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, moduleLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.moduleLabel); return li; } @@ -641,10 +640,10 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW public Content getNavLinkPrevious() { Content li; if (prevModule == null) { - li = HtmlTree.LI(prevmoduleLabel); + li = HtmlTree.LI(contents.prevModuleLabel); } else { li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary( - prevModule)), prevmoduleLabel, "", "")); + prevModule)), contents.prevModuleLabel, "", "")); } return li; } @@ -657,10 +656,10 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW public Content getNavLinkNext() { Content li; if (nextModule == null) { - li = HtmlTree.LI(nextmoduleLabel); + li = HtmlTree.LI(contents.nextModuleLabel); } else { li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary( - nextModule)), nextmoduleLabel, "", "")); + nextModule)), contents.nextModuleLabel, "", "")); } return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java index c0828b8d5e2..f43f53eb39a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java @@ -83,21 +83,13 @@ public class NestedClassWriterImpl extends AbstractMemberWriter writer.addMemberTree(memberSummaryTree, memberTree); } - /** - * Close the writer. - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Nested_Class_Summary")); + contents.nestedClassSummary); memberTree.addContent(label); } @@ -106,9 +98,9 @@ public class NestedClassWriterImpl extends AbstractMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Nested_Class_Summary"), - configuration.getText("doclet.nested_classes")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Nested_Class_Summary"), + resources.getText("doclet.nested_classes")); } /** @@ -116,7 +108,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Nested_Classes"); + return configuration.getContent("doclet.Nested_Classes"); } /** @@ -169,7 +161,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter : configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(writer.getSpace()); + labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); inheritedTree.addContent(labelHeading); } @@ -221,14 +213,14 @@ public class NestedClassWriterImpl extends AbstractMemberWriter if (typeElement == null) { return writer.getHyperLink( SectionName.NESTED_CLASS_SUMMARY, - writer.getResource("doclet.navNested")); + contents.navNested); } else { return writer.getHyperLink( SectionName.NESTED_CLASSES_INHERITANCE, - utils.getFullyQualifiedName(typeElement), writer.getResource("doclet.navNested")); + utils.getFullyQualifiedName(typeElement), contents.navNested); } } else { - return writer.getResource("doclet.navNested"); + return contents.navNested; } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java index 1ad89ea05b2..2d3b9f74900 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java @@ -38,6 +38,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -80,8 +81,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { * @param configuration the configuration of the doclet. * @param packageElement PackageElement under consideration. */ - public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement) - throws IOException { + public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement) { super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME)); this.packageElement = packageElement; if (utils.getSpecifiedPackages().isEmpty()) { @@ -119,10 +119,9 @@ public class PackageFrameWriter extends HtmlDocletWriter { } packgen.printHtmlDocument( configuration.metakeywords.getMetaKeywords(packageElement), false, body); - packgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), DocPaths.PACKAGE_FRAME.getPath()); throw new DocletAbortException(exc); } @@ -139,30 +138,30 @@ public class PackageFrameWriter extends HtmlDocletWriter { Configuration config = configuration; if (utils.isIncluded(packageElement)) { addClassKindListing(utils.getInterfaces(packageElement), - getResource("doclet.Interfaces"), contentTree); + contents.interfaces, contentTree); addClassKindListing(utils.getOrdinaryClasses(packageElement), - getResource("doclet.Classes"), contentTree); + contents.classes, contentTree); addClassKindListing(utils.getEnums(packageElement), - getResource("doclet.Enums"), contentTree); + contents.enums, contentTree); addClassKindListing(utils.getExceptions(packageElement), - getResource("doclet.Exceptions"), contentTree); + contents.exceptions, contentTree); addClassKindListing(utils.getErrors(packageElement), - getResource("doclet.Errors"), contentTree); + contents.errors, contentTree); addClassKindListing(utils.getAnnotationTypes(packageElement), - getResource("doclet.AnnotationTypes"), contentTree); + contents.annotationTypes, contentTree); } else { addClassKindListing(config.typeElementCatalog.interfaces(packageElement), - getResource("doclet.Interfaces"), contentTree); + contents.interfaces, contentTree); addClassKindListing(config.typeElementCatalog.ordinaryClasses(packageElement), - getResource("doclet.Classes"), contentTree); + contents.classes, contentTree); addClassKindListing(config.typeElementCatalog.enums(packageElement), - getResource("doclet.Enums"), contentTree); + contents.enums, contentTree); addClassKindListing(config.typeElementCatalog.exceptions(packageElement), - getResource("doclet.Exceptions"), contentTree); + contents.exceptions, contentTree); addClassKindListing(config.typeElementCatalog.errors(packageElement), - getResource("doclet.Errors"), contentTree); + contents.errors, contentTree); addClassKindListing(config.typeElementCatalog.annotationTypes(packageElement), - getResource("doclet.AnnotationTypes"), contentTree); + contents.annotationTypes, contentTree); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java index e83d4ab3b61..be2b1a9fc4c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java @@ -37,6 +37,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -76,10 +77,9 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { try { packgen = new PackageIndexFrameWriter(configuration, filename); packgen.buildPackageIndexFile("doclet.Window_Overview", false); - packgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -91,12 +91,12 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { protected void addPackagesList(Collection packages, String text, String tableSummary, Content body) { Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, - packagesLabel); + contents.packagesLabel); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) : HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); - ul.setTitle(packagesLabel); + ul.setTitle(contents.packagesLabel); for (PackageElement aPackage : packages) { // Do not list the package if -nodeprecated option is set and the // package is marked as deprecated. @@ -161,7 +161,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { */ protected void addAllClassesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, - allclassesLabel, "", "packageFrame"); + contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -174,7 +174,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { */ protected void addAllModulesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME, - allmodulesLabel, "", "packageListFrame"); + contents.allModulesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); ul.addContent(li); } @@ -183,7 +183,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { * {@inheritDoc} */ protected void addNavigationBarFooter(Content body) { - Content p = HtmlTree.P(getSpace()); + Content p = HtmlTree.P(Contents.SPACE); body.addContent(p); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java index d6d839cac28..fa1a9abb571 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java @@ -31,11 +31,13 @@ import java.util.*; import javax.lang.model.element.PackageElement; import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -103,10 +105,9 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { try { packgen = new PackageIndexWriter(configuration, filename); packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); - packgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -189,12 +190,13 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { subTitleDiv.addStyle(HtmlStyle.subTitle); addSummaryComment(configuration.overviewElement, subTitleDiv); Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv); - Content see = seeLabel; - see.addContent(" "); - Content descPara = HtmlTree.P(see); + Content descBody = new ContentBuilder(); + descBody.addContent(contents.seeLabel); + descBody.addContent(" "); + Content descPara = HtmlTree.P(descBody); Content descLink = getHyperLink(getDocLink( SectionName.OVERVIEW_DESCRIPTION), - descriptionLabel, "", ""); + contents.descriptionLabel, "", ""); descPara.addContent(descLink); div.addContent(descPara); if (configuration.allowTag(HtmlTag.MAIN)) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java index 4db9a00c804..d48e0e17704 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java @@ -34,6 +34,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -112,10 +113,9 @@ public class PackageTreeWriter extends AbstractTreeWriter { packgen = new PackageTreeWriter(configuration, path, pkg, prev, next); packgen.generatePackageTreeFile(); - packgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), path.getPath()); throw new DocletAbortException(exc); } @@ -130,7 +130,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN() : body; - Content headContent = getResource("doclet.Hierarchy_For_Package", + Content headContent = contents.getContent("doclet.Hierarchy_For_Package", utils.getPackageName(packageElement)); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, headContent); @@ -187,7 +187,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { */ protected void addLinkToMainTree(Content div) { Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, - getResource("doclet.Package_Hierarchies")); + contents.packageHierarchies); div.addContent(span); HtmlTree ul = new HtmlTree (HtmlTag.UL); ul.addStyle(HtmlStyle.horizontal); @@ -231,7 +231,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -243,7 +243,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { */ protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, - packageLabel); + contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java index d73fab18f8d..b653aedf77a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java @@ -38,6 +38,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -108,11 +109,9 @@ public class PackageUseWriter extends SubWriterHolderWriter { try { pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement); pkgusegen.generatePackageUseFile(); - pkgusegen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", - exc.toString(), filename); + Messages messages = configuration.getMessages(); + messages.error(exc.toString(), filename); throw new DocletAbortException(exc); } } @@ -125,7 +124,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); if (usingPackageToUsedClasses.isEmpty()) { - div.addContent(getResource("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement))); + div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement))); } else { addPackageUse(div); } @@ -167,7 +166,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * @param contentTree the content tree to which the package list will be added */ protected void addPackageList(Content contentTree) throws IOException { - Content caption = getTableCaption(configuration.getResource( + Content caption = getTableCaption(configuration.getContent( "doclet.ClassUse_Packages.that.use.0", getPackageLink(packageElement, utils.getPackageName(packageElement)))); Content table = (configuration.isOutputHtml5()) @@ -208,7 +207,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { } String tableSummary = configuration.getText("doclet.Use_Table_Summary", configuration.getText("doclet.classes")); - Content caption = getTableCaption(configuration.getResource( + Content caption = getTableCaption(configuration.getContent( "doclet.ClassUse_Classes.in.0.used.by.1", getPackageLink(packageElement, utils.getPackageName(packageElement)), getPackageLink(usingPackage, utils.getPackageName(usingPackage)))); @@ -265,7 +264,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { if (pkg != null && !pkg.isUnnamed()) { addSummaryComment(pkg, tdLast); } else { - tdLast.addContent(getSpace()); + tdLast.addContent(Contents.SPACE); } contentTree.addContent(tdLast); } @@ -289,7 +288,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { bodyTree.addContent(htmlTree); } ContentBuilder headContent = new ContentBuilder(); - headContent.addContent(getResource("doclet.ClassUse_Title", packageText)); + headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(name); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, @@ -311,7 +310,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -323,7 +322,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { */ protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, - packageLabel); + contents.packageLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -334,7 +333,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * @return a content tree for the use link */ protected Content getNavLinkClassUse() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); return li; } @@ -345,7 +344,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { */ protected Content getNavLinkTree() { Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE, - treeLabel); + contents.treeLabel); Content li = HtmlTree.LI(linkContent); return li; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java index 759f7a5a8b9..7ca79165032 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java @@ -100,8 +100,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * @param next Next package in the sorted array. */ public PackageWriterImpl(ConfigurationImpl configuration, - PackageElement packageElement, PackageElement prev, PackageElement next) - throws IOException { + PackageElement packageElement, PackageElement prev, PackageElement next) { super(configuration, DocPath .forPackage(packageElement) .resolve(DocPaths.PACKAGE_SUMMARY)); @@ -127,9 +126,9 @@ public class PackageWriterImpl extends HtmlDocletWriter div.addStyle(HtmlStyle.header); ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(packageElement); if (mdle != null && !mdle.isUnnamed()) { - Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, moduleLabel); + Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); - moduleNameDiv.addContent(getSpace()); + moduleNameDiv.addContent(Contents.SPACE); moduleNameDiv.addContent(getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()))); div.addContent(moduleNameDiv); @@ -138,8 +137,8 @@ public class PackageWriterImpl extends HtmlDocletWriter addAnnotationInfo(packageElement, annotationContent); div.addContent(annotationContent); Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, - HtmlStyle.title, packageLabel); - tHeading.addContent(getSpace()); + HtmlStyle.title, contents.packageLabel); + tHeading.addContent(Contents.SPACE); Content packageHead = new StringContent(heading); tHeading.addContent(packageHead); div.addContent(tHeading); @@ -149,11 +148,11 @@ public class PackageWriterImpl extends HtmlDocletWriter docSummaryDiv.addStyle(HtmlStyle.docSummary); addSummaryComment(packageElement, docSummaryDiv); div.addContent(docSummaryDiv); - Content space = getSpace(); + Content space = Contents.SPACE; Content descLink = getHyperLink(getDocLink( SectionName.PACKAGE_DESCRIPTION), - descriptionLabel, "", ""); - Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink); + contents.descriptionLabel, "", ""); + Content descPara = new HtmlTree(HtmlTag.P, contents.seeLabel, space, descLink); div.addContent(descPara); } if (configuration.allowTag(HtmlTag.MAIN)) { @@ -184,7 +183,7 @@ public class PackageWriterImpl extends HtmlDocletWriter CommentHelper ch = utils.getCommentHelper(packageElement); HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.addStyle(HtmlStyle.deprecatedContent); - Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); deprDiv.addContent(deprPhrase); if (!deprs.isEmpty()) { List commentTags = ch.getDescription(configuration, deprs.get(0)); @@ -233,7 +232,7 @@ public class PackageWriterImpl extends HtmlDocletWriter HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD); tdClassDescription.addStyle(HtmlStyle.colLast); if (utils.isDeprecated(klass)) { - tdClassDescription.addContent(deprecatedLabel); + tdClassDescription.addContent(contents.deprecatedLabel); List tags = utils.getDeprecatedTrees(klass); if (!tags.isEmpty()) { addSummaryDeprecatedComment(klass, tags.get(0), tdClassDescription); @@ -323,7 +322,7 @@ public class PackageWriterImpl extends HtmlDocletWriter */ protected Content getNavLinkClassUse() { Content useLink = getHyperLink(DocPaths.PACKAGE_USE, - useLabel, "", ""); + contents.useLabel, "", ""); Content li = HtmlTree.LI(useLink); return li; } @@ -336,11 +335,11 @@ public class PackageWriterImpl extends HtmlDocletWriter public Content getNavLinkPrevious() { Content li; if (prev == null) { - li = HtmlTree.LI(prevpackageLabel); + li = HtmlTree.LI(contents.prevPackageLabel); } else { DocPath path = DocPath.relativePath(packageElement, prev); li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), - prevpackageLabel, "", "")); + contents.prevPackageLabel, "", "")); } return li; } @@ -353,11 +352,11 @@ public class PackageWriterImpl extends HtmlDocletWriter public Content getNavLinkNext() { Content li; if (next == null) { - li = HtmlTree.LI(nextpackageLabel); + li = HtmlTree.LI(contents.nextPackageLabel); } else { DocPath path = DocPath.relativePath(packageElement, next); li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY), - nextpackageLabel, "", "")); + contents.nextPackageLabel, "", "")); } return li; } @@ -370,7 +369,7 @@ public class PackageWriterImpl extends HtmlDocletWriter */ protected Content getNavLinkTree() { Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, - treeLabel, "", ""); + contents.treeLabel, "", ""); Content li = HtmlTree.LI(useLink); return li; } @@ -383,7 +382,7 @@ public class PackageWriterImpl extends HtmlDocletWriter @Override protected Content getNavLinkModule() { Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement), - moduleLabel); + contents.moduleLabel); Content li = HtmlTree.LI(linkContent); return li; } @@ -394,7 +393,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * @return a content tree for the package link */ protected Content getNavLinkPackage() { - Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel); + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.packageLabel); return li; } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java index 9b7ca5da8ed..24c9f96776c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java @@ -94,7 +94,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter propertyDetailsTree.addContent(writer.getMarkerAnchor( SectionName.PROPERTY_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, - writer.propertyDetailsLabel); + contents.propertyDetailsLabel); propertyDetailsTree.addContent(heading); return propertyDetailsTree; } @@ -163,9 +163,9 @@ public class PropertyWriterImpl extends AbstractMemberWriter Content codeLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, utils.isClass(holder) - ? writer.descfrmClassLabel - : writer.descfrmInterfaceLabel); - descfrmLabel.addContent(writer.getSpace()); + ? contents.descfrmClassLabel + : contents.descfrmInterfaceLabel); + descfrmLabel.addContent(Contents.SPACE); descfrmLabel.addContent(codeLink); propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(property, propertyDocTree); @@ -202,21 +202,13 @@ public class PropertyWriterImpl extends AbstractMemberWriter return getMemberTree(propertyDocTree, isLastContent); } - /** - * Close the writer. - */ - @Override - public void close() throws IOException { - writer.close(); - } - /** * {@inheritDoc} */ @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, - writer.getResource("doclet.Property_Summary")); + contents.propertySummary); memberTree.addContent(label); } @@ -225,9 +217,9 @@ public class PropertyWriterImpl extends AbstractMemberWriter */ @Override public String getTableSummary() { - return configuration.getText("doclet.Member_Table_Summary", - configuration.getText("doclet.Property_Summary"), - configuration.getText("doclet.properties")); + return resources.getText("doclet.Member_Table_Summary", + resources.getText("doclet.Property_Summary"), + resources.getText("doclet.properties")); } /** @@ -235,7 +227,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter */ @Override public Content getCaption() { - return configuration.getResource("doclet.Properties"); + return contents.properties; } /** @@ -282,7 +274,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter : configuration.getText("doclet.Properties_Inherited_From_Interface")); Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(writer.getSpace()); + labelHeading.addContent(Contents.SPACE); labelHeading.addContent(classLink); inheritedTree.addContent(labelHeading); } @@ -342,14 +334,14 @@ public class PropertyWriterImpl extends AbstractMemberWriter if (typeElement == null) { return writer.getHyperLink( SectionName.PROPERTY_SUMMARY, - writer.getResource("doclet.navProperty")); + contents.navProperty); } else { return writer.getHyperLink( SectionName.PROPERTIES_INHERITANCE, - configuration.getClassName(typeElement), writer.getResource("doclet.navProperty")); + configuration.getClassName(typeElement), contents.navProperty); } } else { - return writer.getResource("doclet.navProperty"); + return contents.navProperty; } } @@ -361,9 +353,9 @@ public class PropertyWriterImpl extends AbstractMemberWriter if (link) { liNav.addContent(writer.getHyperLink( SectionName.PROPERTY_DETAIL, - writer.getResource("doclet.navProperty"))); + contents.navProperty)); } else { - liNav.addContent(writer.getResource("doclet.navProperty")); + liNav.addContent(contents.navProperty); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java index 601aa7b4cac..3d1daeeb464 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java @@ -136,8 +136,8 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter */ public Content getPackageHeader(String packageName) { Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, - packageLabel); - heading.addContent(getSpace()); + contents.packageLabel); + heading.addContent(Contents.SPACE); heading.addContent(packageName); return heading; } @@ -183,9 +183,9 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter //Print the heading. Content className = superClassLink == null ? - configuration.getResource( + configuration.getContent( "doclet.Class_0_implements_serializable", classLink) : - configuration.getResource( + configuration.getContent( "doclet.Class_0_extends_implements_serializable", classLink, superClassLink); li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java index 81189d6ee61..42a09f8aa85 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -33,6 +33,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -84,10 +85,9 @@ public class SingleIndexWriter extends AbstractIndexWriter { indexgen = new SingleIndexWriter(configuration, filename, indexbuilder); indexgen.generateIndexFile(); - indexgen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -150,7 +150,7 @@ public class SingleIndexWriter extends AbstractIndexWriter { contentTree.addContent( getHyperLink(getNameForIndex(unicode), new StringContent(unicode))); - contentTree.addContent(getSpace()); + contentTree.addContent(Contents.SPACE); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java index a9759c933ad..decebffe4fd 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java @@ -40,6 +40,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -73,6 +74,7 @@ public class SourceToHTMLConverter { private static final String NEW_LINE = DocletConstants.NL; private final ConfigurationImpl configuration; + private final Messages messages; private final Utils utils; private final DocletEnvironment docEnv; @@ -88,6 +90,7 @@ public class SourceToHTMLConverter { private SourceToHTMLConverter(ConfigurationImpl configuration, DocletEnvironment rd, DocPath outputdir) { this.configuration = configuration; + this.messages = configuration.getMessages(); this.utils = configuration.utils; this.docEnv = rd; this.outputdir = outputdir; @@ -200,7 +203,7 @@ public class SourceToHTMLConverter { Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body); Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree); - configuration.message.notice("doclet.Generating_0", path.getPath()); + messages.notice("doclet.Generating_0", path.getPath()); DocFile df = DocFile.createFileForOutput(configuration, path); try (Writer w = df.openWriter()) { htmlDocument.write(w, true); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java index f73407cd5e2..8b7bbc9eca1 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -32,11 +32,13 @@ import java.util.List; import java.util.ListIterator; import java.util.Set; import java.util.TreeSet; + import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; @@ -115,11 +117,10 @@ public class SplitIndexWriter extends AbstractIndexWriter { if (!li.hasNext()) { indexgen.createSearchIndexFiles(); } - indexgen.close(); } } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename.getPath()); throw new DocletAbortException(exc); } @@ -178,7 +179,7 @@ public class SplitIndexWriter extends AbstractIndexWriter { int j = i + 1; contentTree.addContent(getHyperLink(DocPaths.indexN(j), new StringContent(indexElements.get(i).toString()))); - contentTree.addContent(getSpace()); + contentTree.addContent(Contents.SPACE); } } @@ -188,7 +189,7 @@ public class SplitIndexWriter extends AbstractIndexWriter { * @return a content tree for the link */ public Content getNavLinkPrevious() { - Content prevletterLabel = getResource("doclet.Prev_Letter"); + Content prevletterLabel = contents.prevLetter; if (prev == -1) { return HtmlTree.LI(prevletterLabel); } @@ -205,7 +206,7 @@ public class SplitIndexWriter extends AbstractIndexWriter { * @return a content tree for the link */ public Content getNavLinkNext() { - Content nextletterLabel = getResource("doclet.Next_Letter"); + Content nextletterLabel = contents.nextLetter; if (next == -1) { return HtmlTree.LI(nextletterLabel); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java index 11888eb26db..f21c71168dc 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java @@ -35,7 +35,6 @@ import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes; @@ -67,8 +66,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { */ protected HtmlTree mainTree = HtmlTree.MAIN(); - public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename) - throws IOException { + public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); } @@ -126,7 +124,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { Content captionSpan; Content span; if (type.isDefaultTab()) { - captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey())); + captionSpan = HtmlTree.SPAN(configuration.getContent(type.resourceKey())); span = HtmlTree.SPAN(type.tabId(), HtmlStyle.activeTableTab, captionSpan); } else { @@ -134,7 +132,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { span = HtmlTree.SPAN(type.tabId(), HtmlStyle.tableTab, captionSpan); } - Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace()); + Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, Contents.SPACE); span.addContent(tabSpan); tabbedCaption.addContent(span); } @@ -149,7 +147,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { */ public Content getMethodTypeLinks(MethodTypes methodType) { String jsShow = "javascript:show(" + methodType.value() +");"; - HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey())); + HtmlTree link = HtmlTree.A(jsShow, configuration.getContent(methodType.resourceKey())); return link; } @@ -189,9 +187,9 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { List deprs = utils.getBlockTags(member, DocTree.Kind.DEPRECATED); Content div; if (utils.isDeprecated(member)) { - Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, deprLabel); - div.addContent(getSpace()); + div.addContent(Contents.SPACE); if (!deprs.isEmpty()) { addInlineDeprecatedComment(member, deprs.get(0), div); } @@ -200,9 +198,9 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { } else { Element te = member.getEnclosingElement(); if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) { - Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); + Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, deprLabel); - div.addContent(getSpace()); + div.addContent(Contents.SPACE); tdSummary.addContent(div); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index 80a4cccf532..7e9a055dad9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -26,6 +26,7 @@ package jdk.javadoc.internal.doclets.formats.html; import java.util.List; + import javax.lang.model.element.Element; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; @@ -51,7 +52,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; -import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** @@ -144,7 +144,7 @@ public class TagletWriterImpl extends TagletWriter { return null; } }.visit(element); - si.setCategory(configuration.getResource("doclet.SearchTags").toString()); + si.setCategory(configuration.getContent("doclet.SearchTags").toString()); configuration.tagSearchIndex.add(si); } return result; @@ -212,13 +212,6 @@ public class TagletWriterImpl extends TagletWriter { return result; } - /** - * {@inheritDoc} - */ - public MessageRetriever getMsgRetriever() { - return configuration.message; - } - /** * {@inheritDoc} */ diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java index 0987cc2d825..3a6f31b1ce2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -36,6 +36,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -96,10 +97,9 @@ public class TreeWriter extends AbstractTreeWriter { try { treegen = new TreeWriter(configuration, filename, classtree); treegen.generateTreeFile(); - treegen.close(); } catch (IOException exc) { - configuration.standardmessage.error( - "doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(exc); } @@ -110,7 +110,7 @@ public class TreeWriter extends AbstractTreeWriter { */ public void generateTreeFile() throws IOException { HtmlTree body = getTreeHeader(); - Content headContent = getResource("doclet.Hierarchy_For_All_Packages"); + Content headContent = contents.hierarchyForAllPackages; Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); @@ -154,7 +154,7 @@ public class TreeWriter extends AbstractTreeWriter { } if (!classesonly) { Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, - getResource("doclet.Package_Hierarchies")); + contents.packageHierarchies); contentTree.addContent(span); HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.horizontal); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java new file mode 100644 index 00000000000..78b27a58c21 --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2010, 2016, 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 jdk.javadoc.internal.doclets.formats.html.markup; + +import java.io.IOException; +import java.io.Writer; + +import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; + +/** + * Class for containing fixed string content for HTML tags of javadoc output. + * + *

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. + */ +public class FixedStringContent extends Content { + private final String string; + + /** + * Constructor to construct FixedStringContent object. + * + * @param content content for the object + */ + public FixedStringContent(CharSequence content) { + string = needEscape(content) + ? escape(content) + : content.toString(); + } + + /** + * This method is not supported by the class. + * + * @param content content that needs to be added + * @throws DocletAbortException this method will always throw a + * DocletAbortException because it + * is not supported. + */ + @Override + public void addContent(Content content) { + throw new DocletAbortException("not supported"); + } + + /** + * Adds content for the StringContent object. The method escapes + * HTML characters for the string content that is added. + * + * @param strContent string content to be added + * @throws DocletAbortException this method will always throw a + * DocletAbortException because it + * is not supported. + */ + @Override + public void addContent(CharSequence strContent) { + throw new DocletAbortException("not supported"); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isEmpty() { + return string.isEmpty(); + } + + @Override + public int charCount() { + return RawHtml.charCount(string); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean write(Writer out, boolean atNewline) throws IOException { + out.write(string); + return string.endsWith(DocletConstants.NL); + } + + private boolean needEscape(CharSequence cs) { + for (int i = 0; i < cs.length(); i++) { + switch (cs.charAt(i)) { + case '<': + case '>': + case '&': + return true; + } + } + return false; + } + private String escape(CharSequence s) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + switch (ch) { + case '<': sb.append("<"); break; + case '>': sb.append(">"); break; + case '&': sb.append("&"); break; + default: sb.append(ch); break; + } + } + return sb.toString(); + } + +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java index 080041e1b6a..e15c2ada422 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java @@ -36,6 +36,7 @@ import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl; import jdk.javadoc.internal.doclets.formats.html.SectionName; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; @@ -67,11 +68,11 @@ public abstract class HtmlDocWriter extends HtmlWriter { * * @param filename String file name. */ - public HtmlDocWriter(Configuration configuration, DocPath filename) - throws IOException { + public HtmlDocWriter(Configuration configuration, DocPath filename) { super(configuration, filename); this.pathToRoot = filename.parent().invert(); - configuration.message.notice("doclet.Generating_0", + Messages messages = configuration.getMessages(); + messages.notice("doclet.Generating_0", DocFile.createFileForOutput(configuration, filename).getPath()); } @@ -310,10 +311,6 @@ public abstract class HtmlDocWriter extends HtmlWriter { return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + "."); } - public boolean getMemberDetailsListPrinted() { - return memberDetailsListPrinted; - } - /** * Print the frames version of the Html file header. * Called only when generating an HTML frames file. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java index 79184184107..b69f8546253 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java @@ -30,6 +30,7 @@ import java.util.*; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; @@ -61,11 +62,6 @@ public class HtmlWriter { */ protected Configuration configuration; - /** - * The flag to indicate whether a member details list is printed or not. - */ - protected boolean memberDetailsListPrinted; - /** * Header for table displaying modules and description.. */ @@ -106,89 +102,7 @@ public class HtmlWriter { */ protected final String modifierTypeHeader; - public final Content overviewLabel; - - public final Content defaultPackageLabel; - - public final Content packageLabel; - - public final Content moduleLabel; - - public final Content useLabel; - - public final Content prevLabel; - - public final Content nextLabel; - - public final Content prevclassLabel; - - public final Content nextclassLabel; - - public final Content summaryLabel; - - public final Content detailLabel; - - public final Content moduleSubNavLabel; - - public final Content framesLabel; - - public final Content noframesLabel; - - public final Content treeLabel; - - public final Content classLabel; - - public final Content deprecatedLabel; - - public final Content deprecatedPhrase; - - public final Content allclassesLabel; - - public final Content allpackagesLabel; - - public final Content allmodulesLabel; - - public final Content indexLabel; - - public final Content helpLabel; - - public final Content seeLabel; - - public final Content descriptionLabel; - - public final Content prevpackageLabel; - - public final Content nextpackageLabel; - - public final Content prevmoduleLabel; - - public final Content nextmoduleLabel; - - public final Content packagesLabel; - - public final Content modulesLabel; - - public final Content methodDetailsLabel; - - public final Content annotationTypeDetailsLabel; - - public final Content fieldDetailsLabel; - - public final Content propertyDetailsLabel; - - public final Content constructorDetailsLabel; - - public final Content enumConstantsDetailsLabel; - - public final Content specifiedByLabel; - - public final Content overridesLabel; - - public final Content descfrmClassLabel; - - public final Content descfrmInterfaceLabel; - - private final Writer writer; + private final DocFile docFile; protected Content script; @@ -198,143 +112,45 @@ public class HtmlWriter { * * @param path The directory path to be created for this file * or null if none to be created. - * @exception IOException Exception raised by the FileWriter is passed on - * to next level. - * @exception UnsupportedEncodingException Exception raised by the - * OutputStreamWriter is passed on to next level. */ - public HtmlWriter(Configuration configuration, DocPath path) - throws IOException, UnsupportedEncodingException { - writer = DocFile.createFileForOutput(configuration, path).openWriter(); + public HtmlWriter(Configuration configuration, DocPath path) { + docFile = DocFile.createFileForOutput(configuration, path); this.configuration = configuration; - this.memberDetailsListPrinted = false; + + // The following should be converted to shared Content objects + // and moved to Contents, but that will require additional + // changes at the use sites. + Resources resources = configuration.getResources(); moduleTableHeader = Arrays.asList( - configuration.getText("doclet.Module"), - configuration.getText("doclet.Description")); + resources.getText("doclet.Module"), + resources.getText("doclet.Description")); packageTableHeader = new ArrayList<>(); - packageTableHeader.add(configuration.getText("doclet.Package")); - packageTableHeader.add(configuration.getText("doclet.Description")); + packageTableHeader.add(resources.getText("doclet.Package")); + packageTableHeader.add(resources.getText("doclet.Description")); requiresTableHeader = new ArrayList<>(); - requiresTableHeader.add(configuration.getText("doclet.Module")); - requiresTableHeader.add(configuration.getText("doclet.Description")); + requiresTableHeader.add(resources.getText("doclet.Module")); + requiresTableHeader.add(resources.getText("doclet.Description")); exportedPackagesTableHeader = new ArrayList<>(); - exportedPackagesTableHeader.add(configuration.getText("doclet.Package")); - exportedPackagesTableHeader.add(configuration.getText("doclet.Module")); - exportedPackagesTableHeader.add(configuration.getText("doclet.Description")); + exportedPackagesTableHeader.add(resources.getText("doclet.Package")); + exportedPackagesTableHeader.add(resources.getText("doclet.Module")); + exportedPackagesTableHeader.add(resources.getText("doclet.Description")); usesTableHeader = new ArrayList<>(); - usesTableHeader.add(configuration.getText("doclet.Type")); - usesTableHeader.add(configuration.getText("doclet.Description")); + usesTableHeader.add(resources.getText("doclet.Type")); + usesTableHeader.add(resources.getText("doclet.Description")); providesTableHeader = new ArrayList<>(); - providesTableHeader.add(configuration.getText("doclet.Type")); - providesTableHeader.add(configuration.getText("doclet.Description")); - useTableSummary = configuration.getText("doclet.Use_Table_Summary", - configuration.getText("doclet.packages")); - modifierTypeHeader = configuration.getText("doclet.0_and_1", - configuration.getText("doclet.Modifier"), - configuration.getText("doclet.Type")); - overviewLabel = getResource("doclet.Overview"); - defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME); - packageLabel = getResource("doclet.Package"); - moduleLabel = getResource("doclet.Module"); - useLabel = getResource("doclet.navClassUse"); - prevLabel = getResource("doclet.Prev"); - nextLabel = getResource("doclet.Next"); - prevclassLabel = getNonBreakResource("doclet.Prev_Class"); - nextclassLabel = getNonBreakResource("doclet.Next_Class"); - summaryLabel = getResource("doclet.Summary"); - detailLabel = getResource("doclet.Detail"); - moduleSubNavLabel = getResource("doclet.Module_Sub_Nav"); - framesLabel = getResource("doclet.Frames"); - noframesLabel = getNonBreakResource("doclet.No_Frames"); - treeLabel = getResource("doclet.Tree"); - classLabel = getResource("doclet.Class"); - deprecatedLabel = getResource("doclet.navDeprecated"); - deprecatedPhrase = getResource("doclet.Deprecated"); - allclassesLabel = getNonBreakResource("doclet.All_Classes"); - allpackagesLabel = getNonBreakResource("doclet.All_Packages"); - allmodulesLabel = getNonBreakResource("doclet.All_Modules"); - indexLabel = getResource("doclet.Index"); - helpLabel = getResource("doclet.Help"); - seeLabel = getResource("doclet.See"); - descriptionLabel = getResource("doclet.Description"); - prevpackageLabel = getNonBreakResource("doclet.Prev_Package"); - nextpackageLabel = getNonBreakResource("doclet.Next_Package"); - prevmoduleLabel = getNonBreakResource("doclet.Prev_Module"); - nextmoduleLabel = getNonBreakResource("doclet.Next_Module"); - packagesLabel = getResource("doclet.Packages"); - modulesLabel = getResource("doclet.Modules"); - methodDetailsLabel = getResource("doclet.Method_Detail"); - annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail"); - fieldDetailsLabel = getResource("doclet.Field_Detail"); - propertyDetailsLabel = getResource("doclet.Property_Detail"); - constructorDetailsLabel = getResource("doclet.Constructor_Detail"); - enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail"); - specifiedByLabel = getResource("doclet.Specified_By"); - overridesLabel = getResource("doclet.Overrides"); - descfrmClassLabel = getResource("doclet.Description_From_Class"); - descfrmInterfaceLabel = getResource("doclet.Description_From_Interface"); + providesTableHeader.add(resources.getText("doclet.Type")); + providesTableHeader.add(resources.getText("doclet.Description")); + useTableSummary = resources.getText("doclet.Use_Table_Summary", + resources.getText("doclet.packages")); + modifierTypeHeader = resources.getText("doclet.0_and_1", + resources.getText("doclet.Modifier"), + resources.getText("doclet.Type")); } public void write(Content c) throws IOException { - c.write(writer, true); - } - - public void close() throws IOException { - writer.close(); - } - - /** - * Get the configuration string as a content. - * - * @param key the key to look for in the configuration file - * @return a content tree for the text - */ - public Content getResource(String key) { - return configuration.getResource(key); - } - - /** - * Get the configuration string as a content, replacing spaces - * with non-breaking spaces. - * - * @param key the key to look for in the configuration file - * @return a content tree for the text - */ - public Content getNonBreakResource(String key) { - String text = configuration.getText(key); - Content c = configuration.newContent(); - int start = 0; - int p; - while ((p = text.indexOf(" ", start)) != -1) { - c.addContent(text.substring(start, p)); - c.addContent(RawHtml.nbsp); - start = p + 1; + try (Writer writer = docFile.openWriter()) { + c.write(writer, true); } - c.addContent(text.substring(start)); - return c; - } - - /** - * Get the configuration string as a content. - * - * @param key the key to look for in the configuration file - * @param o string or content argument added to configuration text - * @return a content tree for the text - */ - public Content getResource(String key, Object o) { - return configuration.getResource(key, o); - } - - /** - * Get the configuration string as a content. - * - * @param key the key to look for in the configuration file - * @param o1 string or content argument added to configuration text - * @param o2 string or content argument added to configuration text - * @return a content tree for the text - */ - public Content getResource(String key, Object o0, Object o1) { - return configuration.getResource(key, o0, o1); } /** @@ -343,21 +159,21 @@ public class HtmlWriter { * @return an HtmlTree for the SCRIPT tag */ protected HtmlTree getWinTitleScript(){ - HtmlTree script = HtmlTree.SCRIPT(); + HtmlTree scriptTree = HtmlTree.SCRIPT(); if(winTitle != null && winTitle.length() > 0) { - String scriptCode = "" + DocletConstants.NL; - RawHtml scriptContent = new RawHtml(scriptCode); - script.addContent(scriptContent); + String scriptCode = "\n"; + RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL)); + scriptTree.addContent(scriptContent); } - return script; + return scriptTree; } /** @@ -413,61 +229,61 @@ public class HtmlWriter { * @return a content for the SCRIPT tag */ protected Content getFramesJavaScript() { - HtmlTree script = HtmlTree.SCRIPT(); - String scriptCode = DocletConstants.NL + - " targetPage = \"\" + window.location.search;" + DocletConstants.NL + - " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + - " targetPage = targetPage.substring(1);" + DocletConstants.NL + - " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL + - " targetPage = \"undefined\";" + DocletConstants.NL + - " function validURL(url) {" + DocletConstants.NL + - " try {" + DocletConstants.NL + - " url = decodeURIComponent(url);" + DocletConstants.NL + - " }" + DocletConstants.NL + - " catch (error) {" + DocletConstants.NL + - " return false;" + DocletConstants.NL + - " }" + DocletConstants.NL + - " var pos = url.indexOf(\".html\");" + DocletConstants.NL + - " if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL + - " return false;" + DocletConstants.NL + - " var allowNumber = false;" + DocletConstants.NL + - " var allowSep = false;" + DocletConstants.NL + - " var seenDot = false;" + DocletConstants.NL + - " for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL + - " var ch = url.charAt(i);" + DocletConstants.NL + - " if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL + - " 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL + - " ch == '$' ||" + DocletConstants.NL + - " ch == '_' ||" + DocletConstants.NL + - " ch.charCodeAt(0) > 127) {" + DocletConstants.NL + - " allowNumber = true;" + DocletConstants.NL + - " allowSep = true;" + DocletConstants.NL + - " } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL + - " || ch == '-') {" + DocletConstants.NL + - " if (!allowNumber)" + DocletConstants.NL + - " return false;" + DocletConstants.NL + - " } else if (ch == '/' || ch == '.') {" + DocletConstants.NL + - " if (!allowSep)" + DocletConstants.NL + - " return false;" + DocletConstants.NL + - " allowNumber = false;" + DocletConstants.NL + - " allowSep = false;" + DocletConstants.NL + - " if (ch == '.')" + DocletConstants.NL + - " seenDot = true;" + DocletConstants.NL + - " if (ch == '/' && seenDot)" + DocletConstants.NL + - " return false;" + DocletConstants.NL + - " } else {" + DocletConstants.NL + - " return false;"+ DocletConstants.NL + - " }" + DocletConstants.NL + - " }" + DocletConstants.NL + - " return true;" + DocletConstants.NL + - " }" + DocletConstants.NL + - " function loadFrames() {" + DocletConstants.NL + - " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + - " top.classFrame.location = top.targetPage;" + DocletConstants.NL + - " }" + DocletConstants.NL; - RawHtml scriptContent = new RawHtml(scriptCode); - script.addContent(scriptContent); - return script; + HtmlTree scriptTree = HtmlTree.SCRIPT(); + String scriptCode = "\n" + + " targetPage = \"\" + window.location.search;\n" + + " if (targetPage != \"\" && targetPage != \"undefined\")\n" + + " targetPage = targetPage.substring(1);\n" + + " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))\n" + + " targetPage = \"undefined\";\n" + + " function validURL(url) {\n" + + " try {\n" + + " url = decodeURIComponent(url);\n" + + " }\n" + + " catch (error) {\n" + + " return false;\n" + + " }\n" + + " var pos = url.indexOf(\".html\");\n" + + " if (pos == -1 || pos != url.length - 5)\n" + + " return false;\n" + + " var allowNumber = false;\n" + + " var allowSep = false;\n" + + " var seenDot = false;\n" + + " for (var i = 0; i < url.length - 5; i++) {\n" + + " var ch = url.charAt(i);\n" + + " if ('a' <= ch && ch <= 'z' ||\n" + + " 'A' <= ch && ch <= 'Z' ||\n" + + " ch == '$' ||\n" + + " ch == '_' ||\n" + + " ch.charCodeAt(0) > 127) {\n" + + " allowNumber = true;\n" + + " allowSep = true;\n" + + " } else if ('0' <= ch && ch <= '9'\n" + + " || ch == '-') {\n" + + " if (!allowNumber)\n" + + " return false;\n" + + " } else if (ch == '/' || ch == '.') {\n" + + " if (!allowSep)\n" + + " return false;\n" + + " allowNumber = false;\n" + + " allowSep = false;\n" + + " if (ch == '.')\n" + + " seenDot = true;\n" + + " if (ch == '/' && seenDot)\n" + + " return false;\n" + + " } else {\n" + + " return false;\n" + + " }\n" + + " }\n" + + " return true;\n" + + " }\n" + + " function loadFrames() {\n" + + " if (targetPage != \"\" && targetPage != \"undefined\")\n" + + " top.classFrame.location = top.targetPage;\n" + + " }\n"; + RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL)); + scriptTree.addContent(scriptContent); + return scriptTree; } /** @@ -487,7 +303,7 @@ public class HtmlWriter { this.script = getWinTitleScript(); body.addContent(script); Content noScript = HtmlTree.NOSCRIPT( - HtmlTree.DIV(getResource("doclet.No_Script_Message"))); + HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message"))); body.addContent(noScript); } return body; @@ -558,17 +374,6 @@ public class HtmlWriter { return title; } - public String codeText(String text) { - return "" + text + ""; - } - - /** - * Return "&nbsp;", non-breaking space. - */ - public Content getSpace() { - return RawHtml.nbsp; - } - /* * Returns a header for Modifier and Type column of a table. */ diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java index ca621a4c75a..599e01dca92 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java @@ -44,7 +44,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; */ public class RawHtml extends Content { - private String rawHtmlContent; + private final String rawHtmlContent; public static final Content nbsp = new RawHtml(" "); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java index 9dfc45d28c0..66ff424dbb2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java @@ -58,7 +58,10 @@ public abstract class AbstractDoclet { /** * The global configuration information for this run. */ - public Configuration configuration; + private Configuration configuration; + + protected Messages messages; + /* * a handle to our utility methods */ @@ -76,7 +79,7 @@ public abstract class AbstractDoclet { */ private boolean isValidDoclet() { if (!getClass().getName().equals(TOOLKIT_DOCLET_NAME)) { - configuration.message.error("doclet.Toolkit_Usage_Violation", + messages.error("doclet.Toolkit_Usage_Violation", TOOLKIT_DOCLET_NAME); return false; } @@ -96,6 +99,8 @@ public abstract class AbstractDoclet { configuration.utils = new Utils(configuration); utils = configuration.utils; configuration.workArounds = new WorkArounds(configuration); + messages = configuration.getMessages(); + if (!isValidDoclet()) { return false; } @@ -116,6 +121,7 @@ public abstract class AbstractDoclet { } return false; } catch (Exception exc) { + exc.printStackTrace(System.err); return false; } return true; @@ -146,14 +152,13 @@ public abstract class AbstractDoclet { */ private void startGeneration(DocletEnvironment root) throws Configuration.Fault, Exception { if (root.getIncludedClasses().isEmpty()) { - configuration.message. - error("doclet.No_Public_Classes_To_Document"); + messages.error("doclet.No_Public_Classes_To_Document"); return; } if (!configuration.setOptions()) { return; } - configuration.getDocletSpecificMsg().notice("doclet.build_version", + messages.notice("doclet.build_version", configuration.getDocletSpecificBuildDate()); ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java index 8fd75dfcec2..e4299695399 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java @@ -124,9 +124,4 @@ public interface AnnotationTypeFieldWriter { * @param annotationDocTree the content tree to which the tags will be added */ public void addTags(Element member, Content annotationDocTree); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java index 0dae3f11917..e6b3c6a09be 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java @@ -125,9 +125,4 @@ public interface AnnotationTypeRequiredMemberWriter { * @param annotationDocTree the content tree to which the tags will be added */ public void addTags(Element member, Content annotationDocTree); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java index 388b938478b..7b23954346d 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java @@ -155,11 +155,6 @@ public interface AnnotationTypeWriter { */ public void printDocument(Content contentTree) throws IOException; - /** - * Close the writer. - */ - public void close() throws IOException; - /** * Return the {@link TypeElement} being documented. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java index d8bb3eae131..33169d216fa 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java @@ -196,11 +196,6 @@ public interface ClassWriter { */ public void printDocument(Content contentTree) throws IOException; - /** - * Close the writer. - */ - public void close() throws IOException; - /** * Return the TypeElement being documented. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java index 61fc2867771..3dbd69bd77a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java @@ -27,8 +27,6 @@ package jdk.javadoc.internal.doclets.toolkit; import java.io.*; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.lang.model.element.Element; import javax.lang.model.element.ModuleElement; @@ -50,7 +48,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.Extern; import jdk.javadoc.internal.doclets.toolkit.util.Group; -import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords; import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog; import jdk.javadoc.internal.doclets.toolkit.util.Utils; @@ -265,15 +262,6 @@ public abstract class Configuration { */ public TypeElementCatalog typeElementCatalog; - /** - * Message Retriever for the doclet, to retrieve message from the resource - * file for this Configuration, which is common for 1.1 and standard - * doclets. - * - * TODO: Make this private!!! - */ - public MessageRetriever message = null; - /** * True if user wants to suppress time stamp in output. * Default is false. @@ -309,6 +297,9 @@ public abstract class Configuration { private List groups; + public abstract Messages getMessages(); + public abstract Resources getResources(); + /** * Return the build date for the doclet. */ @@ -322,12 +313,6 @@ public abstract class Configuration { public abstract boolean finishOptionSettings(); - /** - * Return the doclet specific {@link MessageRetriever} - * @return the doclet specific MessageRetriever. - */ - public abstract MessageRetriever getDocletSpecificMsg(); - public CommentUtils cmtUtils; public SortedSet modules; @@ -354,11 +339,12 @@ public abstract class Configuration { */ public Map> modulePackages; + protected static final String sharedResourceBundleName = + "jdk.javadoc.internal.doclets.toolkit.resources.doclets"; /** * Constructor. Constructs the message retriever with resource file. */ public Configuration() { - message = new MessageRetriever(this, "jdk.javadoc.internal.doclets.toolkit.resources.doclets"); excludedDocFileDirs = new HashSet<>(); excludedQualifiers = new HashSet<>(); setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); @@ -578,7 +564,7 @@ public abstract class Configuration { sourcetab = -1; } if (sourcetab <= 0) { - message.warning("doclet.sourcetab_warning"); + getMessages().warning("doclet.sourcetab_warning"); setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); } return true; @@ -696,7 +682,7 @@ public abstract class Configuration { */ private void initTagletManager(Set> customTagStrs) { tagletManager = tagletManager == null ? - new TagletManager(nosince, showversion, showauthor, javafx, message) : + new TagletManager(nosince, showversion, showauthor, javafx, this) : tagletManager; for (List args : customTagStrs) { if (args.get(0).equals("-taglet")) { @@ -721,7 +707,8 @@ public abstract class Configuration { } else if (tokens.size() >= 3) { tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(2), tokens.get(1)); } else { - message.error("doclet.Error_invalid_custom_tag_argument", args.get(1)); + Messages messages = getMessages(); + messages.error("doclet.Error_invalid_custom_tag_argument", args.get(1)); } } } @@ -893,123 +880,69 @@ public abstract class Configuration { : utils.getFullyQualifiedName(te); } - public String getText(String key) { - // Check the doclet specific properties file. - MessageRetriever docletMessage = getDocletSpecificMsg(); - if (docletMessage.containsKey(key)) { - return docletMessage.getText(key); - } - // Check the shared properties file. - return message.getText(key); - } - - public String getText(String key, String a1) { - // Check the doclet specific properties file. - MessageRetriever docletMessage = getDocletSpecificMsg(); - if (docletMessage.containsKey(key)) { - return docletMessage.getText(key, a1); - } - // Check the shared properties file. - return message.getText(key, a1); - } - - public String getText(String key, String a1, String a2) { - // Check the doclet specific properties file. - MessageRetriever docletMessage = getDocletSpecificMsg(); - if (docletMessage.containsKey(key)) { - return docletMessage.getText(key, a1, a2); - } - // Check the shared properties file. - return message.getText(key, a1, a2); - } - - public String getText(String key, String a1, String a2, String a3) { - // Check the doclet specific properties file. - MessageRetriever docletMessage = getDocletSpecificMsg(); - if (docletMessage.containsKey(key)) { - return docletMessage.getText(key, a1, a2, a3); - } - // Check the shared properties file. - return message.getText(key, a1, a2, a3); - } - - public abstract Content newContent(); + /** + * Convenience method to obtain a resource from the doclet's + * {@link Resources resources}. + * Equivalent to getResources.getText(key);. + * @param key the key for the desired string + * @return the string for the given key + * @throws MissingResourceException if the key is not found in either + * bundle. + */ + public abstract String getText(String key); /** - * Get the configuration string as a content. + * Convenience method to obtain a resource from the doclet's + * {@link Resources resources}. + * Equivalent to getResources.getText(key, args);. + * @param key the key for the desired string + * @param args values to be substituted into the resulting string + * @return the string for the given key + * @throws MissingResourceException if the key is not found in either + * bundle. + */ + public abstract String getText(String key, String... args); + + /** + * Convenience method to obtain a resource from the doclet's + * {@link Resources resources} as a {@code Content} object. * - * @param key the key to look for in the configuration file + * @param key the key for the desired string * @return a content tree for the text */ - public Content getResource(String key) { - Content c = newContent(); - c.addContent(getText(key)); - return c; - } + public abstract Content getContent(String key); /** - * Get the configuration string as a content. + * Convenience method to obtain a resource from the doclet's + * {@link Resources resources} as a {@code Content} object. * - * @param key the key to look for in the configuration file + * @param key the key for the desired string * @param o string or content argument added to configuration text * @return a content tree for the text */ - public Content getResource(String key, Object o) { - return getResource(key, o, null, null); - } + public abstract Content getContent(String key, Object o); /** - * Get the configuration string as a content. + * Convenience method to obtain a resource from the doclet's + * {@link Resources resources} as a {@code Content} object. * - * @param key the key to look for in the configuration file + * @param key the key for the desired string * @param o1 resource argument * @param o2 resource argument * @return a content tree for the text */ - public Content getResource(String key, Object o1, Object o2) { - return getResource(key, o1, o2, null); - } + public abstract Content getContent(String key, Object o1, Object o2); /** * Get the configuration string as a content. * - * @param key the key to look for in the configuration file + * @param key the key for the desired string * @param o0 string or content argument added to configuration text * @param o1 string or content argument added to configuration text * @param o2 string or content argument added to configuration text * @return a content tree for the text */ - public Content getResource(String key, Object o0, Object o1, Object o2) { - Content c = newContent(); - Pattern p = Pattern.compile("\\{([012])\\}"); - String text = getText(key); - Matcher m = p.matcher(text); - int start = 0; - while (m.find(start)) { - c.addContent(text.substring(start, m.start())); - - Object o = null; - switch (m.group(1).charAt(0)) { - case '0': o = o0; break; - case '1': o = o1; break; - case '2': o = o2; break; - } - - if (o == null) { - c.addContent("{" + m.group(1) + "}"); - } else if (o instanceof String) { - c.addContent((String) o); - } else if (o instanceof Content) { - c.addContent((Content) o); - } - - start = m.end(); - } - - c.addContent(text.substring(start)); - return c; - } - + public abstract Content getContent(String key, Object o0, Object o1, Object o2); /** * Return true if the TypeElement element is getting documented, depending upon @@ -1110,7 +1043,7 @@ public abstract class Configuration { private String getOptionsMessage(String key) { try { - return c.getDocletSpecificMsg().getText(key, (Object[]) null); + return c.getResources().getText(key); } catch (MissingResourceException ignore) { return ""; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java index c7493c604d2..536b9791e12 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java @@ -46,11 +46,6 @@ import javax.lang.model.element.VariableElement; public interface ConstantsSummaryWriter { - /** - * Close the writer. - */ - public abstract void close() throws IOException; - /** * Get the header for the constant summary documentation. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java index 02d0f2725b1..2f306666f95 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java @@ -119,9 +119,4 @@ public interface ConstructorWriter { * @param foundNonPubConstructor true if we found a non public constructor. */ public void setFoundNonPubConstructor(boolean foundNonPubConstructor); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java index 2ed845c882a..1e6b35f3cdf 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java @@ -112,9 +112,4 @@ public interface EnumConstantWriter { * @return content tree for the enum constants documentation */ public Content getEnumConstants(Content enumConstantsTree, boolean isLastContent); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java index 30323614ef5..e5b141a01b3 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java @@ -113,9 +113,4 @@ public interface FieldWriter { * @return content tree for the field documentation */ public Content getFieldDoc(Content fieldDocTree, boolean isLastContent); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java index f50bc02163f..415de482e73 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java @@ -122,9 +122,4 @@ public interface MemberSummaryWriter { * @return a content tree for the member */ public Content getMemberTree(Content memberTree); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java new file mode 100644 index 00000000000..689a45c9a34 --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2016, 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 jdk.javadoc.internal.doclets.toolkit; + +import javax.lang.model.element.Element; +import javax.tools.Diagnostic; + +import com.sun.source.util.DocTreePath; +import jdk.javadoc.doclet.Reporter; + +import static javax.tools.Diagnostic.Kind.*; + +/** + * Provides standardized access to the diagnostic reporting facilities + * for a doclet. + * + * Messages are specified by resource keys to be found in the doclet's + * {@link Resources resources}. Values can be substituted into the + * strings obtained from the resource files. + * + * Messages are reported to the doclet's {@link Reporter reporter}. + */ +public class Messages { + private final Configuration configuration; + private final Resources resources; + private Reporter reporter; + + /** + * Creates a {@code Messages} object to provide standardized access to + * the doclet's diagnostic reporting mechanisms. + * + * @param configuration the doclet's configuration, used to access + * the doclet's resources, reporter, and additional methods and state + * used to filter out messages, if any, which should be suppressed. + */ + public Messages(Configuration configuration) { + this.configuration = configuration; + resources = configuration.getResources(); + } + + // ***** Errors ***** + + /** + * Reports an error message to the doclet's reporter. + * + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void error(String key, Object... args) { + report(ERROR, resources.getText(key, args)); + } + + /** + * Reports an error message to the doclet's reporter. + * + * @param path a path identifying the position to be included with + * the message + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void error(DocTreePath path, String key, Object... args) { + report(ERROR, path, resources.getText(key, args)); + } + + // ***** Warnings ***** + + /** + * Reports a warning message to the doclet's reporter. + * + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void warning(String key, Object... args) { + report(WARNING, resources.getText(key, args)); + } + + /** + * Reports a warning message to the doclet's reporter. + * + * @param path a path identifying the position to be included with + * the message + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void warning(DocTreePath path, String key, Object... args) { + if (configuration.showMessage(path, key)) + report(WARNING, path, resources.getText(key, args)); + } + + /** + * Reports a warning message to the doclet's reporter. + * + * @param e an element identifying the declaration whose position should + * to be included with the message + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void warning(Element e, String key, Object... args) { + if (configuration.showMessage(e, key)) { + report(WARNING, e, resources.getText(key, args)); + } + } + + // ***** Notices ***** + + /** + * Reports an informational notice to the doclet's reporter. + * + * @param key the name of a resource containing the message to be printed + * @param args optional arguments to be replaced in the message. + */ + public void notice(String key, Object... args) { + if (!configuration.quiet) { + report(NOTE, resources.getText(key, args)); + } + } + + // ***** Internal support ***** + + private void report(Diagnostic.Kind k, String msg) { + initReporter(); + reporter.print(k, msg); + } + + private void report(Diagnostic.Kind k, DocTreePath p, String msg) { + initReporter(); + reporter.print(k, p, msg); + } + + private void report(Diagnostic.Kind k, Element e, String msg) { + initReporter(); + reporter.print(k, e, msg); + } + + // Lazy init the reporter for now, until we can fix/improve + // the init of ConfigurationImpl in HtmlDoclet (and similar.) + private void initReporter() { + if (reporter == null) { + reporter = configuration.reporter; + } + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java index 7629c49ee80..08d91045cdc 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java @@ -114,9 +114,4 @@ public interface MethodWriter { * @return content tree for the method documentation */ public Content getMethodDoc(Content methodDocTree, boolean isLastContent); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java index 27906a50daa..a49bf26d0b2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java @@ -132,10 +132,4 @@ public interface ModuleSummaryWriter { * @param contentTree the content tree that will be printed */ public abstract void printDocument(Content contentTree) throws IOException; - - /** - * Close the writer. - */ - public abstract void close() throws IOException; - } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java index 3c075bb3771..a3fdb9e39a9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java @@ -40,9 +40,4 @@ import java.io.*; */ public interface NestedClassWriter { - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java index c6f52860dcc..8e24984486b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java @@ -121,9 +121,4 @@ public interface PackageSummaryWriter { */ public abstract void printDocument(Content contentTree) throws IOException; - /** - * Close the writer. - */ - public abstract void close() throws IOException; - } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java index 0ce595ccae3..e005546eda7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java @@ -112,9 +112,4 @@ public interface PropertyWriter { * @return content tree for the property documentation */ public Content getPropertyDoc(Content propertyDocTree, boolean isLastContent); - - /** - * Close the writer. - */ - public void close() throws IOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java new file mode 100644 index 00000000000..7c1a1683bcf --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2016, 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 jdk.javadoc.internal.doclets.toolkit; + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Access to the localizable resources used by a doclet. + * The resources are split across two resource bundles: + * one that contains format-neutral strings common to + * all supported formats, and one that contains strings + * specific to the selected doclet, such as the standard + * HTML doclet. + */ +public class Resources { + private final Configuration configuration; + private final String commonBundleName; + private final String docletBundleName; + + protected ResourceBundle commonBundle; + protected ResourceBundle docletBundle; + + /** + * Creates a {@code Resources} to provide access the resource + * bundles used by a doclet. + * + * @param configuration the configuration for the doclet, + * to provide access the locale to be used when accessing the + * names resource bundles. + * @param commonBundleName the name of the bundle containing the strings + * common to all output formats + * @param docletBundleName the name of the bundle containing the strings + * specific to a particular format + */ + public Resources(Configuration configuration, String commonBundleName, String docletBundleName) { + this.configuration = configuration; + this.commonBundleName = commonBundleName; + this.docletBundleName = docletBundleName; + } + + /** + * Gets the string for the given key from one of the doclet's + * resource bundles. + * + * The more specific bundle is checked first; + * if it is not there, the common bundle is then checked. + * + * @param key the key for the desired string + * @return the string for the given key + * @throws MissingResourceException if the key is not found in either + * bundle. + */ + public String getText(String key) throws MissingResourceException { + initBundles(); + + if (docletBundle.containsKey(key)) + return docletBundle.getString(key); + + return commonBundle.getString(key); + } + /** + * Gets the string for the given key from one of the doclet's + * resource bundles, substituting additional arguments into + * into the resulting string with {@link MessageFormat#format}. + * + * The more specific bundle is checked first; + * if it is not there, the common bundle is then checked. + * + * @param key the key for the desired string + * @param args values to be substituted into the resulting string + * @return the string for the given key + * @throws MissingResourceException if the key is not found in either + * bundle. + */ + public String getText(String key, Object... args) throws MissingResourceException { + return MessageFormat.format(getText(key), args); + } + + /** + * Lazily initializes the bundles. This is (currently) necessary because + * this object may be created before the locale to be used is known. + */ + protected void initBundles() { + if (commonBundle == null) { + Locale locale = configuration.getLocale(); + this.commonBundle = ResourceBundle.getBundle(commonBundleName, locale); + this.docletBundle = ResourceBundle.getBundle(docletBundleName, locale); + } + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java index 30215db10f0..a72c51c76e0 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java @@ -137,11 +137,6 @@ public interface SerializedFormWriter { */ public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement); - /** - * Close the writer. - */ - public abstract void close() throws IOException; - /** * Get the serialized content. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java index 468e759ee4c..777d1d25ef6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; @@ -89,6 +90,7 @@ public abstract class AbstractBuilder { */ protected final Configuration configuration; + protected final Messages messages; protected final Utils utils; /** @@ -112,6 +114,7 @@ public abstract class AbstractBuilder { */ public AbstractBuilder(Context c) { this.configuration = c.configuration; + this.messages = configuration.getMessages(); this.utils = configuration.utils; this.containingPackagesSeen = c.containingPackagesSeen; this.layoutParser = c.layoutParser; @@ -144,13 +147,18 @@ public abstract class AbstractBuilder { new Class[]{XMLNode.class, Content.class}, new Object[]{node, contentTree}); } catch (NoSuchMethodException e) { - e.printStackTrace(); + e.printStackTrace(System.err); configuration.reporter.print(ERROR, "Unknown element: " + component); throw new DocletAbortException(e); } catch (InvocationTargetException e) { - throw new DocletAbortException(e.getCause()); + Throwable cause = e.getCause(); + if (cause instanceof DocletAbortException) { + throw (DocletAbortException) cause; + } else { + throw new DocletAbortException(e.getCause()); + } } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(System.err); configuration.reporter.print(ERROR, "Exception " + e.getClass().getName() + " thrown while processing element: " + component); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java index d83947c48f5..bec5010b927 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java @@ -124,7 +124,6 @@ public class AnnotationTypeBuilder extends AbstractBuilder { writer.addAnnotationContentTree(contentTree, annotationContentTree); writer.addFooter(contentTree); writer.printDocument(contentTree); - writer.close(); copyDocFiles(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java index 60e61eace26..5ad0b019848 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java @@ -152,7 +152,6 @@ public class ClassBuilder extends AbstractBuilder { writer.addClassContentTree(contentTree, classContentTree); writer.addFooter(contentTree); writer.printDocument(contentTree); - writer.close(); copyDocFiles(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java index d0a36f78377..704cb55efe8 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java @@ -153,7 +153,6 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { buildChildren(node, contentTree); writer.addFooter(contentTree); writer.printDocument(contentTree); - writer.close(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java index 7bfb05b51b3..0b6d48c1ca8 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java @@ -132,7 +132,6 @@ public class ModuleSummaryBuilder extends AbstractBuilder { buildChildren(node, contentTree); moduleWriter.addModuleFooter(contentTree); moduleWriter.printDocument(contentTree); - moduleWriter.close(); // TEMPORARY: // The use of SOURCE_PATH on the next line is temporary. As we transition into the // modules world, this should migrate into using a location for the appropriate module diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java index 4d98abb328a..8cfef1350d0 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java @@ -131,7 +131,6 @@ public class PackageSummaryBuilder extends AbstractBuilder { buildChildren(node, contentTree); packageWriter.addPackageFooter(contentTree); packageWriter.printDocument(contentTree); - packageWriter.close(); utils.copyDocFiles(packageElement); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java index 4c2c43ce99e..077c7d40f0b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java @@ -140,7 +140,6 @@ public class SerializedFormBuilder extends AbstractBuilder { throw new DocletAbortException(e); } build(layoutParser.parseXML(NAME), contentTree); - writer.close(); } /** @@ -162,7 +161,6 @@ public class SerializedFormBuilder extends AbstractBuilder { buildChildren(node, serializedTree); writer.addFooter(serializedTree); writer.printDocument(serializedTree); - writer.close(); } /** @@ -362,7 +360,7 @@ public class SerializedFormBuilder extends AbstractBuilder { && utils.getSerialDataTrees(method).isEmpty()) { if (configuration.serialwarn) { TypeElement encl = (TypeElement) method.getEnclosingElement(); - configuration.getDocletSpecificMsg().warning(currentMember, + messages.warning(currentMember, "doclet.MissingSerialDataTag", encl.getQualifiedName().toString(), method.getSimpleName().toString()); } @@ -526,7 +524,7 @@ public class SerializedFormBuilder extends AbstractBuilder { // Process default Serializable field. if ((utils.getSerialTrees(field).isEmpty()) /*&& ! field.isSynthetic()*/ && configuration.serialwarn) { - configuration.message.warning(field, + messages.warning(field, "doclet.MissingSerialTag", utils.getFullyQualifiedName(te), utils.getSimpleName(field)); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java index 59b11f5d677..7b02fb0fb82 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java @@ -31,6 +31,7 @@ import javax.lang.model.element.ExecutableElement; import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input; @@ -135,6 +136,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { Element e, DocTree holderTag, boolean isFirstSentence) { Content replacement = writer.getOutputInstance(); Configuration configuration = writer.configuration(); + Messages messages = configuration.getMessages(); Utils utils = configuration.utils; CommentHelper ch = utils.getCommentHelper(e); Taglet inheritableTaglet = holderTag == null @@ -147,7 +149,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { ? utils.flatSignature((ExecutableElement)e) : ""); //This tag does not support inheritence. - configuration.message.warning(e, "doclet.noInheritedDoc", message); + messages.warning(e, "doclet.noInheritedDoc", message); } Input input = new DocFinder.Input(utils, e, (InheritableTaglet) inheritableTaglet, new DocFinder.DocTreeInfo(holderTag, e), @@ -165,7 +167,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { ((utils.isExecutableElement(e)) ? utils.flatSignature((ExecutableElement)e) : ""); - configuration.message.warning(e, "doclet.noInheritedDoc", message); + messages.warning(e, "doclet.noInheritedDoc", message); } return replacement; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java index ef1e6565269..8b0de21ce37 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java @@ -34,6 +34,7 @@ import javax.lang.model.element.TypeElement; import com.sun.source.doctree.DocTree; import com.sun.source.doctree.ParamTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input; @@ -288,6 +289,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { private Content processParamTags(Element e, boolean isParams, List paramTags, Map rankMap, TagletWriter writer, Set alreadyDocumented) { + Messages messages = writer.configuration().getMessages(); Content result = writer.getOutputInstance(); if (!paramTags.isEmpty()) { CommentHelper ch = writer.configuration().utils.getCommentHelper(e); @@ -296,22 +298,22 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { ? ch.getParameterName(dt) : "<" + ch.getParameterName(dt) + ">"; if (!rankMap.containsKey(ch.getParameterName(dt))) { - writer.getMsgRetriever().warning(ch.getDocTreePath(dt), - isParams ? - "doclet.Parameters_warn" : - "doclet.Type_Parameters_warn", - paramName); + messages.warning(ch.getDocTreePath(dt), + isParams + ? "doclet.Parameters_warn" + : "doclet.Type_Parameters_warn", + paramName); } String rank = rankMap.get(ch.getParameterName(dt)); if (rank != null && alreadyDocumented.contains(rank)) { - writer.getMsgRetriever().warning(ch.getDocTreePath(dt), - isParams ? - "doclet.Parameters_dup_warn" : - "doclet.Type_Parameters_dup_warn", - paramName); + messages.warning(ch.getDocTreePath(dt), + isParams + ? "doclet.Parameters_dup_warn" + : "doclet.Type_Parameters_dup_warn", + paramName); } result.addContent(processParamTag(e, isParams, writer, dt, - ch.getParameterName(dt), alreadyDocumented.isEmpty())); + ch.getParameterName(dt), alreadyDocumented.isEmpty())); alreadyDocumented.add(rank); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java index ef67a446ca6..53912b990eb 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java @@ -34,6 +34,7 @@ import javax.lang.model.type.TypeMirror; import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input; @@ -87,6 +88,7 @@ public class ReturnTaglet extends BaseExecutableMemberTaglet implements Inherita * {@inheritDoc} */ public Content getTagletOutput(Element holder, TagletWriter writer) { + Messages messages = writer.configuration().getMessages(); Utils utils = writer.configuration().utils; TypeMirror returnType = utils.getReturnType((ExecutableElement)holder); List tags = utils.getBlockTags(holder, name); @@ -94,7 +96,7 @@ public class ReturnTaglet extends BaseExecutableMemberTaglet implements Inherita //Make sure we are not using @return tag on method with void return type. if (returnType != null && utils.isVoid(returnType)) { if (!tags.isEmpty()) { - writer.getMsgRetriever().warning(holder, "doclet.Return_tag_on_void_method"); + messages.warning(holder, "doclet.Return_tag_on_void_method"); } return null; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java index 16edc599587..24f2a53e4bc 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java @@ -26,7 +26,6 @@ package jdk.javadoc.internal.doclets.toolkit.taglets; import java.io.*; -import java.lang.reflect.Method; import java.util.*; import javax.lang.model.element.Element; @@ -42,9 +41,11 @@ import javax.tools.StandardJavaFileManager; import com.sun.source.doctree.DocTree; import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; +import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; -import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.DocumentationTool.Location.*; @@ -126,10 +127,8 @@ public class TagletManager { */ private List serializedFormTags; - /** - * The message retriever that will be used to print error messages. - */ - private final MessageRetriever message; + private final Messages messages; + private final Resources resources; /** * Keep track of standard tags. @@ -191,7 +190,7 @@ public class TagletManager { */ public TagletManager(boolean nosince, boolean showversion, boolean showauthor, boolean javafx, - MessageRetriever message) { + Configuration configuration) { overridenStandardTags = new HashSet<>(); potentiallyConflictingTags = new HashSet<>(); standardTags = new HashSet<>(); @@ -202,7 +201,8 @@ public class TagletManager { this.showversion = showversion; this.showauthor = showauthor; this.javafx = javafx; - this.message = message; + this.messages = configuration.getMessages(); + this.resources = configuration.getResources(); initStandardTaglets(); initStandardTagsLowercase(); } @@ -260,9 +260,9 @@ public class TagletManager { customTags.remove(tname); } customTags.put(tname, newLegacy); - message.notice("doclet.Notice_taglet_registered", classname); + messages.notice("doclet.Notice_taglet_registered", classname); } catch (Exception exc) { - message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname); + messages.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname); } } @@ -359,10 +359,10 @@ public class TagletManager { } if (! (standardTags.contains(name) || customTags.containsKey(name))) { if (standardTagsLowercase.contains(Utils.toLowerCase(name))) { - message.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag)); + messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag)); continue; } else { - message.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag)); + messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag)); continue; } } @@ -481,7 +481,7 @@ public class TagletManager { } combined_locations.append(locations[i]); } - message.warning(ch.getDocTreePath(tag), "doclet.tag_misuse", + messages.warning(ch.getDocTreePath(tag), "doclet.tag_misuse", "@" + taglet.getName(), holderType, combined_locations.toString()); } @@ -698,17 +698,17 @@ public class TagletManager { addStandardTaglet(new ThrowsTaglet()); addStandardTaglet(new SimpleTaglet(EXCEPTION.tagName, null, SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)); - addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, message.getText("doclet.Since"), + addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, resources.getText("doclet.Since"), SimpleTaglet.ALL)); - addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, message.getText("doclet.Version"), + addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, resources.getText("doclet.Version"), SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)); - addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, message.getText("doclet.Author"), + addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, resources.getText("doclet.Author"), SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)); - addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, message.getText("doclet.SerialData"), + addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, resources.getText("doclet.SerialData"), SimpleTaglet.EXCLUDED)); - addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, message.getText("doclet.Hidden"), + addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, resources.getText("doclet.Hidden"), SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)); - customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"), + customTags.put((temp = new SimpleTaglet("factory", resources.getText("doclet.Factory"), SimpleTaglet.METHOD)).getName(), temp); addStandardTaglet(new SeeTaglet()); //Standard inline tags @@ -735,9 +735,9 @@ public class TagletManager { addStandardTaglet(new PropertyGetterTaglet()); addStandardTaglet(new PropertySetterTaglet()); addStandardTaglet(new SimpleTaglet("propertyDescription", - message.getText("doclet.PropertyDescription"), + resources.getText("doclet.PropertyDescription"), SimpleTaglet.FIELD + SimpleTaglet.METHOD)); - addStandardTaglet(new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"), + addStandardTaglet(new SimpleTaglet("defaultValue", resources.getText("doclet.DefaultValue"), SimpleTaglet.FIELD + SimpleTaglet.METHOD)); addStandardTaglet(new SimpleTaglet("treatAsPrivate", null, SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)); @@ -790,7 +790,7 @@ public class TagletManager { result += ", "; } } - message.notice(noticeKey, result); + messages.notice(noticeKey, result); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java index 8d2df8207e2..652ea7e98c6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java @@ -36,7 +36,6 @@ import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.taglets.Taglet.UnsupportedTagletOperationException; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; -import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** @@ -106,13 +105,6 @@ public abstract class TagletWriter { */ protected abstract Content literalTagOutput(Element element, DocTree tag); - /** - * Returns {@link MessageRetriever} for output purposes. - * - * @return {@link MessageRetriever} for output purposes. - */ - protected abstract MessageRetriever getMsgRetriever(); - /** * Return the header for the param tags. * diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java index ac6f6e2ffb6..1fab013781f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java @@ -34,6 +34,7 @@ import javax.lang.model.util.Elements; import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.Utils; @@ -181,15 +182,16 @@ public class ValueTaglet extends BaseInlineTaglet { */ public Content getTagletOutput(Element holder, DocTree tag, TagletWriter writer) { Utils utils = writer.configuration().utils; + Messages messages = writer.configuration().getMessages(); VariableElement field = getVariableElement(holder, writer.configuration(), tag); if (field == null) { if (tag.toString().isEmpty()) { //Invalid use of @value - writer.getMsgRetriever().warning(holder, + messages.warning(holder, "doclet.value_tag_invalid_use"); } else { //Reference is unknown. - writer.getMsgRetriever().warning(holder, + messages.warning(holder, "doclet.value_tag_invalid_reference", tag.toString()); } } else if (field.getConstantValue() != null) { @@ -202,7 +204,7 @@ public class ValueTaglet extends BaseInlineTaglet { ); } else { //Referenced field is not a constant. - writer.getMsgRetriever().warning(holder, + messages.warning(holder, "doclet.value_tag_invalid_constant", utils.getSimpleName(field)); } return writer.getOutputInstance(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java index b6eb1207962..38b3bd204c2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java @@ -44,6 +44,7 @@ import javax.lang.model.type.TypeMirror; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; /** * Build Class Hierarchy for all the Classes. This class builds the Class @@ -105,9 +106,12 @@ public class ClassTree { * true. */ public ClassTree(Configuration configuration, boolean noDeprecated) { - configuration.message.notice("doclet.Building_Tree"); this.configuration = configuration; this.utils = configuration.utils; + + Messages messages = configuration.getMessages(); + messages.notice("doclet.Building_Tree"); + comparator = utils.makeClassUseComparator(); baseAnnotationTypes = new TreeSet<>(comparator); baseEnums = new TreeSet<>(comparator); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java index 03c734d9914..28d216bc1f7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java @@ -31,6 +31,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; /** @@ -87,6 +88,7 @@ public class Group { * The global configuration information for this run. */ private final Configuration configuration; + private Messages messages; /** * Since we need to sort the keys in the reverse order(longest key first), @@ -101,6 +103,7 @@ public class Group { public Group(Configuration configuration) { this.configuration = configuration; + messages = configuration.getMessages(); } /** @@ -120,14 +123,16 @@ public class Group { public boolean checkPackageGroups(String groupname, String pkgNameFormList) { StringTokenizer strtok = new StringTokenizer(pkgNameFormList, ":"); if (groupList.contains(groupname)) { - configuration.message.warning("doclet.Groupname_already_used", groupname); + initMessages(); + messages.warning("doclet.Groupname_already_used", groupname); return false; } groupList.add(groupname); while (strtok.hasMoreTokens()) { String id = strtok.nextToken(); if (id.length() == 0) { - configuration.message.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList); + initMessages(); + messages.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList); return false; } if (id.endsWith("*")) { @@ -148,6 +153,14 @@ public class Group { return true; } + // Lazy init of the messages for now, because Group is created + // in Configuration before configuration is fully initialized. + private void initMessages() { + if (messages == null) { + messages = configuration.getMessages(); + } + } + /** * Search if the given map has given the package format. * @@ -158,7 +171,8 @@ public class Group { */ boolean foundGroupFormat(Map map, String pkgFormat) { if (map.containsKey(pkgFormat)) { - configuration.message.error("doclet.Same_package_name_used", pkgFormat); + initMessages(); + messages.error("doclet.Same_package_name_used", pkgFormat); return true; } return false; @@ -181,8 +195,8 @@ public class Group { Map> groupPackageMap = new HashMap<>(); String defaultGroupName = (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())? - configuration.message.getText("doclet.Packages") : - configuration.message.getText("doclet.Other_Packages"); + configuration.getResources().getText("doclet.Packages") : + configuration.getResources().getText("doclet.Other_Packages"); // if the user has not used the default group name, add it if (!groupList.contains(defaultGroupName)) { groupList.add(defaultGroupName); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java index 1cd161bf83a..bc52fd4ab08 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; /** * Build the mapping of each Unicode character with it's member lists @@ -98,11 +99,14 @@ public class IndexBuilder { boolean classesOnly) { this.configuration = configuration; this.utils = configuration.utils; + + Messages messages = configuration.getMessages(); if (classesOnly) { - configuration.message.notice("doclet.Building_Index_For_All_Classes"); + messages.notice("doclet.Building_Index_For_All_Classes"); } else { - configuration.message.notice("doclet.Building_Index"); + messages.notice("doclet.Building_Index"); } + this.noDeprecated = noDeprecated; this.classesOnly = classesOnly; this.javafx = configuration.javafx; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java deleted file mode 100644 index 63f2ce78cdb..00000000000 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 1998, 2016, 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 jdk.javadoc.internal.doclets.toolkit.util; - -import java.text.MessageFormat; -import java.util.*; - -import javax.lang.model.element.Element; - -import com.sun.source.util.DocTreePath; -import jdk.javadoc.internal.doclets.toolkit.Configuration; - -import static javax.tools.Diagnostic.Kind.*; - - -/** - * Retrieve and format messages stored in a resource. - * - *

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. - * - * @author Atul M Dambalkar - * @author Robert Field - */ -public class MessageRetriever { - /** - * The global configuration information for this run. - */ - private final Configuration configuration; - - /** - * The location from which to lazily fetch the resource.. - */ - private final String resourcelocation; - - /** - * The lazily fetched resource.. - */ - private ResourceBundle messageRB; - - /** - * Initialize the ResourceBundle with the given resource. - * - * @param rb the resource bundle to read. - */ - public MessageRetriever(ResourceBundle rb) { - this.configuration = null; - this.messageRB = rb; - this.resourcelocation = null; - } - - /** - * Initialize the ResourceBundle with the given resource. - * - * @param configuration the configuration - * @param resourcelocation Resource. - */ - public MessageRetriever(Configuration configuration, - String resourcelocation) { - this.configuration = configuration; - this.resourcelocation = resourcelocation; - } - - private ResourceBundle initRB() { - ResourceBundle bundle = messageRB; - if (bundle == null) { - try { - messageRB = bundle = - ResourceBundle.getBundle(resourcelocation, configuration.getLocale()); - } catch (MissingResourceException e) { - throw new Error("Fatal: Resource (" + resourcelocation - + ") for javadoc doclets is missing."); - } - } - return bundle; - } - - /** - * Determines whether the given key can be retrieved - * from this MessageRetriever - * - * @param key - * the resource key - * @return true if the given key is - * contained in the underlying ResourceBundle. - */ - public boolean containsKey(String key) { - ResourceBundle bundle = initRB(); - return bundle.containsKey(key); - } - - /** - * Get and format message string from resource - * - * @param key selects message from resource - * @param args arguments to be replaced in the message. - * @return the composed text - * @throws MissingResourceException when the key does not - * exist in the properties file. - */ - public String getText(String key, Object... args) throws MissingResourceException { - ResourceBundle bundle = initRB(); - String message = bundle.getString(key); - return MessageFormat.format(message, args); - } - - /** - * Print error message, increment error count. - * - * @param pos the position of the source - * @param msg message to print - */ - private void printError(DocTreePath path, String msg) { - configuration.reporter.print(ERROR, path, msg); - } - - /** - * Print error message, increment error count. - * - * @param msg message to print - */ - private void printError(String msg) { - configuration.reporter.print(ERROR, msg); - } - - /** - * Print warning message, increment warning count. - * - * @param pos the position of the source - * @param msg message to print - */ - private void printWarning(DocTreePath path, String msg) { - configuration.reporter.print(WARNING, path, msg); - } - - private void printWarning(Element e, String msg) { - configuration.reporter.print(WARNING, e, msg); - } - - /** - * Print warning message, increment warning count. - * - * @param msg message to print - */ - private void printWarning(String msg) { - configuration.reporter.print(WARNING, msg); - } - -// Note: the following do not appear to be needed any more, delete me. -// /** -// * Print a message. -// * -// * @param pos the position of the source -// * @param msg message to print -// */ -// private void printNotice(DocTreePath path, String msg) { -// DocEnv env = ((RootDocImpl)configuration.root).env; -// if (env.isQuiet() || env.isSilent()) { -// return; -// } -// configuration.reporter.print(NOTE, path, msg); -// } - -// Note: does not appear to be needed any more. -// /** -// * Print a message. -// * -// * @param pos the position of the source -// * @param key selects message from resource -// * @param args arguments to be replaced in the message. -// */ -// public void notice(DocTreePath path, String key, Object... args) { -// printNotice(path, getText(key, args)); -// } - - // ERRORS - /** - * Print error message, increment error count. - * - * @param path the path to the source - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void error(DocTreePath path, String key, Object... args) { - printError(path, getText(key, args)); - } - - /** - * Print error message, increment error count. - * - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void error(String key, Object... args) { - printError(getText(key, args)); - } - - // WARNINGS - /** - * Print warning message, increment warning count. - - * @param path the path to the source - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void warning(DocTreePath path, String key, Object... args) { - if (configuration.showMessage(path, key)) - printWarning(path, getText(key, args)); - } - - /** - * Print warning message, increment warning count. - * - * @param e element target of the message - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void warning(Element e, String key, Object... args) { - if (configuration.showMessage(e, key)) - printWarning(e, getText(key, args)); - } - - /** - * Print warning message, increment warning count. - * - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void warning(String key, Object... args) { - printWarning(getText(key, args)); - } - - // NOTICES - /** - * Print a message. - * - * @param msg message to print - */ - private void printNotice(String msg) { - if (configuration.quiet) { - return; - } - configuration.reporter.print(NOTE, msg); - } - - /** - * Print a message. - * - * @param key selects message from resource - * @param args arguments to be replaced in the message. - */ - public void notice(String key, Object... args) { - printNotice(getText(key, args)); - } -} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java index 8d6721a151f..efad119e445 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java @@ -32,6 +32,7 @@ import javax.lang.model.element.PackageElement; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; /** @@ -73,7 +74,8 @@ public class PackageListWriter extends PrintWriter { packgen.generatePackageListFile(configuration.docEnv); packgen.close(); } catch (IOException exc) { - configuration.message.error("doclet.exception_encountered", + Messages messages = configuration.getMessages(); + messages.error("doclet.exception_encountered", exc.toString(), DocPaths.PACKAGE_LIST); throw new DocletAbortException(exc); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index abc5b31d94e..48b1710bb93 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -85,7 +85,10 @@ import static javax.lang.model.element.Modifier.*; import static javax.lang.model.type.TypeKind.*; import static com.sun.source.doctree.DocTree.Kind.*; + import com.sun.source.util.SimpleDocTreeVisitor; +import jdk.javadoc.internal.doclets.toolkit.Messages; + import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.MAX_CONSTANT_VALUE_INDEX_LENGTH; @@ -102,12 +105,14 @@ import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuil */ public class Utils { public final Configuration configuration; + public final Messages messages; public final DocTrees docTrees; public final Elements elementUtils; public final Types typeUtils; public Utils(Configuration c) { configuration = c; + messages = configuration.getMessages(); elementUtils = c.docEnv.getElementUtils(); typeUtils = c.docEnv.getTypeUtils(); docTrees = c.docEnv.getDocTrees(); @@ -293,11 +298,10 @@ public class Utils { DocFile destfile = destdir.resolve(srcfile.getName()); if (srcfile.isFile()) { if (destfile.exists() && !first) { - configuration.message.warning("doclet.Copy_Overwrite_warning", + messages.warning("doclet.Copy_Overwrite_warning", srcfile.getPath(), destdir.getPath()); } else { - configuration.message.notice( - "doclet.Copying_File_0_To_Dir_1", + messages.notice("doclet.Copying_File_0_To_Dir_1", srcfile.getPath(), destdir.getPath()); destfile.copyFile(srcfile); } @@ -1577,11 +1581,10 @@ public class Utils { DocFile destfile = destdir.resolve(srcfile.getName()); if (srcfile.isFile()) { if (destfile.exists() && !first) { - configuration.message.warning("doclet.Copy_Overwrite_warning", + messages.warning("doclet.Copy_Overwrite_warning", srcfile.getPath(), destdir.getPath()); } else { - configuration.message.notice( - "doclet.Copying_File_0_To_Dir_1", + messages.notice("doclet.Copying_File_0_To_Dir_1", srcfile.getPath(), destdir.getPath()); destfile.copyFile(srcfile); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java index 723c1db73f9..6fbae159bf1 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java @@ -39,6 +39,7 @@ import com.sun.source.doctree.DocCommentTree; import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; /** * A data structure that encapsulates the visible members of a particular @@ -126,6 +127,7 @@ public class VisibleMemberMap { * The configuration this VisibleMemberMap was created with. */ private final Configuration configuration; + private final Messages messages; private final Utils utils; private final Comparator comparator; @@ -149,6 +151,7 @@ public class VisibleMemberMap { this.typeElement = typeElement; this.kind = kind; this.configuration = configuration; + this.messages = configuration.getMessages(); this.utils = configuration.utils; propertiesCache = configuration.propertiesCache; classPropertiesMap = configuration.classPropertiesMap; @@ -697,7 +700,7 @@ public class VisibleMemberMap { || tagName.equals("@propertyGetter") || tagName.equals("@propertyDescription")) { if (!isPropertyGetterOrSetter(members, ee)) { - configuration.message.warning(ch.getDocTreePath(tree), + messages.warning(ch.getDocTreePath(tree), "doclet.javafx_tag_misuse"); } break; From ebf98a1654939d977cd10f20fbc57e2c42176643 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 10 Aug 2016 11:21:01 +0800 Subject: [PATCH 08/66] 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test Reviewed-by: chegar --- .../tools/jarsigner/TsacertOptionTest.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java index 3481e43b3ef..71aef388ed3 100644 --- a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java +++ b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java @@ -77,11 +77,6 @@ public class TsacertOptionTest { Utils.createFiles(FILENAME); JarUtils.createJar(UNSIGNED_JARFILE, FILENAME); - // look for free network port for TSA service - int port = jdk.testlibrary.Utils.getFreePort(); - String host = "127.0.0.1"; - String tsaUrl = "http://" + host + ":" + port; - // create key pair for jar signing ProcessTools.executeCommand(KEYTOOL, "-genkey", @@ -126,24 +121,30 @@ public class TsacertOptionTest { "-keypass", PASSWORD, "-file", "cert").shouldHaveExitValue(0); - // create key pair for TSA service - // SubjectInfoAccess extension contains URL to TSA service - ProcessTools.executeCommand(KEYTOOL, - "-genkey", - "-v", - "-alias", TSA_KEY_ALIAS, - "-keyalg", KEY_ALG, - "-keysize", Integer.toString(KEY_SIZE), - "-keystore", KEYSTORE, - "-storepass", PASSWORD, - "-keypass", PASSWORD, - "-dname", "CN=TSA", - "-ext", "ExtendedkeyUsage:critical=timeStamping", - "-ext", "SubjectInfoAccess=timeStamping:URI:" + tsaUrl, - "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0); - try (TimestampCheck.Handler tsa = TimestampCheck.Handler.init(port, - KEYSTORE);) { + try (TimestampCheck.Handler tsa = TimestampCheck.Handler.init(0, + KEYSTORE)) { + + // look for free network port for TSA service + int port = tsa.getPort(); + String host = "127.0.0.1"; + String tsaUrl = "http://" + host + ":" + port; + + // create key pair for TSA service + // SubjectInfoAccess extension contains URL to TSA service + ProcessTools.executeCommand(KEYTOOL, + "-genkey", + "-v", + "-alias", TSA_KEY_ALIAS, + "-keyalg", KEY_ALG, + "-keysize", Integer.toString(KEY_SIZE), + "-keystore", KEYSTORE, + "-storepass", PASSWORD, + "-keypass", PASSWORD, + "-dname", "CN=TSA", + "-ext", "ExtendedkeyUsage:critical=timeStamping", + "-ext", "SubjectInfoAccess=timeStamping:URI:" + tsaUrl, + "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0); // start TSA tsa.start(); From 359795c50d67528f9a881f4fd45f62afd9ffa908 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 10 Aug 2016 11:30:53 +0800 Subject: [PATCH 09/66] 8162739: Create new keytool option to access cacerts file Reviewed-by: erikj, vinnie, mullan --- jdk/make/copy/Copy-java.base.gmk | 2 +- .../sun/security/tools/KeyStoreUtil.java | 28 +++--- .../sun/security/tools/keytool/Main.java | 39 ++++--- .../sun/security/tools/keytool/Resources.java | 6 ++ .../share/{conf => lib}/security/cacerts | Bin .../security/tools/keytool/CacertsOption.java | 95 ++++++++++++++++++ 6 files changed, 141 insertions(+), 29 deletions(-) rename jdk/src/java.base/share/{conf => lib}/security/cacerts (100%) create mode 100644 jdk/test/sun/security/tools/keytool/CacertsOption.java diff --git a/jdk/make/copy/Copy-java.base.gmk b/jdk/make/copy/Copy-java.base.gmk index e2061e35c33..5fb26d4b4d2 100644 --- a/jdk/make/copy/Copy-java.base.gmk +++ b/jdk/make/copy/Copy-java.base.gmk @@ -203,7 +203,7 @@ TARGETS += $(DEF_POLICY_DST) ################################################################################ ifeq ($(CACERTS_FILE), ) - CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/conf/security/cacerts + CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/lib/security/cacerts endif CACERTS_DST := $(LIB_DST_DIR)/security/cacerts diff --git a/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java b/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java index 7c33d0753f6..0aca1f39bd5 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java @@ -63,8 +63,6 @@ public class KeyStoreUtil { // this class is not meant to be instantiated } - private static final String JKS = "jks"; - private static final Collator collator = Collator.getInstance(); static { // this is for case insensitive string comparisons @@ -112,25 +110,25 @@ public class KeyStoreUtil { } } + /** + * Returns the file name of the keystore with the configured CA certificates. + */ + public static String getCacerts() { + String sep = File.separator; + return System.getProperty("java.home") + sep + + "lib" + sep + "security" + sep + + "cacerts"; + } + /** * Returns the keystore with the configured CA certificates. */ - public static KeyStore getCacertsKeyStore() - throws Exception - { - String sep = File.separator; - File file = new File(System.getProperty("java.home") + sep - + "lib" + sep + "security" + sep - + "cacerts"); + public static KeyStore getCacertsKeyStore() throws Exception { + File file = new File(getCacerts()); if (!file.exists()) { return null; } - KeyStore caks = null; - try (FileInputStream fis = new FileInputStream(file)) { - caks = KeyStore.getInstance(JKS); - caks.load(fis, null); - } - return caks; + return KeyStore.getInstance(file, (char[])null); } public static char[] getPassWithModifier(String modifier, String arg, diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java index e48f12b592e..12b5041ea41 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -153,6 +153,7 @@ public final class Main { private boolean trustcacerts = false; private boolean protectedPath = false; private boolean srcprotectedPath = false; + private boolean cacerts = false; private CertificateFactory cf = null; private KeyStore caks = null; // "cacerts" keystore private char[] srcstorePass = null; @@ -169,15 +170,15 @@ public final class Main { STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), CHANGEALIAS("Changes.an.entry.s.alias", - ALIAS, DESTALIAS, KEYPASS, KEYSTORE, STOREPASS, + ALIAS, DESTALIAS, KEYPASS, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), DELETE("Deletes.an.entry", - ALIAS, KEYSTORE, STOREPASS, STORETYPE, + ALIAS, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), EXPORTCERT("Exports.certificate", - RFC, ALIAS, FILEOUT, KEYSTORE, STOREPASS, + RFC, ALIAS, FILEOUT, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), GENKEYPAIR("Generates.a.key.pair", @@ -196,7 +197,7 @@ public final class Main { PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), IMPORTCERT("Imports.a.certificate.or.a.certificate.chain", NOPROMPT, TRUSTCACERTS, PROTECTED, ALIAS, FILEIN, - KEYPASS, KEYSTORE, STOREPASS, STORETYPE, + KEYPASS, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), IMPORTPASS("Imports.a.password", @@ -215,7 +216,7 @@ public final class Main { STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), LIST("Lists.entries.in.a.keystore", - RFC, ALIAS, KEYSTORE, STOREPASS, STORETYPE, + RFC, ALIAS, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V, PROTECTED), PRINTCERT("Prints.the.content.of.a.certificate", @@ -225,7 +226,7 @@ public final class Main { PRINTCRL("Prints.the.content.of.a.CRL.file", FILEIN, V), STOREPASSWD("Changes.the.store.password.of.a.keystore", - NEW, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME, + NEW, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V), // Undocumented start here, KEYCLONE is used a marker in -help; @@ -306,6 +307,7 @@ public final class Main { KEYPASS("keypass", "", "key.password"), KEYSIZE("keysize", "", "key.bit.size"), KEYSTORE("keystore", "", "keystore.name"), + CACERTS("cacerts", null, "access.the.cacerts.keystore"), NEW("new", "", "new.password"), NOPROMPT("noprompt", null, "do.not.prompt"), OUTFILE("outfile", "", "output.file.name"), @@ -472,14 +474,16 @@ public final class Main { help = true; } else if (collator.compare(flags, "-conf") == 0) { i++; - } - - /* - * specifiers - */ - else if (collator.compare(flags, "-keystore") == 0 || - collator.compare(flags, "-destkeystore") == 0) { + } else if (collator.compare(flags, "-keystore") == 0) { ksfname = args[++i]; + if (new File(ksfname).getCanonicalPath().equals( + new File(KeyStoreUtil.getCacerts()).getCanonicalPath())) { + System.err.println(rb.getString("warning.cacerts.option")); + } + } else if (collator.compare(flags, "-destkeystore") == 0) { + ksfname = args[++i]; + } else if (collator.compare(flags, "-cacerts") == 0) { + cacerts = true; } else if (collator.compare(flags, "-storepass") == 0 || collator.compare(flags, "-deststorepass") == 0) { storePass = getPass(modifier, args[++i]); @@ -636,6 +640,15 @@ public final class Main { * Execute the commands. */ void doCommands(PrintStream out) throws Exception { + + if (cacerts) { + if (ksfname != null || storetype != null) { + throw new IllegalArgumentException(rb.getString + ("the.keystore.or.storetype.option.cannot.be.used.with.the.cacerts.option")); + } + ksfname = KeyStoreUtil.getCacerts(); + } + if (storetype == null) { storetype = KeyStore.getDefaultType(); } diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java index 2f755677dfc..8ede53992d8 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java @@ -127,6 +127,10 @@ public class Resources extends java.util.ListResourceBundle { "key bit size"}, //-keysize {"keystore.name", "keystore name"}, //-keystore + {"access.the.cacerts.keystore", + "access the cacerts keystore"}, // -cacerts + {"warning.cacerts.option", + "Warning: use -cacerts option to access cacerts keystore"}, {"new.password", "new password"}, //-new {"do.not.prompt", @@ -194,6 +198,8 @@ public class Resources extends java.util.ListResourceBundle { {"Command.option.flag.needs.an.argument.", "Command option {0} needs an argument."}, {"Warning.Different.store.and.key.passwords.not.supported.for.PKCS12.KeyStores.Ignoring.user.specified.command.value.", "Warning: Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified {0} value."}, + {"the.keystore.or.storetype.option.cannot.be.used.with.the.cacerts.option", + "The -keystore or -storetype option cannot be used with the -cacerts option"}, {".keystore.must.be.NONE.if.storetype.is.{0}", "-keystore must be NONE if -storetype is {0}"}, {"Too.many.retries.program.terminated", diff --git a/jdk/src/java.base/share/conf/security/cacerts b/jdk/src/java.base/share/lib/security/cacerts similarity index 100% rename from jdk/src/java.base/share/conf/security/cacerts rename to jdk/src/java.base/share/lib/security/cacerts diff --git a/jdk/test/sun/security/tools/keytool/CacertsOption.java b/jdk/test/sun/security/tools/keytool/CacertsOption.java new file mode 100644 index 00000000000..23e118fb606 --- /dev/null +++ b/jdk/test/sun/security/tools/keytool/CacertsOption.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8162739 + * @summary Create new keytool option to access cacerts file + * @modules java.base/sun.security.tools.keytool + * java.base/sun.security.tools + * @run main/othervm -Duser.language=en -Duser.country=US CacertsOption + */ + +import sun.security.tools.KeyStoreUtil; +import sun.security.tools.keytool.Main; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; +import java.security.KeyStore; +import java.util.Collections; + +public class CacertsOption { + + public static void main(String[] args) throws Exception { + + run("-help -list"); + if (!msg.contains("-cacerts")) { + throw new Exception("No cacerts in help:\n" + msg); + } + + String cacerts = KeyStoreUtil.getCacerts(); + + run("-list -keystore " + cacerts); + if (!msg.contains("Warning:")) { + throw new Exception("No warning in output:\n" + msg); + } + + run("-list -cacerts"); + KeyStore ks = KeyStore.getInstance(new File(cacerts), (char[])null); + for (String alias: Collections.list(ks.aliases())) { + if (!msg.contains(alias)) { + throw new Exception(alias + " not found in\n" + msg); + } + } + + try { + run("-list -cacerts -storetype jks"); + throw new Exception("Should fail"); + } catch (IllegalArgumentException iae) { + if (!msg.contains("cannot be used with")) { + throw new Exception("Bad error msg\n" + msg); + } + } + } + + private static String msg = null; + + private static void run(String cmd) throws Exception { + msg = null; + cmd += " -storepass changeit -debug"; + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(bout); + PrintStream oldOut = System.out; + PrintStream oldErr = System.err; + try { + System.setOut(ps); + System.setErr(ps); + Main.main(cmd.split(" ")); + } finally { + System.setErr(oldErr); + System.setOut(oldOut); + msg = new String(bout.toByteArray()); + } + } +} From b6e6759ba9b1a1fcfbb9c8dbdc7cd5eec6cd6124 Mon Sep 17 00:00:00 2001 From: Jamil Nimeh Date: Tue, 9 Aug 2016 22:31:41 -0700 Subject: [PATCH 10/66] 8132943: ServerHandshaker may select non-empty OCSPStatusRequest structures when Responder ID Select only OCSPStatusRequest objects that have no responder IDs in them when deciding whether to do OCSP stapling and what form of stapling. Reviewed-by: xuelei --- .../sun/security/ssl/ServerHandshaker.java | 78 +- .../ssl/StatusStapling/RunStatReqSelect.java | 33 + .../sun/security/ssl/StatusReqSelection.java | 899 ++++++++++++++++++ 3 files changed, 990 insertions(+), 20 deletions(-) create mode 100644 jdk/test/sun/security/ssl/StatusStapling/RunStatReqSelect.java create mode 100644 jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusReqSelection.java diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java index 10df67d2eaa..c68e7431053 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java @@ -1994,7 +1994,7 @@ final class ServerHandshaker extends Handshaker { private StaplingParameters processStapling(ClientHello mesg) { StaplingParameters params = null; - ExtensionType ext; + ExtensionType ext = null; StatusRequestType type = null; StatusRequest req = null; Map responses; @@ -2012,33 +2012,40 @@ final class ServerHandshaker extends Handshaker { CertStatusReqListV2Extension statReqExtV2 = (CertStatusReqListV2Extension)mesg.extensions.get( ExtensionType.EXT_STATUS_REQUEST_V2); - // Keep processing only if either status_request or status_request_v2 - // has been sent in the ClientHello. - if (statReqExt == null && statReqExtV2 == null) { - return null; - } // Determine which type of stapling we are doing and assert the // proper extension in the server hello. // Favor status_request_v2 over status_request and ocsp_multi // over ocsp. // If multiple ocsp or ocsp_multi types exist, select the first - // instance of a given type - ext = ExtensionType.EXT_STATUS_REQUEST; + // instance of a given type. Also since we don't support ResponderId + // selection yet, only accept a request if the ResponderId field + // is empty. if (statReqExtV2 != null) { // RFC 6961 stapling ext = ExtensionType.EXT_STATUS_REQUEST_V2; List reqItems = statReqExtV2.getRequestItems(); int ocspIdx = -1; int ocspMultiIdx = -1; - for (int pos = 0; pos < reqItems.size(); pos++) { + for (int pos = 0; (pos < reqItems.size() && + (ocspIdx == -1 || ocspMultiIdx == -1)); pos++) { CertStatusReqItemV2 item = reqItems.get(pos); - if (ocspIdx < 0 && item.getType() == - StatusRequestType.OCSP) { - ocspIdx = pos; - } else if (ocspMultiIdx < 0 && item.getType() == - StatusRequestType.OCSP_MULTI) { - ocspMultiIdx = pos; + StatusRequestType curType = item.getType(); + if (ocspIdx < 0 && curType == StatusRequestType.OCSP) { + OCSPStatusRequest ocspReq = + (OCSPStatusRequest)item.getRequest(); + if (ocspReq.getResponderIds().isEmpty()) { + ocspIdx = pos; + } + } else if (ocspMultiIdx < 0 && + curType == StatusRequestType.OCSP_MULTI) { + // If the type is OCSP, then the request + // is guaranteed to be OCSPStatusRequest + OCSPStatusRequest ocspReq = + (OCSPStatusRequest)item.getRequest(); + if (ocspReq.getResponderIds().isEmpty()) { + ocspMultiIdx = pos; + } } } if (ocspMultiIdx >= 0) { @@ -2047,16 +2054,47 @@ final class ServerHandshaker extends Handshaker { } else if (ocspIdx >= 0) { type = reqItems.get(ocspIdx).getType(); req = reqItems.get(ocspIdx).getRequest(); + } else { + if (debug != null && Debug.isOn("handshake")) { + System.out.println("Warning: No suitable request " + + "found in the status_request_v2 extension."); + } + } + } + + // Only attempt to process a status_request extension if: + // * The status_request extension is set AND + // * either the status_request_v2 extension is not present OR + // * none of the underlying OCSPStatusRequest structures is suitable + // for stapling. + // If either of the latter two bullet items is true the ext, type and + // req variables should all be null. If any are null we will try + // processing an asserted status_request. + if ((statReqExt != null) && + (ext == null || type == null || req == null)) { + ext = ExtensionType.EXT_STATUS_REQUEST; + type = statReqExt.getType(); + if (type == StatusRequestType.OCSP) { + // If the type is OCSP, then the request is guaranteed + // to be OCSPStatusRequest + OCSPStatusRequest ocspReq = + (OCSPStatusRequest)statReqExt.getRequest(); + if (ocspReq.getResponderIds().isEmpty()) { + req = ocspReq; + } else { + if (debug != null && Debug.isOn("handshake")) { + req = null; + System.out.println("Warning: No suitable request " + + "found in the status_request extension."); + } + } } - } else { // RFC 6066 stapling - type = StatusRequestType.OCSP; - req = statReqExt.getRequest(); } // If, after walking through the extensions we were unable to // find a suitable StatusRequest, then stapling is disabled. - // Both statReqType and statReqData must have been set to continue. - if (type == null || req == null) { + // The ext, type and req variables must have been set to continue. + if (type == null || req == null || ext == null) { return null; } diff --git a/jdk/test/sun/security/ssl/StatusStapling/RunStatReqSelect.java b/jdk/test/sun/security/ssl/StatusStapling/RunStatReqSelect.java new file mode 100644 index 00000000000..625731cdcf6 --- /dev/null +++ b/jdk/test/sun/security/ssl/StatusStapling/RunStatReqSelect.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8132943 + * @library ../../../../java/security/testlibrary + * @build CertificateBuilder SimpleOCSPServer + * @run main/othervm java.base/sun.security.ssl.StatusReqSelection + * @summary ServerHandshaker may select non-empty OCSPStatusRequest + * structures when Responder ID selection is not supported + */ + diff --git a/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusReqSelection.java b/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusReqSelection.java new file mode 100644 index 00000000000..72acaac55c1 --- /dev/null +++ b/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusReqSelection.java @@ -0,0 +1,899 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +// See ../../../../RunStatReqSelect.java for the jtreg header + +package sun.security.ssl; + +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.*; +import javax.security.auth.x500.X500Principal; +import java.io.*; +import java.math.BigInteger; +import java.security.*; +import java.nio.*; +import java.security.cert.X509Certificate; +import java.security.cert.Extension; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import sun.security.provider.certpath.OCSPNonceExtension; +import sun.security.provider.certpath.ResponderId; +import sun.security.testlibrary.SimpleOCSPServer; +import sun.security.testlibrary.CertificateBuilder; + +public class StatusReqSelection { + + /* + * Enables logging of the SSLEngine operations. + */ + private static final boolean logging = true; + + /* + * Enables the JSSE system debugging system property: + * + * -Djavax.net.debug=all + * + * This gives a lot of low-level information about operations underway, + * including specific handshake messages, and might be best examined + * after gaining some familiarity with this application. + */ + private static final boolean debug = false; + + // The following items are used to set up the keystores. + private static final String passwd = "passphrase"; + private static final String ROOT_ALIAS = "root"; + private static final String INT_ALIAS = "intermediate"; + private static final String SSL_ALIAS = "ssl"; + + // PKI and server components we will need for this test + private static KeyManagerFactory kmf; + private static TrustManagerFactory tmf; + private static KeyStore rootKeystore; // Root CA Keystore + private static KeyStore intKeystore; // Intermediate CA Keystore + private static KeyStore serverKeystore; // SSL Server Keystore + private static KeyStore trustStore; // SSL Client trust store + private static SimpleOCSPServer rootOcsp; // Root CA OCSP Responder + private static int rootOcspPort; // Port for root OCSP + private static SimpleOCSPServer intOcsp; // Intermediate CA OCSP server + private static int intOcspPort; // Port for intermediate OCSP + private static SSLContext ctxStaple; // SSLContext for all tests + + // Some useful objects we will need for test purposes + private static final SecureRandom RNG = new SecureRandom(); + + // We'll be using these objects repeatedly to make hello messages + private static final ProtocolVersion VER_1_0 = ProtocolVersion.TLS10; + private static final ProtocolVersion VER_1_2 = ProtocolVersion.TLS12; + private static final CipherSuiteList SUITES = new CipherSuiteList( + CipherSuite.valueOf("TLS_RSA_WITH_AES_128_GCM_SHA256")); + private static final SessionId SID = new SessionId(new byte[0]); + private static final HelloExtension RNIEXT = + new RenegotiationInfoExtension(new byte[0], new byte[0]); + private static final List algList = + new ArrayList() {{ + add(SignatureAndHashAlgorithm.valueOf(4, 1, 0)); + }}; // List with only SHA256withRSA + private static final SignatureAlgorithmsExtension SIGALGEXT = + new SignatureAlgorithmsExtension(algList); + + /* + * Main entry point for this test. + */ + public static void main(String args[]) throws Exception { + int testsPassed = 0; + + if (debug) { + System.setProperty("javax.net.debug", "ssl"); + } + + // All tests will have stapling enabled on the server side + System.setProperty("jdk.tls.server.enableStatusRequestExtension", + "true"); + + // Create a single SSLContext that we can use for all tests + ctxStaple = SSLContext.getInstance("TLS"); + + // Create the PKI we will use for the test and start the OCSP servers + createPKI(); + + // Set up the KeyManagerFactory and TrustManagerFactory + kmf = KeyManagerFactory.getInstance("PKIX"); + kmf.init(serverKeystore, passwd.toCharArray()); + tmf = TrustManagerFactory.getInstance("PKIX"); + tmf.init(trustStore); + + List testList = new ArrayList() {{ + add(new TestCase("ClientHello: No stapling extensions", + makeHelloNoStaplingExts(), false, false)); + add(new TestCase("ClientHello: Default status_request only", + makeDefaultStatReqOnly(), true, false)); + add(new TestCase("ClientHello: Default status_request_v2 only", + makeDefaultStatReqV2Only(), false, true)); + add(new TestCase("ClientHello: Both status_request exts, default", + makeDefaultStatReqBoth(), false, true)); + add(new TestCase( + "ClientHello: Hello with status_request and responder IDs", + makeStatReqWithRid(), false, false)); + add(new TestCase( + "ClientHello: Hello with status_request using no " + + "responder IDs but provides the OCSP nonce extension", + makeStatReqNoRidNonce(), true, false)); + add(new TestCase("ClientHello with default status_request and " + + "status_request_v2 with ResponderIds", + makeStatReqDefV2WithRid(), true, false)); + add(new TestCase("ClientHello with default status_request and " + + "status_request_v2 (OCSP_MULTI with ResponderId, " + + "OCSP as a default request)", + makeStatReqDefV2MultiWithRidSingleDef(), false, true)); + add(new TestCase("ClientHello with status_request and " + + "status_request_v2 and all OCSPStatusRequests use " + + "Responder IDs", + makeStatReqAllWithRid(), false, false)); + add(new TestCase("ClientHello with default status_request and " + + "status_request_v2 that has a default OCSP item and " + + "multiple OCSP_MULTI items, only one is default", + makeHelloMultiV2andSingle(), false, true)); + }}; + + // Run the client and server property tests + for (TestCase test : testList) { + try { + log("*** Test: " + test.testName); + if (runTest(test)) { + log("PASS: status_request: " + test.statReqEnabled + + ", status_request_v2: " + test.statReqV2Enabled); + testsPassed++; + } + } catch (Exception e) { + // If we get an exception, we'll count it as a failure + log("Test failure due to exception: " + e); + } + log(""); + } + + // Summary + if (testsPassed != testList.size()) { + throw new RuntimeException(testList.size() - testsPassed + + " tests failed out of " + testList.size() + " total."); + } else { + log("Total tests: " + testList.size() + ", all passed"); + } + } + + private static boolean runTest(TestCase test) throws Exception { + SSLEngineResult serverResult; + + // Create a Server SSLEngine to receive our customized ClientHello + ctxStaple.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + SSLEngine engine = ctxStaple.createSSLEngine(); + engine.setUseClientMode(false); + engine.setNeedClientAuth(false); + + SSLSession session = engine.getSession(); + ByteBuffer serverOut = ByteBuffer.wrap("I'm a Server".getBytes()); + ByteBuffer serverIn = + ByteBuffer.allocate(session.getApplicationBufferSize() + 50); + ByteBuffer sTOc = + ByteBuffer.allocateDirect(session.getPacketBufferSize()); + + // Send the ClientHello ByteBuffer in the test case + if (debug) { + System.out.println("Sending Client Hello:\n" + + dumpHexBytes(test.data)); + } + + // Consume the client hello + serverResult = engine.unwrap(test.data, serverIn); + if (debug) { + log("server unwrap: ", serverResult); + } + if (serverResult.getStatus() != SSLEngineResult.Status.OK) { + throw new SSLException("Server unwrap got status: " + + serverResult.getStatus()); + } else if (serverResult.getHandshakeStatus() != + SSLEngineResult.HandshakeStatus.NEED_TASK) { + throw new SSLException("Server unwrap expected NEED_TASK, got: " + + serverResult.getHandshakeStatus()); + } + runDelegatedTasks(serverResult, engine); + if (engine.getHandshakeStatus() != + SSLEngineResult.HandshakeStatus.NEED_WRAP) { + throw new SSLException("Expected NEED_WRAP, got: " + + engine.getHandshakeStatus()); + } + + // Generate a TLS record with the ServerHello + serverResult = engine.wrap(serverOut, sTOc); + if (debug) { + log("client wrap: ", serverResult); + } + if (serverResult.getStatus() != SSLEngineResult.Status.OK) { + throw new SSLException("Client wrap got status: " + + serverResult.getStatus()); + } + sTOc.flip(); + + if (debug) { + log("Server Response:\n" + dumpHexBytes(sTOc)); + } + + return checkServerHello(sTOc, test.statReqEnabled, + test.statReqV2Enabled); + } + + /** + * Make a TLSv1.2 ClientHello with only RNI and no stapling extensions + */ + private static ByteBuffer makeHelloNoStaplingExts() throws IOException { + // Craft the ClientHello byte buffer + HelloExtensions exts = new HelloExtensions(); + exts.add(RNIEXT); + exts.add(SIGALGEXT); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a TLSv1.2 ClientHello with the RNI and Status Request extensions + */ + private static ByteBuffer makeDefaultStatReqOnly() throws IOException { + // Craft the ClientHello byte buffer + HelloExtensions exts = new HelloExtensions(); + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a TLSv1.2 ClientHello with the RNI and Status Request V2 extension + */ + private static ByteBuffer makeDefaultStatReqV2Only() throws IOException { + // Craft the ClientHello byte buffer + HelloExtensions exts = new HelloExtensions(); + OCSPStatusRequest osr = new OCSPStatusRequest(); + List itemList = new ArrayList<>(2); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + osr)); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, osr)); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + /** + * Make a TLSv1.2 ClientHello with Status Request and Status Request V2 + * extensions. + */ + private static ByteBuffer makeDefaultStatReqBoth() throws IOException { + // Craft the ClientHello byte buffer + HelloExtensions exts = new HelloExtensions(); + OCSPStatusRequest osr = new OCSPStatusRequest(); + List itemList = new ArrayList<>(2); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + osr)); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, osr)); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a ClientHello using a status_request that has a single + * responder ID in it. + */ + private static ByteBuffer makeStatReqWithRid() throws IOException { + HelloExtensions exts = new HelloExtensions(); + exts.add(RNIEXT); + exts.add(SIGALGEXT); + List rids = new ArrayList() {{ + add(new ResponderId(new X500Principal("CN=Foo"))); + }}; + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(rids, null))); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a ClientHello using a status_request that has no + * responder IDs but does provide the nonce extension. + */ + private static ByteBuffer makeStatReqNoRidNonce() throws IOException { + HelloExtensions exts = new HelloExtensions(); + exts.add(RNIEXT); + exts.add(SIGALGEXT); + List ocspExts = new ArrayList() {{ + add(new OCSPNonceExtension(16)); + }}; + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, ocspExts))); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a ClientHello using a default status_request and a + * status_request_v2 that has a single responder ID in it. + */ + private static ByteBuffer makeStatReqDefV2WithRid() throws IOException { + HelloExtensions exts = new HelloExtensions(); + List rids = new ArrayList() {{ + add(new ResponderId(new X500Principal("CN=Foo"))); + }}; + List itemList = new ArrayList<>(2); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(rids, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, + new OCSPStatusRequest(rids, null))); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a ClientHello using a default status_request and a + * status_request_v2 that has a single responder ID in it for the + * OCSP_MULTI request item and a default OCSP request item. + */ + private static ByteBuffer makeStatReqDefV2MultiWithRidSingleDef() + throws IOException { + HelloExtensions exts = new HelloExtensions(); + List rids = new ArrayList() {{ + add(new ResponderId(new X500Principal("CN=Foo"))); + }}; + List itemList = new ArrayList<>(2); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(rids, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a ClientHello using status_request and status_request_v2 where + * all underlying OCSPStatusRequests use responder IDs. + */ + private static ByteBuffer makeStatReqAllWithRid() throws IOException { + HelloExtensions exts = new HelloExtensions(); + List rids = new ArrayList() {{ + add(new ResponderId(new X500Principal("CN=Foo"))); + }}; + List itemList = new ArrayList<>(2); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(rids, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, + new OCSPStatusRequest(rids, null))); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(rids, null))); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Make a TLSv1.2 ClientHello multiple CertStatusReqItemV2s of different + * types. One of the middle items should be acceptable while the others + * have responder IDs. The status_request (v1) should also be acceptable + * but should be overridden in favor of the status_request_v2. + */ + private static ByteBuffer makeHelloMultiV2andSingle() throws IOException { + // Craft the ClientHello byte buffer + HelloExtensions exts = new HelloExtensions(); + List fooRid = Collections.singletonList( + new ResponderId(new X500Principal("CN=Foo"))); + List barRid = Collections.singletonList( + new ResponderId(new X500Principal("CN=Bar"))); + List itemList = new ArrayList<>(); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(fooRid, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(null, null))); + itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI, + new OCSPStatusRequest(barRid, null))); + + exts.add(RNIEXT); + exts.add(SIGALGEXT); + exts.add(new CertStatusReqExtension(StatusRequestType.OCSP, + new OCSPStatusRequest(null, null))); + exts.add(new CertStatusReqListV2Extension(itemList)); + return createTlsRecord(Record.ct_handshake, VER_1_2, + createClientHelloMsg(VER_1_2, SID, SUITES, exts)); + } + + /** + * Wrap a TLS content message into a TLS record header + * + * @param contentType a byte containing the content type value + * @param pv the protocol version for this record + * @param data a byte buffer containing the message data + * @return + */ + private static ByteBuffer createTlsRecord(byte contentType, + ProtocolVersion pv, ByteBuffer data) { + int msgLen = (data != null) ? data.limit() : 0; + + // Allocate enough space to hold the TLS record header + the message + ByteBuffer recordBuf = ByteBuffer.allocate(msgLen + 5); + recordBuf.put(contentType); + recordBuf.putShort((short)pv.v); + recordBuf.putShort((short)msgLen); + if (msgLen > 0) { + recordBuf.put(data); + } + + recordBuf.flip(); + return recordBuf; + } + + /** + * Craft and encode a ClientHello message as a byte array. + * + * @param pv the protocol version asserted in the hello message. + * @param sessId the session ID for this hello message. + * @param suites a list consisting of one or more cipher suite objects + * @param extensions a list of HelloExtension objects + * + * @return a byte array containing the encoded ClientHello message. + */ + private static ByteBuffer createClientHelloMsg(ProtocolVersion pv, + SessionId sessId, CipherSuiteList suites, + HelloExtensions extensions) throws IOException { + ByteBuffer msgBuf; + + HandshakeOutStream hsos = + new HandshakeOutStream(new SSLEngineOutputRecord()); + + // Construct the client hello object from the first 3 parameters + HandshakeMessage.ClientHello cHello = + new HandshakeMessage.ClientHello(RNG, pv, sessId, suites, + false); + + // Use the HelloExtensions provided by the caller + if (extensions != null) { + cHello.extensions = extensions; + } + + cHello.send(hsos); + msgBuf = ByteBuffer.allocate(hsos.size() + 4); + + // Combine the handshake type with the length + msgBuf.putInt((HandshakeMessage.ht_client_hello << 24) | + (hsos.size() & 0x00FFFFFF)); + msgBuf.put(hsos.toByteArray()); + msgBuf.flip(); + return msgBuf; + } + + /* + * If the result indicates that we have outstanding tasks to do, + * go ahead and run them in this thread. + */ + private static void runDelegatedTasks(SSLEngineResult result, + SSLEngine engine) throws Exception { + + if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = engine.getDelegatedTask()) != null) { + if (debug) { + log("\trunning delegated task..."); + } + runnable.run(); + } + HandshakeStatus hsStatus = engine.getHandshakeStatus(); + if (hsStatus == HandshakeStatus.NEED_TASK) { + throw new Exception( + "handshake shouldn't need additional tasks"); + } + if (debug) { + log("\tnew HandshakeStatus: " + hsStatus); + } + } + } + + private static void log(String str, SSLEngineResult result) { + if (!logging) { + return; + } + HandshakeStatus hsStatus = result.getHandshakeStatus(); + log(str + + result.getStatus() + "/" + hsStatus + ", " + + result.bytesConsumed() + "/" + result.bytesProduced() + + " bytes"); + if (hsStatus == HandshakeStatus.FINISHED) { + log("\t...ready for application data"); + } + } + + private static void log(String str) { + if (logging) { + System.out.println(str); + } + } + + /** + * Dump a ByteBuffer as a hexdump to stdout. The dumping routine will + * start at the current position of the buffer and run to its limit. + * After completing the dump, the position will be returned to its + * starting point. + * + * @param data the ByteBuffer to dump to stdout. + * + * @return the hexdump of the byte array. + */ + private static String dumpHexBytes(ByteBuffer data) { + StringBuilder sb = new StringBuilder(); + if (data != null) { + int i = 0; + data.mark(); + while (data.hasRemaining()) { + if (i % 16 == 0 && i != 0) { + sb.append("\n"); + } + sb.append(String.format("%02X ", data.get())); + i++; + } + data.reset(); + } + + return sb.toString(); + } + + /** + * Tests the ServerHello for the presence (or not) of the status_request + * or status_request_v2 hello extension. It is assumed that the provided + * ByteBuffer has its position set at the first byte of the TLS record + * containing the ServerHello and contains the entire hello message. Upon + * successful completion of this method the ByteBuffer will have its + * position reset to the initial offset in the buffer. If an exception is + * thrown the position at the time of the exception will be preserved. + * + * @param statReqPresent true if the status_request hello extension should + * be present. + * @param statReqV2Present true if the status_request_v2 hello extension + * should be present. + * + * @return true if the ServerHello's extension set matches the presence + * booleans for status_request and status_request_v2. False if + * not, or if the TLS record or message is of the wrong type. + */ + private static boolean checkServerHello(ByteBuffer data, + boolean statReqPresent, boolean statReqV2Present) { + boolean hasV1 = false; + boolean hasV2 = false; + Objects.requireNonNull(data); + int startPos = data.position(); + data.mark(); + + // Process the TLS record header + int type = Byte.toUnsignedInt(data.get()); + int ver_major = Byte.toUnsignedInt(data.get()); + int ver_minor = Byte.toUnsignedInt(data.get()); + int recLen = Short.toUnsignedInt(data.getShort()); + + // Simple sanity checks + if (type != 22) { + log("Not a handshake: Type = " + type); + return false; + } else if (recLen > data.remaining()) { + log("Incomplete record in buffer: Record length = " + recLen + + ", Remaining = " + data.remaining()); + return false; + } + + // Grab the handshake message header. + int msgHdr = data.getInt(); + int msgType = (msgHdr >> 24) & 0x000000FF; + int msgLen = msgHdr & 0x00FFFFFF; + + // More simple sanity checks + if (msgType != 2) { + log("Not a ServerHello: Type = " + msgType); + return false; + } + + // Skip over the protocol version and server random + data.position(data.position() + 34); + + // Jump past the session ID + int sessLen = Byte.toUnsignedInt(data.get()); + if (sessLen != 0) { + data.position(data.position() + sessLen); + } + + // Skip the cipher suite and compression method + data.position(data.position() + 3); + + // Go through the extensions and look for the request extension + // expected by the caller. + int extsLen = Short.toUnsignedInt(data.getShort()); + while (data.position() < recLen + startPos + 5) { + int extType = Short.toUnsignedInt(data.getShort()); + int extLen = Short.toUnsignedInt(data.getShort()); + hasV1 |= (extType == ExtensionType.EXT_STATUS_REQUEST.id); + hasV2 |= (extType == ExtensionType.EXT_STATUS_REQUEST_V2.id); + data.position(data.position() + extLen); + } + + if (hasV1 != statReqPresent) { + log("The status_request extension is " + + "inconsistent with the expected result: expected = " + + statReqPresent + ", actual = " + hasV1); + } + if (hasV2 != statReqV2Present) { + log("The status_request_v2 extension is " + + "inconsistent with the expected result: expected = " + + statReqV2Present + ", actual = " + hasV2); + } + + // Reset the position to the initial spot at the start of this method. + data.reset(); + + return ((hasV1 == statReqPresent) && (hasV2 == statReqV2Present)); + } + + /** + * Creates the PKI components necessary for this test, including + * Root CA, Intermediate CA and SSL server certificates, the keystores + * for each entity, a client trust store, and starts the OCSP responders. + */ + private static void createPKI() throws Exception { + CertificateBuilder cbld = new CertificateBuilder(); + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); + keyGen.initialize(2048); + KeyStore.Builder keyStoreBuilder = + KeyStore.Builder.newInstance("PKCS12", null, + new KeyStore.PasswordProtection(passwd.toCharArray())); + + // Generate Root, IntCA, EE keys + KeyPair rootCaKP = keyGen.genKeyPair(); + log("Generated Root CA KeyPair"); + KeyPair intCaKP = keyGen.genKeyPair(); + log("Generated Intermediate CA KeyPair"); + KeyPair sslKP = keyGen.genKeyPair(); + log("Generated SSL Cert KeyPair"); + + // Set up the Root CA Cert + cbld.setSubjectName("CN=Root CA Cert, O=SomeCompany"); + cbld.setPublicKey(rootCaKP.getPublic()); + cbld.setSerialNumber(new BigInteger("1")); + // Make a 3 year validity starting from 60 days ago + long start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60); + long end = start + TimeUnit.DAYS.toMillis(1085); + cbld.setValidity(new Date(start), new Date(end)); + addCommonExts(cbld, rootCaKP.getPublic(), rootCaKP.getPublic()); + addCommonCAExts(cbld); + // Make our Root CA Cert! + X509Certificate rootCert = cbld.build(null, rootCaKP.getPrivate(), + "SHA256withRSA"); + log("Root CA Created:\n" + certInfo(rootCert)); + + // Now build a keystore and add the keys and cert + rootKeystore = keyStoreBuilder.getKeyStore(); + java.security.cert.Certificate[] rootChain = {rootCert}; + rootKeystore.setKeyEntry(ROOT_ALIAS, rootCaKP.getPrivate(), + passwd.toCharArray(), rootChain); + + // Now fire up the OCSP responder + rootOcsp = new SimpleOCSPServer(rootKeystore, passwd, ROOT_ALIAS, null); + rootOcsp.enableLog(debug); + rootOcsp.setNextUpdateInterval(3600); + rootOcsp.start(); + + // Wait 5 seconds for server ready + for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) { + Thread.sleep(50); + } + if (!rootOcsp.isServerReady()) { + throw new RuntimeException("Server not ready yet"); + } + + rootOcspPort = rootOcsp.getPort(); + String rootRespURI = "http://localhost:" + rootOcspPort; + log("Root OCSP Responder URI is " + rootRespURI); + + // Now that we have the root keystore and OCSP responder we can + // create our intermediate CA. + cbld.reset(); + cbld.setSubjectName("CN=Intermediate CA Cert, O=SomeCompany"); + cbld.setPublicKey(intCaKP.getPublic()); + cbld.setSerialNumber(new BigInteger("100")); + // Make a 2 year validity starting from 30 days ago + start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30); + end = start + TimeUnit.DAYS.toMillis(730); + cbld.setValidity(new Date(start), new Date(end)); + addCommonExts(cbld, intCaKP.getPublic(), rootCaKP.getPublic()); + addCommonCAExts(cbld); + cbld.addAIAExt(Collections.singletonList(rootRespURI)); + // Make our Intermediate CA Cert! + X509Certificate intCaCert = cbld.build(rootCert, rootCaKP.getPrivate(), + "SHA256withRSA"); + log("Intermediate CA Created:\n" + certInfo(intCaCert)); + + // Provide intermediate CA cert revocation info to the Root CA + // OCSP responder. + Map revInfo = + new HashMap<>(); + revInfo.put(intCaCert.getSerialNumber(), + new SimpleOCSPServer.CertStatusInfo( + SimpleOCSPServer.CertStatus.CERT_STATUS_GOOD)); + rootOcsp.updateStatusDb(revInfo); + + // Now build a keystore and add the keys, chain and root cert as a TA + intKeystore = keyStoreBuilder.getKeyStore(); + java.security.cert.Certificate[] intChain = {intCaCert, rootCert}; + intKeystore.setKeyEntry(INT_ALIAS, intCaKP.getPrivate(), + passwd.toCharArray(), intChain); + intKeystore.setCertificateEntry(ROOT_ALIAS, rootCert); + + // Now fire up the Intermediate CA OCSP responder + intOcsp = new SimpleOCSPServer(intKeystore, passwd, + INT_ALIAS, null); + intOcsp.enableLog(debug); + intOcsp.setNextUpdateInterval(3600); + intOcsp.start(); + + // Wait 5 seconds for server ready + for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) { + Thread.sleep(50); + } + if (!intOcsp.isServerReady()) { + throw new RuntimeException("Server not ready yet"); + } + + intOcspPort = intOcsp.getPort(); + String intCaRespURI = "http://localhost:" + intOcspPort; + log("Intermediate CA OCSP Responder URI is " + intCaRespURI); + + // Last but not least, let's make our SSLCert and add it to its own + // Keystore + cbld.reset(); + cbld.setSubjectName("CN=SSLCertificate, O=SomeCompany"); + cbld.setPublicKey(sslKP.getPublic()); + cbld.setSerialNumber(new BigInteger("4096")); + // Make a 1 year validity starting from 7 days ago + start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7); + end = start + TimeUnit.DAYS.toMillis(365); + cbld.setValidity(new Date(start), new Date(end)); + + // Add extensions + addCommonExts(cbld, sslKP.getPublic(), intCaKP.getPublic()); + boolean[] kuBits = {true, false, true, false, false, false, + false, false, false}; + cbld.addKeyUsageExt(kuBits); + List ekuOids = new ArrayList<>(); + ekuOids.add("1.3.6.1.5.5.7.3.1"); + ekuOids.add("1.3.6.1.5.5.7.3.2"); + cbld.addExtendedKeyUsageExt(ekuOids); + cbld.addSubjectAltNameDNSExt(Collections.singletonList("localhost")); + cbld.addAIAExt(Collections.singletonList(intCaRespURI)); + // Make our SSL Server Cert! + X509Certificate sslCert = cbld.build(intCaCert, intCaKP.getPrivate(), + "SHA256withRSA"); + log("SSL Certificate Created:\n" + certInfo(sslCert)); + + // Provide SSL server cert revocation info to the Intermeidate CA + // OCSP responder. + revInfo = new HashMap<>(); + revInfo.put(sslCert.getSerialNumber(), + new SimpleOCSPServer.CertStatusInfo( + SimpleOCSPServer.CertStatus.CERT_STATUS_GOOD)); + intOcsp.updateStatusDb(revInfo); + + // Now build a keystore and add the keys, chain and root cert as a TA + serverKeystore = keyStoreBuilder.getKeyStore(); + java.security.cert.Certificate[] sslChain = {sslCert, intCaCert, rootCert}; + serverKeystore.setKeyEntry(SSL_ALIAS, sslKP.getPrivate(), + passwd.toCharArray(), sslChain); + serverKeystore.setCertificateEntry(ROOT_ALIAS, rootCert); + + // And finally a Trust Store for the client + trustStore = keyStoreBuilder.getKeyStore(); + trustStore.setCertificateEntry(ROOT_ALIAS, rootCert); + } + + private static void addCommonExts(CertificateBuilder cbld, + PublicKey subjKey, PublicKey authKey) throws IOException { + cbld.addSubjectKeyIdExt(subjKey); + cbld.addAuthorityKeyIdExt(authKey); + } + + private static void addCommonCAExts(CertificateBuilder cbld) + throws IOException { + cbld.addBasicConstraintsExt(true, true, -1); + // Set key usage bits for digitalSignature, keyCertSign and cRLSign + boolean[] kuBitSettings = {true, false, false, false, false, true, + true, false, false}; + cbld.addKeyUsageExt(kuBitSettings); + } + + /** + * Helper routine that dumps only a few cert fields rather than + * the whole toString() output. + * + * @param cert an X509Certificate to be displayed + * + * @return the String output of the issuer, subject and + * serial number + */ + private static String certInfo(X509Certificate cert) { + StringBuilder sb = new StringBuilder(); + sb.append("Issuer: ").append(cert.getIssuerX500Principal()). + append("\n"); + sb.append("Subject: ").append(cert.getSubjectX500Principal()). + append("\n"); + sb.append("Serial: ").append(cert.getSerialNumber()).append("\n"); + return sb.toString(); + } + + private static class TestCase { + public final String testName; + public final ByteBuffer data; + public final boolean statReqEnabled; + public final boolean statReqV2Enabled; + + TestCase(String name, ByteBuffer buffer, boolean srEn, boolean srv2En) { + testName = (name != null) ? name : ""; + data = Objects.requireNonNull(buffer, + "TestCase requires a non-null ByteBuffer"); + statReqEnabled = srEn; + statReqV2Enabled = srv2En; + } + } +} From 81c36d2f40ddf7b83f4a5703b02afeae5bf9a3a9 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Tue, 9 Aug 2016 23:00:49 -0700 Subject: [PATCH 11/66] 8143964: JShell API: convert query responses to Stream instead of List Reviewed-by: psandoz, shinyafox --- .../jdk/internal/jshell/tool/JShellTool.java | 95 ++++++------- .../share/classes/jdk/jshell/JShell.java | 43 +++--- .../share/classes/jdk/jshell/Unit.java | 34 +++-- langtools/test/jdk/jshell/ClassesTest.java | 5 +- .../test/jdk/jshell/JShellQueryTest.java | 131 ++++++++++++++++++ langtools/test/jdk/jshell/KullaTesting.java | 82 +++++------ .../test/jdk/jshell/RejectedFailedTest.java | 5 +- langtools/test/jdk/jshell/ReplaceTest.java | 34 ++--- langtools/test/jdk/jshell/VariablesTest.java | 3 +- 9 files changed, 283 insertions(+), 149 deletions(-) create mode 100644 langtools/test/jdk/jshell/JShellQueryTest.java diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 5e7a9371f1b..1367f15af67 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -973,10 +973,10 @@ public class JShellTool implements MessageHandler { p.getFileName().toString().endsWith(".jar")); } - private CompletionProvider snippetCompletion(Supplier> snippetsSupplier) { + private CompletionProvider snippetCompletion(Supplier> snippetsSupplier) { return (prefix, cursor, anchor) -> { anchor[0] = 0; - return snippetsSupplier.get() .stream() + return snippetsSupplier.get() .flatMap(k -> (k instanceof DeclarationSnippet) ? Stream.of(String.valueOf(k.id()), ((DeclarationSnippet) k).name()) : Stream.of(String.valueOf(k.id()))) @@ -986,7 +986,7 @@ public class JShellTool implements MessageHandler { }; } - private CompletionProvider snippetKeywordCompletion(Supplier> snippetsSupplier) { + private CompletionProvider snippetKeywordCompletion(Supplier> snippetsSupplier) { return (code, cursor, anchor) -> { List result = new ArrayList<>(); result.addAll(KEYWORD_COMPLETION_PROVIDER.completionSuggestions(code, cursor, anchor)); @@ -1020,36 +1020,32 @@ public class JShellTool implements MessageHandler { // Snippet lists - List allSnippets() { + Stream allSnippets() { return state.snippets(); } - List dropableSnippets() { - return state.snippets().stream() + Stream dropableSnippets() { + return state.snippets() .filter(sn -> state.status(sn).isActive() && sn instanceof PersistentSnippet) - .map(sn -> (PersistentSnippet) sn) - .collect(toList()); + .map(sn -> (PersistentSnippet) sn); } - List allVarSnippets() { - return state.snippets().stream() + Stream allVarSnippets() { + return state.snippets() .filter(sn -> sn.kind() == Snippet.Kind.VAR) - .map(sn -> (VarSnippet) sn) - .collect(toList()); + .map(sn -> (VarSnippet) sn); } - List allMethodSnippets() { - return state.snippets().stream() + Stream allMethodSnippets() { + return state.snippets() .filter(sn -> sn.kind() == Snippet.Kind.METHOD) - .map(sn -> (MethodSnippet) sn) - .collect(toList()); + .map(sn -> (MethodSnippet) sn); } - List allTypeSnippets() { - return state.snippets().stream() + Stream allTypeSnippets() { + return state.snippets() .filter(sn -> sn.kind() == Snippet.Kind.TYPE_DECL) - .map(sn -> (TypeDeclSnippet) sn) - .collect(toList()); + .map(sn -> (TypeDeclSnippet) sn); } // Table of commands -- with command forms, argument kinds, helpKey message, implementation, ... @@ -1549,7 +1545,7 @@ public class JShellTool implements MessageHandler { * string * @return a Stream of referenced snippets or null if no matches are found */ - private Stream argsOptionsToSnippets(List snippets, + private Stream argsOptionsToSnippets(Supplier> snippetSupplier, Predicate defFilter, String rawargs, String cmd) { ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim()); at.allowedOptions("-all", "-start"); @@ -1571,38 +1567,38 @@ public class JShellTool implements MessageHandler { } if (at.hasOption("-all")) { // all snippets including start-up, failed, and overwritten - return snippets.stream(); + return snippetSupplier.get(); } if (at.hasOption("-start")) { // start-up snippets - return snippets.stream() + return snippetSupplier.get() .filter(this::inStartUp); } if (args.isEmpty()) { // Default is all active user snippets - return snippets.stream() + return snippetSupplier.get() .filter(defFilter); } - return argsToSnippets(snippets, args); + return argsToSnippets(snippetSupplier, args); } /** * Convert user arguments to a Stream of snippets referenced by those * arguments. * - * @param snippets the base list of possible snippets + * @param snippetSupplier the base list of possible snippets * @param args the user's argument to the command, maybe be the empty list * @return a Stream of referenced snippets or null if no matches to specific * arg */ - private Stream argsToSnippets(List snippets, + private Stream argsToSnippets(Supplier> snippetSupplier, List args) { Stream result = null; for (String arg : args) { // Find the best match - Stream st = layeredSnippetSearch(snippets, arg); + Stream st = layeredSnippetSearch(snippetSupplier, arg); if (st == null) { - Stream est = layeredSnippetSearch(state.snippets(), arg); + Stream est = layeredSnippetSearch(state::snippets, arg); if (est == null) { errormsg("jshell.err.no.such.snippets", arg); } else { @@ -1620,10 +1616,10 @@ public class JShellTool implements MessageHandler { return result; } - private Stream layeredSnippetSearch(List snippets, String arg) { + private Stream layeredSnippetSearch(Supplier> snippetSupplier, String arg) { return nonEmptyStream( // the stream supplier - () -> snippets.stream(), + snippetSupplier, // look for active user declarations matching the name sn -> isActive(sn) && matchingDeclaration(sn, arg), // else, look for any declarations matching the name @@ -1648,7 +1644,7 @@ public class JShellTool implements MessageHandler { errormsg("jshell.err.drop.arg"); return false; } - Stream stream = argsToSnippets(dropableSnippets(), args); + Stream stream = argsToSnippets(this::dropableSnippets, args); if (stream == null) { // Snippet not found. Error already printed fluffmsg("jshell.msg.see.classes.etc"); @@ -1670,7 +1666,7 @@ public class JShellTool implements MessageHandler { } private boolean cmdEdit(String arg) { - Stream stream = argsOptionsToSnippets(state.snippets(), + Stream stream = argsOptionsToSnippets(state::snippets, this::mainActive, arg, "/edit"); if (stream == null) { return false; @@ -1775,7 +1771,7 @@ public class JShellTool implements MessageHandler { if (arg.length() >= 2 && "-history".startsWith(arg)) { return cmdHistory(); } - Stream stream = argsOptionsToSnippets(state.snippets(), + Stream stream = argsOptionsToSnippets(state::snippets, this::mainActive, arg, "/list"); if (stream == null) { return false; @@ -1896,13 +1892,12 @@ public class JShellTool implements MessageHandler { } else if (at.hasOption("-start")) { writer.append(startup); } else { - List sns = at.hasOption("-all") + String sources = (at.hasOption("-all") ? state.snippets() - : state.snippets().stream().filter(this::mainActive).collect(toList()); - for (Snippet sn : sns) { - writer.write(sn.source()); - writer.write("\n"); - } + : state.snippets().filter(this::mainActive)) + .map(Snippet::source) + .collect(Collectors.joining("\n")); + writer.write(sources); } } catch (FileNotFoundException e) { errormsg("jshell.err.file.not.found", "/save", filename, e.getMessage()); @@ -1915,7 +1910,7 @@ public class JShellTool implements MessageHandler { } private boolean cmdVars(String arg) { - Stream stream = argsOptionsToSnippets(allVarSnippets(), + Stream stream = argsOptionsToSnippets(this::allVarSnippets, this::isActive, arg, "/vars"); if (stream == null) { return false; @@ -1931,7 +1926,7 @@ public class JShellTool implements MessageHandler { } private boolean cmdMethods(String arg) { - Stream stream = argsOptionsToSnippets(allMethodSnippets(), + Stream stream = argsOptionsToSnippets(this::allMethodSnippets, this::isActive, arg, "/methods"); if (stream == null) { return false; @@ -1943,7 +1938,7 @@ public class JShellTool implements MessageHandler { } private boolean cmdTypes(String arg) { - Stream stream = argsOptionsToSnippets(allTypeSnippets(), + Stream stream = argsOptionsToSnippets(this::allTypeSnippets, this::isActive, arg, "/types"); if (stream == null) { return false; @@ -1982,7 +1977,7 @@ public class JShellTool implements MessageHandler { } private boolean cmdUseHistoryEntry(int index) { - List keys = state.snippets(); + List keys = state.snippets().collect(toList()); if (index < 0) index += keys.size(); else @@ -2012,7 +2007,7 @@ public class JShellTool implements MessageHandler { } private boolean rerunHistoryEntryById(String id) { - Optional snippet = state.snippets().stream() + Optional snippet = state.snippets() .filter(s -> s.id().equals(id)) .findFirst(); return snippet.map(s -> { @@ -2135,7 +2130,7 @@ public class JShellTool implements MessageHandler { debug("Event with null key: %s", ste); return false; } - List diagnostics = state.diagnostics(sn); + List diagnostics = state.diagnostics(sn).collect(toList()); String source = sn.source(); if (ste.causeSnippet() == null) { // main event @@ -2212,7 +2207,7 @@ public class JShellTool implements MessageHandler { //where void printUnresolvedException(UnresolvedReferenceException ex) { DeclarationSnippet corralled = ex.getSnippet(); - List otherErrors = errorsOnly(state.diagnostics(corralled)); + List otherErrors = errorsOnly(state.diagnostics(corralled).collect(toList())); new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors) .displayDeclarationAndValue(); } @@ -2280,13 +2275,13 @@ public class JShellTool implements MessageHandler { for (Diag d : errors) { displayDiagnostics(sn.source(), d, errorLines); } - int unresolvedCount; + long unresolvedCount; if (sn instanceof DeclarationSnippet && (status == Status.RECOVERABLE_DEFINED || status == Status.RECOVERABLE_NOT_DEFINED)) { resolution = (status == Status.RECOVERABLE_NOT_DEFINED) ? FormatResolve.NOTDEFINED : FormatResolve.DEFINED; unresolved = unresolved((DeclarationSnippet) sn); - unresolvedCount = state.unresolvedDependencies((DeclarationSnippet) sn).size(); + unresolvedCount = state.unresolvedDependencies((DeclarationSnippet) sn).count(); } else { resolution = FormatResolve.OK; unresolved = ""; @@ -2305,7 +2300,7 @@ public class JShellTool implements MessageHandler { } private String unresolved(DeclarationSnippet key) { - List unr = state.unresolvedDependencies(key); + List unr = state.unresolvedDependencies(key).collect(toList()); StringBuilder sb = new StringBuilder(); int fromLast = unr.size(); if (fromLast > 0) { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java index 8e2517cf0b5..6cdadabd4b3 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java @@ -43,6 +43,7 @@ import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Supplier; +import java.util.stream.Stream; import jdk.internal.jshell.debug.InternalDebugControl; import jdk.jshell.Snippet.Status; import jdk.jshell.execution.JDIDefaultExecutionControl; @@ -504,9 +505,9 @@ public class JShell implements AutoCloseable { * @return the snippets for all current snippets in id order. * @throws IllegalStateException if this JShell instance is closed. */ - public List snippets() throws IllegalStateException { + public Stream snippets() throws IllegalStateException { checkIfAlive(); - return Collections.unmodifiableList(maps.snippetList()); + return maps.snippetList().stream(); } /** @@ -518,11 +519,10 @@ public class JShell implements AutoCloseable { * @return the active declared variables. * @throws IllegalStateException if this JShell instance is closed. */ - public List variables() throws IllegalStateException { - return snippets().stream() + public Stream variables() throws IllegalStateException { + return snippets() .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.VAR) - .map(sn -> (VarSnippet) sn) - .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + .map(sn -> (VarSnippet) sn); } /** @@ -534,11 +534,10 @@ public class JShell implements AutoCloseable { * @return the active declared methods. * @throws IllegalStateException if this JShell instance is closed. */ - public List methods() throws IllegalStateException { - return snippets().stream() + public Stream methods() throws IllegalStateException { + return snippets() .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.METHOD) - .map(sn -> (MethodSnippet)sn) - .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + .map(sn -> (MethodSnippet)sn); } /** @@ -550,11 +549,10 @@ public class JShell implements AutoCloseable { * @return the active declared type declarations. * @throws IllegalStateException if this JShell instance is closed. */ - public List types() throws IllegalStateException { - return snippets().stream() + public Stream types() throws IllegalStateException { + return snippets() .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.TYPE_DECL) - .map(sn -> (TypeDeclSnippet) sn) - .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + .map(sn -> (TypeDeclSnippet) sn); } /** @@ -566,11 +564,10 @@ public class JShell implements AutoCloseable { * @return the active declared import declarations. * @throws IllegalStateException if this JShell instance is closed. */ - public List imports() throws IllegalStateException { - return snippets().stream() + public Stream imports() throws IllegalStateException { + return snippets() .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.IMPORT) - .map(sn -> (ImportSnippet) sn) - .collect(collectingAndThen(toList(), Collections::unmodifiableList)); + .map(sn -> (ImportSnippet) sn); } /** @@ -598,8 +595,8 @@ public class JShell implements AutoCloseable { * @throws IllegalArgumentException if the snippet is not associated with * this {@code JShell} instance. */ - public List diagnostics(Snippet snippet) { - return Collections.unmodifiableList(checkValidSnippet(snippet).diagnostics()); + public Stream diagnostics(Snippet snippet) { + return checkValidSnippet(snippet).diagnostics().stream(); } /** @@ -611,13 +608,13 @@ public class JShell implements AutoCloseable { * {@code eval()} or {@code drop()} of another snippet causes * an update of a dependency. * @param snippet the declaration {@code Snippet} to look up - * @return the list of symbol names that are currently unresolvedDependencies. + * @return a stream of symbol names that are currently unresolvedDependencies. * @throws IllegalStateException if this {@code JShell} instance is closed. * @throws IllegalArgumentException if the snippet is not associated with * this {@code JShell} instance. */ - public List unresolvedDependencies(DeclarationSnippet snippet) { - return Collections.unmodifiableList(checkValidSnippet(snippet).unresolved()); + public Stream unresolvedDependencies(DeclarationSnippet snippet) { + return checkValidSnippet(snippet).unresolved().stream(); } /** diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java index e83b0b848b7..c890c61c83d 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java @@ -414,25 +414,29 @@ final class Unit { // types are the same. if so, consider it an overwrite replacement. private Status overwriteMatchingMethod(MethodSnippet msi) { String qpt = msi.qualifiedParameterTypes(); + List matching = state.methods() + .filter(sn -> + sn != null + && sn != msi + && sn.status().isActive() + && sn.name().equals(msi.name()) + && qpt.equals(sn.qualifiedParameterTypes())) + .collect(toList()); // Look through all methods for a method of the same name, with the // same computed qualified parameter types Status overwrittenStatus = null; - for (MethodSnippet sn : state.methods()) { - if (sn != null && sn != msi && sn.status().isActive() && sn.name().equals(msi.name())) { - if (qpt.equals(sn.qualifiedParameterTypes())) { - overwrittenStatus = sn.status(); - SnippetEvent se = new SnippetEvent( - sn, overwrittenStatus, OVERWRITTEN, - false, msi, null, null); - sn.setOverwritten(); - secondaryEvents.add(se); - state.debug(DBG_EVNT, - "Overwrite event #%d -- key: %s before: %s status: %s sig: %b cause: %s\n", - secondaryEvents.size(), se.snippet(), se.previousStatus(), - se.status(), se.isSignatureChange(), se.causeSnippet()); - } - } + for (MethodSnippet sn : matching) { + overwrittenStatus = sn.status(); + SnippetEvent se = new SnippetEvent( + sn, overwrittenStatus, OVERWRITTEN, + false, msi, null, null); + sn.setOverwritten(); + secondaryEvents.add(se); + state.debug(DBG_EVNT, + "Overwrite event #%d -- key: %s before: %s status: %s sig: %b cause: %s\n", + secondaryEvents.size(), se.snippet(), se.previousStatus(), + se.status(), se.isSignatureChange(), se.causeSnippet()); } return overwrittenStatus; } diff --git a/langtools/test/jdk/jshell/ClassesTest.java b/langtools/test/jdk/jshell/ClassesTest.java index a0848f12f1c..fd629480aac 100644 --- a/langtools/test/jdk/jshell/ClassesTest.java +++ b/langtools/test/jdk/jshell/ClassesTest.java @@ -41,6 +41,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import jdk.jshell.Diag; +import static java.util.stream.Collectors.toList; import static jdk.jshell.Snippet.Status.VALID; import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED; import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED; @@ -210,8 +211,8 @@ public class ClassesTest extends KullaTesting { ste(b, RECOVERABLE_NOT_DEFINED, RECOVERABLE_NOT_DEFINED, false, MAIN_SNIPPET)); ***/ // It is random which one it shows up in, but cyclic error should be there - List diagsA = getState().diagnostics(a); - List diagsB = getState().diagnostics(b); + List diagsA = getState().diagnostics(a).collect(toList()); + List diagsB = getState().diagnostics(b).collect(toList()); List diags; if (diagsA.isEmpty()) { diags = diagsB; diff --git a/langtools/test/jdk/jshell/JShellQueryTest.java b/langtools/test/jdk/jshell/JShellQueryTest.java new file mode 100644 index 00000000000..0bdb5db1c59 --- /dev/null +++ b/langtools/test/jdk/jshell/JShellQueryTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8143964 + * @summary test queries to the JShell that return Streams + * @build KullaTesting + * @run testng JShellQueryTest + */ +import java.util.Set; +import java.util.stream.Stream; +import jdk.jshell.Snippet; +import org.testng.annotations.Test; + +import jdk.jshell.ImportSnippet; +import jdk.jshell.MethodSnippet; +import jdk.jshell.TypeDeclSnippet; +import jdk.jshell.VarSnippet; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toSet; +import static org.testng.Assert.assertEquals; + +@Test +public class JShellQueryTest extends KullaTesting { + + private void checkStreamMatch(Stream result, T... expected) { + Set sns = result.collect(toSet()); + Set exp = Stream.of(expected).collect(toSet()); + assertEquals(sns, exp); + } + + public void testSnippets() { + checkStreamMatch(getState().snippets()); + VarSnippet sx = varKey(assertEval("int x = 5;")); + VarSnippet sfoo = varKey(assertEval("String foo;")); + MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }")); + MethodSnippet svv = methodKey(assertEval("void vv() { }")); + checkStreamMatch(getState().snippets(), sx, sfoo, smm, svv); + TypeDeclSnippet sc = classKey(assertEval("class C { }")); + TypeDeclSnippet si = classKey(assertEval("interface I { }")); + ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;")); + checkStreamMatch(getState().snippets(), sx, sfoo, smm, svv, sc, si, simp); + } + + public void testVars() { + checkStreamMatch(getState().variables()); + VarSnippet sx = varKey(assertEval("int x = 5;")); + VarSnippet sfoo = varKey(assertEval("String foo;")); + MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }")); + MethodSnippet svv = methodKey(assertEval("void vv() { }")); + checkStreamMatch(getState().variables(), sx, sfoo); + TypeDeclSnippet sc = classKey(assertEval("class C { }")); + TypeDeclSnippet si = classKey(assertEval("interface I { }")); + ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;")); + checkStreamMatch(getState().variables(), sx, sfoo); + } + + public void testMethods() { + checkStreamMatch(getState().methods()); + VarSnippet sx = varKey(assertEval("int x = 5;")); + VarSnippet sfoo = varKey(assertEval("String foo;")); + MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }")); + MethodSnippet svv = methodKey(assertEval("void vv() { }")); + TypeDeclSnippet sc = classKey(assertEval("class C { }")); + TypeDeclSnippet si = classKey(assertEval("interface I { }")); + ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;")); + checkStreamMatch(getState().methods(), smm, svv); + } + + public void testTypes() { + checkStreamMatch(getState().types()); + VarSnippet sx = varKey(assertEval("int x = 5;")); + VarSnippet sfoo = varKey(assertEval("String foo;")); + MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }")); + MethodSnippet svv = methodKey(assertEval("void vv() { }")); + TypeDeclSnippet sc = classKey(assertEval("class C { }")); + TypeDeclSnippet si = classKey(assertEval("interface I { }")); + ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;")); + checkStreamMatch(getState().types(), sc, si); + } + + public void testImports() { + checkStreamMatch(getState().imports()); + VarSnippet sx = varKey(assertEval("int x = 5;")); + VarSnippet sfoo = varKey(assertEval("String foo;")); + MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }")); + MethodSnippet svv = methodKey(assertEval("void vv() { }")); + TypeDeclSnippet sc = classKey(assertEval("class C { }")); + TypeDeclSnippet si = classKey(assertEval("interface I { }")); + ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;")); + checkStreamMatch(getState().imports(), simp); + } + + public void testDiagnostics() { + Snippet sx = varKey(assertEval("int x = 5;")); + checkStreamMatch(getState().diagnostics(sx)); + Snippet broken = methodKey(assertEvalFail("int m() { blah(); return \"hello\"; }")); + String res = getState().diagnostics(broken) + .map(d -> d.getCode()) + .collect(joining("+")); + assertEquals(res, "compiler.err.cant.resolve.location.args+compiler.err.prob.found.req"); + } + + public void testUnresolvedDependencies() { + VarSnippet sx = varKey(assertEval("int x = 5;")); + checkStreamMatch(getState().unresolvedDependencies(sx)); + MethodSnippet unr = methodKey(getState().eval("void uu() { baz(); zips(); }")); + checkStreamMatch(getState().unresolvedDependencies(unr), "method zips()", "method baz()"); + } +} diff --git a/langtools/test/jdk/jshell/KullaTesting.java b/langtools/test/jdk/jshell/KullaTesting.java index f36adba2401..ae09ed59390 100644 --- a/langtools/test/jdk/jshell/KullaTesting.java +++ b/langtools/test/jdk/jshell/KullaTesting.java @@ -70,6 +70,7 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import jdk.jshell.Diag; +import static java.util.stream.Collectors.toList; import static jdk.jshell.Snippet.Status.*; import static org.testng.Assert.*; import static jdk.jshell.Snippet.SubKind.METHOD_SUBKIND; @@ -183,7 +184,7 @@ public class KullaTesting { } public List assertUnresolvedDependencies(DeclarationSnippet key, int unresolvedSize) { - List unresolved = getState().unresolvedDependencies(key); + List unresolved = getState().unresolvedDependencies(key).collect(toList()); assertEquals(unresolved.size(), unresolvedSize, "Input: " + key.source() + ", checking unresolved: "); return unresolved; } @@ -202,8 +203,8 @@ public class KullaTesting { SnippetEvent ste = events.get(0); DeclarationSnippet sn = ((UnresolvedReferenceException) ste.exception()).getSnippet(); assertEquals(sn.name(), name, "Given input: " + input + ", checking name"); - assertEquals(getState().unresolvedDependencies(sn).size(), unresolvedSize, "Given input: " + input + ", checking unresolved"); - assertEquals(getState().diagnostics(sn).size(), diagnosticsSize, "Given input: " + input + ", checking diagnostics"); + assertEquals(getState().unresolvedDependencies(sn).count(), unresolvedSize, "Given input: " + input + ", checking unresolved"); + assertEquals(getState().diagnostics(sn).count(), (long) diagnosticsSize, "Given input: " + input + ", checking diagnostics"); return sn; } @@ -546,7 +547,7 @@ public class KullaTesting { " got: " + main.exception().toString()); } } - List diagnostics = getState().diagnostics(mainKey); + List diagnostics = getState().diagnostics(mainKey).collect(toList()); switch (diagMain) { case DIAG_OK: assertEquals(diagnostics.size(), 0, "Expected no diagnostics, got: " + diagnosticsToString(diagnostics)); @@ -560,7 +561,7 @@ public class KullaTesting { } if (eventChain.mainInfo != null) { for (STEInfo ste : eventChain.updates) { - diagnostics = getState().diagnostics(ste.snippet()); + diagnostics = getState().diagnostics(ste.snippet()).collect(toList()); switch (diagUpdates) { case DIAG_OK: assertEquals(diagnostics.size(), 0, "Expected no diagnostics, got: " + diagnosticsToString(diagnostics)); @@ -637,7 +638,7 @@ public class KullaTesting { SnippetEvent e = events.get(0); Snippet key = e.snippet(); assertEquals(getState().status(key), REJECTED); - List diagnostics = getState().diagnostics(e.snippet()); + List diagnostics = getState().diagnostics(e.snippet()).collect(toList()); assertTrue(diagnostics.size() > 0, "Expected diagnostics, got none"); assertDiagnostic(input, diagnostics.get(0), expectedDiagnostic); assertTrue(key != null, "key must never be null, but it was for: " + input); @@ -656,7 +657,7 @@ public class KullaTesting { List events = assertEval(input, IGNORE_VALUE, null, DiagCheck.DIAG_WARNING, DiagCheck.DIAG_IGNORE, mainInfo, updates); SnippetEvent e = events.get(0); - List diagnostics = getState().diagnostics(e.snippet()); + List diagnostics = getState().diagnostics(e.snippet()).collect(toList()); if (expectedDiagnostic != null) assertDiagnostic(input, diagnostics.get(0), expectedDiagnostic); return e.snippet(); } @@ -704,12 +705,12 @@ public class KullaTesting { String source = declarationKey.source(); assertEquals(declarationKey.name(), expectedName, "Expected " + source + " to have the name: " + expectedName + ", got: " + declarationKey.name()); - List unresolved = getState().unresolvedDependencies(declarationKey); - assertEquals(unresolved.size(), unressz, "Expected " + source + " to have " + unressz - + " unresolved symbols, got: " + unresolved.size()); - List otherCorralledErrors = getState().diagnostics(declarationKey); - assertEquals(otherCorralledErrors.size(), othersz, "Expected " + source + " to have " + othersz - + " other errors, got: " + otherCorralledErrors.size()); + long unresolved = getState().unresolvedDependencies(declarationKey).count(); + assertEquals(unresolved, unressz, "Expected " + source + " to have " + unressz + + " unresolved symbols, got: " + unresolved); + long otherCorralledErrorsCount = getState().diagnostics(declarationKey).count(); + assertEquals(otherCorralledErrorsCount, othersz, "Expected " + source + " to have " + othersz + + " other errors, got: " + otherCorralledErrorsCount); } public void assertKey(Snippet key, Status expectedStatus, SubKind expectedSubKind) { @@ -757,31 +758,20 @@ public class KullaTesting { } public void assertNumberOfActiveVariables(int cnt) { - Collection variables = getState().variables(); - assertEquals(variables.size(), cnt, "Variables : " + variables); + assertEquals(getState().variables().count(), cnt, "Variables : " + getState().variables().collect(toList())); } public void assertNumberOfActiveMethods(int cnt) { - Collection methods = getState().methods(); - assertEquals(methods.size(), cnt, "Methods : " + methods); + assertEquals(getState().methods().count(), cnt, "Methods : " + getState().methods().collect(toList())); } public void assertNumberOfActiveClasses(int cnt) { - Collection classes = getState().types(); - assertEquals(classes.size(), cnt, "Classes : " + classes); - } - - public void assertMembers(Collection members, Set expected) { - assertEquals(members.size(), expected.size(), "Expected : " + expected + ", actual : " + members); - assertEquals(members.stream() - .map(this::getMemberInfo) - .collect(Collectors.toSet()), - expected); + assertEquals(getState().types().count(), cnt, "Types : " + getState().types().collect(toList())); } public void assertKeys(MemberInfo... expected) { int index = 0; - List snippets = getState().snippets(); + List snippets = getState().snippets().collect(toList()); assertEquals(allSnippets.size(), snippets.size()); for (Snippet sn : snippets) { if (sn.kind().isPersistent() && getState().status(sn).isActive()) { @@ -801,7 +791,7 @@ public class KullaTesting { public void assertActiveKeys(Snippet... expected) { int index = 0; - for (Snippet key : getState().snippets()) { + for (Snippet key : getState().snippets().collect(toList())) { if (state.status(key).isActive()) { assertEquals(expected[index], key, String.format("Difference in #%d. Expected: %s, actual: %s", index, key, expected[index])); ++index; @@ -809,31 +799,43 @@ public class KullaTesting { } } - private List filterDeclaredKeys(Predicate p) { - return getActiveKeys().stream() + private void assertActiveSnippets(Stream snippets, Predicate p, String label) { + Set active = getActiveKeys().stream() .filter(p) - .collect(Collectors.toList()); + .collect(Collectors.toSet()); + Set got = snippets + .collect(Collectors.toSet()); + assertEquals(active, got, label); } public void assertVariables() { - assertEquals(getState().variables(), filterDeclaredKeys((key) -> key instanceof VarSnippet), "Variables"); + assertActiveSnippets(getState().variables(), (key) -> key instanceof VarSnippet, "Variables"); } public void assertMethods() { - assertEquals(getState().methods(), filterDeclaredKeys((key) -> key instanceof MethodSnippet), "Methods"); + assertActiveSnippets(getState().methods(), (key) -> key instanceof MethodSnippet, "Methods"); } public void assertClasses() { - assertEquals(getState().types(), filterDeclaredKeys((key) -> key instanceof TypeDeclSnippet), "Classes"); + assertActiveSnippets(getState().types(), (key) -> key instanceof TypeDeclSnippet, "Classes"); + } + + public void assertMembers(Stream members, MemberInfo...expectedInfos) { + Set expected = Stream.of(expectedInfos).collect(Collectors.toSet()); + Set got = members + .map(this::getMemberInfo) + .collect(Collectors.toSet()); + assertEquals(got.size(), expected.size(), "Expected : " + expected + ", actual : " + members); + assertEquals(got, expected); } public void assertVariables(MemberInfo...expected) { - assertMembers(getState().variables(), Stream.of(expected).collect(Collectors.toSet())); + assertMembers(getState().variables(), expected); } public void assertMethods(MemberInfo...expected) { - assertMembers(getState().methods(), Stream.of(expected).collect(Collectors.toSet())); - for (MethodSnippet methodKey : getState().methods()) { + assertMembers(getState().methods(), expected); + getState().methods().forEach(methodKey -> { MemberInfo expectedInfo = null; for (MemberInfo info : expected) { if (info.name.equals(methodKey.name()) && info.type.equals(methodKey.signature())) { @@ -843,11 +845,11 @@ public class KullaTesting { assertNotNull(expectedInfo, "Not found method: " + methodKey.name()); int lastIndexOf = expectedInfo.type.lastIndexOf(')'); assertEquals(methodKey.parameterTypes(), expectedInfo.type.substring(1, lastIndexOf), "Parameter types"); - } + }); } public void assertClasses(MemberInfo...expected) { - assertMembers(getState().types(), Stream.of(expected).collect(Collectors.toSet())); + assertMembers(getState().types(), expected); } public void assertCompletion(String code, String... expected) { diff --git a/langtools/test/jdk/jshell/RejectedFailedTest.java b/langtools/test/jdk/jshell/RejectedFailedTest.java index d66c3890424..b9d8bece7cb 100644 --- a/langtools/test/jdk/jshell/RejectedFailedTest.java +++ b/langtools/test/jdk/jshell/RejectedFailedTest.java @@ -39,6 +39,7 @@ import jdk.jshell.Snippet.Kind; import jdk.jshell.Snippet.Status; import jdk.jshell.SnippetEvent; +import static java.util.stream.Collectors.toList; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -49,7 +50,7 @@ public class RejectedFailedTest extends KullaTesting { List events = assertEvalFail(input); assertEquals(events.size(), 1, "Expected one event, got: " + events.size()); SnippetEvent e = events.get(0); - List diagnostics = getState().diagnostics(e.snippet()); + List diagnostics = getState().diagnostics(e.snippet()).collect(toList()); assertTrue(diagnostics.size() > 0, "Expected diagnostics, got none"); assertEquals(e.exception(), null, "Expected exception to be null."); assertEquals(e.value(), null, "Expected value to be null."); @@ -60,7 +61,7 @@ public class RejectedFailedTest extends KullaTesting { SubKind expectedSubKind = kind == Kind.ERRONEOUS ? SubKind.UNKNOWN_SUBKIND : SubKind.METHOD_SUBKIND; assertEquals(key.subKind(), expectedSubKind, "SubKind: "); assertTrue(key.id().compareTo(prevId) > 0, "Current id: " + key.id() + ", previous: " + prevId); - assertEquals(getState().diagnostics(key), diagnostics, "Expected retrieved diagnostics to match, but didn't."); + assertEquals(getState().diagnostics(key).collect(toList()), diagnostics, "Expected retrieved diagnostics to match, but didn't."); assertEquals(key.source(), input, "Expected retrieved source: " + key.source() + " to match input: " + input); assertEquals(getState().status(key), Status.REJECTED, "Expected status of REJECTED, got: " + getState().status(key)); diff --git a/langtools/test/jdk/jshell/ReplaceTest.java b/langtools/test/jdk/jshell/ReplaceTest.java index b631c4958c9..ca049581d65 100644 --- a/langtools/test/jdk/jshell/ReplaceTest.java +++ b/langtools/test/jdk/jshell/ReplaceTest.java @@ -28,9 +28,9 @@ * @run testng ReplaceTest */ -import java.util.Collection; - +import java.util.Iterator; import java.util.List; +import java.util.stream.Stream; import jdk.jshell.Snippet; import jdk.jshell.MethodSnippet; import jdk.jshell.PersistentSnippet; @@ -42,6 +42,7 @@ import org.testng.annotations.Test; import jdk.jshell.SnippetEvent; import jdk.jshell.UnresolvedReferenceException; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static jdk.jshell.Snippet.Status.*; import static jdk.jshell.Snippet.SubKind.*; import static org.testng.Assert.assertTrue; @@ -90,17 +91,22 @@ public class ReplaceTest extends KullaTesting { assertActiveKeys(); } + private void identityMatch(Stream got, T expected) { + Iterator it = got.iterator(); + assertTrue(it.hasNext(), "expected exactly one"); + assertTrue(expected == it.next(), "Identity must not change"); + assertFalse(it.hasNext(), "expected exactly one"); + } + public void testReplaceVarToMethod() { Snippet x = varKey(assertEval("int x;")); - Snippet musn = methodKey(assertEval("double mu() { return x * 4; }")); + MethodSnippet musn = methodKey(assertEval("double mu() { return x * 4; }")); assertEval("x == 0;", "true"); assertEval("mu() == 0.0;", "true"); assertEval("double x = 2.5;", ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); - Collection meths = getState().methods(); - assertEquals(meths.size(), 1); - assertTrue(musn == meths.iterator().next(), "Identity must not change"); + identityMatch(getState().methods(), musn); assertEval("x == 2.5;", "true"); assertEval("mu() == 10.0;", "true"); // Auto redefine assertActiveKeys(); @@ -132,15 +138,13 @@ public class ReplaceTest extends KullaTesting { public void testReplaceVarToClass() { Snippet x = varKey(assertEval("int x;")); - Snippet c = classKey(assertEval("class A { double a = 4 * x; }")); + TypeDeclSnippet c = classKey(assertEval("class A { double a = 4 * x; }")); assertEval("x == 0;", "true"); assertEval("new A().a == 0.0;", "true"); assertEval("double x = 2.5;", ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); - Collection classes = getState().types(); - assertEquals(classes.size(), 1); - assertTrue(c == classes.iterator().next(), "Identity must not change"); + identityMatch(getState().types(), c); assertEval("x == 2.5;", "true"); assertEval("new A().a == 10.0;", "true"); assertActiveKeys(); @@ -148,16 +152,14 @@ public class ReplaceTest extends KullaTesting { public void testReplaceMethodToClass() { Snippet x = methodKey(assertEval("int x() { return 0; }")); - Snippet c = classKey(assertEval("class A { double a = 4 * x(); }")); + TypeDeclSnippet c = classKey(assertEval("class A { double a = 4 * x(); }")); assertEval("x() == 0;", "true"); assertEval("new A().a == 0.0;", "true"); assertEval("double x() { return 2.5; }", ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); assertEval("x();", "2.5"); - Collection classes = getState().types(); - assertEquals(classes.size(), 1); - assertTrue(c == classes.iterator().next(), "Identity must not change"); + identityMatch(getState().types(), c); assertEval("x() == 2.5;", "true"); assertEval("new A().a == 10.0;", "true"); assertActiveKeys(); @@ -313,8 +315,8 @@ public class ReplaceTest extends KullaTesting { Snippet assn = ste.snippet(); DeclarationSnippet unsn = ((UnresolvedReferenceException) ste.exception()).getSnippet(); assertEquals(unsn.name(), "A", "Wrong with unresolved"); - assertEquals(getState().unresolvedDependencies(unsn).size(), 1, "Wrong size unresolved"); - assertEquals(getState().diagnostics(unsn).size(), 0, "Expected no diagnostics"); + assertEquals(getState().unresolvedDependencies(unsn).count(), 1, "Wrong size unresolved"); + assertEquals(getState().diagnostics(unsn).count(), 0L, "Expected no diagnostics"); Snippet g = varKey(assertEval("int g = 10;", "10", added(VALID), diff --git a/langtools/test/jdk/jshell/VariablesTest.java b/langtools/test/jdk/jshell/VariablesTest.java index 35eda77cdcc..94b26a7b8ba 100644 --- a/langtools/test/jdk/jshell/VariablesTest.java +++ b/langtools/test/jdk/jshell/VariablesTest.java @@ -39,6 +39,7 @@ import jdk.jshell.Snippet.SubKind; import jdk.jshell.SnippetEvent; import org.testng.annotations.Test; +import static java.util.stream.Collectors.toList; import static jdk.jshell.Snippet.Status.*; import static jdk.jshell.Snippet.SubKind.VAR_DECLARATION_SUBKIND; import static org.testng.Assert.assertEquals; @@ -331,7 +332,7 @@ public class VariablesTest extends KullaTesting { //assertEquals(getState().source(snippet), src); //assertEquals(snippet, undefKey); assertEquals(getState().status(undefKey), RECOVERABLE_NOT_DEFINED); - List unr = getState().unresolvedDependencies((VarSnippet) undefKey); + List unr = getState().unresolvedDependencies((VarSnippet) undefKey).collect(toList());; assertEquals(unr.size(), 1); assertEquals(unr.get(0), "class undefined"); assertVariables(variable("undefined", "d")); From 23853ed3e482278fcd44521dc463acfb0bf396a9 Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Wed, 10 Aug 2016 11:54:12 +0100 Subject: [PATCH 12/66] 8163104: Unexpected NPE still possible on some Kerberos ticket calls Reviewed-by: weijun --- .../classes/sun/security/jgss/krb5/Krb5InitCredential.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java index aabe0a103de..28dbb189bd9 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java @@ -235,8 +235,11 @@ public class Krb5InitCredential */ public int getInitLifetime() throws GSSException { int retVal = 0; - retVal = (int)(getEndTime().getTime() - - (new Date().getTime())); + Date d = getEndTime(); + if (d == null) { + return 0; + } + retVal = (int)(d.getTime() - (new Date().getTime())); return retVal/1000; } From bb95ea61018272bc42bfd248b47e7e5eec03c6a6 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 10 Aug 2016 13:54:38 +0200 Subject: [PATCH 13/66] 8163370: Reduce number of classes loaded by common usage of java.lang.invoke Reviewed-by: igerasim, psandoz --- .../java/lang/invoke/DirectMethodHandle.java | 2 +- .../java/lang/invoke/LambdaFormEditor.java | 98 +++--- .../classes/java/lang/invoke/MemberName.java | 4 +- .../java/lang/invoke/MethodHandles.java | 4 +- .../java/lang/invoke/StringConcatFactory.java | 280 +++++++----------- .../invoke/TypeConvertingMethodAdapter.java | 2 +- .../classes/java/lang/invoke/VarHandle.java | 93 +++--- .../sun/invoke/util/ValueConversions.java | 27 +- .../classes/sun/invoke/util/Wrapper.java | 7 +- 9 files changed, 224 insertions(+), 293 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index c980fb80f69..17bf2d9c5e7 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -515,7 +515,7 @@ class DirectMethodHandle extends MethodHandle { // Enumerate the different field kinds using Wrapper, // with an extra case added for checked references. private static final int - FT_LAST_WRAPPER = Wrapper.values().length-1, + FT_LAST_WRAPPER = Wrapper.COUNT-1, FT_UNCHECKED_REF = Wrapper.OBJECT.ordinal(), FT_CHECKED_REF = FT_LAST_WRAPPER+1, FT_LIMIT = FT_LAST_WRAPPER+2; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java index 9d6c865eae5..cec4ff1ea54 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java @@ -60,7 +60,7 @@ class LambdaFormEditor { } /** A description of a cached transform, possibly associated with the result of the transform. - * The logical content is a sequence of byte values, starting with a Kind.ordinal value. + * The logical content is a sequence of byte values, starting with a kind value. * The sequence is unterminated, ending with an indefinite number of zero bytes. * Sequences that are simple (short enough and with small enough values) pack into a 64-bit long. */ @@ -68,17 +68,22 @@ class LambdaFormEditor { final long packedBytes; final byte[] fullBytes; - private enum Kind { - NO_KIND, // necessary because ordinal must be greater than zero - BIND_ARG, ADD_ARG, DUP_ARG, - SPREAD_ARGS, - FILTER_ARG, FILTER_RETURN, FILTER_RETURN_TO_ZERO, - COLLECT_ARGS, COLLECT_ARGS_TO_VOID, COLLECT_ARGS_TO_ARRAY, - FOLD_ARGS, FOLD_ARGS_TO_VOID, - PERMUTE_ARGS, - LOCAL_TYPES - //maybe add more for guard with test, catch exception, pointwise type conversions - } + // maybe add more for guard with test, catch exception, pointwise type conversions + private static final byte + BIND_ARG = 1, + ADD_ARG = 2, + DUP_ARG = 3, + SPREAD_ARGS = 4, + FILTER_ARG = 5, + FILTER_RETURN = 6, + FILTER_RETURN_TO_ZERO = 7, + COLLECT_ARGS = 8, + COLLECT_ARGS_TO_VOID = 9, + COLLECT_ARGS_TO_ARRAY = 10, + FOLD_ARGS = 11, + FOLD_ARGS_TO_VOID = 12, + PERMUTE_ARGS = 13, + LOCAL_TYPES = 14; private static final boolean STRESS_TEST = false; // turn on to disable most packing private static final int @@ -131,20 +136,6 @@ class LambdaFormEditor { return bytes; } - private byte byteAt(int i) { - long pb = packedBytes; - if (pb == 0) { - if (i >= fullBytes.length) return 0; - return fullBytes[i]; - } - assert(fullBytes == null); - if (i > PACKED_BYTE_MAX_LENGTH) return 0; - int pos = (i * PACKED_BYTE_SIZE); - return (byte)((pb >>> pos) & PACKED_BYTE_MASK); - } - - Kind kind() { return Kind.values()[byteAt(0)]; } - private Transform(long packedBytes, byte[] fullBytes, LambdaForm result) { super(result); this.packedBytes = packedBytes; @@ -162,44 +153,39 @@ class LambdaFormEditor { assert((b & 0xFF) == b); // incoming value must fit in *unsigned* byte return (byte)b; } - private static byte bval(Kind k) { - return bval(k.ordinal()); - } - static Transform of(Kind k, int b1) { + static Transform of(byte k, int b1) { byte b0 = bval(k); if (inRange(b0 | b1)) return new Transform(packedBytes(b0, b1)); else return new Transform(fullBytes(b0, b1)); } - static Transform of(Kind k, int b1, int b2) { - byte b0 = (byte) k.ordinal(); + static Transform of(byte b0, int b1, int b2) { if (inRange(b0 | b1 | b2)) return new Transform(packedBytes(b0, b1, b2)); else return new Transform(fullBytes(b0, b1, b2)); } - static Transform of(Kind k, int b1, int b2, int b3) { - byte b0 = (byte) k.ordinal(); + static Transform of(byte b0, int b1, int b2, int b3) { if (inRange(b0 | b1 | b2 | b3)) return new Transform(packedBytes(b0, b1, b2, b3)); else return new Transform(fullBytes(b0, b1, b2, b3)); } private static final byte[] NO_BYTES = {}; - static Transform of(Kind k, int... b123) { - return ofBothArrays(k, b123, NO_BYTES); + static Transform of(byte kind, int... b123) { + return ofBothArrays(kind, b123, NO_BYTES); } - static Transform of(Kind k, int b1, byte[] b234) { - return ofBothArrays(k, new int[]{ b1 }, b234); + static Transform of(byte kind, int b1, byte[] b234) { + return ofBothArrays(kind, new int[]{ b1 }, b234); } - static Transform of(Kind k, int b1, int b2, byte[] b345) { - return ofBothArrays(k, new int[]{ b1, b2 }, b345); + static Transform of(byte kind, int b1, int b2, byte[] b345) { + return ofBothArrays(kind, new int[]{ b1, b2 }, b345); } - private static Transform ofBothArrays(Kind k, int[] b123, byte[] b456) { + private static Transform ofBothArrays(byte kind, int[] b123, byte[] b456) { byte[] fullBytes = new byte[1 + b123.length + b456.length]; int i = 0; - fullBytes[i++] = bval(k); + fullBytes[i++] = bval(kind); for (int bv : b123) { fullBytes[i++] = bval(bv); } @@ -449,7 +435,7 @@ class LambdaFormEditor { // Each editing method can (potentially) cache the edited LF so that it can be reused later. LambdaForm bindArgumentForm(int pos) { - Transform key = Transform.of(Transform.Kind.BIND_ARG, pos); + Transform key = Transform.of(Transform.BIND_ARG, pos); LambdaForm form = getInCache(key); if (form != null) { assert(form.parameterConstraint(0) == newSpeciesData(lambdaForm.parameterType(pos))); @@ -484,7 +470,7 @@ class LambdaFormEditor { } LambdaForm addArgumentForm(int pos, BasicType type) { - Transform key = Transform.of(Transform.Kind.ADD_ARG, pos, type.ordinal()); + Transform key = Transform.of(Transform.ADD_ARG, pos, type.ordinal()); LambdaForm form = getInCache(key); if (form != null) { assert(form.arity == lambdaForm.arity+1); @@ -501,7 +487,7 @@ class LambdaFormEditor { } LambdaForm dupArgumentForm(int srcPos, int dstPos) { - Transform key = Transform.of(Transform.Kind.DUP_ARG, srcPos, dstPos); + Transform key = Transform.of(Transform.DUP_ARG, srcPos, dstPos); LambdaForm form = getInCache(key); if (form != null) { assert(form.arity == lambdaForm.arity-1); @@ -530,7 +516,7 @@ class LambdaFormEditor { elementTypeKey = TYPE_LIMIT + Wrapper.forPrimitiveType(elementType).ordinal(); } } - Transform key = Transform.of(Transform.Kind.SPREAD_ARGS, pos, elementTypeKey, arrayLength); + Transform key = Transform.of(Transform.SPREAD_ARGS, pos, elementTypeKey, arrayLength); LambdaForm form = getInCache(key); if (form != null) { assert(form.arity == lambdaForm.arity - arrayLength + 1); @@ -569,9 +555,9 @@ class LambdaFormEditor { return filterArgumentForm(pos, basicType(collectorType.parameterType(0))); } byte[] newTypes = BasicType.basicTypesOrd(collectorType.parameterArray()); - Transform.Kind kind = (dropResult - ? Transform.Kind.COLLECT_ARGS_TO_VOID - : Transform.Kind.COLLECT_ARGS); + byte kind = (dropResult + ? Transform.COLLECT_ARGS_TO_VOID + : Transform.COLLECT_ARGS); if (dropResult && collectorArity == 0) pos = 1; // pure side effect Transform key = Transform.of(kind, pos, collectorArity, newTypes); LambdaForm form = getInCache(key); @@ -598,7 +584,7 @@ class LambdaFormEditor { argTypeKey = TYPE_LIMIT + Wrapper.forPrimitiveType(elementType).ordinal(); } assert(collectorType.parameterList().equals(Collections.nCopies(collectorArity, elementType))); - Transform.Kind kind = Transform.Kind.COLLECT_ARGS_TO_ARRAY; + byte kind = Transform.COLLECT_ARGS_TO_ARRAY; Transform key = Transform.of(kind, pos, collectorArity, argTypeKey); LambdaForm form = getInCache(key); if (form != null) { @@ -634,7 +620,7 @@ class LambdaFormEditor { } LambdaForm filterArgumentForm(int pos, BasicType newType) { - Transform key = Transform.of(Transform.Kind.FILTER_ARG, pos, newType.ordinal()); + Transform key = Transform.of(Transform.FILTER_ARG, pos, newType.ordinal()); LambdaForm form = getInCache(key); if (form != null) { assert(form.arity == lambdaForm.arity); @@ -710,7 +696,7 @@ class LambdaFormEditor { } LambdaForm filterReturnForm(BasicType newType, boolean constantZero) { - Transform.Kind kind = (constantZero ? Transform.Kind.FILTER_RETURN_TO_ZERO : Transform.Kind.FILTER_RETURN); + byte kind = (constantZero ? Transform.FILTER_RETURN_TO_ZERO : Transform.FILTER_RETURN); Transform key = Transform.of(kind, newType.ordinal()); LambdaForm form = getInCache(key); if (form != null) { @@ -762,11 +748,11 @@ class LambdaFormEditor { LambdaForm foldArgumentsForm(int foldPos, boolean dropResult, MethodType combinerType) { int combinerArity = combinerType.parameterCount(); - Transform.Kind kind = (dropResult ? Transform.Kind.FOLD_ARGS_TO_VOID : Transform.Kind.FOLD_ARGS); + byte kind = (dropResult ? Transform.FOLD_ARGS_TO_VOID : Transform.FOLD_ARGS); Transform key = Transform.of(kind, foldPos, combinerArity); LambdaForm form = getInCache(key); if (form != null) { - assert(form.arity == lambdaForm.arity - (kind == Transform.Kind.FOLD_ARGS ? 1 : 0)); + assert(form.arity == lambdaForm.arity - (kind == Transform.FOLD_ARGS ? 1 : 0)); return form; } form = makeArgumentCombinationForm(foldPos, combinerType, true, dropResult); @@ -786,7 +772,7 @@ class LambdaFormEditor { } assert(skip + reorder.length == lambdaForm.arity); if (nullPerm) return lambdaForm; // do not bother to cache - Transform key = Transform.of(Transform.Kind.PERMUTE_ARGS, reorder); + Transform key = Transform.of(Transform.PERMUTE_ARGS, reorder); LambdaForm form = getInCache(key); if (form != null) { assert(form.arity == skip+inTypes) : form; @@ -855,7 +841,7 @@ class LambdaFormEditor { int[] desc = BasicType.basicTypeOrds(localTypes); desc = Arrays.copyOf(desc, desc.length + 1); desc[desc.length - 1] = pos; - Transform key = Transform.of(Transform.Kind.LOCAL_TYPES, desc); + Transform key = Transform.of(Transform.LOCAL_TYPES, desc); LambdaForm form = getInCache(key); if (form != null) { return form; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java index 3b56095d438..7deb1f7d81f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -1002,7 +1002,9 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; Collections.addAll(result, buf0); } } - result.addAll(Arrays.asList(buf).subList(0, bufCount)); + for (int i = 0; i < bufCount; i++) { + result.add(buf[i]); + } // Signature matching is not the same as type matching, since // one signature might correspond to several types. // So if matchType is a Class or MethodType, refilter the results. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 60077a889b0..3163cdee24e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -3115,7 +3115,7 @@ assert((int)twice.invokeExact(21) == 42); return dropArguments(zero(type.returnType()), 0, type.parameterList()); } - private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.values().length]; + private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.COUNT]; private static MethodHandle makeIdentity(Class ptype) { MethodType mtype = methodType(ptype, ptype); LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype)); @@ -3133,7 +3133,7 @@ assert((int)twice.invokeExact(21) == 42); assert(btw == Wrapper.OBJECT); return makeZero(rtype); } - private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.values().length]; + private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.COUNT]; private static MethodHandle makeZero(Class rtype) { MethodType mtype = methodType(rtype); LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype)); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java index 4702bd55ba4..fcacf1b04ea 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java @@ -281,8 +281,7 @@ public final class StringConcatFactory { if (c == TAG_CONST) { Object cnst = constants[constC++]; el.add(new RecipeElement(cnst)); - } - if (c == TAG_ARG) { + } else if (c == TAG_ARG) { el.add(new RecipeElement(argC++)); } } else { @@ -322,32 +321,30 @@ public final class StringConcatFactory { private static final class RecipeElement { private final Object value; private final int argPos; - private final Tag tag; public RecipeElement(Object cnst) { this.value = Objects.requireNonNull(cnst); this.argPos = -1; - this.tag = Tag.CONST; } public RecipeElement(int arg) { this.value = null; + assert (arg >= 0); this.argPos = arg; - this.tag = Tag.ARG; } public Object getValue() { - assert (tag == Tag.CONST); + assert (isConst()); return value; } public int getArgPos() { - assert (tag == Tag.ARG); + assert (!isConst()); return argPos; } - public Tag getTag() { - return tag; + public boolean isConst() { + return argPos == -1; } @Override @@ -357,22 +354,19 @@ public final class StringConcatFactory { RecipeElement that = (RecipeElement) o; - if (tag != that.tag) return false; - if (tag == Tag.CONST && (!value.equals(that.value))) return false; - if (tag == Tag.ARG && (argPos != that.argPos)) return false; + boolean isConst = isConst(); + if (isConst != that.isConst()) return false; + if (isConst && (!value.equals(that.value))) return false; + if (!isConst && (argPos != that.argPos)) return false; return true; } @Override public int hashCode() { - return tag.hashCode(); + return argPos; } } - private enum Tag { - CONST, ARG - } - /** * Facilitates the creation of optimized String concatenation methods, that * can be used to efficiently concatenate a known number of arguments of @@ -880,31 +874,24 @@ public final class StringConcatFactory { int off = 0; for (RecipeElement el : recipe.getElements()) { - switch (el.getTag()) { - case CONST: { - // Guaranteed non-null, no null check required. - break; + if (el.isConst()) { + // Guaranteed non-null, no null check required. + } else { + // Null-checks are needed only for String arguments, and when a previous stage + // did not do implicit null-checks. If a String is null, we eagerly replace it + // with "null" constant. Note, we omit Objects here, because we don't call + // .length() on them down below. + int ac = el.getArgPos(); + Class cl = arr[ac]; + if (cl == String.class && !guaranteedNonNull[ac]) { + Label l0 = new Label(); + mv.visitIntInsn(ALOAD, off); + mv.visitJumpInsn(IFNONNULL, l0); + mv.visitLdcInsn("null"); + mv.visitIntInsn(ASTORE, off); + mv.visitLabel(l0); } - case ARG: { - // Null-checks are needed only for String arguments, and when a previous stage - // did not do implicit null-checks. If a String is null, we eagerly replace it - // with "null" constant. Note, we omit Objects here, because we don't call - // .length() on them down below. - int ac = el.getArgPos(); - Class cl = arr[ac]; - if (cl == String.class && !guaranteedNonNull[ac]) { - Label l0 = new Label(); - mv.visitIntInsn(ALOAD, off); - mv.visitJumpInsn(IFNONNULL, l0); - mv.visitLdcInsn("null"); - mv.visitIntInsn(ASTORE, off); - mv.visitLabel(l0); - } - off += getParameterSize(cl); - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); + off += getParameterSize(cl); } } } @@ -925,37 +912,30 @@ public final class StringConcatFactory { mv.visitInsn(ICONST_0); for (RecipeElement el : recipe.getElements()) { - switch (el.getTag()) { - case CONST: { - Object cnst = el.getValue(); - len += cnst.toString().length(); - break; + if (el.isConst()) { + Object cnst = el.getValue(); + len += cnst.toString().length(); + } else { + /* + If an argument is String, then we can call .length() on it. Sized/Exact modes have + converted arguments for us. If an argument is primitive, we can provide a guess + for its String representation size. + */ + Class cl = arr[el.getArgPos()]; + if (cl == String.class) { + mv.visitIntInsn(ALOAD, off); + mv.visitMethodInsn( + INVOKEVIRTUAL, + "java/lang/String", + "length", + "()I", + false + ); + mv.visitInsn(IADD); + } else if (cl.isPrimitive()) { + len += estimateSize(cl); } - case ARG: { - /* - If an argument is String, then we can call .length() on it. Sized/Exact modes have - converted arguments for us. If an argument is primitive, we can provide a guess - for its String representation size. - */ - Class cl = arr[el.getArgPos()]; - if (cl == String.class) { - mv.visitIntInsn(ALOAD, off); - mv.visitMethodInsn( - INVOKEVIRTUAL, - "java/lang/String", - "length", - "()I", - false - ); - mv.visitInsn(IADD); - } else if (cl.isPrimitive()) { - len += estimateSize(cl); - } - off += getParameterSize(cl); - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); + off += getParameterSize(cl); } } @@ -987,23 +967,17 @@ public final class StringConcatFactory { int off = 0; for (RecipeElement el : recipe.getElements()) { String desc; - switch (el.getTag()) { - case CONST: { - Object cnst = el.getValue(); - mv.visitLdcInsn(cnst); - desc = getSBAppendDesc(cnst.getClass()); - break; - } - case ARG: { - Class cl = arr[el.getArgPos()]; - mv.visitVarInsn(getLoadOpcode(cl), off); - off += getParameterSize(cl); - desc = getSBAppendDesc(cl); - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); + if (el.isConst()) { + Object cnst = el.getValue(); + mv.visitLdcInsn(cnst); + desc = getSBAppendDesc(cnst.getClass()); + } else { + Class cl = arr[el.getArgPos()]; + mv.visitVarInsn(getLoadOpcode(cl), off); + off += getParameterSize(cl); + desc = getSBAppendDesc(cl); } + mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/StringBuilder", @@ -1279,26 +1253,19 @@ public final class StringConcatFactory { // call the usual String.length(). Primitive values string sizes can be estimated. int initial = 0; for (RecipeElement el : recipe.getElements()) { - switch (el.getTag()) { - case CONST: { - Object cnst = el.getValue(); - initial += cnst.toString().length(); - break; + if (el.isConst()) { + Object cnst = el.getValue(); + initial += cnst.toString().length(); + } else { + final int i = el.getArgPos(); + Class type = ptypesList.get(i); + if (type.isPrimitive()) { + MethodHandle est = MethodHandles.constant(int.class, estimateSize(type)); + est = MethodHandles.dropArguments(est, 0, type); + lengthers[i] = est; + } else { + lengthers[i] = STRING_LENGTH; } - case ARG: { - final int i = el.getArgPos(); - Class type = ptypesList.get(i); - if (type.isPrimitive()) { - MethodHandle est = MethodHandles.constant(int.class, estimateSize(type)); - est = MethodHandles.dropArguments(est, 0, type); - lengthers[i] = est; - } else { - lengthers[i] = STRING_LENGTH; - } - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); } } @@ -1311,26 +1278,19 @@ public final class StringConcatFactory { for (int i = elements.size() - 1; i >= 0; i--) { RecipeElement el = elements.get(i); MethodHandle appender; - switch (el.getTag()) { - case CONST: { - Object constant = el.getValue(); - MethodHandle mh = appender(adaptToStringBuilder(constant.getClass())); - appender = MethodHandles.insertArguments(mh, 1, constant); - break; - } - case ARG: { - int ac = el.getArgPos(); - appender = appender(ptypesList.get(ac)); + if (el.isConst()) { + Object constant = el.getValue(); + MethodHandle mh = appender(adaptToStringBuilder(constant.getClass())); + appender = MethodHandles.insertArguments(mh, 1, constant); + } else { + int ac = el.getArgPos(); + appender = appender(ptypesList.get(ac)); - // Insert dummy arguments to match the prefix in the signature. - // The actual appender argument will be the ac-ith argument. - if (ac != 0) { - appender = MethodHandles.dropArguments(appender, 1, ptypesList.subList(0, ac)); - } - break; + // Insert dummy arguments to match the prefix in the signature. + // The actual appender argument will be the ac-ith argument. + if (ac != 0) { + appender = MethodHandles.dropArguments(appender, 1, ptypesList.subList(0, ac)); } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); } builder = MethodHandles.foldArguments(builder, appender); } @@ -1521,19 +1481,12 @@ public final class StringConcatFactory { // *ending* index. for (RecipeElement el : recipe.getElements()) { MethodHandle prepender; - switch (el.getTag()) { - case CONST: { - Object cnst = el.getValue(); - prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst); - break; - } - case ARG: { - int pos = el.getArgPos(); - prepender = selectArgument(prepender(ptypesList.get(pos)), 3, ptypesList, pos); - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); + if (el.isConst()) { + Object cnst = el.getValue(); + prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst); + } else { + int pos = el.getArgPos(); + prepender = selectArgument(prepender(ptypesList.get(pos)), 3, ptypesList, pos); } // Remove "old" index from arguments @@ -1573,43 +1526,36 @@ public final class StringConcatFactory { byte initialCoder = INITIAL_CODER; int initialLen = 0; // initial length, in characters for (RecipeElement el : recipe.getElements()) { - switch (el.getTag()) { - case CONST: { - Object constant = el.getValue(); - String s = constant.toString(); - initialCoder = (byte) coderMixer(String.class).invoke(initialCoder, s); - initialLen += s.length(); - break; - } - case ARG: { - int ac = el.getArgPos(); + if (el.isConst()) { + Object constant = el.getValue(); + String s = constant.toString(); + initialCoder = (byte) coderMixer(String.class).invoke(initialCoder, s); + initialLen += s.length(); + } else { + int ac = el.getArgPos(); - Class argClass = ptypesList.get(ac); - MethodHandle lm = selectArgument(lengthMixer(argClass), 1, ptypesList, ac); - lm = MethodHandles.dropArguments(lm, 0, byte.class); // (*) - lm = MethodHandles.dropArguments(lm, 2, byte.class); + Class argClass = ptypesList.get(ac); + MethodHandle lm = selectArgument(lengthMixer(argClass), 1, ptypesList, ac); + lm = MethodHandles.dropArguments(lm, 0, byte.class); // (*) + lm = MethodHandles.dropArguments(lm, 2, byte.class); - MethodHandle cm = selectArgument(coderMixer(argClass), 1, ptypesList, ac); - cm = MethodHandles.dropArguments(cm, 0, int.class); // (**) + MethodHandle cm = selectArgument(coderMixer(argClass), 1, ptypesList, ac); + cm = MethodHandles.dropArguments(cm, 0, int.class); // (**) - // Read this bottom up: + // Read this bottom up: - // 4. Drop old index and coder, producing ("new-index", "new-coder", ) - mh = MethodHandles.dropArguments(mh, 2, int.class, byte.class); + // 4. Drop old index and coder, producing ("new-index", "new-coder", ) + mh = MethodHandles.dropArguments(mh, 2, int.class, byte.class); - // 3. Compute "new-index", producing ("new-index", "new-coder", "old-index", "old-coder", ) - // Length mixer ignores both "new-coder" and "old-coder" due to dropArguments above (*) - mh = MethodHandles.foldArguments(mh, lm); + // 3. Compute "new-index", producing ("new-index", "new-coder", "old-index", "old-coder", ) + // Length mixer ignores both "new-coder" and "old-coder" due to dropArguments above (*) + mh = MethodHandles.foldArguments(mh, lm); - // 2. Compute "new-coder", producing ("new-coder", "old-index", "old-coder", ) - // Coder mixer ignores the "old-index" arg due to dropArguments above (**) - mh = MethodHandles.foldArguments(mh, cm); + // 2. Compute "new-coder", producing ("new-coder", "old-index", "old-coder", ) + // Coder mixer ignores the "old-index" arg due to dropArguments above (**) + mh = MethodHandles.foldArguments(mh, cm); - // 1. The mh shape here is ("old-index", "old-coder", ) - break; - } - default: - throw new StringConcatException("Unhandled tag: " + el.getTag()); + // 1. The mh shape here is ("old-index", "old-coder", ) } } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java b/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java index 38892d07f2a..1724d827cd1 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java @@ -38,7 +38,7 @@ class TypeConvertingMethodAdapter extends MethodVisitor { super(Opcodes.ASM5, mv); } - private static final int NUM_WRAPPERS = Wrapper.values().length; + private static final int NUM_WRAPPERS = Wrapper.COUNT; private static final String NAME_OBJECT = "java/lang/Object"; private static final String WRAPPER_PREFIX = "Ljava/lang/"; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index f8f60c3962a..5e71204b6d0 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -1057,57 +1057,11 @@ public abstract class VarHandle { Object addAndGet(Object... args); enum AccessType { - GET(Object.class) { - @Override - MethodType accessModeType(Class receiver, Class value, - Class... intermediate) { - Class[] ps = allocateParameters(0, receiver, intermediate); - fillParameters(ps, receiver, intermediate); - return MethodType.methodType(value, ps); - } - }, - SET(void.class) { - @Override - MethodType accessModeType(Class receiver, Class value, - Class... intermediate) { - Class[] ps = allocateParameters(1, receiver, intermediate); - int i = fillParameters(ps, receiver, intermediate); - ps[i] = value; - return MethodType.methodType(void.class, ps); - } - }, - COMPARE_AND_SWAP(boolean.class) { - @Override - MethodType accessModeType(Class receiver, Class value, - Class... intermediate) { - Class[] ps = allocateParameters(2, receiver, intermediate); - int i = fillParameters(ps, receiver, intermediate); - ps[i++] = value; - ps[i] = value; - return MethodType.methodType(boolean.class, ps); - } - }, - COMPARE_AND_EXCHANGE(Object.class) { - @Override - MethodType accessModeType(Class receiver, Class value, - Class... intermediate) { - Class[] ps = allocateParameters(2, receiver, intermediate); - int i = fillParameters(ps, receiver, intermediate); - ps[i++] = value; - ps[i] = value; - return MethodType.methodType(value, ps); - } - }, - GET_AND_UPDATE(Object.class) { - @Override - MethodType accessModeType(Class receiver, Class value, - Class... intermediate) { - Class[] ps = allocateParameters(1, receiver, intermediate); - int i = fillParameters(ps, receiver, intermediate); - ps[i] = value; - return MethodType.methodType(value, ps); - } - }; + GET(Object.class), + SET(void.class), + COMPARE_AND_SWAP(boolean.class), + COMPARE_AND_EXCHANGE(Object.class), + GET_AND_UPDATE(Object.class); final Class returnType; final boolean isMonomorphicInReturnType; @@ -1117,8 +1071,41 @@ public abstract class VarHandle { isMonomorphicInReturnType = returnType != Object.class; } - abstract MethodType accessModeType(Class receiver, Class value, - Class... intermediate); + MethodType accessModeType(Class receiver, Class value, + Class... intermediate) { + Class[] ps; + int i; + switch (this) { + case GET: + ps = allocateParameters(0, receiver, intermediate); + fillParameters(ps, receiver, intermediate); + return MethodType.methodType(value, ps); + case SET: + ps = allocateParameters(1, receiver, intermediate); + i = fillParameters(ps, receiver, intermediate); + ps[i] = value; + return MethodType.methodType(void.class, ps); + case COMPARE_AND_SWAP: + ps = allocateParameters(2, receiver, intermediate); + i = fillParameters(ps, receiver, intermediate); + ps[i++] = value; + ps[i] = value; + return MethodType.methodType(boolean.class, ps); + case COMPARE_AND_EXCHANGE: + ps = allocateParameters(2, receiver, intermediate); + i = fillParameters(ps, receiver, intermediate); + ps[i++] = value; + ps[i] = value; + return MethodType.methodType(value, ps); + case GET_AND_UPDATE: + ps = allocateParameters(1, receiver, intermediate); + i = fillParameters(ps, receiver, intermediate); + ps[i] = value; + return MethodType.methodType(value, ps); + default: + throw new InternalError("Unknown AccessType"); + } + } private static Class[] allocateParameters(int values, Class receiver, Class... intermediate) { diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java b/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java index 52ca7026c05..1a9580dcc14 100644 --- a/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java +++ b/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java @@ -29,27 +29,32 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodType; -import java.util.EnumMap; +import jdk.internal.vm.annotation.Stable; public class ValueConversions { private static final Class THIS_CLASS = ValueConversions.class; private static final Lookup IMPL_LOOKUP = MethodHandles.lookup(); - /** Thread-safe canonicalized mapping from Wrapper to MethodHandle + /** + * Thread-safe canonicalized mapping from Wrapper to MethodHandle * with unsynchronized reads and synchronized writes. - * It's safe to publish MethodHandles by data race because they are immutable. */ + * It's safe to publish MethodHandles by data race because they are immutable. + */ private static class WrapperCache { - /** EnumMap uses preconstructed array internally, which is constant during it's lifetime. */ - private final EnumMap map = new EnumMap<>(Wrapper.class); + @Stable + private final MethodHandle[] map = new MethodHandle[Wrapper.COUNT]; public MethodHandle get(Wrapper w) { - return map.get(w); + return map[w.ordinal()]; } public synchronized MethodHandle put(final Wrapper w, final MethodHandle mh) { - // Simulate CAS to avoid racy duplication - MethodHandle prev = map.putIfAbsent(w, mh); - if (prev != null) return prev; - return mh; + MethodHandle prev = map[w.ordinal()]; + if (prev != null) { + return prev; + } else { + map[w.ordinal()] = mh; + return mh; + } } } @@ -623,7 +628,7 @@ public class ValueConversions { return (x ? (byte)1 : (byte)0); } - private static final WrapperCache[] CONVERT_PRIMITIVE_FUNCTIONS = newWrapperCaches(Wrapper.values().length); + private static final WrapperCache[] CONVERT_PRIMITIVE_FUNCTIONS = newWrapperCaches(Wrapper.COUNT); public static MethodHandle convertPrimitive(Wrapper wsrc, Wrapper wdst) { WrapperCache cache = CONVERT_PRIMITIVE_FUNCTIONS[wsrc.ordinal()]; diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java index a6054924ff5..f22eda0ea45 100644 --- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java +++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java @@ -42,6 +42,8 @@ public enum Wrapper { VOID ( Void.class, void.class, 'V', null, Format.other( 0)), ; + public static final int COUNT = 10; + private final Class wrapperType; private final Class primitiveType; private final char basicTypeChar; @@ -160,7 +162,10 @@ public enum Wrapper { return true; } - static { assert(checkConvertibleFrom()); } + static { + assert(checkConvertibleFrom()); + assert(COUNT == Wrapper.values().length); + } private static boolean checkConvertibleFrom() { // Check the matrix for correct classification of widening conversions. for (Wrapper w : values()) { From 0e13ad60ad0cb31467f20f0c1cea3a481f152ee0 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Wed, 10 Aug 2016 17:55:08 +0200 Subject: [PATCH 14/66] 8163408: Fix wrong prototype of getNativeScaleFactor() in systemScale.h Reviewed-by: serb --- .../unix/native/common/awt/systemscale/systemScale.h | 2 +- .../java.desktop/unix/native/libsplashscreen/splashscreen_sys.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h index 697a8bd33d3..b9c2b4f3f65 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h @@ -26,7 +26,7 @@ #include #include -double getNativeScaleFactor(); +double getNativeScaleFactor(char *output_name); #endif diff --git a/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c b/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c index 11b979f4264..30739f03a4e 100644 --- a/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c +++ b/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c @@ -806,7 +806,7 @@ SplashGetScaledImageName(const char* jarName, const char* fileName, #ifndef __linux__ return JNI_FALSE; #endif - *scaleFactor = getNativeScaleFactor(); + *scaleFactor = getNativeScaleFactor(NULL); if (*scaleFactor == 2.0) { size_t length = 0; char *stringToAppend = ".java-scale2x"; From 54130ef8d323b2495b50a412cadce2891aaa97af Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Wed, 10 Aug 2016 09:21:58 -0700 Subject: [PATCH 15/66] 8134304: NPE in initialization of OptimisticTypesPersistence Reviewed-by: hannesw, jlaskey, mhaupt --- .../internal/codegen/OptimisticTypesPersistence.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java index 0301f46dfe6..b793a68d6f9 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -324,6 +324,8 @@ public final class OptimisticTypesPersistence { } versionDir.mkdirs(); if (versionDir.isDirectory()) { + //FIXME:Logger is disabled as Context.getContext() always returns null here because global scope object will not be created + //by the time this method gets invoked getLogger().info("Optimistic type persistence directory is " + versionDir); return versionDir; } @@ -450,10 +452,12 @@ public final class OptimisticTypesPersistence { private static DebugLogger getLogger() { try { return Context.getContext().getLogger(RecompilableScriptFunctionData.class); + } catch (final NullPointerException e) { + //Don't print stacktrace until we revisit this, NPE is a known issue here } catch (final Exception e) { e.printStackTrace(); - return DebugLogger.DISABLED_LOGGER; } + return DebugLogger.DISABLED_LOGGER; } private static void scheduleCleanup() { From a2f7c1568c6cbd4291c7c76253ed5bc22437afda Mon Sep 17 00:00:00 2001 From: Robert Field Date: Wed, 10 Aug 2016 10:47:43 -0700 Subject: [PATCH 16/66] 8163500: JShell: ProblemList.txt update: 8139872 and 8080843 fixed Reviewed-by: jlahoda --- langtools/test/ProblemList.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index f54ea86a7f1..e2f9fcfe039 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -54,8 +54,6 @@ jdk/javadoc/tool/varArgs/Main.java # # jshell -jdk/jshell/EditorPadTest.java 8139872 generic-all test requires a non-headless environment -jdk/jshell/ExternalEditorTest.java 8080843 generic-all invalid key error occurs when external editor is used. jdk/jshell/ToolBasicTest.java 8139873 generic-all JShell tests failing ########################################################################### From 73b11dc1d0806b7b67c1d24195198329b0ceb791 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 10 Aug 2016 21:55:25 +0200 Subject: [PATCH 17/66] 8163373: Rewrite GenerateJLIClassesPlugin to avoid reflective calls into java.lang.invoke Reviewed-by: vlivanov, mchung --- .../java/lang/invoke/BoundMethodHandle.java | 21 +---------- .../java/lang/invoke/DirectMethodHandle.java | 16 +------- .../lang/invoke/InvokerBytecodeGenerator.java | 32 ++-------------- .../classes/java/lang/invoke/MemberName.java | 26 ------------- .../java/lang/invoke/MethodHandleImpl.java | 36 ++++++++++++++++++ .../internal/misc/JavaLangInvokeAccess.java | 29 +++++++++++++-- .../jdk/internal/misc/SharedSecrets.java | 2 +- .../plugins/GenerateJLIClassesPlugin.java | 37 +++++-------------- 8 files changed, 78 insertions(+), 121 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java index a5db25507cb..16f0970a4c5 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -587,26 +587,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; return bmhClass; } - /** - * @implNote this method is used by GenerateBMHClassesPlugin to enable - * ahead-of-time generation of BMH classes at link time. It does - * added validation since this string may be user provided. - */ - static Map.Entry generateConcreteBMHClassBytes( - final String types) { - for (char c : types.toCharArray()) { - if ("LIJFD".indexOf(c) < 0) { - throw new IllegalArgumentException("All characters must " - + "correspond to a basic field type: LIJFD"); - } - } - String shortTypes = LambdaForm.shortenSignature(types); - final String className = speciesInternalClassName(shortTypes); - return Map.entry(className, - generateConcreteBMHClassBytes(shortTypes, types, className)); - } - - private static String speciesInternalClassName(String shortTypes) { + static String speciesInternalClassName(String shortTypes) { return SPECIES_PREFIX_PATH + shortTypes; } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index 17bf2d9c5e7..bf00ab7f55a 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -186,7 +186,7 @@ class DirectMethodHandle extends MethodHandle { return mtype.form().setCachedLambdaForm(which, lform); } - private static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) { + static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) { boolean needsInit = (which == LF_INVSTATIC_INIT); boolean doesAlloc = (which == LF_NEWINVSPECIAL); String linkerName, lambdaName; @@ -248,20 +248,6 @@ class DirectMethodHandle extends MethodHandle { return lform; } - /* - * NOTE: This method acts as an API hook for use by the - * GenerateJLIClassesPlugin to generate a class wrapping DirectMethodHandle - * methods for an array of method types. - */ - static byte[] generateDMHClassBytes(String className, MethodType[] methodTypes, int[] types) { - LambdaForm[] forms = new LambdaForm[methodTypes.length]; - for (int i = 0; i < forms.length; i++) { - forms[i] = makePreparedLambdaForm(methodTypes[i], types[i]); - methodTypes[i] = forms[i].methodType(); - } - return InvokerBytecodeGenerator.generateCodeBytesForMultiple(className, forms, methodTypes); - } - static Object findDirectMethodHandle(Name name) { if (name.function == NF_internalMemberName || name.function == NF_internalMemberNameEnsureInit || diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 507bcdb4c61..46f29fd6fb8 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -70,7 +70,7 @@ class InvokerBytecodeGenerator { private static final String LLV_SIG = "(L" + OBJ + ";L" + OBJ + ";)V"; /** Name of its super class*/ - private static final String INVOKER_SUPER_NAME = OBJ; + static final String INVOKER_SUPER_NAME = OBJ; /** Name of new class */ private final String className; @@ -124,7 +124,7 @@ class InvokerBytecodeGenerator { } /** For generating customized code for a single LambdaForm. */ - private InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) { + InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) { this(form, form.names.length, className, form.debugName, invokerType); // Create an array to map name indexes to locals indexes. @@ -655,35 +655,11 @@ class InvokerBytecodeGenerator { return classFile; } - /* - * NOTE: This is used from GenerateJLIClassesPlugin via - * DirectMethodHandle::generateDMHClassBytes. - * - * Generate customized code for a set of LambdaForms of specified types into - * a class with a specified name. - */ - static byte[] generateCodeBytesForMultiple(String className, - LambdaForm[] forms, MethodType[] types) { - assert(forms.length == types.length); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); - cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, - className, null, INVOKER_SUPER_NAME, null); - cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null); - for (int i = 0; i < forms.length; i++) { - InvokerBytecodeGenerator g - = new InvokerBytecodeGenerator(className, forms[i], types[i]); - g.setClassWriter(cw); - g.addMethod(); - } - return cw.toByteArray(); - } - - private void setClassWriter(ClassWriter cw) { + void setClassWriter(ClassWriter cw) { this.cw = cw; } - private void addMethod() { + void addMethod() { methodPrologue(); // Suppress this method in backtraces displayed to the user. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java index 7deb1f7d81f..a0a1465cbac 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -25,8 +25,6 @@ package java.lang.invoke; -import jdk.internal.misc.JavaLangInvokeAccess; -import jdk.internal.misc.SharedSecrets; import sun.invoke.util.BytecodeDescriptor; import sun.invoke.util.VerifyAccess; @@ -37,7 +35,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Module; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -1152,27 +1149,4 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; return buf; } } - - static { - // StackFrameInfo stores Member and this provides the shared secrets - // for stack walker to access MemberName information. - SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() { - @Override - public Object newMemberName() { - return new MemberName(); - } - - @Override - public String getName(Object mname) { - MemberName memberName = (MemberName)mname; - return memberName.getName(); - } - - @Override - public boolean isNative(Object mname) { - MemberName memberName = (MemberName)mname; - return memberName.isNative(); - } - }); - } } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 6702a89f0ce..1d4b3115aa1 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -25,6 +25,8 @@ package java.lang.invoke; +import jdk.internal.misc.JavaLangInvokeAccess; +import jdk.internal.misc.SharedSecrets; import jdk.internal.org.objectweb.asm.AnnotationVisitor; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; @@ -44,6 +46,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.stream.Stream; @@ -1710,6 +1713,39 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; } catch (ReflectiveOperationException ex) { throw newInternalError(ex); } + + SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() { + @Override + public Object newMemberName() { + return new MemberName(); + } + + @Override + public String getName(Object mname) { + MemberName memberName = (MemberName)mname; + return memberName.getName(); + } + + @Override + public boolean isNative(Object mname) { + MemberName memberName = (MemberName)mname; + return memberName.isNative(); + } + + @Override + public byte[] generateDMHClassBytes(String className, + MethodType[] methodTypes, int[] types) { + return GenerateJLIClassesHelper + .generateDMHClassBytes(className, methodTypes, types); + } + + @Override + public Map.Entry generateConcreteBMHClassBytes( + final String types) { + return GenerateJLIClassesHelper + .generateConcreteBMHClassBytes(types); + } + }); } /** Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore(). */ diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java index 5e2c4d28e93..e514e5c95c0 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java @@ -25,19 +25,42 @@ package jdk.internal.misc; +import java.lang.invoke.MethodType; +import java.util.Map; + public interface JavaLangInvokeAccess { /** - * Create a new MemberName instance + * Create a new MemberName instance. Used by {@see StackFrameInfo}. */ Object newMemberName(); /** - * Returns the name for the given MemberName + * Returns the name for the given MemberName. Used by {@see StackFrameInfo}. */ String getName(Object mname); /** - * Returns {@code true} if the given MemberName is a native method + * Returns {@code true} if the given MemberName is a native method. Used by + * {@see StackFrameInfo}. */ boolean isNative(Object mname); + + /** + * Returns a {@code byte[]} containing the bytecode for a class implementing + * DirectMethodHandle of each pairwise combination of {@code MethodType} and + * an {@code int} representing method type. Used by + * GenerateJLIClassesPlugin to generate such a class during the jlink phase. + */ + byte[] generateDMHClassBytes(String className, MethodType[] methodTypes, + int[] types); + + /** + * Returns a {@code byte[]} containing the bytecode for a BoundMethodHandle + * species class implementing the signature defined by {@code types}. Used + * by GenerateBMHClassesPlugin to enable generation of such classes during + * the jlink phase. Should do some added validation since this string may be + * user provided. + */ + Map.Entry generateConcreteBMHClassBytes( + final String types); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index 5e3fb126b58..fed1b694548 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java @@ -95,7 +95,7 @@ public class SharedSecrets { public static JavaLangInvokeAccess getJavaLangInvokeAccess() { if (javaLangInvokeAccess == null) { try { - Class c = Class.forName("java.lang.invoke.MemberName"); + Class c = Class.forName("java.lang.invoke.MethodHandleImpl"); unsafe.ensureClassInitialized(c); } catch (ClassNotFoundException e) {}; } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index c50860aa517..1697e988b53 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -25,7 +25,6 @@ package jdk.tools.jlink.internal.plugins; import java.lang.invoke.MethodType; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; @@ -33,6 +32,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import jdk.internal.misc.SharedSecrets; +import jdk.internal.misc.JavaLangInvokeAccess; import jdk.tools.jlink.plugin.ResourcePoolEntry; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ResourcePool; @@ -54,9 +55,6 @@ public final class GenerateJLIClassesPlugin implements Plugin { private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME); - private static final String BMH = "java/lang/invoke/BoundMethodHandle"; - private static final Method BMH_FACTORY_METHOD; - private static final String DMH = "java/lang/invoke/DirectMethodHandle$Holder"; private static final String DMH_INVOKE_VIRTUAL = "invokeVirtual"; private static final String DMH_INVOKE_STATIC = "invokeStatic"; @@ -64,7 +62,9 @@ public final class GenerateJLIClassesPlugin implements Plugin { private static final String DMH_NEW_INVOKE_SPECIAL = "newInvokeSpecial"; private static final String DMH_INVOKE_INTERFACE = "invokeInterface"; private static final String DMH_INVOKE_STATIC_INIT = "invokeStaticInit"; - private static final Method DMH_FACTORY_METHOD; + + private static final JavaLangInvokeAccess JLIA + = SharedSecrets.getJavaLangInvokeAccess(); List speciesTypes; @@ -232,8 +232,8 @@ public final class GenerateJLIClassesPlugin implements Plugin { private void generateBMHClass(String types, ResourcePoolBuilder out) { try { // Generate class - Map.Entry result = (Map.Entry) - BMH_FACTORY_METHOD.invoke(null, types); + Map.Entry result = + JLIA.generateConcreteBMHClassBytes(types); String className = result.getKey(); byte[] bytes = result.getValue(); @@ -264,11 +264,8 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } try { - byte[] bytes = (byte[])DMH_FACTORY_METHOD - .invoke(null, - DMH, - methodTypes, - dmhTypes); + byte[] bytes = + JLIA.generateDMHClassBytes(DMH, methodTypes, dmhTypes); ResourcePoolEntry ndata = ResourcePoolEntry.create(DMH_ENTRY, bytes); out.add(ndata); } catch (Exception ex) { @@ -277,22 +274,6 @@ public final class GenerateJLIClassesPlugin implements Plugin { } private static final String DMH_ENTRY = "/java.base/" + DMH + ".class"; - static { - try { - Class BMHFactory = Class.forName("java.lang.invoke.BoundMethodHandle$Factory"); - BMH_FACTORY_METHOD = BMHFactory.getDeclaredMethod("generateConcreteBMHClassBytes", - String.class); - BMH_FACTORY_METHOD.setAccessible(true); - - Class DMHFactory = Class.forName("java.lang.invoke.DirectMethodHandle"); - DMH_FACTORY_METHOD = DMHFactory.getDeclaredMethod("generateDMHClassBytes", - String.class, MethodType[].class, int[].class); - DMH_FACTORY_METHOD.setAccessible(true); - } catch (Exception e) { - throw new PluginException(e); - } - } - // Convert LL -> LL, L3 -> LLL private static String expandSignature(String signature) { StringBuilder sb = new StringBuilder(); From 855893cb3b2b74468839a0cd307f157382615df2 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 10 Aug 2016 22:49:05 +0200 Subject: [PATCH 18/66] 8163814: JDK build has been failing after 8163373 Reviewed-by: mchung --- .../lang/invoke/GenerateJLIClassesHelper.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java b/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java new file mode 100644 index 00000000000..5edf33c8c60 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016, 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 java.lang.invoke; + +import java.util.Map; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Opcodes; + +/** + * Helper class to assist the GenerateJLIClassesPlugin to get access to + * generate classes ahead of time. + */ +class GenerateJLIClassesHelper { + + static byte[] generateDMHClassBytes(String className, + MethodType[] methodTypes, int[] types) { + LambdaForm[] forms = new LambdaForm[methodTypes.length]; + for (int i = 0; i < forms.length; i++) { + forms[i] = DirectMethodHandle.makePreparedLambdaForm(methodTypes[i], + types[i]); + methodTypes[i] = forms[i].methodType(); + } + return generateCodeBytesForLFs(className, forms, methodTypes); + } + + /* + * Generate customized code for a set of LambdaForms of specified types into + * a class with a specified name. + */ + private static byte[] generateCodeBytesForLFs(String className, + LambdaForm[] forms, MethodType[] types) { + assert(forms.length == types.length); + + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, + className, null, InvokerBytecodeGenerator.INVOKER_SUPER_NAME, null); + cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null); + for (int i = 0; i < forms.length; i++) { + InvokerBytecodeGenerator g + = new InvokerBytecodeGenerator(className, forms[i], types[i]); + g.setClassWriter(cw); + g.addMethod(); + } + return cw.toByteArray(); + } + + static Map.Entry generateConcreteBMHClassBytes( + final String types) { + for (char c : types.toCharArray()) { + if ("LIJFD".indexOf(c) < 0) { + throw new IllegalArgumentException("All characters must " + + "correspond to a basic field type: LIJFD"); + } + } + String shortTypes = LambdaForm.shortenSignature(types); + final String className = + BoundMethodHandle.Factory.speciesInternalClassName(shortTypes); + return Map.entry(className, + BoundMethodHandle.Factory.generateConcreteBMHClassBytes( + shortTypes, types, className)); + } +} From 3b8055916291b1f470139faa9038b74cafed6945 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 10 Aug 2016 13:52:02 -0700 Subject: [PATCH 19/66] 8160156: javac is generating let expressions unnecessarily Co-authored-by: Maurizio Cimadamore Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Lower.java | 41 +++++++- ...ressionsAreUnnecessarilyGeneratedTest.java | 98 +++++++++++++++++++ 2 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 langtools/test/tools/javac/T8160156/LetExpressionsAreUnnecessarilyGeneratedTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index f06a238b2b9..0333f735416 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -3184,11 +3184,13 @@ public class Lower extends TreeTranslator { } public void visitAssignop(final JCAssignOp tree) { - JCTree lhsAccess = access(TreeInfo.skipParens(tree.lhs)); final boolean boxingReq = !tree.lhs.type.isPrimitive() && tree.operator.type.getReturnType().isPrimitive(); - if (boxingReq || lhsAccess.hasTag(APPLY)) { + AssignopDependencyScanner depScanner = new AssignopDependencyScanner(tree); + depScanner.scan(tree.rhs); + + if (boxingReq || depScanner.dependencyFound) { // boxing required; need to rewrite as x = (unbox typeof x)(x op y); // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y) // (but without recomputing x) @@ -3238,6 +3240,41 @@ public class Lower extends TreeTranslator { } } + class AssignopDependencyScanner extends TreeScanner { + + Symbol sym; + boolean dependencyFound = false; + + AssignopDependencyScanner(JCAssignOp tree) { + this.sym = TreeInfo.symbol(tree.lhs); + } + + @Override + public void scan(JCTree tree) { + if (tree != null && sym != null) { + tree.accept(this); + } + } + + @Override + public void visitAssignop(JCAssignOp tree) { + if (TreeInfo.symbol(tree.lhs) == sym) { + dependencyFound = true; + return; + } + super.visitAssignop(tree); + } + + @Override + public void visitUnary(JCUnary tree) { + if (TreeInfo.symbol(tree.arg) == sym) { + dependencyFound = true; + return; + } + super.visitUnary(tree); + } + } + /** Lower a tree of the form e++ or e-- where e is an object type */ JCExpression lowerBoxedPostop(final JCUnary tree) { // translate to tmp1=lval(e); tmp2=tmp1; tmp1 OP 1; tmp2 diff --git a/langtools/test/tools/javac/T8160156/LetExpressionsAreUnnecessarilyGeneratedTest.java b/langtools/test/tools/javac/T8160156/LetExpressionsAreUnnecessarilyGeneratedTest.java new file mode 100644 index 00000000000..1b31c0e40b1 --- /dev/null +++ b/langtools/test/tools/javac/T8160156/LetExpressionsAreUnnecessarilyGeneratedTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/** + * @test 8160156 + * @summary javac is generating let expressions unnecessarily + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask + * @run main LetExpressionsAreUnnecessarilyGeneratedTest + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class LetExpressionsAreUnnecessarilyGeneratedTest extends TestRunner { + ToolBox tb; + + public static void main(String... args) throws Exception { + new LetExpressionsAreUnnecessarilyGeneratedTest().runTests(); + } + + public LetExpressionsAreUnnecessarilyGeneratedTest() { + super(System.err); + tb = new ToolBox(); + } + + protected void runTests() throws Exception { + runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + @Test + public void testDontGenerateLetExpr(Path testBase) throws Exception { + Path src = testBase.resolve("src"); + tb.writeJavaFiles(src, + "package base;\n" + + "public abstract class Base {\n" + + " protected int i = 1;\n" + + "}", + + "package sub;\n" + + "import base.Base;\n" + + "public class Sub extends Base {\n" + + " private int i = 4;\n" + + " void m() {\n" + + " new Runnable() {\n" + + " public void run() {\n" + + " Sub.super.i += 10;\n" + + " }\n" + + " };\n" + + " }\n" + + "}"); + + Path out = testBase.resolve("out"); + Files.createDirectories(out); + Path base = src.resolve("base"); + Path sub = src.resolve("sub"); + + new JavacTask(tb) + .outdir(out) + .files(tb.findJavaFiles(base)) + .run(Task.Expect.SUCCESS); + + new JavacTask(tb) + .classpath(out) + .outdir(out) + .files(tb.findJavaFiles(sub)) + .run(Task.Expect.SUCCESS); + } +} From 521206523514b8c60ff234b11bd42d457a552da7 Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Wed, 10 Aug 2016 22:48:25 +0100 Subject: [PATCH 20/66] 8163586: java.net.http.RawChannel has been made public by mistake Reviewed-by: chegar --- .../java.httpclient/share/classes/java/net/http/RawChannel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java index 3086d7a50b9..fb73eb6b082 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java @@ -31,7 +31,7 @@ import java.nio.ByteBuffer; /* * I/O abstraction used to implement WebSocket. */ -public interface RawChannel { +interface RawChannel { interface RawEvent { From 978417c4c771927b0a04267cf7fea3699a87eb9f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 10 Aug 2016 15:47:46 -0700 Subject: [PATCH 21/66] 8136930: Simplify use of module-system options by custom launchers 8160489: Multiple -Xpatch lines ignored by javac 8156998: javac should support new option -XinheritRuntimeEnvironment Reviewed-by: jlahoda, ksrini --- .../tools/crules/MutableFieldsAnalyzer.java | 2 + .../com/sun/tools/javac/api/JavacTool.java | 7 +- .../com/sun/tools/javac/code/ClassFinder.java | 9 +- .../com/sun/tools/javac/comp/Modules.java | 8 +- .../sun/tools/javac/file/BaseFileManager.java | 33 +- .../com/sun/tools/javac/file/Locations.java | 78 ++- .../com/sun/tools/javac/jvm/ClassReader.java | 5 +- .../com/sun/tools/javac/main/Arguments.java | 119 ++-- .../sun/tools/javac/main/JavaCompiler.java | 8 +- .../com/sun/tools/javac/main/Main.java | 9 +- .../com/sun/tools/javac/main/Option.java | 592 +++++++++++++----- .../sun/tools/javac/main/OptionHelper.java | 9 + .../JavacProcessingEnvironment.java | 18 +- .../tools/javac/resources/compiler.properties | 2 +- .../tools/javac/resources/javac.properties | 67 +- .../sun/tools/javac/util/JDK9Wrappers.java | 36 ++ .../classes/com/sun/tools/javac/util/Log.java | 8 + .../com/sun/tools/javac/util/Options.java | 14 +- .../com/sun/tools/javah/JavahTask.java | 12 +- .../classes/com/sun/tools/javah/Util.java | 15 +- .../sun/tools/javah/resources/l10n.properties | 79 +-- .../com/sun/tools/sjavac/options/Option.java | 32 +- .../com/sun/tools/sjavac/options/Options.java | 6 +- .../com/sun/tools/javadoc/main/Start.java | 25 +- .../sun/tools/javadoc/main/ToolOption.java | 139 +++- .../javadoc/resources/javadoc.properties | 43 +- .../jdk/javadoc/internal/tool/Start.java | 8 +- .../jdk/javadoc/internal/tool/ToolOption.java | 119 +++- .../tool/resources/javadoc.properties | 38 +- .../com/sun/tools/javap/JavapTask.java | 33 +- .../tools/javap/resources/javap.properties | 62 +- .../sun/tools/jdeps/JdepsConfiguration.java | 2 +- .../com/sun/tools/jdeps/JdepsTask.java | 30 +- .../com/sun/tools/jdeps/ModuleAnalyzer.java | 2 +- .../tools/jdeps/resources/jdeps.properties | 39 +- langtools/test/ProblemList.txt | 5 + langtools/test/TEST.ROOT | 8 +- .../doclet/testModules/TestModules.java | 20 +- .../javadoc/tool/6964914/TestStdDoclet.java | 7 - .../javadoc/tool/6964914/TestUserDoclet.java | 5 - .../jdk/javadoc/tool/CheckResourceKeys.java | 2 +- .../test/jdk/javadoc/tool/ReleaseOption.java | 7 +- langtools/test/tools/all/RunCodingRules.java | 12 +- .../test/tools/javac/6410653/T6410653.java | 7 +- langtools/test/tools/javac/T6358024.java | 6 +- langtools/test/tools/javac/T6358166.java | 8 +- langtools/test/tools/javac/T6403466.java | 8 +- langtools/test/tools/javac/T6406771.java | 4 +- .../T8003967/DetectMutableStaticFields.java | 2 + ...rNamesAreNotCopiedToAnonymousInitTest.java | 10 +- langtools/test/tools/javac/api/T6358786.java | 4 +- langtools/test/tools/javac/api/T6412669.java | 4 +- .../javac/api/TestClientCodeWrapper.java | 4 +- .../tools/javac/api/TestJavacTaskScanner.java | 8 +- langtools/test/tools/javac/api/TestTrees.java | 6 +- .../attributes/Module/ModuleTestBase.java | 4 +- langtools/test/tools/javac/diags/Example.java | 4 +- .../tools/javac/diags/examples.not-yet.txt | 1 + .../module-info.java | 2 +- .../CantFindModule/CantFindModule.java | 2 +- .../IllegalArgumentForOption.java | 2 +- .../InvalidArgForXpatch.java | 27 - .../InvalidDefaultInterface.java | 2 +- .../InvalidStaticInterface.java | 2 +- .../examples/XaddexportsMalformedEntry.java | 2 +- .../diags/examples/XaddexportsTooMany.java | 2 +- .../examples/XaddreadsMalformedEntry.java | 2 +- .../diags/examples/XaddreadsTooMany.java | 2 +- .../javac/fatalErrors/NoJavaLangTest.java | 2 +- langtools/test/tools/javac/file/T7018098.java | 12 +- .../tools/javac/modules/AddLimitMods.java | 96 +-- .../tools/javac/modules/AddReadsTest.java | 38 +- .../javac/modules/AnnotationProcessing.java | 4 +- .../AnnotationProcessorsInModulesTest.java | 16 +- .../tools/javac/modules/AutomaticModules.java | 18 +- .../javac/modules/DoclintOtherModules.java | 2 +- .../javac/modules/DuplicateClassTest.java | 2 +- .../test/tools/javac/modules/EdgeCases.java | 18 +- .../test/tools/javac/modules/EnvVarTest.java | 6 +- .../test/tools/javac/modules/GraphsTest.java | 8 +- .../tools/javac/modules/HelloWorldTest.java | 4 +- .../InheritRuntimeEnvironmentTest.java | 421 +++++++++++++ .../test/tools/javac/modules/MOptionTest.java | 14 +- .../modules/MissingJarInModulePathTest.java | 2 +- .../tools/javac/modules/ModuleFinderTest.java | 2 +- .../tools/javac/modules/ModuleInfoTest.java | 12 +- .../tools/javac/modules/ModulePathTest.java | 40 +- .../javac/modules/ModuleSourcePathTest.java | 44 +- .../tools/javac/modules/ModuleTestBase.java | 18 - .../modules/ModulesAndClassPathTest.java | 17 +- .../javac/modules/MultiModuleModeTest.java | 14 +- .../tools/javac/modules/NPEEmptyFileTest.java | 2 +- .../tools/javac/modules/OutputDirTest.java | 10 +- .../javac/modules/PackageConflictTest.java | 16 +- .../javac/modules/PackageMultipleModules.java | 3 +- .../tools/javac/modules/PatchModulesTest.java | 127 ++++ .../javac/modules/PluginsInModulesTest.java | 4 +- .../tools/javac/modules/ProvidesTest.java | 4 +- .../tools/javac/modules/QueryBeforeEnter.java | 24 +- .../javac/modules/RequiresPublicTest.java | 6 +- .../test/tools/javac/modules/ResolveTest.java | 12 +- ...rviceProvidedButNotExportedOrUsedTest.java | 2 +- .../javac/modules/SingleModuleModeTest.java | 4 +- .../tools/javac/modules/SubpackageTest.java | 2 +- .../javac/modules/UpgradeModulePathTest.java | 42 +- .../test/tools/javac/modules/UsesTest.java | 10 +- .../test/tools/javac/modules/XModuleTest.java | 14 +- .../javac/platform/PlatformProviderTest.java | 14 +- .../test/tools/javac/processing/T8142931.java | 12 +- .../loader/testClose/TestClose.java | 4 +- .../loader/testClose/TestClose2.java | 6 +- .../model/testgetallmembers/Main.java | 2 +- langtools/test/tools/javac/util/T6597678.java | 4 +- .../tools/javadoc/6964914/TestStdDoclet.java | 7 - .../tools/javadoc/6964914/TestUserDoclet.java | 5 - .../test/tools/javadoc/CheckResourceKeys.java | 4 +- .../test/tools/javadoc/ReleaseOption.java | 12 +- langtools/test/tools/javap/T7004698.java | 2 +- langtools/test/tools/jdeps/APIDeps.java | 4 +- .../jdeps/jdkinternals/ShowReplacement.java | 2 +- langtools/test/tools/jdeps/lib/JdepsUtil.java | 2 +- .../tools/jdeps/modules/CheckModuleTest.java | 4 +- .../tools/jdeps/modules/GenModuleInfo.java | 12 +- .../test/tools/jdeps/modules/InverseDeps.java | 10 +- .../test/tools/jdeps/modules/ModuleTest.java | 14 +- .../tools/jdeps/modules/SplitPackage.java | 4 +- .../tools/jdeps/modules/TransitiveDeps.java | 4 +- .../jdeps/modules/src/m3/module-info.java | 2 +- .../jdeps/modules/src/m5/module-info.java | 2 +- langtools/test/tools/lib/toolbox/Assert.java | 162 +++++ .../test/tools/lib/toolbox/JavaTask.java | 20 + .../test/tools/lib/toolbox/JavacTask.java | 10 + .../test/tools/lib/toolbox/TestRunner.java | 2 +- .../test/tools/sjavac/ApiExtraction.java | 10 +- .../tools/sjavac/ClasspathDependencies.java | 7 +- .../tools/sjavac/CompileCircularSources.java | 1 - .../sjavac/CompileExcludingDependency.java | 2 - .../test/tools/sjavac/CompileWithAtFile.java | 1 - .../sjavac/CompileWithInvisibleSources.java | 2 - .../sjavac/CompileWithOverrideSources.java | 2 - langtools/test/tools/sjavac/HiddenFiles.java | 15 +- langtools/test/tools/sjavac/IdleShutdown.java | 4 +- .../test/tools/sjavac/IgnoreSymbolFile.java | 3 +- .../test/tools/sjavac/IncCompInheritance.java | 2 +- .../tools/sjavac/IncCompileChangeNative.java | 2 - .../tools/sjavac/IncCompileDropClasses.java | 2 - .../sjavac/IncCompileFullyQualifiedRef.java | 1 - .../tools/sjavac/IncCompileNoChanges.java | 1 - .../tools/sjavac/IncCompileUpdateNative.java | 2 - .../tools/sjavac/IncCompileWithChanges.java | 2 - .../tools/sjavac/IncludeExcludePatterns.java | 15 +- langtools/test/tools/sjavac/NoState.java | 7 +- .../test/tools/sjavac/OptionDecoding.java | 9 +- .../test/tools/sjavac/OverlappingSrcDst.java | 3 +- .../tools/sjavac/PackagePathMismatch.java | 2 +- .../tools/sjavac/ParallelCompilations.java | 3 - .../test/tools/sjavac/PermittedArtifact.java | 2 - .../test/tools/sjavac/PooledExecution.java | 4 +- langtools/test/tools/sjavac/SjavacBase.java | 5 +- langtools/test/tools/sjavac/StateDir.java | 2 - langtools/test/tools/sjavac/Wrapper.java | 43 +- 161 files changed, 2421 insertions(+), 1050 deletions(-) delete mode 100644 langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java create mode 100644 langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java create mode 100644 langtools/test/tools/javac/modules/PatchModulesTest.java create mode 100644 langtools/test/tools/lib/toolbox/Assert.java diff --git a/langtools/make/tools/crules/MutableFieldsAnalyzer.java b/langtools/make/tools/crules/MutableFieldsAnalyzer.java index 5609556be5c..538f7827dfa 100644 --- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java +++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java @@ -107,6 +107,8 @@ public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer { "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper", "loadMethod"); + ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper", + "vmClass", "getRuntimeArgumentsMethod"); ignoreFields("com.sun.tools.javac.util.ModuleHelper", "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod"); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java index fba01f1be5a..69615ce6af5 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java @@ -179,10 +179,10 @@ public final class JavacTool implements JavaCompiler { args.init("javac", options, classes, compilationUnits); // init multi-release jar handling - if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) { + if (fileManager.isSupportedOption(Option.MULTIRELEASE.primaryName) == 1) { Target target = Target.instance(context); List list = List.of(target.multiReleaseValue()); - fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator()); + fileManager.handleOption(Option.MULTIRELEASE.primaryName, list.iterator()); } return new JavacTaskImpl(context); @@ -212,8 +212,9 @@ public final class JavacTool implements JavaCompiler { public int isSupportedOption(String option) { Set

This is NOT part of any supported API. @@ -89,17 +100,12 @@ public enum Option { XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC), - XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) { - private static final String LINT_KEY_FORMAT = " %-19s %s"; + XLINT_CUSTOM("-Xlint:", "opt.arg.Xlint", "opt.Xlint.custom", EXTENDED, BASIC, ANYOF, getXLintChoices()) { + private final String LINT_KEY_FORMAT = LARGE_INDENT + " %-" + + (DEFAULT_SYNOPSIS_WIDTH + SMALL_INDENT.length() - LARGE_INDENT.length() - 2) + "s %s"; @Override - void help(Log log, OptionKind kind) { - if (this.kind != kind) - return; - - log.printRawLines(WriterKind.STDOUT, - String.format(HELP_LINE_FORMAT, - log.localize(PrefixKind.JAVAC, "opt.Xlint.subopts"), - log.localize(PrefixKind.JAVAC, "opt.Xlint.suboptlist"))); + protected void help(Log log) { + super.help(log); log.printRawLines(WriterKind.STDOUT, String.format(LINT_KEY_FORMAT, "all", @@ -125,14 +131,14 @@ public enum Option { @Override public boolean matches(String option) { return DocLint.isValidOption( - option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX)); + option.replace(XDOCLINT_CUSTOM.primaryName, DocLint.XMSGS_CUSTOM_PREFIX)); } @Override public boolean process(OptionHelper helper, String option) { String prev = helper.get(XDOCLINT_CUSTOM); String next = (prev == null) ? option : (prev + " " + option); - helper.put(XDOCLINT_CUSTOM.text, next); + helper.put(XDOCLINT_CUSTOM.primaryName, next); return false; } }, @@ -141,14 +147,14 @@ public enum Option { @Override public boolean matches(String option) { return DocLint.isValidOption( - option.replace(XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE)); + option.replace(XDOCLINT_PACKAGE.primaryName, DocLint.XCHECK_PACKAGE)); } @Override public boolean process(OptionHelper helper, String option) { String prev = helper.get(XDOCLINT_PACKAGE); String next = (prev == null) ? option : (prev + " " + option); - helper.put(XDOCLINT_PACKAGE.text, next); + helper.put(XDOCLINT_PACKAGE.primaryName, next); return false; } }, @@ -173,35 +179,55 @@ public enum Option { } }, - CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER), + CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER), - CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) { + SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), + + MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), + + MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), + + UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), + + SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), + + PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { + // The deferred filemanager diagnostics mechanism assumes a single value per option, + // but --patch-module can be used multiple times, once per module. Therefore we compose + // a value for the option containing the last value specified for each module, and separate + // the the module=path pairs by an invalid path character, NULL. + // The standard file manager code knows to split apart the NULL-separated components. @Override public boolean process(OptionHelper helper, String option, String arg) { - return super.process(helper, "-classpath", arg); + if (!arg.contains("=")) { // could be more strict regeex, e.g. "(?i)[a-z0-9_.]+=.*" + helper.error(Errors.LocnInvalidArgForXpatch(arg)); + } + + String previous = helper.get(this); + if (previous == null) { + return super.process(helper, option, arg); + } + + Map map = new LinkedHashMap<>(); + for (String s : previous.split("\0")) { + int sep = s.indexOf('='); + map.put(s.substring(0, sep), s.substring(sep + 1)); + } + + int sep = arg.indexOf('='); + map.put(arg.substring(0, sep), arg.substring(sep + 1)); + + StringBuilder sb = new StringBuilder(); + map.forEach((m, p) -> { + if (sb.length() > 0) + sb.append('\0'); + sb.append(m).append('=').append(p); + }); + return super.process(helper, option, sb.toString()); } }, - SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), - - MODULESOURCEPATH("-modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), - - MODULEPATH("-modulepath", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), - - MP("-mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER) { - @Override - public boolean process(OptionHelper helper, String option, String arg) { - return super.process(helper, "-modulepath", arg); - } - }, - - UPGRADEMODULEPATH("-upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), - - SYSTEM("-system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), - - XPATCH("-Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER), - - BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) { + BOOT_CLASS_PATH("--boot-class-path -bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) { @Override public boolean process(OptionHelper helper, String option, String arg) { helper.remove("-Xbootclasspath/p:"); @@ -228,7 +254,7 @@ public enum Option { DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) { @Override public boolean process(OptionHelper helper, String option, String arg) { - return super.process(helper, "-extdirs", arg); + return EXTDIRS.process(helper, "-extdirs", arg); } }, @@ -237,7 +263,7 @@ public enum Option { DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) { @Override public boolean process(OptionHelper helper, String option, String arg) { - return super.process(helper, "-endorseddirs", arg); + return ENDORSEDDIRS.process(helper, "-endorseddirs", arg); } }, @@ -245,9 +271,9 @@ public enum Option { PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC), - PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), + PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), - PROCESSORMODULEPATH("-processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), + PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), @@ -285,12 +311,9 @@ public enum Option { } }, - RELEASE("-release", "opt.arg.release", "opt.release", STANDARD, BASIC) { + RELEASE("--release -release", "opt.arg.release", "opt.release", STANDARD, BASIC) { @Override - void help(Log log, OptionKind kind) { - if (this.kind != kind) - return; - + protected void help(Log log) { Iterable providers = ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader()); Set platforms = StreamSupport.stream(providers.spliterator(), false) @@ -307,10 +330,7 @@ public enum Option { delim = ", "; } - log.printRawLines(WriterKind.STDOUT, - String.format(HELP_LINE_FORMAT, - super.helpSynopsis(log), - log.localize(PrefixKind.JAVAC, descrKey, targets.toString()))); + super.help(log, log.localize(PrefixKind.JAVAC, descrKey, targets.toString())); } }, @@ -346,21 +366,20 @@ public enum Option { } }, - HELP("-help", "opt.help", STANDARD, INFO) { + // Note: -h is already taken for "native header output directory". + HELP("--help -help", "opt.help", STANDARD, INFO) { @Override public boolean process(OptionHelper helper, String option) { Log log = helper.getLog(); String ownName = helper.getOwnName(); log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.header", ownName); - for (Option o: getJavaCompilerOptions()) { - o.help(log, OptionKind.STANDARD); - } + showHelp(log, OptionKind.STANDARD); log.printNewline(WriterKind.STDOUT); return super.process(helper, option); } }, - A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) { + A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, ArgKind.ADJACENT) { @Override public boolean matches(String arg) { return arg.startsWith("-A"); @@ -385,7 +404,8 @@ public enum Option { helper.error("err.invalid.A.key", option); return true; } - return process(helper, option, option); + helper.put(option, option); + return false; } }, @@ -393,9 +413,7 @@ public enum Option { @Override public boolean process(OptionHelper helper, String option) { Log log = helper.getLog(); - for (Option o: getJavaCompilerOptions()) { - o.help(log, OptionKind.EXTENDED); - } + showHelp(log, OptionKind.EXTENDED); log.printNewline(WriterKind.STDOUT); log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.nonstandard.footer"); return super.process(helper, option); @@ -404,7 +422,7 @@ public enum Option { // This option exists only for the purpose of documenting itself. // It's actually implemented by the launcher. - J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) { + J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) { @Override public boolean process(OptionHelper helper, String option) { throw new AssertionError @@ -484,7 +502,7 @@ public enum Option { public boolean process(OptionHelper helper, String option) { String p = option.substring(option.indexOf(':') + 1).trim(); String prev = helper.get(PLUGIN); - helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p); + helper.put(PLUGIN.primaryName, (prev == null) ? p : prev + '\0' + p); return false; } }, @@ -517,7 +535,7 @@ public enum Option { } }, - DIAGS("-diags:", null, HIDDEN, BASIC, true) { + DIAGS("-diags:", null, HIDDEN, BASIC) { @Override public boolean process(OptionHelper helper, String option) { return HiddenGroup.DIAGS.process(helper, option); @@ -531,11 +549,11 @@ public enum Option { XD("-XD", null, HIDDEN, BASIC) { @Override public boolean matches(String s) { - return s.startsWith(text); + return s.startsWith(primaryName); } @Override public boolean process(OptionHelper helper, String option) { - return process(helper, option, option.substring(text.length())); + return process(helper, option, option.substring(primaryName.length())); } @Override @@ -548,47 +566,45 @@ public enum Option { } }, - XADDEXPORTS("-XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { + ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { @Override - public boolean process(OptionHelper helper, String option) { - String p = option.substring(option.indexOf(':') + 1).trim(); - String prev = helper.get(XADDEXPORTS); - helper.put(XADDEXPORTS.text, (prev == null) ? p : prev + '\0' + p); + public boolean process(OptionHelper helper, String option, String arg) { + String prev = helper.get(ADD_EXPORTS); + helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg); return false; } }, - XADDREADS("-XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { + ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { @Override - public boolean process(OptionHelper helper, String option) { - String p = option.substring(option.indexOf(':') + 1).trim(); - String prev = helper.get(XADDREADS); - helper.put(XADDREADS.text, (prev == null) ? p : prev + '\0' + p); + public boolean process(OptionHelper helper, String option, String arg) { + String prev = helper.get(ADD_READS); + helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg); return false; } }, XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) { @Override - public boolean process(OptionHelper helper, String option) { + public boolean process(OptionHelper helper, String option, String arg) { String prev = helper.get(XMODULE); if (prev != null) { - helper.error("err.option.too.many", XMODULE.text); + helper.error("err.option.too.many", XMODULE.primaryName); } - String p = option.substring(option.indexOf(':') + 1); - helper.put(XMODULE.text, p); + helper.put(XMODULE.primaryName, arg); return false; } }, - M("-m", "opt.arg.m", "opt.m", STANDARD, BASIC), + MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC), - ADDMODS("-addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), - LIMITMODS("-limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), + ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), + + LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), // This option exists only for the purpose of documenting itself. // It's actually implemented by the CommandLine class. - AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) { + AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, ArgKind.ADJACENT) { @Override public boolean process(OptionHelper helper, String option) { throw new AssertionError("the @ flag should be caught by CommandLine."); @@ -629,9 +645,78 @@ public enum Option { } }, - MULTIRELEASE("-multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER); + MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), - /** The kind of an Option. This is used by the -help and -X options. */ + INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment", + EXTENDED, BASIC) { + @Override + public boolean process(OptionHelper helper, String option) { + try { + Class.forName(JDK9Wrappers.VMHelper.VM_CLASSNAME); + String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments(); + for (String arg : runtimeArgs) { + // Handle any supported runtime options; ignore all others. + // The runtime arguments always use the single token form, e.g. "--name=value". + for (Option o : getSupportedRuntimeOptions()) { + if (o.matches(arg)) { + o.handleOption(helper, arg, Collections.emptyIterator()); + break; + } + } + } + } catch (ClassNotFoundException | SecurityException e) { + helper.error("err.cannot.access.runtime.env"); + } + return false; + } + + private Option[] getSupportedRuntimeOptions() { + Option[] supportedRuntimeOptions = { + ADD_EXPORTS, + ADD_MODULES, + LIMIT_MODULES, + MODULE_PATH, + UPGRADE_MODULE_PATH, + PATCH_MODULE + }; + return supportedRuntimeOptions; + } + }; + + /** + * The kind of argument, if any, accepted by this option. The kind is augmented + * by characters in the name of the option. + */ + public enum ArgKind { + /** This option does not take any argument. */ + NONE, + +// Not currently supported +// /** +// * This option takes an optional argument, which may be provided directly after an '=' +// * separator, or in the following argument position if that word does not itself appear +// * to be the name of an option. +// */ +// OPTIONAL, + + /** + * This option takes an argument. + * If the name of option ends with ':' or '=', the argument must be provided directly + * after that separator. + * Otherwise, if may appear after an '=' or in the following argument position. + */ + REQUIRED, + + /** + * This option takes an argument immediately after the option name, with no separator + * character. + */ + ADJACENT + } + + /** + * The kind of an Option. This is used by the -help and -X options. + */ public enum OptionKind { /** A standard option, documented by -help. */ STANDARD, @@ -641,8 +726,10 @@ public enum Option { HIDDEN, } - /** The group for an Option. This determines the situations in which the - * option is applicable. */ + /** + * The group for an Option. This determines the situations in which the + * option is applicable. + */ enum OptionGroup { /** A basic option, available for use on the command line or via the * Compiler API. */ @@ -656,7 +743,9 @@ public enum Option { OPERAND } - /** The kind of choice for "choice" options. */ + /** + * The kind of choice for "choice" options. + */ enum ChoiceKind { /** The expected value is exactly one of the set of choices. */ ONEOF, @@ -684,65 +773,113 @@ public enum Option { } } - public final String text; - - final OptionKind kind; - - final OptionGroup group; - - /** Documentation key for arguments. + /** + * The "primary name" for this option. + * This is the name that is used to put values in the {@link Options} table. */ - final String argsNameKey; + public final String primaryName; + + /** + * The set of names (primary name and aliases) for this option. + * Note that some names may end in a separator, to indicate that an argument must immediately + * follow the separator (and cannot appear in the following argument position. + */ + public final String[] names; + + /** Documentation key for arguments. */ + protected final String argsNameKey; /** Documentation key for description. */ - final String descrKey; + protected final String descrKey; - /** Suffix option (-foo=bar or -foo:bar) + /** The kind of this option. */ + private final OptionKind kind; + + /** The group for this option. */ + private final OptionGroup group; + + /** The kind of argument for this option. */ + private final ArgKind argKind; + + /** The kind of choices for this option, if any. */ + private final ChoiceKind choiceKind; + + /** The choices for this option, if any, and whether or not the choices are hidden. */ + private final Map choices; + + /** + * Looks up the first option matching the given argument in the full set of options. + * @param arg the argument to be matches + * @return the first option that matches, or null if none. */ - final boolean hasSuffix; + public static Option lookup(String arg) { + return lookup(arg, EnumSet.allOf(Option.class)); + } - /** The kind of choices for this option, if any. + /** + * Looks up the first option matching the given argument within a set of options. + * @param arg the argument to be matches + * @return the first option that matches, or null if none. */ - final ChoiceKind choiceKind; + public static Option lookup(String arg, Set

Output directory\n\t\ --o Output file (only one of -d or -o may be used)\n\t\ --jni Generate JNI-style header file (default)\n\t\ --version Print version information\n\t\ --verbose Enable verbose output\n\t\ --force Always write output files\n\ -\n\ - are specified with their fully qualified names, optionally\n\ -prefixed by a module name followed by '/'. Examples:\n\ - java.lang.Object\n\ - java.base/java.io.File\n\ - main.usage=\ Usage: \n\ \ javah [options] \n\ where [options] include: + main.opt.o=\ -\ -o Output file (only one of -d or -o may be used) +\ -o Output file (only one of -d or -o may be used) + main.opt.d=\ -\ -d Output directory +\ -d Output directory + main.opt.v=\ -\ -v -verbose Enable verbose output +\ -v -verbose Enable verbose output + main.opt.h=\ -\ -h --help -? Print this message +\ -h --help -? Print this message + main.opt.version=\ -\ -version Print version information +\ -version Print version information + main.opt.jni=\ -\ -jni Generate JNI-style header file (default) +\ -jni Generate JNI-style header file (default) + main.opt.force=\ -\ -force Always write output files +\ -force Always write output files + +main.opt.module_path=\ +\ --module-path Path from which to load application modules + +main.opt.upgrade_module_path=\ +\ --upgrade_module-path Path from which to load application modules + main.opt.classpath=\ -\ -classpath Path from which to load classes +\ -classpath Path from which to load classes + +main.opt.class_path=\ +\ --class-path Path from which to load classes + main.opt.cp=\ -\ -cp Path from which to load classes +\ -cp Path from which to load classes + main.opt.bootclasspath=\ -\ -bootclasspath Path from which to load bootstrap classes -main.usage.foot=\ - are specified with their fully qualified names\n\ -(for example, java.lang.Object). +\ -bootclasspath Path from which to load bootstrap classes + +main.opt.system=\ +\ --system Specify where to find system modules + +main.usage.foot=\n\ +GNU-style options may use '=' instead whitespace to separate the name of an option\n\ +from its value.\n\ +\n\ +Each class must be specified by its fully qualified names, optionally\n\ +prefixed by a module name followed by '/'. Examples:\n\ +\ java.lang.Object\n\ +\ java.base/java.io.File\n\ # # Version string. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java index fa5df170e4b..fb07a4fdae0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java @@ -63,7 +63,7 @@ public enum Option { helper.sourceRoots(paths); } }, - SOURCEPATH("-sourcepath", "Specify search path for sources.") { + SOURCE_PATH("--source-path", "Specify search path for sources.") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { List paths = getFileListArg(iter, helper); @@ -71,7 +71,13 @@ public enum Option { helper.sourcepath(paths); } }, - MODULEPATH("-modulepath", "Specify search path for modules.") { + SOURCEPATH("-sourcepath", "An alias for -sourcepath") { + @Override + protected void processMatching(ArgumentIterator iter, OptionHelper helper) { + SOURCE_PATH.processMatching(iter, helper); + } + }, + MODULE_PATH("--module-path", "Specify search path for modules.") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { List paths = getFileListArg(iter, helper); @@ -79,7 +85,19 @@ public enum Option { helper.modulepath(paths); } }, - CLASSPATH("-classpath", "Specify search path for classes.") { + MODULEPATH("-modulepath", "An alias for -modulepath") { + @Override + protected void processMatching(ArgumentIterator iter, OptionHelper helper) { + MODULE_PATH.processMatching(iter, helper); + } + }, + P("-p", "An alias for -modulepath") { + @Override + protected void processMatching(ArgumentIterator iter, OptionHelper helper) { + MODULE_PATH.processMatching(iter, helper); + } + }, + CLASS_PATH("--class-path", "Specify search path for classes.") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { List paths = getFileListArg(iter, helper); @@ -87,10 +105,16 @@ public enum Option { helper.classpath(paths); } }, + CLASSPATH("-classpath", "An alias for -classpath.") { + @Override + protected void processMatching(ArgumentIterator iter, OptionHelper helper) { + CLASS_PATH.processMatching(iter, helper); + } + }, CP("-cp", "An alias for -classpath") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { - CLASSPATH.processMatching(iter, helper); + CLASS_PATH.processMatching(iter, helper); } }, X("-x", "Exclude files matching the given pattern") { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java index f3a3f8fadc1..a6299916709 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java @@ -251,9 +251,9 @@ public class Options { // Source roots args.addSourceLocations(Option.SRC, sources); - args.addSourceLocations(Option.SOURCEPATH, sourceSearchPaths); - args.addSourceLocations(Option.CLASSPATH, classSearchPaths); - args.addSourceLocations(Option.MODULEPATH, moduleSearchPaths); + args.addSourceLocations(Option.SOURCE_PATH, sourceSearchPaths); + args.addSourceLocations(Option.CLASS_PATH, classSearchPaths); + args.addSourceLocations(Option.MODULE_PATH, moduleSearchPaths); // Boolean options if (permitSourcesInDefaultPackage) diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java index 5b5b5881682..30936ce1c24 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java @@ -45,6 +45,8 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.main.CommandLine; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.file.BaseFileManager; +import com.sun.tools.javac.main.OptionHelper; +import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; import com.sun.tools.javac.platform.PlatformDescription; import com.sun.tools.javac.platform.PlatformUtils; import com.sun.tools.javac.util.ClientCodeException; @@ -173,7 +175,7 @@ public class Start extends ToolOption.Helper { } void usage(boolean exit) { - usage("main.usage", "-help", null, exit); + usage("main.usage", "-help", "main.usage.foot", exit); } @Override @@ -365,14 +367,14 @@ public class Start extends ToolOption.Helper { ((BaseFileManager) fileManager).handleOptions(fileManagerOpts); } - String platformString = compOpts.get("-release"); + String platformString = compOpts.get("--release"); if (platformString != null) { if (compOpts.isSet("-source")) { usageError("main.release.bootclasspath.conflict", "-source"); } - if (fileManagerOpts.containsKey(Option.BOOTCLASSPATH)) { - usageError("main.release.bootclasspath.conflict", Option.BOOTCLASSPATH.getText()); + if (fileManagerOpts.containsKey(Option.BOOT_CLASS_PATH)) { + usageError("main.release.bootclasspath.conflict", Option.BOOT_CLASS_PATH.getPrimaryName()); } PlatformDescription platformDescription = @@ -555,4 +557,19 @@ public class Start extends ToolOption.Helper { } options.append(args); } + + @Override + OptionHelper getOptionHelper() { + return new GrumpyHelper(null) { + @Override + public String get(com.sun.tools.javac.main.Option option) { + return compOpts.get(option); + } + + @Override + public void put(String name, String value) { + compOpts.put(name, value); + } + }; + } } diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java index 47afb073ee5..0838966e1c4 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java @@ -31,6 +31,7 @@ import java.util.StringTokenizer; import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.main.Option; +import com.sun.tools.javac.main.OptionHelper; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Options; @@ -50,21 +51,28 @@ public enum ToolOption { BOOTCLASSPATH("-bootclasspath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg); + helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg); } }, CLASSPATH("-classpath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.CLASSPATH, arg); + helper.setFileManagerOpt(Option.CLASS_PATH, arg); } }, CP("-cp", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.CP, arg); + helper.setFileManagerOpt(Option.CLASS_PATH, arg); + } + }, + + CLASS_PATH("--class-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.CLASS_PATH, arg); } }, @@ -78,28 +86,49 @@ public enum ToolOption { SOURCEPATH("-sourcepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SOURCEPATH, arg); + helper.setFileManagerOpt(Option.SOURCE_PATH, arg); + } + }, + + SOURCE_PATH("--source-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.SOURCE_PATH, arg); } }, SYSCLASSPATH("-sysclasspath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg); + helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg); } }, MODULESOURCEPATH("-modulesourcepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg); + helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); + } + }, + + MODULE_SOURCE_PATH("--module-source-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); } }, UPGRADEMODULEPATH("-upgrademodulepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg); + helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); + } + }, + + UPGRADE_MODULE_PATH("--upgrade-module-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); } }, @@ -110,10 +139,31 @@ public enum ToolOption { } }, + SYSTEM_("--system", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.SYSTEM, arg); + } + }, + MODULEPATH("-modulepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULEPATH, arg); + helper.setFileManagerOpt(Option.MODULE_PATH, arg); + } + }, + + MODULE_PATH("--module-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_PATH, arg); + } + }, + + P("-p", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_PATH, arg); } }, @@ -124,6 +174,13 @@ public enum ToolOption { } }, + ADD_MODULES("--add-modules", true) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg); + } + }, + LIMITMODS("-limitmods", true) { @Override public void process(Helper helper, String arg) { @@ -131,6 +188,13 @@ public enum ToolOption { } }, + LIMIT_MODULES("--limit-modules", true) { + @Override + public void process(Helper helper, String arg) { + Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg); + } + }, + ENCODING("-encoding", true) { @Override public void process(Helper helper, String arg) { @@ -139,13 +203,20 @@ public enum ToolOption { } }, - RELEASE("-release", true) { + RELEASE("--release", true) { @Override public void process(Helper helper, String arg) { helper.setCompilerOpt(opt, arg); } }, + RELEASE_OLD("-release", true) { + @Override + public void process(Helper helper, String arg) { + helper.setCompilerOpt("--release", arg); + } + }, + SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { @@ -167,6 +238,55 @@ public enum ToolOption { } }, + XADDREADS("-XaddReads:", false) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_READS.process(helper.getOptionHelper(), arg); + } + }, + + ADD_READS("--add-reads", true) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_READS.process(helper.getOptionHelper(), opt, arg); + } + }, + + ADDEXPORTS("-XaddExports:", false) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); + } + }, + + ADD_EXPORTS("--add-exports", true) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg); + } + }, + + XMODULE("-Xmodule:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XMODULE.process(helper.getOptionHelper(), arg); + } + }, + + XPATCH("-Xpatch:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XMODULE.process(helper.getOptionHelper(), arg); + } + }, + + PATCH_MODULE("--patch-module", true) { + @Override + public void process(Helper helper, String arg) { + Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg); + } + }, + // ----- doclet options ----- DOCLET("-doclet", true), // handled in setDocletInvoker @@ -362,6 +482,7 @@ public enum ToolOption { abstract void Xusage(); abstract void usageError(String msg, Object... args); + abstract OptionHelper getOptionHelper(); void addToList(ListBuffer list, String str){ StringTokenizer st = new StringTokenizer(str, ":"); diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties index dbd499359f3..fc39e35078e 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2016, 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 @@ -37,15 +37,28 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ \ -help Display command line options and exit\n\ \ -doclet Generate output via alternate doclet\n\ \ -docletpath Specify where to find doclet class files\n\ -\ -sourcepath Specify where to find source files\n\ -\ -classpath Specify where to find user class files\n\ -\ -cp Specify where to find user class files\n\ +\ --module-source-path Specify where to find input source files for multiple modules\n\ +\ --upgrade-module-path Override location of upgradeable modules\n\ +\ --module-path , -p Specify where to find application modules\n\ +\ --add-modules (,)*\n\ +\ Root modules to resolve in addition to the initial modules,\n\ +\ or all modules on the module path if is ALL-MODULE-PATH.\n\ +\ --limit-modules (,)*\n\ +\ Limit the universe of observable modules\n\ +\ --source-path Specify where to find source files\n\ +\ -sourcepath Specify where to find source files\n\ +\ --class-path Specify where to find user class files\n\ +\ -classpath Specify where to find user class files\n\ +\ -cp Specify where to find user class files\n\ \ -exclude Specify a list of packages to exclude\n\ \ -subpackages Specify subpackages to recursively load\n\ \ -breakiterator Compute first sentence with BreakIterator\n\ -\ -bootclasspath Override location of class files loaded\n\ -\ by the bootstrap class loader\n\ +\ -bootclasspath Override location of platform class files\n\ +\ used for non-modular releases\n\ +\ --system Override location of system modules used\n\ +\ for modular releases.\n\ \ -source Provide source compatibility with specified release\n\ +\ --release Provide source compatibility with specified release\n\ \ -extdirs Override location of installed extensions\n\ \ -verbose Output messages about what Javadoc is doing\n\ \ -locale Locale to be used, e.g. en_US or en_US_WIN\n\ @@ -54,9 +67,25 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ \ -J Pass directly to the runtime system\n\ \ -X Print a synopsis of nonstandard options and exit\n +main.usage.foot=\n\ +GNU-style options may use '=' instead whitespace to separate the name of an option\n\ +from its value.\n + main.Xusage=\ \ -Xmaxerrs Set the maximum number of errors to print\n\ -\ -Xmaxwarns Set the maximum number of warnings to print\n +\ -Xmaxwarns Set the maximum number of warnings to print\n\ +\ --add-exports /=(,)*\n\ +\ Specify a package to be considered as exported from its \n\ +\ defining module to additional modules, or to all unnamed \n\ +\ modules if is ALL-UNNAMED.\n\ +\ --add-reads =(,)*\n\ +\ Specify additional modules to be considered as required by a\n\ +\ given module. may be ALL-UNNAMED to require\n\ +\ the unnamed module.\n\ +\ -Xmodule: Specify a module to which the classes being compiled belong.\n\ +\ --patch-module =(:)*\n\ +\ Override or augment a module with classes and resources\n\ +\ in JAR files or directories\n main.Xusage.foot=\ These options are non-standard and subject to change without notice. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index 30fdb0ba645..fb029284540 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -172,7 +172,7 @@ public class Start extends ToolOption.Helper { } void usage(boolean exit) { - usage("main.usage", "-help", null, exit); + usage("main.usage", "-help", "main.usage.foot", exit); } @Override @@ -355,14 +355,14 @@ public class Start extends ToolOption.Helper { ((BaseFileManager) fileManager).handleOptions(fileManagerOpts); } - String platformString = compOpts.get("-release"); + String platformString = compOpts.get("--release"); if (platformString != null) { if (compOpts.isSet("-source")) { usageError("main.release.bootclasspath.conflict", "-source"); } - if (fileManagerOpts.containsKey(BOOTCLASSPATH)) { - usageError("main.release.bootclasspath.conflict", BOOTCLASSPATH.getText()); + if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) { + usageError("main.release.bootclasspath.conflict", BOOT_CLASS_PATH.getPrimaryName()); } PlatformDescription platformDescription = diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java index 9eaa29213d6..2118b540fd0 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java @@ -49,21 +49,28 @@ public enum ToolOption { BOOTCLASSPATH("-bootclasspath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg); + helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg); } }, CLASSPATH("-classpath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.CLASSPATH, arg); + helper.setFileManagerOpt(Option.CLASS_PATH, arg); } }, CP("-cp", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.CP, arg); + helper.setFileManagerOpt(Option.CLASS_PATH, arg); + } + }, + + CLASS_PATH("--class-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.CLASS_PATH, arg); } }, @@ -77,28 +84,49 @@ public enum ToolOption { SOURCEPATH("-sourcepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SOURCEPATH, arg); + helper.setFileManagerOpt(Option.SOURCE_PATH, arg); + } + }, + + SOURCE_PATH("--source-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.SOURCE_PATH, arg); } }, SYSCLASSPATH("-sysclasspath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg); + helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg); } }, MODULESOURCEPATH("-modulesourcepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg); + helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); + } + }, + + MODULE_SOURCE_PATH("--module-source-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); } }, UPGRADEMODULEPATH("-upgrademodulepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg); + helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); + } + }, + + UPGRADE_MODULE_PATH("--upgrade-module-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); } }, @@ -109,24 +137,59 @@ public enum ToolOption { } }, + SYSTEM_("--system", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.SYSTEM, arg); + } + }, + MODULEPATH("-modulepath", true) { @Override public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULEPATH, arg); + helper.setFileManagerOpt(Option.MODULE_PATH, arg); + } + }, + + MODULE_PATH("--module-path", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_PATH, arg); + } + }, + + P("-p", true) { + @Override + public void process(Helper helper, String arg) { + helper.setFileManagerOpt(Option.MODULE_PATH, arg); } }, ADDMODS("-addmods", true) { @Override public void process(Helper helper, String arg) { - Option.ADDMODS.process(helper.getOptionHelper(), opt, arg); + Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg); + } + }, + + ADD_MODULES("--add-modules", true) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg); } }, LIMITMODS("-limitmods", true) { @Override public void process(Helper helper, String arg) { - Option.LIMITMODS.process(helper.getOptionHelper(), opt, arg); + Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg); + } + }, + + LIMIT_MODULES("--limit-modules", true) { + @Override + public void process(Helper helper, String arg) { + Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg); } }, @@ -138,7 +201,14 @@ public enum ToolOption { } }, - RELEASE("-release", true) { + RELEASE("--release", true) { + @Override + public void process(Helper helper, String arg) { + Option.RELEASE.process(helper.getOptionHelper(), opt, arg); + } + }, + + RELEASE_OLD("-release", true) { @Override public void process(Helper helper, String arg) { Option.RELEASE.process(helper.getOptionHelper(), opt, arg); @@ -169,14 +239,28 @@ public enum ToolOption { XADDREADS("-XaddReads:", false) { @Override public void process(Helper helper, String arg) { - Option.XADDREADS.process(helper.getOptionHelper(), arg); + Option.ADD_READS.process(helper.getOptionHelper(), arg); } }, - XADDEXPORTS("-XaddExports:", false) { + ADD_READS("--add-reads", true) { @Override public void process(Helper helper, String arg) { - Option.XADDEXPORTS.process(helper.getOptionHelper(), arg); + Option.ADD_READS.process(helper.getOptionHelper(), opt, arg); + } + }, + + ADDEXPORTS("-XaddExports:", false) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); + } + }, + + ADD_EXPORTS("--add-exports", true) { + @Override + public void process(Helper helper, String arg) { + Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg); } }, @@ -194,6 +278,13 @@ public enum ToolOption { } }, + PATCH_MODULE("--patch-module", true) { + @Override + public void process(Helper helper, String arg) { + Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg); + } + }, + // ----- doclet options ----- DOCLET("-doclet", true), // handled in setDocletInvoker diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties index f2a60263f74..3d235828ed7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties @@ -37,21 +37,27 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ \ -help Display command line options and exit\n\ \ -doclet Generate output via alternate doclet\n\ \ -docletpath Specify where to find doclet class files\n\ -\ -modulesourcepath Specify where to find input source files for multiple modules\n\ -\ -upgrademodulepath Override location of upgradeable modules\n\ -\ -modulepath Specify where to find application modules\n\ -\ -mp Specify where to find application modules\n\ -\ -addmods (,)* Root modules to resolve in addition to the initial modules,\n\ +\ --module-source-path Specify where to find input source files for multiple modules\n\ +\ --upgrade-module-path Override location of upgradeable modules\n\ +\ --module-path , -p Specify where to find application modules\n\ +\ --add-modules (,)*\n\ +\ Root modules to resolve in addition to the initial modules,\n\ \ or all modules on the module path if is ALL-MODULE-PATH.\n\ -\ -limitmods (,)* Limit the universe of observable modules\n\ -\ -sourcepath Specify where to find source files\n\ -\ -classpath Specify where to find user class files\n\ -\ -cp Specify where to find user class files\n\ +\ --limit-modules (,)*\n\ +\ Limit the universe of observable modules\n\ +\ --source-path Specify where to find source files\n\ +\ -sourcepath Specify where to find source files\n\ +\ --class-path Specify where to find user class files\n\ +\ -classpath Specify where to find user class files\n\ +\ -cp Specify where to find user class files\n\ \ -exclude Specify a list of packages to exclude\n\ \ -subpackages Specify subpackages to recursively load\n\ \ -breakiterator Compute first sentence with BreakIterator\n\ -\ -bootclasspath Override location of class files loaded\n\ -\ by the bootstrap class loader\n\ +\ -bootclasspath Override location of platform class files\n\ +\ used for non-modular releases\n\ +\ --system Override location of system modules used\n\ +\ for modular releases.\n\ +\ --release Provide source compatibility with specified release\n\ \ -source Provide source compatibility with specified release\n\ \ -extdirs Override location of installed extensions\n\ \ -verbose Output messages about what Javadoc is doing\n\ @@ -61,19 +67,23 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ \ -J Pass directly to the runtime system\n\ \ -X Print a synopsis of nonstandard options and exit\n +main.usage.foot=\n\ +GNU-style options may use '=' instead whitespace to separate the name of an option\n\ +from its value.\n + main.Xusage=\ \ -Xmaxerrs Set the maximum number of errors to print\n\ \ -Xmaxwarns Set the maximum number of warnings to print\n\ -\ -XaddExports:/=(,)*\n\ +\ --add-exports /=(,)*\n\ \ Specify a package to be considered as exported from its \n\ \ defining module to additional modules, or to all unnamed \n\ \ modules if is ALL-UNNAMED.\n\ -\ -XaddReads:=(,)*\n\ +\ --add-reads =(,)*\n\ \ Specify additional modules to be considered as required by a\n\ \ given module. may be ALL-UNNAMED to require\n\ \ the unnamed module.\n\ \ -Xmodule: Specify a module to which the classes being compiled belong.\n\ -\ -Xpatch:=(:)*\n\ +\ --patch-module =(:)*\n\ \ Override or augment a module with classes and resources\n\ \ in JAR files or directories\n\ \ -Xold Invoke the legacy javadoc tool\n diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java index c63caa21b65..7cd4090bdc0 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java @@ -126,24 +126,28 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { static final Option[] recognizedOptions = { new Option(false, "-help", "--help", "-?") { + @Override void process(JavapTask task, String opt, String arg) { task.options.help = true; } }, new Option(false, "-version") { + @Override void process(JavapTask task, String opt, String arg) { task.options.version = true; } }, new Option(false, "-fullversion") { + @Override void process(JavapTask task, String opt, String arg) { task.options.fullVersion = true; } }, new Option(false, "-v", "-verbose", "-all") { + @Override void process(JavapTask task, String opt, String arg) { task.options.verbose = true; task.options.showDescriptors = true; @@ -153,12 +157,14 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-l") { + @Override void process(JavapTask task, String opt, String arg) { task.options.showLineAndLocalVariableTables = true; } }, new Option(false, "-public") { + @Override void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PUBLIC; @@ -166,6 +172,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-protected") { + @Override void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PROTECTED; @@ -173,6 +180,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-package") { + @Override void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = 0; @@ -180,6 +188,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-p", "-private") { + @Override void process(JavapTask task, String opt, String arg) { if (!task.options.accessOptions.contains("-p") && !task.options.accessOptions.contains("-private")) { @@ -190,24 +199,28 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-c") { + @Override void process(JavapTask task, String opt, String arg) { task.options.showDisassembled = true; } }, new Option(false, "-s") { + @Override void process(JavapTask task, String opt, String arg) { task.options.showDescriptors = true; } }, new Option(false, "-sysinfo") { + @Override void process(JavapTask task, String opt, String arg) { task.options.sysInfo = true; } }, new Option(false, "-XDdetails") { + @Override void process(JavapTask task, String opt, String arg) { task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class); } @@ -221,6 +234,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { return sep != -1 && super.matches(opt.substring(0, sep + 1)); } + @Override void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); for (String v: opt.substring(sep + 1).split("[,: ]+")) { @@ -258,12 +272,14 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { }, new Option(false, "-constants") { + @Override void process(JavapTask task, String opt, String arg) { task.options.showConstants = true; } }, new Option(false, "-XDinner") { + @Override void process(JavapTask task, String opt, String arg) { task.options.showInnerClasses = true; } @@ -276,6 +292,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { return sep != -1 && super.matches(opt.substring(0, sep + 1)); } + @Override void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); try { @@ -294,6 +311,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { return sep != -1 && super.matches(opt.substring(0, sep + 1)); } + @Override void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); try { @@ -305,7 +323,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { } }, - new Option(true, "-m") { + new Option(true, "--module", "-m") { @Override void process(JavapTask task, String opt, String arg) throws BadArgs { task.options.moduleName = arg; @@ -929,21 +947,26 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { private void showHelp() { printLines(getMessage("main.usage", progname)); for (Option o: recognizedOptions) { - String name = o.aliases[0].substring(1); // there must always be at least one name + String name = o.aliases[0].replaceAll("^-+", "").replaceAll("-+", "_"); // there must always be at least one name if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify")) continue; printLines(getMessage("main.opt." + name)); } + String[] fmOptions = { - "-classpath", "-cp", "-bootclasspath", - "-upgrademodulepath", "-system", "-modulepath" }; + "--module-path", "--system", + "--class-path", "-classpath", "-cp", + "-bootclasspath" + }; + for (String o: fmOptions) { if (fileManager.isSupportedOption(o) == -1) continue; - String name = o.substring(1); + String name = o.replaceAll("^-+", "").replaceAll("-+", "_"); printLines(getMessage("main.opt." + name)); } + printLines(getMessage("main.usage.foot")); } private void showVersion(boolean full) { diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties index fb8d19bc05a..673cb548e5e 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties @@ -41,61 +41,73 @@ where possible options include: main.opt.help=\ -\ -help --help -? Print this usage message +\ -help --help -? Print this usage message main.opt.version=\ -\ -version Version information +\ -version Version information main.opt.v=\ -\ -v -verbose Print additional information +\ -v -verbose Print additional information main.opt.l=\ -\ -l Print line number and local variable tables +\ -l Print line number and local variable tables main.opt.public=\ -\ -public Show only public classes and members +\ -public Show only public classes and members main.opt.protected=\ -\ -protected Show protected/public classes and members +\ -protected Show protected/public classes and members main.opt.package=\ -\ -package Show package/protected/public classes\n\ -\ and members (default) +\ -package Show package/protected/public classes\n\ +\ and members (default) main.opt.p=\ -\ -p -private Show all classes and members +\ -p -private Show all classes and members main.opt.c=\ -\ -c Disassemble the code +\ -c Disassemble the code main.opt.s=\ -\ -s Print internal type signatures +\ -s Print internal type signatures + +main.opt.class_path=\ +\ --class-path Specify where to find user class files main.opt.classpath=\ -\ -classpath Specify where to find user class files +\ -classpath Specify where to find user class files main.opt.cp=\ -\ -cp Specify where to find user class files +\ -cp Specify where to find user class files main.opt.bootclasspath=\ -\ -bootclasspath Override location of bootstrap class files +\ -bootclasspath Override location of bootstrap class files -main.opt.upgrademodulepath=\ -\ -upgrademodulepath Specify where to find upgradeable modules +main.opt.upgrade_module_path=\ +\ --upgrade-module-path Specify where to find upgradeable modules main.opt.system=\ -\ -system Specify where to find system modules +\ --system Specify where to find system modules -main.opt.modulepath=\ -\ -modulepath Specify where to find application modules +main.opt.module_path=\ +\ --module-path Specify where to find application modules main.opt.constants=\ -\ -constants Show final constants - +\ -constants Show final constants main.opt.sysinfo=\ -\ -sysinfo Show system info (path, size, date, MD5 hash)\n\ -\ of class being processed +\ -sysinfo Show system info (path, size, date, MD5 hash)\n\ +\ of class being processed -main.opt.m=\ -\ -m Specify module containing classes to be disassembled +main.opt.module=\ +\ --module , -m Specify module containing classes to be disassembled + +main.usage.foot=\n\ +GNU-style options may use '=' instead of whitespace to separate the name of an option\n\ +from its value.\n\ +\n\ +Each class to be shown may be specified by a filename, a URL, or by its fully\n\ +qualified class name. Examples:\n\ +\ path/to/MyClass.class\n\ +\ jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class\n\ +\ java.lang.Object\n diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java index a4186d27d8d..2975651e373 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java @@ -514,7 +514,7 @@ public class JdepsConfiguration implements AutoCloseable { } /* - * This method is for -check option to find all target modules specified + * This method is for --check option to find all target modules specified * in qualified exports. * * Include all system modules and modules found on modulepath diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java index 698e728f6e0..2cdca8bb839 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -144,7 +144,7 @@ class JdepsTask { } static Option[] recognizedOptions = { - new Option(false, "-h", "-?", "-help") { + new Option(false, "-h", "-?", "-help", "--help") { void process(JdepsTask task, String opt, String arg) { task.options.help = true; } @@ -195,14 +195,14 @@ class JdepsTask { task.options.apiOnly = true; } }, - new Option(true, "-check") { + new Option(true, "--check") { void process(JdepsTask task, String opt, String arg) throws BadArgs { Set mods = Set.of(arg.split(",")); task.options.checkModuleDeps = mods; task.options.addmods.addAll(mods); } }, - new Option(true, "-genmoduleinfo") { + new Option(true, "--gen-module-info") { void process(JdepsTask task, String opt, String arg) throws BadArgs { Path p = Paths.get(arg); if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { @@ -222,22 +222,22 @@ class JdepsTask { }, // ---- paths option ---- - new Option(true, "-cp", "-classpath") { + new Option(true, "-cp", "-classpath", "--class-path") { void process(JdepsTask task, String opt, String arg) { task.options.classpath = arg; } }, - new Option(true, "-mp", "-modulepath") { + new Option(true, "--module-path") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.modulePath = arg; } }, - new Option(true, "-upgrademodulepath") { + new Option(true, "--upgrade-module-path") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.upgradeModulePath = arg; } }, - new Option(true, "-system") { + new Option(true, "--system") { void process(JdepsTask task, String opt, String arg) throws BadArgs { if (arg.equals("none")) { task.options.systemModulePath = null; @@ -250,13 +250,13 @@ class JdepsTask { } } }, - new Option(true, "-addmods") { + new Option(true, "--add-modules") { void process(JdepsTask task, String opt, String arg) throws BadArgs { Set mods = Set.of(arg.split(",")); task.options.addmods.addAll(mods); } }, - new Option(true, "-m") { + new Option(true, "-m", "--module") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.rootModule = arg; task.options.addmods.add(arg); @@ -314,7 +314,7 @@ class JdepsTask { }, // Another alternative to list modules in -addmods option - new HiddenOption(true, "-include-system-modules") { + new HiddenOption(true, "--include-system-modules") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.includeSystemModulePattern = Pattern.compile(arg); } @@ -345,7 +345,7 @@ class JdepsTask { } }, - new Option(false, "-ct", "-compile-time") { + new Option(false, "--compile-time") { void process(JdepsTask task, String opt, String arg) { task.options.compileTimeView = true; task.options.filterSamePackage = true; @@ -375,7 +375,7 @@ class JdepsTask { task.options.showLabel = true; } }, - new HiddenOption(false, "-hide-module") { + new HiddenOption(false, "--hide-show-module") { void process(JdepsTask task, String opt, String arg) { task.options.showModule = false; } @@ -464,7 +464,7 @@ class JdepsTask { return EXIT_CMDERR; } if (options.checkModuleDeps != null && !inputArgs.isEmpty()) { - reportError("err.invalid.module.option", inputArgs, "-check"); + reportError("err.invalid.module.option", inputArgs, "--check"); } boolean ok = run(); @@ -501,12 +501,12 @@ class JdepsTask { .forEach(mn -> config.findModule(mn).orElseThrow(() -> new UncheckedBadArgs(new BadArgs("err.module.not.found", mn)))); - // -genmoduleinfo + // --gen-module-info if (options.genModuleInfo != null) { return genModuleInfo(config); } - // -check + // --check if (options.checkModuleDeps != null) { return new ModuleAnalyzer(config, log, options.checkModuleDeps).run(); } diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java index d17424007b2..a0030fbac8b 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java @@ -77,7 +77,7 @@ public class ModuleAnalyzer { String list = config.initialArchives().stream() .map(Archive::getPathName).collect(joining(" ")); throw new JdepsTask.UncheckedBadArgs(new BadArgs("err.invalid.module.option", - list, "-check")); + list, "--check")); } this.configuration = config; diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties index 117baf1fc53..571126c7383 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties @@ -1,6 +1,6 @@ main.usage.summary=\ Usage: {0} ]\n\ -use -h, -? or -help for a list of possible options +use -h, -?, -help, or --help for a list of possible options main.usage=\ Usage: {0} ]\n\ @@ -12,7 +12,8 @@ error.prefix=Error: warn.prefix=Warning: main.opt.h=\ -\ -h -? -help Print this usage message +\ -h -? -help\n\ +\ --help Print this usage message main.opt.version=\ \ -version Version information @@ -64,24 +65,26 @@ main.opt.P=\ \ -P -profile Show profile containing a package main.opt.cp=\ -\ -cp -classpath Specify where to find class files +\ -cp \n\ +\ -classpath \n\ +\ --class-path Specify where to find class files -main.opt.mp=\ -\ -mp ...\n\ -\ -modulepath ... Specify module path +main.opt.module-path=\ +\ --module-path ... Specify module path -main.opt.upgrademodulepath=\ -\ -upgrademodulepath ... Specify upgrade module path +main.opt.upgrade-module-path=\ +\ --upgrade-module-path ... Specify upgrade module path main.opt.system=\ -\ -system Specify an alternate system module path +\ --system Specify an alternate system module path -main.opt.addmods=\ -\ -addmods [,...]\n\ +main.opt.add-modules=\ +\ --add-modules [,...]\n\ \ Adds modules to the root set for analysis main.opt.m=\ -\ -m Specify the root module for analysis +\ -m \n\ +\ --module Specify the root module for analysis main.opt.R=\ \ -R -recursive Recursively traverse all run-time dependencies.\n\ @@ -98,8 +101,8 @@ main.opt.I=\ \ dependency summary. This option must use\n\ \ with -requires, -package or -regex option. -main.opt.ct=\ -\ -ct -compile-time Compile-time view of transitive dependencies\n\ +main.opt.compile-time=\ +\ --compile-time Compile-time view of transitive dependencies\n\ \ i.e. compile-time view of -R option.\n\ \ Analyzes the dependences per other given options\n\ \ If a dependence is found from a directory,\n\ @@ -113,14 +116,14 @@ main.opt.apionly=\ \ type, method parameter types, returned type,\n\ \ checked exception types etc. -main.opt.genmoduleinfo=\ -\ -genmoduleinfo Generate module-info.java under the specified\n\ +main.opt.gen-module-info=\ +\ --gen-module-info Generate module-info.java under the specified\n\ \ directory. The specified JAR files will be\n\ \ analyzed. This option cannot be used with\n\ \ -dotoutput or -cp. main.opt.check=\ -\ -check [,...\n\ +\ --check [,...\n\ \ Analyze the dependence of the specified modules\n\ \ It prints the module descriptor, the resulting\n\ \ module dependences after analysis and the\n\ @@ -151,7 +154,7 @@ err.unknown.option=unknown option: {0} err.missing.arg=no value given for {0} err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} -err.genmoduleinfo.not.jarfile={0} not valid for -genmoduleinfo option (must be non-modular JAR file) +err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file) err.profiles.msg=No profile information err.exception.message={0} err.invalid.path=invalid path: {0} diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index e2f9fcfe039..04b9370fb4d 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -86,6 +86,11 @@ tools/javap/output/RepeatingTypeAnnotations.java tools/sjavac/IncCompileFullyQualifiedRef.java 8152055 generic-all Requires dependency code to deal with in-method dependencies. tools/sjavac/IncCompileWithChanges.java 8152055 generic-all Requires dependency code to deal with in-method dependencies. +tools/sjavac/ApiExtraction.java 8158002 generic-all Requires investigation +tools/sjavac/IgnoreSymbolFile.java 8158002 generic-all Requires investigation +tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires investigation + + ########################################################################### # # jdeps diff --git a/langtools/test/TEST.ROOT b/langtools/test/TEST.ROOT index 690b5631668..dc236a5fd39 100644 --- a/langtools/test/TEST.ROOT +++ b/langtools/test/TEST.ROOT @@ -14,8 +14,8 @@ keys=intermittent randomness # Group definitions groups=TEST.groups -# Tests using jtreg 4.2 b02 features -requiredVersion=4.2 b02 +# Tests using jtreg 4.2 b03 features +requiredVersion=4.2 b03 -# Use new form of -Xpatch -useNewXpatch=true +# Use new module options +useNewOptions=true diff --git a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java index 3d9234a34d2..14ca520e6ea 100644 --- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java +++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java @@ -42,8 +42,8 @@ public class TestModules extends JavadocTester { @Test void test1() { javadoc("-d", "out", "-use", - "-modulesourcepath", testSrc, - "-addmods", "module1,module2", + "--module-source-path", testSrc, + "--add-modules", "module1,module2", "testpkgmdl1", "testpkgmdl2"); checkExit(Exit.OK); testDescription(true); @@ -57,8 +57,8 @@ public class TestModules extends JavadocTester { @Test void test2() { javadoc("-d", "out-html5", "-html5", "-use", - "-modulesourcepath", testSrc, - "-addmods", "module1,module2", + "--module-source-path", testSrc, + "--add-modules", "module1,module2", "testpkgmdl1", "testpkgmdl2"); checkExit(Exit.OK); testHtml5Description(true); @@ -72,8 +72,8 @@ public class TestModules extends JavadocTester { @Test void test3() { javadoc("-d", "out-nocomment", "-nocomment", "-use", - "-modulesourcepath", testSrc, - "-addmods", "module1,module2", + "--module-source-path", testSrc, + "--add-modules", "module1,module2", "testpkgmdl1", "testpkgmdl2"); checkExit(Exit.OK); testDescription(false); @@ -84,8 +84,8 @@ public class TestModules extends JavadocTester { @Test void test4() { javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use", - "-modulesourcepath", testSrc, - "-addmods", "module1,module2", + "--module-source-path", testSrc, + "--add-modules", "module1,module2", "testpkgmdl1", "testpkgmdl2"); checkExit(Exit.OK); testHtml5Description(false); @@ -108,8 +108,8 @@ public class TestModules extends JavadocTester { javadoc("-d", "out-mdltags", "-author", "-version", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", - "-modulesourcepath", testSrc, - "-addmods", "moduletags,module2", + "--module-source-path", testSrc, + "--add-modules", "moduletags,module2", "testpkgmdltags", "testpkgmdl2"); checkExit(Exit.OK); testModuleTags(); diff --git a/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java b/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java index 3803a5241e9..458f9a8dd4b 100644 --- a/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java +++ b/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java @@ -47,8 +47,6 @@ public class TestStdDoclet { */ void run() throws Exception { File javaHome = new File(System.getProperty("java.home")); - if (javaHome.getName().equals("jre")) - javaHome = javaHome.getParentFile(); File javadoc = new File(new File(javaHome, "bin"), "javadoc"); File testSrc = new File(System.getProperty("test.src")); @@ -57,11 +55,6 @@ public class TestStdDoclet { String thisClassName = TestStdDoclet.class.getName(); List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); - int i = 0; - String prop; - while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) { - cmdArgs.add("-J-Xpatch:" + prop); - } cmdArgs.addAll(Arrays.asList( "-classpath", ".", // insulates us from ambient classpath "-Xdoclint:none", diff --git a/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java b/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java index 02c6ec882b3..f585c7c6511 100644 --- a/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java +++ b/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java @@ -68,11 +68,6 @@ public class TestUserDoclet implements Doclet { String thisClassName = TestUserDoclet.class.getName(); List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); - int i = 0; - String prop; - while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) { - cmdArgs.add("-J-Xpatch:" + prop); - } cmdArgs.addAll(Arrays.asList( "-doclet", thisClassName, "-docletpath", testClasses.getPath(), diff --git a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java index aecaaae15d3..c3ba662e2bd 100644 --- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java +++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java @@ -148,7 +148,7 @@ public class CheckResourceKeys { if (codeKeys.contains(rk)) continue; - error("Resource key not found in code: " + rk); + error("Resource key not found in code: '" + rk + '"'); } } diff --git a/langtools/test/jdk/javadoc/tool/ReleaseOption.java b/langtools/test/jdk/javadoc/tool/ReleaseOption.java index fde63952aa9..9761af3f039 100644 --- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java +++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java @@ -21,6 +21,7 @@ * questions. */ +import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; @@ -53,16 +54,16 @@ public class ReleaseOption { List options = new ArrayList<>(); options.addAll(Arrays.asList(args)); options.add("-XDrawDiagnostics"); - options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java"); + options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath()); StringWriter out = new StringWriter(); PrintWriter pw = new PrintWriter(out); int actualResult = Main.execute(options.toArray(new String[0]), pw); System.err.println("actual result=" + actualResult); System.err.println("actual output=" + out.toString()); if (actualResult != expectedResult) - throw new Error(); + throw new Error("Exit code not as expected"); if (!validate.test(out.toString())) { - throw new Error("Not an expected error output: " + out.toString()); + throw new Error("Output not as expected"); } } } diff --git a/langtools/test/tools/all/RunCodingRules.java b/langtools/test/tools/all/RunCodingRules.java index 8e345ce1b5e..60a0470a053 100644 --- a/langtools/test/tools/all/RunCodingRules.java +++ b/langtools/test/tools/all/RunCodingRules.java @@ -111,11 +111,11 @@ public class RunCodingRules { Path crulesTarget = targetDir.resolve("crules"); Files.createDirectories(crulesTarget); List crulesOptions = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-d", crulesTarget.toString()); javaCompiler.getTask(null, fm, noErrors, crulesOptions, null, fm.getJavaFileObjectsFromFiles(crulesFiles)).call(); @@ -178,7 +178,7 @@ public class RunCodingRules { List options = Arrays.asList( "-d", sourceTarget.toString(), - "-modulesourcepath", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS + "--module-source-path", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS + genSrcTarget + FS + "*" + FS + "share" + FS + "classes", "-XDaccessInternalAPI", "-processorpath", processorPath, diff --git a/langtools/test/tools/javac/6410653/T6410653.java b/langtools/test/tools/javac/6410653/T6410653.java index 1d9a883b830..ff0d89a60e6 100644 --- a/langtools/test/tools/javac/6410653/T6410653.java +++ b/langtools/test/tools/javac/6410653/T6410653.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -49,9 +49,8 @@ public class T6410653 { compiler.run(null, null, out, "-d", source, source); System.err.println(">>>" + out + "<<<"); useRawMessages.setBoolean(null, false); - if (!out.toString().equals(String.format("%s%n%s%n", - "javac: javac.err.file.not.directory", - "javac.msg.usage"))) { + if (!out.toString().equals(String.format("%s%n", + "javac: javac.err.file.not.directory"))) { throw new AssertionError(out); } System.out.println("Test PASSED. Running javac again to see localized output:"); diff --git a/langtools/test/tools/javac/T6358024.java b/langtools/test/tools/javac/T6358024.java index 17d2277b91e..86bc37afda9 100644 --- a/langtools/test/tools/javac/T6358024.java +++ b/langtools/test/tools/javac/T6358024.java @@ -70,9 +70,9 @@ public class T6358024 extends AbstractProcessor { JavacTool tool = JavacTool.create(); List flags = new ArrayList(); flags.addAll(Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")); + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")); for (Option opt: opts) { flags.add(opt.name); for (Object arg : opt.args) diff --git a/langtools/test/tools/javac/T6358166.java b/langtools/test/tools/javac/T6358166.java index aa9c4c763a6..e1aa2e00bbf 100644 --- a/langtools/test/tools/javac/T6358166.java +++ b/langtools/test/tools/javac/T6358166.java @@ -56,10 +56,10 @@ public class T6358166 extends AbstractProcessor { JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java"); List addExports = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"); + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"); test(fm, f, addExports, "-verbose", "-d", "."); diff --git a/langtools/test/tools/javac/T6403466.java b/langtools/test/tools/javac/T6403466.java index 1d441f24125..9cf291ea36b 100644 --- a/langtools/test/tools/javac/T6403466.java +++ b/langtools/test/tools/javac/T6403466.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -58,10 +58,10 @@ public class T6403466 extends AbstractProcessor { fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java"))); Iterable options = Arrays.asList( - "-XaddExports:" - + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED," + "--add-exports", + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED," + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", - "-processorpath", testClassDir, + "--processor-path", testClassDir, "-processor", self, "-s", ".", "-d", "."); diff --git a/langtools/test/tools/javac/T6406771.java b/langtools/test/tools/javac/T6406771.java index 03e0851f4ae..a6ddd05ea4b 100644 --- a/langtools/test/tools/javac/T6406771.java +++ b/langtools/test/tools/javac/T6406771.java @@ -50,8 +50,8 @@ public class T6406771 extends AbstractProcessor { JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next(); List opts = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", "-XDaccessInternalAPI", "-d", ".", "-processorpath", testClasses, diff --git a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java index 3134c72991c..a80877ed10d 100644 --- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java +++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java @@ -116,6 +116,8 @@ public class DetectMutableStaticFields { "moduleFinderClass", "ofMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper", "loadMethod"); + ignore("com/sun/tools/javac/util/JDK9Wrappers$VMHelper", + "vmClass", "getRuntimeArgumentsMethod"); } private final List errors = new ArrayList<>(); diff --git a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java index d80da6d8d6d..18cb8ebbe4c 100644 --- a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java +++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java @@ -143,11 +143,11 @@ public class ParameterNamesAreNotCopiedToAnonymousInitTest { Arrays.asList(new File(System.getProperty("test.src"), this.getClass().getName() + ".java"))); java.util.List options = Arrays.asList( - "-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-d", System.getProperty("user.dir") ); JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos); diff --git a/langtools/test/tools/javac/api/T6358786.java b/langtools/test/tools/javac/api/T6358786.java index 811a74cfb28..c3e91ccb617 100644 --- a/langtools/test/tools/javac/api/T6358786.java +++ b/langtools/test/tools/javac/api/T6358786.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -49,7 +49,7 @@ public class T6358786 { String srcdir = System.getProperty("test.src"); File file = new File(srcdir, args[0]); List options = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" ); JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file))); Elements elements = task.getElements(); diff --git a/langtools/test/tools/javac/api/T6412669.java b/langtools/test/tools/javac/api/T6412669.java index 5d1ce559769..114c896fdf1 100644 --- a/langtools/test/tools/javac/api/T6412669.java +++ b/langtools/test/tools/javac/api/T6412669.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -54,7 +54,7 @@ public class T6412669 extends AbstractProcessor { String[] opts = { "-proc:only", "-processor", T6412669.class.getName(), - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" }; StringWriter sw = new StringWriter(); JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files); diff --git a/langtools/test/tools/javac/api/TestClientCodeWrapper.java b/langtools/test/tools/javac/api/TestClientCodeWrapper.java index cd86281771f..3020629c1da 100644 --- a/langtools/test/tools/javac/api/TestClientCodeWrapper.java +++ b/langtools/test/tools/javac/api/TestClientCodeWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -133,7 +133,7 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor { PrintWriter pw = new PrintWriter(sw); List javacOptions = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", "-extdirs", extDirs.getPath(), // for use by filemanager handleOption "-processor", TestClientCodeWrapper.class.getName() ); diff --git a/langtools/test/tools/javac/api/TestJavacTaskScanner.java b/langtools/test/tools/javac/api/TestJavacTaskScanner.java index 15071d815da..e8110396dac 100644 --- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java +++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java @@ -74,10 +74,10 @@ public class TestJavacTaskScanner extends ToolTester { fm.getJavaFileObjects(new File[] {file}); StandardJavaFileManager fm = getLocalFileManager(tool, null, null); java.util.List options = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"); + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"); task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, compilationUnits); task.getContext().put(ScannerFactory.scannerFactoryKey, new MyScanner.Factory(task.getContext(), this)); diff --git a/langtools/test/tools/javac/api/TestTrees.java b/langtools/test/tools/javac/api/TestTrees.java index 3b730c2e0af..2e910f005de 100644 --- a/langtools/test/tools/javac/api/TestTrees.java +++ b/langtools/test/tools/javac/api/TestTrees.java @@ -79,8 +79,7 @@ public class TestTrees extends AbstractProcessor { fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java"))); Iterable opts = Arrays.asList( - "-XaddExports:" - + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", "-d", ".", "-XDcompilePolicy=simple"); @@ -91,8 +90,7 @@ public class TestTrees extends AbstractProcessor { throw new AssertionError("compilation failed"); opts = Arrays.asList( - "-XaddExports:" - + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", "-XDaccessInternalAPI", "-d", ".", "-processorpath", testClassDir, diff --git a/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java b/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java index 1e372c0a690..b48942dea73 100644 --- a/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java @@ -35,6 +35,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -127,8 +128,9 @@ public class ModuleTestBase { tr.checkContains(actualProvides, moduleDescriptor.provides, "Lists of provides don't match"); } - protected void compile(Path base) throws IOException { + protected void compile(Path base, String... options) throws IOException { new JavacTask(tb) + .options(options) .files(findJavaFiles(base)) .run(Task.Expect.SUCCESS) .writeAll(); diff --git a/langtools/test/tools/javac/diags/Example.java b/langtools/test/tools/javac/diags/Example.java index b9c09cf0e2e..8ffe263878a 100644 --- a/langtools/test/tools/javac/diags/Example.java +++ b/langtools/test/tools/javac/diags/Example.java @@ -223,7 +223,7 @@ class Example implements Comparable { // source for import statements or a magic comment for (File pf: procFiles) { if (pf.getName().equals("CreateBadClassFile.java")) { - pOpts.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); + pOpts.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); } } @@ -248,7 +248,7 @@ class Example implements Comparable { } if (moduleSourcePathDir != null) { - opts.add("-modulesourcepath"); + opts.add("--module-source-path"); opts.add(moduleSourcePathDir.getPath()); files = moduleSourcePathFiles; } diff --git a/langtools/test/tools/javac/diags/examples.not-yet.txt b/langtools/test/tools/javac/diags/examples.not-yet.txt index 02ca2329c77..9b82412bf93 100644 --- a/langtools/test/tools/javac/diags/examples.not-yet.txt +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt @@ -122,6 +122,7 @@ compiler.err.locn.bad.module-info # bad class file compiler.err.locn.cant.read.file # bad class file compiler.misc.module.info.invalid.super.class # bad class file compiler.err.locn.cant.read.directory # file system issue +compiler.err.locn.invalid.arg.for.xpatch # command line option error compiler.misc.unnamed.module # fragment uninteresting in and of itself compiler.misc.kindname.module # fragment uninteresting in and of itself compiler.misc.locn.module_path # fragment uninteresting in and of itself diff --git a/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java b/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java index 95c566a9467..0deeae71978 100644 --- a/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java +++ b/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java @@ -22,5 +22,5 @@ */ // key: compiler.err.addmods.all.module.path.invalid -// options: -addmods ALL-MODULE-PATH +// options: --add-modules ALL-MODULE-PATH module m {} diff --git a/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java b/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java index 5446a4b1ee8..40b78f4c7b3 100644 --- a/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java +++ b/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java @@ -24,7 +24,7 @@ // key: compiler.err.cant.find.module // key: compiler.err.doesnt.exist -// options: -XaddExports:undef/undef=ALL-UNNAMED +// options: --add-exports undef/undef=ALL-UNNAMED import undef.Any; diff --git a/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java index 81205c4a845..90c2c1fb79b 100644 --- a/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java +++ b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java @@ -22,7 +22,7 @@ */ // key: compiler.err.illegal.argument.for.option -// options: -modulepath doesNotExist +// options: --module-path doesNotExist // run: simple class X {} diff --git a/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java b/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java deleted file mode 100644 index 20d501b0dd7..00000000000 --- a/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2016, 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. - * - * 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. - */ - -// key: compiler.err.locn.invalid.arg.for.xpatch -// options: -Xpatch:blah - -class InvalidArgForXpatch {} diff --git a/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java b/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java index e433305f10e..9159e0f5bed 100644 --- a/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java +++ b/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java @@ -25,7 +25,7 @@ // key: compiler.misc.bad.class.file.header // key: compiler.err.cant.access // options: -processor CreateBadClassFile -// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED +// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED /* The annotation processor will create an invalid classfile with version 51.0 * and a non-abstract method in an interface. Loading the classfile will produce diff --git a/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java b/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java index 751409a78c9..e637d6a37ec 100644 --- a/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java +++ b/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java @@ -25,7 +25,7 @@ // key: compiler.misc.bad.class.file.header // key: compiler.err.cant.access // options: -processor CreateBadClassFile -// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED +// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED /* The annotation processor will create an invalid classfile with version 51.0 * and a static method in an interface. Loading the classfile will produce diff --git a/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java b/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java index 07d54310038..326a2b17f87 100644 --- a/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java +++ b/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java @@ -22,7 +22,7 @@ */ // key: compiler.err.xaddexports.malformed.entry -// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util +// options: --add-exports jdk.compiler/com.sun.tools.javac.util public class XaddexportsMalformedEntry { } diff --git a/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java b/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java index 6f6c064dd40..6fac72572e3 100644 --- a/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java +++ b/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java @@ -22,7 +22,7 @@ */ // key: compiler.err.xaddexports.too.many -// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +// options: --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED public class XaddexportsTooMany { } diff --git a/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java b/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java index 650cf6196a6..b38f4bed7e7 100644 --- a/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java +++ b/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java @@ -22,7 +22,7 @@ */ // key: compiler.err.xaddreads.malformed.entry -// options: -XaddReads:jdk.compiler +// options: --add-reads jdk.compiler public class XaddreadsMalformedEntry { } diff --git a/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java b/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java index d0b2551abc6..11560450da0 100644 --- a/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java +++ b/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java @@ -22,7 +22,7 @@ */ // key: compiler.err.xaddreads.too.many -// options: -XaddReads:jdk.compiler=ALL-UNNAMED -XaddReads:jdk.compiler=ALL-UNNAMED +// options: --add-reads jdk.compiler=ALL-UNNAMED --add-reads jdk.compiler=ALL-UNNAMED public class XaddreadsTooMany { } diff --git a/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java index f6c3c35f70c..39d90491eb5 100644 --- a/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java +++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java @@ -88,7 +88,7 @@ public class NoJavaLangTest { .run(); // ideally we'd have a better message for this case - String[] mpOpts = { "-system", "none", "-modulepath", "modules" }; + String[] mpOpts = { "--system", "none", "--module-path", "modules" }; test(mpOpts, compilerErrorMessage); } diff --git a/langtools/test/tools/javac/file/T7018098.java b/langtools/test/tools/javac/file/T7018098.java index a8d8b2fc7df..0c902575648 100644 --- a/langtools/test/tools/javac/file/T7018098.java +++ b/langtools/test/tools/javac/file/T7018098.java @@ -60,9 +60,9 @@ public class T7018098 extends JavacTestingAbstractProcessor { _assert(!testDir.exists()); compile( - "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDaccessInternalAPI", "-proc:only", "-processor", myName, @@ -73,9 +73,9 @@ public class T7018098 extends JavacTestingAbstractProcessor { _assert(testDir.exists()); compile( - "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDaccessInternalAPI", "-proc:only", "-processor", myName, diff --git a/langtools/test/tools/javac/modules/AddLimitMods.java b/langtools/test/tools/javac/modules/AddLimitMods.java index 6cdd3ec9006..85785b6d4b8 100644 --- a/langtools/test/tools/javac/modules/AddLimitMods.java +++ b/langtools/test/tools/javac/modules/AddLimitMods.java @@ -23,7 +23,7 @@ /** * @test - * @summary Test -addmods and -limitmods; also test the "enabled" modules. + * @summary Test --add-modules and --limit-modules; also test the "enabled" modules. * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api @@ -103,14 +103,14 @@ public class AddLimitMods extends ModuleTestBase { Files.createDirectories(modulePath); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(m3)) .run() .writeAll(); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(m2)) .run() @@ -118,57 +118,57 @@ public class AddLimitMods extends ModuleTestBase { //real test new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "java.base") + "--limit-modules", "java.base") .outdir(modulePath) .files(findJavaFiles(m1)) .run(Task.Expect.FAIL) .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "java.base", - "-addmods", "m2") + "--limit-modules", "java.base", + "--add-modules", "m2") .outdir(modulePath) .files(findJavaFiles(m1)) .run(Task.Expect.FAIL) .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "java.base", - "-addmods", "m2,m3") + "--limit-modules", "java.base", + "--add-modules", "m2,m3") .outdir(modulePath) .files(findJavaFiles(m1)) .run() .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "m2") + "--limit-modules", "m2") .outdir(modulePath) .files(findJavaFiles(m1)) .run() .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "m3") + "--limit-modules", "m3") .outdir(modulePath) .files(findJavaFiles(m1)) .run(Task.Expect.FAIL) .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), + .options("--module-path", modulePath.toString(), "-Xshouldstop:ifNoError=FLOW", - "-limitmods", "m3", - "-addmods", "m2") + "--limit-modules", "m3", + "--add-modules", "m2") .outdir(modulePath) .files(findJavaFiles(m1)) .run() @@ -219,11 +219,11 @@ public class AddLimitMods extends ModuleTestBase { "Test.java:2:18: compiler.err.doesnt.exist: javax.annotation\n" + "Test.java:5:19: compiler.err.doesnt.exist: javax.xml.bind\n" + "2 errors\n"), - new SimpleEntry(new String[] {"-addmods", "java.annotations.common,java.xml.bind"}, + new SimpleEntry(new String[] {"--add-modules", "java.annotations.common,java.xml.bind"}, null), - new SimpleEntry(new String[] {"-limitmods", "java.xml.ws,jdk.compiler"}, + new SimpleEntry(new String[] {"--limit-modules", "java.xml.ws,jdk.compiler"}, null), - new SimpleEntry(new String[] {"-addmods", "ALL-SYSTEM"}, + new SimpleEntry(new String[] {"--add-modules", "ALL-SYSTEM"}, null) ); @@ -244,7 +244,7 @@ public class AddLimitMods extends ModuleTestBase { Files.createDirectories(modulePath); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(moduleSrc)) .run() @@ -258,15 +258,15 @@ public class AddLimitMods extends ModuleTestBase { Files.createDirectories(cpOut); new JavacTask(tb) - .options("-modulepath", modulePath.toString()) + .options("--module-path", modulePath.toString()) .outdir(cpOut) .files(findJavaFiles(cpSrc)) .run(Task.Expect.FAIL) .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), - "-addmods", "ALL-MODULE-PATH") + .options("--module-path", modulePath.toString(), + "--add-modules", "ALL-MODULE-PATH") .outdir(cpOut) .files(findJavaFiles(cpSrc)) .run() @@ -278,9 +278,9 @@ public class AddLimitMods extends ModuleTestBase { "1 error"); actual = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), + .options("--module-source-path", moduleSrc.toString(), "-XDrawDiagnostics", - "-addmods", "ALL-MODULE-PATH") + "--add-modules", "ALL-MODULE-PATH") .outdir(modulePath) .files(findJavaFiles(moduleSrc)) .run(Task.Expect.FAIL) @@ -294,7 +294,7 @@ public class AddLimitMods extends ModuleTestBase { actual = new JavacTask(tb) .options("-Xmodule:java.base", "-XDrawDiagnostics", - "-addmods", "ALL-MODULE-PATH") + "--add-modules", "ALL-MODULE-PATH") .outdir(cpOut) .files(findJavaFiles(cpSrc)) .run(Task.Expect.FAIL) @@ -308,14 +308,14 @@ public class AddLimitMods extends ModuleTestBase { actual = new JavacTask(tb, Task.Mode.CMDLINE) .options("-source", "8", "-target", "8", "-XDrawDiagnostics", - "-addmods", "ALL-MODULE-PATH") + "--add-modules", "ALL-MODULE-PATH") .outdir(cpOut) .files(findJavaFiles(cpSrc)) .run(Task.Expect.FAIL) .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - if (!actual.contains("javac: option -addmods not allowed with target 1.8")) { + if (!actual.contains("javac: option --add-modules not allowed with target 1.8")) { throw new IllegalStateException("incorrect errors; actual=" + actual); } @@ -323,7 +323,7 @@ public class AddLimitMods extends ModuleTestBase { actual = new JavacTask(tb) .options("-XDrawDiagnostics", - "-addmods", "ALL-MODULE-PATH") + "--add-modules", "ALL-MODULE-PATH") .outdir(cpOut) .files(findJavaFiles(cpSrc)) .run(Task.Expect.FAIL) @@ -386,7 +386,7 @@ public class AddLimitMods extends ModuleTestBase { "package api; public class Api { public void test() { } }"); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(moduleSrc)) .run() @@ -428,7 +428,7 @@ public class AddLimitMods extends ModuleTestBase { tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString()); new JavacTask(tb) - .options("-modulepath", modulePath.toString()) + .options("--module-path", modulePath.toString()) .outdir(out) .files(findJavaFiles(m2Runtime)) .run() @@ -441,9 +441,9 @@ public class AddLimitMods extends ModuleTestBase { output = new JavaTask(tb) .vmOptions(augmentOptions(options, Collections.emptyList(), - "-modulepath", modulePath.toString() + File.pathSeparator + out.getParent().toString(), - "-classpath", classpathOut.toString(), - "-XaddReads:m2=ALL-UNNAMED,automatic", + "--module-path", modulePath.toString() + File.pathSeparator + out.getParent().toString(), + "--class-path", classpathOut.toString(), + "--add-reads", "m2=ALL-UNNAMED,automatic", "-m", "m2/test.Test")) .run() .writeAll() @@ -463,7 +463,7 @@ public class AddLimitMods extends ModuleTestBase { "public class Test {}\n"); List auxOptions = success ? Arrays.asList( - "-processorpath", System.getProperty("test.class.path"), + "--processor-path", System.getProperty("test.class.path"), "-processor", CheckVisibleModule.class.getName(), "-Aoutput=" + output, "-XDaccessInternalAPI=true" @@ -471,8 +471,8 @@ public class AddLimitMods extends ModuleTestBase { new JavacTask(tb) .options(augmentOptions(options, auxOptions, - "-modulepath", modulePath.toString(), - "-classpath", classpathOut.toString(), + "--module-path", modulePath.toString(), + "--class-path", classpathOut.toString(), "-Xshouldstop:ifNoError=FLOW")) .outdir(modulePath) .files(findJavaFiles(m2)) @@ -578,14 +578,14 @@ public class AddLimitMods extends ModuleTestBase { }; private static final String[][] OPTIONS_VARIANTS = { - {"-addmods", "automatic"}, - {"-addmods", "m1,automatic"}, - {"-addmods", "jdk.compiler,automatic"}, - {"-addmods", "m1,jdk.compiler,automatic"}, - {"-addmods", "ALL-SYSTEM,automatic"}, - {"-limitmods", "java.base", "-addmods", "automatic"}, - {"-limitmods", "java.base", "-addmods", "ALL-SYSTEM,automatic"}, - {"-limitmods", "m2", "-addmods", "automatic"}, - {"-limitmods", "jdk.compiler", "-addmods", "automatic"}, + {"--add-modules", "automatic"}, + {"--add-modules", "m1,automatic"}, + {"--add-modules", "jdk.compiler,automatic"}, + {"--add-modules", "m1,jdk.compiler,automatic"}, + {"--add-modules", "ALL-SYSTEM,automatic"}, + {"--limit-modules", "java.base", "--add-modules", "automatic"}, + {"--limit-modules", "java.base", "--add-modules", "ALL-SYSTEM,automatic"}, + {"--limit-modules", "m2", "--add-modules", "automatic"}, + {"--limit-modules", "jdk.compiler", "--add-modules", "automatic"}, }; } diff --git a/langtools/test/tools/javac/modules/AddReadsTest.java b/langtools/test/tools/javac/modules/AddReadsTest.java index 2c3c6c66e3b..1e09bebaae0 100644 --- a/langtools/test/tools/javac/modules/AddReadsTest.java +++ b/langtools/test/tools/javac/modules/AddReadsTest.java @@ -23,7 +23,7 @@ /* * @test - * @summary Test the -XaddReads option + * @summary Test the --add-reads option * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -73,7 +73,7 @@ public class AddReadsTest extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -85,8 +85,8 @@ public class AddReadsTest extends ModuleTestBase { //test add dependencies: new JavacTask(tb) - .options("-XaddReads:m2=m1", - "-modulesourcepath", src.toString(), + .options("--add-reads", "m2=m1", + "--module-source-path", src.toString(), "-processor", VerifyRequires.class.getName()) .outdir(classes) .files(findJavaFiles(src)) @@ -104,8 +104,8 @@ public class AddReadsTest extends ModuleTestBase { //cyclic dependencies OK when created through addReads: new JavacTask(tb) - .options("-XaddReads:m2=m1,m1=m2", - "-modulesourcepath", src.toString()) + .options("--add-reads", "m2=m1,m1=m2", + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run() @@ -115,8 +115,8 @@ public class AddReadsTest extends ModuleTestBase { "module m2 { requires m1; }"); new JavacTask(tb) - .options("-XaddReads:m1=m2", - "-modulesourcepath", src.toString()) + .options("--add-reads", "m1=m2", + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run() @@ -165,8 +165,8 @@ public class AddReadsTest extends ModuleTestBase { "package impl; public class Impl { api.Api api; }"); new JavacTask(tb) - .options("-classpath", jar.toString(), - "-XaddReads:m1=ALL-UNNAMED", + .options("--class-path", jar.toString(), + "--add-reads", "m1=ALL-UNNAMED", "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(moduleSrc)) @@ -191,9 +191,9 @@ public class AddReadsTest extends ModuleTestBase { "package impl; public class Impl { { api.Api.test(); } }"); new JavacTask(tb) - .options("-classpath", jar.toString(), - "-modulesourcepath", moduleSrc.toString(), - "-XaddReads:m1=ALL-UNNAMED", + .options("--class-path", jar.toString(), + "--module-source-path", moduleSrc.toString(), + "--add-reads", "m1=ALL-UNNAMED", "-XDrawDiagnostics") .outdir(classes) .files(m1.resolve("impl").resolve("Impl.java")) @@ -213,8 +213,8 @@ public class AddReadsTest extends ModuleTestBase { "package impl; public class Impl { api.Api a; }"); new JavacTask(tb) - .options("-classpath", jar.toString(), - "-XaddReads:java.base=ALL-UNNAMED", + .options("--class-path", jar.toString(), + "--add-reads", "java.base=ALL-UNNAMED", "-Xmodule:java.base") .outdir(classes) .files(src.resolve("impl").resolve("Impl.java")) @@ -233,7 +233,7 @@ public class AddReadsTest extends ModuleTestBase { "package impl; public class Impl { javax.swing.JButton b; }"); new JavacTask(tb) - .options("-XaddReads:java.base=java.desktop", + .options("--add-reads", "java.base=java.desktop", "-Xmodule:java.base") .outdir(classes) .files(findJavaFiles(src)) @@ -285,7 +285,7 @@ public class AddReadsTest extends ModuleTestBase { tb.createDirectories(classes); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run() @@ -300,9 +300,9 @@ public class AddReadsTest extends ModuleTestBase { "package impl; public class Impl { }"); new JavacTask(tb) - .options("-XaddReads:m1=ALL-UNNAMED", + .options("--add-reads", "m1=ALL-UNNAMED", "-Xmodule:m1", - "-modulepath", classes.toString()) + "--module-path", classes.toString()) .outdir(unnamedClasses) .files(findJavaFiles(unnamedSrc)) .run() diff --git a/langtools/test/tools/javac/modules/AnnotationProcessing.java b/langtools/test/tools/javac/modules/AnnotationProcessing.java index 9fa9e082d37..ba3fb09ffe3 100644 --- a/langtools/test/tools/javac/modules/AnnotationProcessing.java +++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java @@ -81,7 +81,7 @@ public class AnnotationProcessing extends ModuleTestBase { "package impl; public class Impl { }"); String log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), + .options("--module-source-path", moduleSrc.toString(), "-processor", AP.class.getName(), "-AexpectedEnclosedElements=m1=>impl") .outdir(classes) @@ -113,7 +113,7 @@ public class AnnotationProcessing extends ModuleTestBase { "package impl2; public class Impl2 { }"); String log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), + .options("--module-source-path", moduleSrc.toString(), "-processor", AP.class.getName(), "-AexpectedEnclosedElements=m1=>impl1,m2=>impl2") .outdir(classes) diff --git a/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java b/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java index 1fe3a769ff7..8fb400daaef 100644 --- a/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java +++ b/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java @@ -136,7 +136,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { annotationProcessor2); String log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(processorCompiledModules) .files(findJavaFiles(moduleSrc)) .run() @@ -159,7 +159,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { public void testUseOnlyOneProcessor(Path base) throws Exception { initialization(base); String log = new JavacTask(tb) - .options("-processormodulepath", processorCompiledModules.toString(), + .options("--processor-module-path", processorCompiledModules.toString(), "-processor", "mypkg2.MyProcessor2") .outdir(classes) .sources(testClass) @@ -175,7 +175,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { public void testAnnotationProcessorExecutionOrder(Path base) throws Exception { initialization(base); List log = new JavacTask(tb) - .options("-processormodulepath", processorCompiledModules.toString(), + .options("--processor-module-path", processorCompiledModules.toString(), "-processor", "mypkg1.MyProcessor1,mypkg2.MyProcessor2") .outdir(classes) .sources(testClass) @@ -188,7 +188,7 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { } log = new JavacTask(tb) - .options("-processormodulepath", processorCompiledModules.toString(), + .options("--processor-module-path", processorCompiledModules.toString(), "-processor", "mypkg2.MyProcessor2,mypkg1.MyProcessor1") .outdir(classes) .sources(testClass) @@ -205,7 +205,8 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { public void testErrorOutputIfOneProcessorNameIsIncorrect(Path base) throws Exception { initialization(base); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(), + .options("-XDrawDiagnostics", + "--processor-module-path", processorCompiledModules.toString(), "-processor", "mypkg2.MyProcessor2,noPackage.noProcessor,mypkg1.MyProcessor1") .outdir(classes) .sources(testClass) @@ -221,8 +222,9 @@ public class AnnotationProcessorsInModulesTest extends ModuleTestBase { public void testOptionsExclusion(Path base) throws Exception { initialization(base); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(), - "-processorpath", processorCompiledModules.toString()) + .options("-XDrawDiagnostics", + "--processor-module-path", processorCompiledModules.toString(), + "--processor-path", processorCompiledModules.toString()) .outdir(classes) .sources(testClass) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/AutomaticModules.java b/langtools/test/tools/javac/modules/AutomaticModules.java index 8fd48a614f1..5cb2ea3eb87 100644 --- a/langtools/test/tools/javac/modules/AutomaticModules.java +++ b/langtools/test/tools/javac/modules/AutomaticModules.java @@ -93,7 +93,7 @@ public class AutomaticModules extends ModuleTestBase { "package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }"); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString()) + .options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString()) .outdir(classes) .files(findJavaFiles(moduleSrc)) .run() @@ -151,7 +151,7 @@ public class AutomaticModules extends ModuleTestBase { "package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }"); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-classpath", baseJar.toString()) + .options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString(), "--class-path", baseJar.toString()) .outdir(classes) .files(findJavaFiles(moduleSrc)) .run() @@ -197,7 +197,7 @@ public class AutomaticModules extends ModuleTestBase { "package dep; public class Dep { api.Api api; }"); new JavacTask(tb) - .options("-modulepath", modulePath.toString()) + .options("--module-path", modulePath.toString()) .outdir(depClasses) .files(findJavaFiles(depSrc)) .run() @@ -221,7 +221,7 @@ public class AutomaticModules extends ModuleTestBase { "package test; public class Test { }"); new JavacTask(tb) - .options("-modulepath", modulePath.toString()) + .options("--module-path", modulePath.toString()) .outdir(testClasses) .files(findJavaFiles(testSrc)) .run() @@ -273,9 +273,9 @@ public class AutomaticModules extends ModuleTestBase { Files.createDirectories(classes); List log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), - "-modulepath", modulePath.toString(), - "-addmods", "automaticB", + .options("--module-source-path", moduleSrc.toString(), + "--module-path", modulePath.toString(), + "--add-modules", "automaticB", "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(moduleSrc)) @@ -291,8 +291,8 @@ public class AutomaticModules extends ModuleTestBase { } log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString(), - "-modulepath", modulePath.toString(), + .options("--module-source-path", moduleSrc.toString(), + "--module-path", modulePath.toString(), "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(moduleSrc)) diff --git a/langtools/test/tools/javac/modules/DoclintOtherModules.java b/langtools/test/tools/javac/modules/DoclintOtherModules.java index cd89636f869..f2960261c59 100644 --- a/langtools/test/tools/javac/modules/DoclintOtherModules.java +++ b/langtools/test/tools/javac/modules/DoclintOtherModules.java @@ -61,7 +61,7 @@ public class DoclintOtherModules extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror") + .options("-XDrawDiagnostics", "--module-source-path", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror") .outdir(classes) .files(findJavaFiles(m1)) .run(Task.Expect.SUCCESS) diff --git a/langtools/test/tools/javac/modules/DuplicateClassTest.java b/langtools/test/tools/javac/modules/DuplicateClassTest.java index 48e8332cd4c..8e1aef06796 100644 --- a/langtools/test/tools/javac/modules/DuplicateClassTest.java +++ b/langtools/test/tools/javac/modules/DuplicateClassTest.java @@ -60,7 +60,7 @@ public class DuplicateClassTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-modulesourcepath", base.toString()) + .options("--module-source-path", base.toString()) .outdir(classes) .files(findJavaFiles(base)) .run() diff --git a/langtools/test/tools/javac/modules/EdgeCases.java b/langtools/test/tools/javac/modules/EdgeCases.java index df3b9f65a9b..1079ba86d4c 100644 --- a/langtools/test/tools/javac/modules/EdgeCases.java +++ b/langtools/test/tools/javac/modules/EdgeCases.java @@ -73,7 +73,7 @@ public class EdgeCases extends ModuleTestBase { tb.createDirectories(classes); List log = new JavacTask(tb) - .options("-XaddExports:undef/undef=ALL-UNNAMED", "-XDrawDiagnostics") + .options("--add-exports", "undef/undef=ALL-UNNAMED", "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -167,7 +167,7 @@ public class EdgeCases extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -222,16 +222,16 @@ public class EdgeCases extends ModuleTestBase { tb.createDirectories(classes); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), - "-modulesourcepath", src.toString()) + .options("--module-path", modulePath.toString(), + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src_m2)) .run() .writeAll(); new JavacTask(tb) - .options("-modulepath", modulePath.toString(), - "-modulesourcepath", src.toString()) + .options("--module-path", modulePath.toString(), + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src_m3)) .run() @@ -250,7 +250,7 @@ public class EdgeCases extends ModuleTestBase { tb.createDirectories(classes); new JavacTask(tb) - .options("-sourcepath", src_m1.toString(), + .options("--source-path", src_m1.toString(), "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(src_m1.resolve("test"))) @@ -261,7 +261,7 @@ public class EdgeCases extends ModuleTestBase { "module m1 {}"); new JavacTask(tb) - .options("-sourcepath", src_m1.toString()) + .options("--source-path", src_m1.toString()) .outdir(classes) .files(findJavaFiles(src_m1.resolve("test"))) .run() @@ -286,7 +286,7 @@ public class EdgeCases extends ModuleTestBase { tb.createDirectories(classes); List log = new JavacTask(tb) - .options("-modulesourcepath", src.toString(), + .options("--module-source-path", src.toString(), "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(src)) diff --git a/langtools/test/tools/javac/modules/EnvVarTest.java b/langtools/test/tools/javac/modules/EnvVarTest.java index 5d134d7fe56..eed5a03f385 100644 --- a/langtools/test/tools/javac/modules/EnvVarTest.java +++ b/langtools/test/tools/javac/modules/EnvVarTest.java @@ -63,7 +63,7 @@ public class EnvVarTest extends ModuleTestBase { tb.out.println("test that addExports can be given to javac"); new JavacTask(tb) - .options("-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") + .options("--add-exports", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") .outdir(classes) .files(findJavaFiles(src)) .run(Expect.SUCCESS) @@ -71,7 +71,7 @@ public class EnvVarTest extends ModuleTestBase { tb.out.println("test that addExports can be provided with env variable"); new JavacTask(tb, Mode.EXEC) - .envVar("_JAVAC_OPTIONS", "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") + .envVar("_JAVAC_OPTIONS", "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") .outdir(classes) .files(findJavaFiles(src)) .run(Expect.SUCCESS) @@ -80,7 +80,7 @@ public class EnvVarTest extends ModuleTestBase { tb.out.println("test that addExports can be provided with env variable using @file"); Path atFile = src.resolve("at-file.txt"); tb.writeFile(atFile, - "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED"); + "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED"); new JavacTask(tb, Mode.EXEC) .envVar("_JAVAC_OPTIONS", "@" + atFile) diff --git a/langtools/test/tools/javac/modules/GraphsTest.java b/langtools/test/tools/javac/modules/GraphsTest.java index f0d523b48d2..8cfce2ad0c9 100644 --- a/langtools/test/tools/javac/modules/GraphsTest.java +++ b/langtools/test/tools/javac/modules/GraphsTest.java @@ -117,7 +117,7 @@ public class GraphsTest extends ModuleTestBase { .write(base.resolve("positiveSrc")); new JavacTask(tb) - .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules) + .options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules) .outdir(Files.createDirectories(base.resolve("positive"))) .files(findJavaFiles(positiveSrc)) .run() @@ -126,7 +126,7 @@ public class GraphsTest extends ModuleTestBase { Path negativeSrc = m.classes("package p; public class Negative { closedO.O o; closedN.N n; closedL.L l; }") .write(base.resolve("negativeSrc")); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules) + .options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules) .outdir(Files.createDirectories(base.resolve("negative"))) .files(findJavaFiles(negativeSrc)) .run(Task.Expect.FAIL) @@ -144,8 +144,8 @@ public class GraphsTest extends ModuleTestBase { m.write(modSrc); List out = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", modSrc.toString(), - "-mp", jarModules.toString() + "--module-source-path", modSrc.toString(), + "-p", jarModules.toString() ) .outdir(Files.createDirectories(base.resolve("negative"))) .files(findJavaFiles(modSrc)) diff --git a/langtools/test/tools/javac/modules/HelloWorldTest.java b/langtools/test/tools/javac/modules/HelloWorldTest.java index 6240e306b14..ba0456f69f0 100644 --- a/langtools/test/tools/javac/modules/HelloWorldTest.java +++ b/langtools/test/tools/javac/modules/HelloWorldTest.java @@ -76,7 +76,7 @@ public class HelloWorldTest extends ModuleTestBase { new JavacTask(tb) .options("-source", "8", "-target", "8", - "-bootclasspath", smallRtJar.toString()) + "--boot-class-path", smallRtJar.toString()) .outdir(classes) .files(src.resolve("HelloWorld.java")) .run(); @@ -131,7 +131,7 @@ public class HelloWorldTest extends ModuleTestBase { Files.createDirectories(classes); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(classes) .files(src_m1.resolve("p/HelloWorld.java")) .run() diff --git a/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java b/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java new file mode 100644 index 00000000000..3ecaf4e46a8 --- /dev/null +++ b/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java @@ -0,0 +1,421 @@ +/* + * Copyright (c) 2015, 2016, 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. + * + * 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. + */ + +/** + * @test + * @bug 8156998 + * @summary Test --inherit-runtime-environment + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavaTask ModuleTestBase + * @run main InheritRuntimeEnvironmentTest + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import toolbox.ModuleBuilder; +import toolbox.JavaTask; +import toolbox.JavacTask; +import toolbox.Task; + +/** + * Tests that javac picks up runtime options with --inherit-runtime-environment. + * For each option, javac is first run using the option directly, as a control. + * javac is then run again, with the same option(s) being passed to the runtime, + * and --inherit-runtime-environment being used by javac. + * @author jjg + */ +public class InheritRuntimeEnvironmentTest extends ModuleTestBase { + public static void main(String... args) throws Exception { + InheritRuntimeEnvironmentTest t = new InheritRuntimeEnvironmentTest(); + t.runTests(); + } + + /** + * Tests that code being compiled can access JDK-internal API using -add-exports. + * @param base + * @throws Exception + */ + @Test + public void testAddExports(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "class C { com.sun.tools.javac.main.Main main; }"); + + new TestCase(base) + .testOpts("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED") + .files(findJavaFiles(src)) + .run(); + } + + /** + * Tests that code in the unnamed module can access a module on the module path using --add-modules. + */ + @Test + public void testAddModules(Path base) throws Exception { + Path modules = base.resolve("modules"); + new ModuleBuilder(tb, "m1") + .exports("pkg1") + .classes("package pkg1; public class C1 { }") + .build(modules); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "class C { pkg1.C1 c1; }"); + + new TestCase(base) + .testOpts("--module-path", modules.toString(), "--add-modules", "m1") + .files(findJavaFiles(src)) + .run(); + } + + /** + * Tests that a module on the module path is not visible when --limit-modules is used to + * restrict the set of observable modules. + */ + @Test + public void testLimitModules(Path base) throws Exception { + Path modules = base.resolve("modules"); + new ModuleBuilder(tb, "m1") + .exports("pkg1") + .classes("package pkg1; public class C1 { }") + .build(modules); + + Path src = base.resolve("src"); + new ModuleBuilder(tb, "m2") + .requires("m1") + .classes("package pkg2; public class C2 { pkg1.C1 c1; }") + .write(src); + + // This is the control, to verify that by default, the module being compiled will + // be able to read modules on the module path + new TestCase(base) + .testOpts("--module-path", modules.toString()) + .otherOpts("--module-source-path", src.toString()) + .files(findJavaFiles(src)) + .run(); + + // This is the test, to verify that the module being compiled will not be able to read + // modules on the module path when a --limit-modules is used + new TestCase(base) + .testOpts("--module-path", modules.toString(), "--limit-modules", "jdk.compiler") + .otherOpts("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .files(findJavaFiles(src)) + .expect(Task.Expect.FAIL, "compiler.err.module.not.found") + .run(); + } + + /** + * Tests that a module being compiled can see another module on the module path + * using --module-path. + */ + @Test + public void testModulePath(Path base) throws Exception { + Path modules = base.resolve("modules"); + new ModuleBuilder(tb, "m1") + .exports("pkg1") + .classes("package pkg1; public class C1 { }") + .build(modules); + + Path src = base.resolve("src"); + new ModuleBuilder(tb, "m2") + .requires("m1") + .classes("package pkg2; public class C2 { pkg1.C1 c1; }") + .write(src); + + new TestCase(base) + .testOpts("--module-path", modules.toString()) + .otherOpts("--module-source-path", src.toString()) + .files(findJavaFiles(src)) + .run(); + } + + /** + * Tests that a module being compiled can see classes patches into an existing module + * with --patch-module + */ + @Test + public void testPatchModule(Path base) throws Exception { + Path patchSrc = base.resolve("patchSrc"); + tb.writeJavaFiles(patchSrc, + "package java.util; public class Xyzzy { }"); + Path patch = base.resolve("patch"); + Files.createDirectories(patch); + + new JavacTask(tb) + .options("-Xmodule:java.base") + .outdir(patch) + .sourcepath(patchSrc) + .files(findJavaFiles(patchSrc)) + .run() + .writeAll(); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "public class C { java.util.Xyzzy x; }"); + + new TestCase(base) + .testOpts("--patch-module", "java.base=" + patch) + .files(findJavaFiles(src)) + .run(); + } + + /** + * Tests that options in @files are also effective. + * The test is similar to testModulePath, except that the test options are provided in an @-file. + */ + @Test + public void testAtFile(Path base) throws Exception { + Path modules = base.resolve("modules"); + new ModuleBuilder(tb, "m1") + .exports("pkg1") + .classes("package pkg1; public class C1 { }") + .build(modules); + + Path src = base.resolve("src"); + new ModuleBuilder(tb, "m2") + .requires("m1") + .classes("package pkg2; public class C2 { pkg1.C1 c1; }") + .write(src); + + Path atFile = base.resolve("atFile"); + tb.writeFile(atFile, "--module-path " + modules); + + new TestCase(base) + .testOpts("@" + atFile) + .otherOpts("--module-source-path", src.toString()) + .files(findJavaFiles(src)) + .run(); + } + + /** + * Tests that --inherit-runtime-environment works in conjunction with + * environment variables. + * This is a variant of testAddExports. + * The use of environment variables is sufficiently custom that it is + * not easy to do this directly with a simple TestCase. + */ + @Test + public void testEnvVars(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "class C { com.sun.tools.javac.main.Main main; }"); + List testOpts = + Arrays.asList("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"); + List files = Arrays.asList(findJavaFiles(src)); + + String envName = "_JAVAC_OPTIONS"; + String envValue = String.join(" ", testOpts); + + out.println(" javac:"); + Path javacOutDir = base.resolve("out-javac"); + Files.createDirectories(javacOutDir); + + out.println(" env: " + envName + "=" + envValue); + out.println(" outdir: " + javacOutDir); + out.println(" files: " + files); + + new JavacTask(tb, Task.Mode.EXEC) + .envVar(envName, envValue) + .outdir(javacOutDir) + .files(files) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + out.println(" java:"); + Path javaOutDir = base.resolve("out-java"); + Files.createDirectories(javaOutDir); + + Path atFile = base.resolve("atFile"); + tb.writeFile(atFile, String.join(" ", testOpts)); + + List vmOpts = Arrays.asList( + "@" + atFile, + "--module", "jdk.compiler/com.sun.tools.javac.Main" + ); + + List classArgs = join( + Arrays.asList("-d", javaOutDir.toString()), + files.stream() + .map(p -> p.toString()) + .collect(Collectors.toList()) + ); + + envValue = "--inherit-runtime-environment"; + + out.println(" env: " + envName + "=" + envValue); + out.println(" vmOpts: " + vmOpts); + out.println(" classArgs: " + classArgs); + + new JavaTask(tb) + .envVar(envName, envValue) + .vmOptions(vmOpts) + .classArgs(classArgs) + .run() + .writeAll() + .getOutput(Task.OutputKind.STDERR); + } + + /** + * Runs javac with given test options, first directly, and then again, specifying the + * options to the runtime, and using --inherit-runtime-environment. + */ + class TestCase { + final Path base; + List testOpts = Collections.emptyList(); + List otherOpts = Collections.emptyList(); + List files = Collections.emptyList(); + Task.Expect expect = Task.Expect.SUCCESS; + String expectedText; + + /** + * Creates a test case, specifying a base directory for work files. + */ + TestCase(Path base) { + this.base = base; + } + + /** + * Set the "test options" to be passed to javac or to the runtime. + */ + TestCase testOpts(String... testOpts) { + this.testOpts = Arrays.asList(testOpts); + return this; + } + + /** + * Sets additional options required for the compilation. + */ + TestCase otherOpts(String... otherOpts) { + this.otherOpts = Arrays.asList(otherOpts); + return this; + } + + /** + * Sets the files to be compiled. + */ + TestCase files(Path... files) { + this.files = Arrays.asList(files); + return this; + } + + /** + * Sets the expected output, and any expected output from javac. + * The default is {@code Expect.SUCCESS} and no specific output expected. + */ + TestCase expect(Task.Expect expect, String expectedText) { + this.expect = expect; + this.expectedText = expectedText; + return this; + } + + /** + * Runs the test case. + * First, javac is run passing the test options directly to javac. + * Then, javac is run again, passing the test options to the runtime, + * and using --inherit-runtime-environment. + */ + void run() throws IOException { + runJavac(); + runJava(); + } + + private void runJavac() throws IOException { + out.println(" javac:"); + Path javacOutDir = base.resolve("out-javac"); + Files.createDirectories(javacOutDir); + + List options = join(testOpts, otherOpts); + + out.println(" options: " + options); + out.println(" outdir: " + javacOutDir); + out.println(" files: " + files); + + String log = new JavacTask(tb, Task.Mode.CMDLINE) + .options(options) + .outdir(javacOutDir) + .files(files) + .run(expect) + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (expectedText != null && !log.contains(expectedText)) + error("expected text not found"); + } + + private void runJava() throws IOException { + out.println(" java:"); + Path javaOutDir = base.resolve("out-java"); + Files.createDirectories(javaOutDir); + + List vmOpts = join( + testOpts, + Arrays.asList("--module", "jdk.compiler/com.sun.tools.javac.Main") + ); + + List classArgs = join( + Arrays.asList("--inherit-runtime-environment", + "-d", javaOutDir.toString()), + otherOpts, + files.stream() + .map(p -> p.toString()) + .collect(Collectors.toList()) + ); + + out.println(" vmOpts: " + vmOpts); + out.println(" classArgs: " + classArgs); + + String log = new JavaTask(tb) + .vmOptions(vmOpts) + .classArgs(classArgs) + .run(expect) + .writeAll() + .getOutput(Task.OutputKind.STDERR); + + if (expectedText != null && !log.contains(expectedText)) + error("expected text not found"); + } + } + + /** + * Join a series of lists. + */ + @SafeVarargs + private List join(List... lists) { + return Arrays.stream(lists) + .flatMap(list -> list.stream()) + .collect(Collectors.toList()); + } + +} + diff --git a/langtools/test/tools/javac/modules/MOptionTest.java b/langtools/test/tools/javac/modules/MOptionTest.java index cea2670f7c8..c0fb0d7968f 100644 --- a/langtools/test/tools/javac/modules/MOptionTest.java +++ b/langtools/test/tools/javac/modules/MOptionTest.java @@ -58,7 +58,7 @@ public class MOptionTest extends ModuleTestBase { "package test; public class Test {}"); new JavacTask(tb) - .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); @@ -81,7 +81,7 @@ public class MOptionTest extends ModuleTestBase { Thread.sleep(2000); //timestamps new JavacTask(tb) - .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); @@ -98,7 +98,7 @@ public class MOptionTest extends ModuleTestBase { Files.setLastModifiedTime(testTest, FileTime.fromMillis(System.currentTimeMillis())); new JavacTask(tb) - .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); @@ -125,7 +125,7 @@ public class MOptionTest extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", "-m", "m1", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); @@ -174,7 +174,7 @@ public class MOptionTest extends ModuleTestBase { "package p2; public class C2 {}"); new JavacTask(tb) - .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); @@ -215,7 +215,7 @@ public class MOptionTest extends ModuleTestBase { Thread.sleep(2000); //timestamps new JavacTask(tb) - .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); @@ -241,7 +241,7 @@ public class MOptionTest extends ModuleTestBase { Files.setLastModifiedTime(C2Source, FileTime.fromMillis(System.currentTimeMillis())); new JavacTask(tb) - .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString()) + .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString()) .run(Task.Expect.SUCCESS) .writeAll(); diff --git a/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java index ec4e637383a..8fb1afeec63 100644 --- a/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java +++ b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java @@ -25,7 +25,7 @@ * @test * @bug 8154824 * @summary Compiler should handle java.nio.file.FileSystemNotFoundException gracefully and not abort - * @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror -modulepath missing.jar MissingJarInModulePathTest.java + * @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror --module-path missing.jar MissingJarInModulePathTest.java */ class MissingJarInModulePathTest {} diff --git a/langtools/test/tools/javac/modules/ModuleFinderTest.java b/langtools/test/tools/javac/modules/ModuleFinderTest.java index ed228469f85..f11ca7c801b 100644 --- a/langtools/test/tools/javac/modules/ModuleFinderTest.java +++ b/langtools/test/tools/javac/modules/ModuleFinderTest.java @@ -78,7 +78,7 @@ public class ModuleFinderTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) - .options("-XDrawDiagnostics", "-modulepath", modules.toString()) + .options("-XDrawDiagnostics", "--module-path", modules.toString()) .outdir(classes) .files(findJavaFiles(src2)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/ModuleInfoTest.java b/langtools/test/tools/javac/modules/ModuleInfoTest.java index e3ccdac749d..62200b0e6f4 100644 --- a/langtools/test/tools/javac/modules/ModuleInfoTest.java +++ b/langtools/test/tools/javac/modules/ModuleInfoTest.java @@ -188,7 +188,7 @@ public class ModuleInfoTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -216,7 +216,7 @@ public class ModuleInfoTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -242,7 +242,7 @@ public class ModuleInfoTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -289,7 +289,7 @@ public class ModuleInfoTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -315,7 +315,7 @@ public class ModuleInfoTest extends ModuleTestBase { Files.createDirectories(classes); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -356,7 +356,7 @@ public class ModuleInfoTest extends ModuleTestBase { tb.writeFile(src_m1.resolve("module-info.java"), moduleInfo); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/ModulePathTest.java b/langtools/test/tools/javac/modules/ModulePathTest.java index db5a7e71474..06785ee4606 100644 --- a/langtools/test/tools/javac/modules/ModulePathTest.java +++ b/langtools/test/tools/javac/modules/ModulePathTest.java @@ -23,7 +23,7 @@ /* * @test - * @summary tests for -modulepath + * @summary tests for --module-path * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api @@ -62,13 +62,13 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", "doesNotExist") + "--module-path", "doesNotExist") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, doesNotExist")) + if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist")) throw new Exception("expected output not found"); } @@ -80,13 +80,13 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", "dummy.txt") + "--module-path", "dummy.txt") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.txt")) + if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.txt")) throw new Exception("expected output not found"); } @@ -98,13 +98,13 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", "dummy.jimage") + "--module-path", "dummy.jimage") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.jimage")) + if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.jimage")) throw new Exception("expected output not found"); } @@ -132,7 +132,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) - .options("-modulepath", modClasses.toString()) + .options("--module-path", modClasses.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -153,7 +153,7 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) .options("-XDrawDiagnostics", - "-modulepath", modClasses.toString()) + "--module-path", modClasses.toString()) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() @@ -190,7 +190,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) - .options("-modulepath", moduleJar.toString(), "-addmods", "m1") + .options("--module-path", moduleJar.toString(), "--add-modules", "m1") .files(findJavaFiles(src)) .run() .writeAll(); @@ -226,7 +226,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) - .options("-modulepath", moduleJar.toString()) + .options("--module-path", moduleJar.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -240,7 +240,7 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", "dummy.jar") + "--module-path", "dummy.jar") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() @@ -277,7 +277,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .outdir(classes) - .options("-modulepath", jmod.toString()) + .options("--module-path", jmod.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -291,7 +291,7 @@ public class ModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", "dummy.jmod") + "--module-path", "dummy.jmod") .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() @@ -311,7 +311,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", modules + "/./../modules") + "--module-path", modules + "/./../modules") .files(findJavaFiles(src)) .run() .writeAll(); @@ -327,7 +327,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", modules + "/./../modules" + PATH_SEP + modules) + "--module-path", modules + "/./../modules" + PATH_SEP + modules) .files(findJavaFiles(src)) .run() .writeAll(); @@ -343,8 +343,8 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", modules.toString(), - "-modulepath", modules.toString()) + "--module-path", modules.toString(), + "--module-path", modules.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -370,7 +370,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", deepModuleDir + PATH_SEP + modules) + "--module-path", deepModuleDir + PATH_SEP + modules) .files(findJavaFiles(src)) .run() .writeAll(); @@ -400,7 +400,7 @@ public class ModulePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", modules.toString()) + "--module-path", modules.toString()) .files(findJavaFiles(src)) .run() .writeAll(); diff --git a/langtools/test/tools/javac/modules/ModuleSourcePathTest.java b/langtools/test/tools/javac/modules/ModuleSourcePathTest.java index e78a368e84d..8202ae52b7a 100644 --- a/langtools/test/tools/javac/modules/ModuleSourcePathTest.java +++ b/langtools/test/tools/javac/modules/ModuleSourcePathTest.java @@ -62,14 +62,14 @@ public class ModuleSourcePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-sourcepath", sp.toString().replace('/', File.separatorChar), - "-modulesourcepath", msp.toString().replace('/', File.separatorChar), + "--source-path", sp.toString().replace('/', File.separatorChar), + "--module-source-path", msp.toString().replace('/', File.separatorChar), "dummyClass") .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("cannot specify both -sourcepath and -modulesourcepath")) + if (!log.contains("cannot specify both --source-path and --module-source-path")) throw new Exception("expected diagnostic not found"); } @@ -83,7 +83,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(modules) .files(prefixAll(findJavaFiles(src), Paths.get("./"))) .run() @@ -100,7 +100,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", "./" + src) + "--module-source-path", "./" + src) .outdir(modules) .files(findJavaFiles(src)) .run() @@ -123,7 +123,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{src1,src2/inner_dir}") + "--module-source-path", base + "/{src1,src2/inner_dir}") .files(base.resolve("src1/m0/pkg0/A.java"), base.resolve("src2/inner_dir/m1/pkg1/A.java")) .outdir(modules) .run() @@ -154,12 +154,12 @@ public class ModuleSourcePathTest extends ModuleTestBase { for (String sourcepath : sourcePaths) { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", sourcepath.replace('/', File.separatorChar)) + "--module-source-path", sourcepath.replace('/', File.separatorChar)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, mismatched braces")) + if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, mismatched braces")) throw new Exception("expected output for path [" + sourcepath + "] not found"); } } @@ -182,7 +182,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", + "--module-source-path", base + "/{src/{{src1,src2,src3},{srcB,srcC}/{src1,src2/srcX{X,Y}/}},.}" .replace('/', File.separatorChar)) .files(findJavaFiles(base.resolve(modulePaths[modulePaths.length - 1]))) @@ -207,7 +207,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{dummy.txt,src}") + "--module-source-path", base + "/{dummy.txt,src}") .files(src.resolve("kettle$/electric/Heater.java")) .outdir(modules) .run() @@ -227,7 +227,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{src}") + "--module-source-path", base + "/{src}") .files(src.resolve("kettle$/electric/Heater.java")) .outdir(modules) .run() @@ -246,7 +246,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{}") + "--module-source-path", base + "/{}") .files(base.resolve("kettle$/electric/Heater.java")) .outdir(modules) .run() @@ -267,7 +267,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", "{" + src + "," + src + "/car}") + "--module-source-path", "{" + src + "," + src + "/car}") .files(findJavaFiles(src)) .outdir(modules) .run() @@ -286,7 +286,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/src/./../src") + "--module-source-path", base + "/src/./../src") .files(src.resolve("kettle/electric/Heater.java")) .outdir(modules) .run() @@ -305,7 +305,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{src,src,src}") + "--module-source-path", base + "/{src,src,src}") .files(src.resolve("m1/a/A.java")) .outdir(modules) .run() @@ -323,7 +323,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}") + "--module-source-path", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}") .files(base.resolve("m1/a/A.java")) .outdir(modules) .run(Task.Expect.FAIL) @@ -342,7 +342,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "{/not_exist,/}") + "--module-source-path", base + "{/not_exist,/}") .files(base.resolve("m1/a/A.java")) .outdir(modules) .run() @@ -361,7 +361,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/{,{,,,,src,,,}}") + "--module-source-path", base + "/{,{,,,,src,,,}}") .files(src.resolve("m1/a/A.java")) .outdir(modules) .run() @@ -380,7 +380,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", base + "/*/classes/") + "--module-source-path", base + "/*/classes/") .files(base.resolve("kettle/classes/electric/Heater.java")) .outdir(modules) .run() @@ -403,7 +403,7 @@ public class ModuleSourcePathTest extends ModuleTestBase { new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP + "--module-source-path", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP + src + "/*/special/classes") .files(findJavaFiles(src)) .outdir(modules) @@ -432,12 +432,12 @@ public class ModuleSourcePathTest extends ModuleTestBase { for (String sourcepath : sourcePaths) { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", sourcepath.replace('/', File.separatorChar)) + "--module-source-path", sourcepath.replace('/', File.separatorChar)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, illegal use of *")) + if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, illegal use of *")) throw new Exception("expected output for path [" + sourcepath + "] not found"); } } diff --git a/langtools/test/tools/javac/modules/ModuleTestBase.java b/langtools/test/tools/javac/modules/ModuleTestBase.java index 8da371c70e6..7ec771cde8d 100644 --- a/langtools/test/tools/javac/modules/ModuleTestBase.java +++ b/langtools/test/tools/javac/modules/ModuleTestBase.java @@ -21,28 +21,10 @@ * questions. */ -import java.io.File; import java.io.IOException; -import java.io.PrintStream; -import java.lang.annotation.Annotation; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; -import toolbox.JavacTask; import toolbox.TestRunner; import toolbox.ToolBox; diff --git a/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java b/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java index ce727c422a2..fc5b51ac777 100644 --- a/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java +++ b/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java @@ -46,7 +46,6 @@ import javax.lang.model.element.TypeElement; import toolbox.JarTask; import toolbox.JavacTask; import toolbox.Task; -import toolbox.ToolBox; public class ModulesAndClassPathTest extends ModuleTestBase { @@ -70,7 +69,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase { "package impl; public class Impl { api.Api api; }"); List modLog = new JavacTask(tb) - .options("-classpath", jar.toString(), + .options("--class-path", jar.toString(), "-XDrawDiagnostics") .outdir(classes) .files(findJavaFiles(moduleSrc)) @@ -86,8 +85,8 @@ public class ModulesAndClassPathTest extends ModuleTestBase { } new JavacTask(tb) - .options("-classpath", jar.toString(), - "-XaddReads:m1=ALL-UNNAMED") + .options("--class-path", jar.toString(), + "--add-reads", "m1=ALL-UNNAMED") .outdir(classes) .files(findJavaFiles(moduleSrc)) .run() @@ -95,8 +94,8 @@ public class ModulesAndClassPathTest extends ModuleTestBase { .getOutputLines(Task.OutputKind.DIRECT); new JavacTask(tb) - .options("-classpath", jar.toString() + File.pathSeparator + System.getProperty("test.classes"), - "-XaddReads:m1=ALL-UNNAMED", + .options("--class-path", jar.toString() + File.pathSeparator + System.getProperty("test.classes"), + "--add-reads", "m1=ALL-UNNAMED", "-processor", ProcessorImpl.class.getName()) .outdir(classes) .files(findJavaFiles(moduleSrc)) @@ -121,7 +120,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase { "package impl; public class Impl { api.Api api; }"); List modLog = new JavacTask(tb) - .options("-classpath", jar.toString(), + .options("--class-path", jar.toString(), "-sourcepath", m1.toString(), "-XDrawDiagnostics") .outdir(classes) @@ -154,7 +153,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase { "package impl; public class Impl { api.Api api; }"); new JavacTask(tb) - .options("-classpath", jar.toString(), + .options("--class-path", jar.toString(), "-XDrawDiagnostics") .outdir(classes) .files(m1.resolve("module-info.java")) @@ -163,7 +162,7 @@ public class ModulesAndClassPathTest extends ModuleTestBase { .getOutputLines(Task.OutputKind.DIRECT); List modLog = new JavacTask(tb) - .options("-classpath", jar.toString(), + .options("--class-path", jar.toString(), "-XDrawDiagnostics") .outdir(classes) .files(m1.resolve("impl").resolve("Impl.java")) diff --git a/langtools/test/tools/javac/modules/MultiModuleModeTest.java b/langtools/test/tools/javac/modules/MultiModuleModeTest.java index e72995bf5ac..90fb571d815 100644 --- a/langtools/test/tools/javac/modules/MultiModuleModeTest.java +++ b/langtools/test/tools/javac/modules/MultiModuleModeTest.java @@ -60,7 +60,7 @@ public class MultiModuleModeTest extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -83,7 +83,7 @@ public class MultiModuleModeTest extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(classes) .files(join(findJavaFiles(src), findJavaFiles(misc))) .run(Task.Expect.FAIL) @@ -104,7 +104,7 @@ public class MultiModuleModeTest extends ModuleTestBase { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -124,7 +124,7 @@ public class MultiModuleModeTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(modules) .files(src.resolve("m2/module-info.java")) .run() @@ -139,7 +139,7 @@ public class MultiModuleModeTest extends ModuleTestBase { Files.createDirectories(modules1); new JavacTask(tb) - .options("-modulesourcepath", src1.toString()) + .options("--module-source-path", src1.toString()) .outdir(modules1) .files(src1.resolve("m1/module-info.java")) .run() @@ -151,8 +151,8 @@ public class MultiModuleModeTest extends ModuleTestBase { Files.createDirectories(modules2); new JavacTask(tb) - .options("-modulepath", modules1.toString(), - "-modulesourcepath", src2.toString()) + .options("--module-path", modules1.toString(), + "--module-source-path", src2.toString()) .outdir(modules2) .files(src2.resolve("m2/module-info.java")) .run() diff --git a/langtools/test/tools/javac/modules/NPEEmptyFileTest.java b/langtools/test/tools/javac/modules/NPEEmptyFileTest.java index 3ace4bb0326..a1ebebfec54 100644 --- a/langtools/test/tools/javac/modules/NPEEmptyFileTest.java +++ b/langtools/test/tools/javac/modules/NPEEmptyFileTest.java @@ -51,7 +51,7 @@ public class NPEEmptyFileTest extends ModuleTestBase { Path emptyJavaFile = base.resolve("Test.java"); tb.writeFile(emptyJavaFile, ""); new JavacTask(tb, Task.Mode.EXEC) - .options("-modulesourcepath", modules.toString(), + .options("--module-source-path", modules.toString(), "-d", modules.toString(), emptyJavaFile.toString()) .run() .writeAll(); diff --git a/langtools/test/tools/javac/modules/OutputDirTest.java b/langtools/test/tools/javac/modules/OutputDirTest.java index 0236a7bda6a..bbaf64ca411 100644 --- a/langtools/test/tools/javac/modules/OutputDirTest.java +++ b/langtools/test/tools/javac/modules/OutputDirTest.java @@ -63,7 +63,7 @@ public class OutputDirTest extends ModuleTestBase { public void testError(Path base) throws Exception { String log = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() @@ -78,7 +78,7 @@ public class OutputDirTest extends ModuleTestBase { new JavacTask(tb) .options("-XDrawDiagnostics", "-proc:only", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .files(findJavaFiles(src)) .run(Task.Expect.SUCCESS) .writeAll(); @@ -90,7 +90,7 @@ public class OutputDirTest extends ModuleTestBase { new JavacTask(tb) .options("-XDrawDiagnostics", "-d", classes.toString(), - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .files(findJavaFiles(src)) .run(Task.Expect.SUCCESS) .writeAll(); @@ -120,7 +120,7 @@ public class OutputDirTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .outdir(modClasses) // an exploded module .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() @@ -157,7 +157,7 @@ public class OutputDirTest extends ModuleTestBase { .outdir(classes) // within an exploded module .options("-XDrawDiagnostics", "-Xlint", "-Werror", - "-modulepath", modClasses.toString()) + "--module-path", modClasses.toString()) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() diff --git a/langtools/test/tools/javac/modules/PackageConflictTest.java b/langtools/test/tools/javac/modules/PackageConflictTest.java index 915051e34e0..3391d4fb3f7 100644 --- a/langtools/test/tools/javac/modules/PackageConflictTest.java +++ b/langtools/test/tools/javac/modules/PackageConflictTest.java @@ -82,7 +82,7 @@ public class PackageConflictTest extends ModuleTestBase { Files.createDirectories(classes); new JavacTask(tb) - .options("-Werror", "-modulesourcepath", base.toString()) + .options("-Werror", "--module-source-path", base.toString()) .outdir(classes) .files(findJavaFiles(base)) .run() @@ -107,7 +107,7 @@ public class PackageConflictTest extends ModuleTestBase { Files.createDirectories(classes); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", base.toString()) + .options("-XDrawDiagnostics", "--module-source-path", base.toString()) .outdir(classes) .files(findJavaFiles(base)) .run(Task.Expect.FAIL) @@ -137,7 +137,7 @@ public class PackageConflictTest extends ModuleTestBase { .write(modSrc); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-mp", modules.toString()) + .options("-XDrawDiagnostics", "-p", modules.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc.resolve("M"))) .run(Task.Expect.FAIL) @@ -162,7 +162,7 @@ public class PackageConflictTest extends ModuleTestBase { .write(modSrc); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", modSrc.toString()) + .options("-XDrawDiagnostics", "--module-source-path", modSrc.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc)) .run(Task.Expect.SUCCESS) @@ -189,7 +189,7 @@ public class PackageConflictTest extends ModuleTestBase { .write(modSrc); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-mp", modules.toString()) + .options("-XDrawDiagnostics", "-p", modules.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc.resolve("M"))) .run(Task.Expect.SUCCESS) @@ -220,7 +220,7 @@ public class PackageConflictTest extends ModuleTestBase { .write(modSrc); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-mp", modules.toString()) + .options("-XDrawDiagnostics", "-p", modules.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc.resolve("K"))) .run(Task.Expect.FAIL) @@ -252,7 +252,7 @@ public class PackageConflictTest extends ModuleTestBase { .classes("package p; public class DependsOnN { boolean f = pkg.A.flagN; } ") .write(modSrc); new JavacTask(tb) - .options("-modulesourcepath", modSrc.toString()) + .options("--module-source-path", modSrc.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc.resolve("K"))) .run(Task.Expect.SUCCESS) @@ -265,7 +265,7 @@ public class PackageConflictTest extends ModuleTestBase { List output = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", modSrc.toString()) + "--module-source-path", modSrc.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modSrc.resolve("K"))) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/PackageMultipleModules.java b/langtools/test/tools/javac/modules/PackageMultipleModules.java index 888fdaa72e9..f47ba95c096 100644 --- a/langtools/test/tools/javac/modules/PackageMultipleModules.java +++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java @@ -39,7 +39,6 @@ import java.util.List; import toolbox.JavacTask; import toolbox.Task; -import toolbox.ToolBox; public class PackageMultipleModules extends ModuleTestBase { @@ -64,7 +63,7 @@ public class PackageMultipleModules extends ModuleTestBase { Files.createDirectories(classes); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", base.toString()) + .options("-XDrawDiagnostics", "--module-source-path", base.toString()) .outdir(classes) .files(findJavaFiles(base)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/PatchModulesTest.java b/langtools/test/tools/javac/modules/PatchModulesTest.java new file mode 100644 index 00000000000..bf481c596e4 --- /dev/null +++ b/langtools/test/tools/javac/modules/PatchModulesTest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8160489 + * @summary tests for --patch-modules + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.file + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase + * @run main PatchModulesTest + */ + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Field; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.tools.JavaFileObject; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.file.BaseFileManager; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.file.Locations; + +import static java.util.Arrays.asList; + + +public class PatchModulesTest extends ModuleTestBase { + + public static void main(String... args) throws Exception { + PatchModulesTest t = new PatchModulesTest(); + t.init(); + t.runTests(); + } + + private static String PS = File.pathSeparator; + + void init() throws IOException { + tb.createDirectories("a", "b", "c", "d", "e"); + tb.writeJavaFiles(Paths.get("."), "class C { }"); + } + + @Test + public void testSimple(Path base) throws Exception { + test(asList("java.base=a"), + "{java.base=[a]}"); + } + + @Test + public void testPair(Path base) throws Exception { + test(asList("java.base=a", "java.compiler=b"), + "{java.base=[a], java.compiler=[b]}"); + } + + @Test + public void testMultiple(Path base) throws Exception { + test(asList("java.base=a:b"), + "{java.base=[a, b]}"); + } + + @Test + public void testLastOneWins(Path base) throws Exception { + test(asList("java.base=a", "java.compiler=b", "java.base=c"), + "{java.base=[c], java.compiler=[b]}"); + } + + void test(List patches, String expect) throws Exception { + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + StringWriter sw = new StringWriter(); + try (PrintWriter pw = new PrintWriter(sw)) { + JavacFileManager fm = tool.getStandardFileManager(null, null, null); + List opts = patches.stream() + .map(p -> "--patch-module=" + p.replace(":", PS)) + .collect(Collectors.toList()); + Iterable files = fm.getJavaFileObjects("C.java"); + JavacTask task = tool.getTask(pw, fm, null, opts, null, files); + + Field locationsField = BaseFileManager.class.getDeclaredField("locations"); + locationsField.setAccessible(true); + Object locations = locationsField.get(fm); + + Field patchMapField = Locations.class.getDeclaredField("patchMap"); + patchMapField.setAccessible(true); + Map patchMap = (Map) patchMapField.get(locations); + String found = patchMap.toString(); + + if (!found.equals(expect)) { + tb.out.println("Expect: " + expect); + tb.out.println("Found: " + found); + error("output not as expected"); + } + } + } +} + diff --git a/langtools/test/tools/javac/modules/PluginsInModulesTest.java b/langtools/test/tools/javac/modules/PluginsInModulesTest.java index 480b147a7a2..b887af8ae1a 100644 --- a/langtools/test/tools/javac/modules/PluginsInModulesTest.java +++ b/langtools/test/tools/javac/modules/PluginsInModulesTest.java @@ -107,7 +107,7 @@ public class PluginsInModulesTest extends ModuleTestBase { plugin1); String log = new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(processorCompiledModules) .files(findJavaFiles(moduleSrc)) .run() @@ -130,7 +130,7 @@ public class PluginsInModulesTest extends ModuleTestBase { public void testUseOnlyOneProcessor(Path base) throws Exception { initialization(base); List log = new JavacTask(tb) - .options("-processormodulepath", processorCompiledModules.toString(), + .options("--processor-module-path", processorCompiledModules.toString(), "-Xplugin:simpleplugin1") .outdir(classes) .sources(testClass) diff --git a/langtools/test/tools/javac/modules/ProvidesTest.java b/langtools/test/tools/javac/modules/ProvidesTest.java index 4d71217fb77..bb3d84a30f3 100644 --- a/langtools/test/tools/javac/modules/ProvidesTest.java +++ b/langtools/test/tools/javac/modules/ProvidesTest.java @@ -77,7 +77,7 @@ public class ProvidesTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.SUCCESS) @@ -160,7 +160,7 @@ public class ProvidesTest extends ModuleTestBase { List output = new JavacTask(tb) .options("-XDrawDiagnostics", - "-modulesourcepath", modules.toString()) + "--module-source-path", modules.toString()) .outdir(Files.createDirectories(base.resolve("classes"))) .files(findJavaFiles(modules)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/QueryBeforeEnter.java b/langtools/test/tools/javac/modules/QueryBeforeEnter.java index 669d95f03ec..83fc1d44cfa 100644 --- a/langtools/test/tools/javac/modules/QueryBeforeEnter.java +++ b/langtools/test/tools/javac/modules/QueryBeforeEnter.java @@ -94,7 +94,7 @@ public class QueryBeforeEnter extends ModuleTestBase { Files.createDirectories(modulePath); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(moduleSrc)) .run() @@ -131,8 +131,8 @@ public class QueryBeforeEnter extends ModuleTestBase { (com.sun.source.util.JavacTask) javaCompiler.getTask(null, null, d -> { throw new IllegalStateException(d.toString()); }, - Arrays.asList("-modulepath", modulePath.toString(), - "-classpath", cp.toString(), + Arrays.asList("--module-path", modulePath.toString(), + "--class-path", cp.toString(), "-sourcepath", src.toString()), null, fm.getJavaFileObjects(src.resolve("test").resolve("Test2.java"))); @@ -170,7 +170,7 @@ public class QueryBeforeEnter extends ModuleTestBase { Files.createDirectories(modulePath); new JavacTask(tb) - .options("-modulesourcepath", moduleSrc.toString()) + .options("--module-source-path", moduleSrc.toString()) .outdir(modulePath) .files(findJavaFiles(moduleSrc)) .run() @@ -207,8 +207,8 @@ public class QueryBeforeEnter extends ModuleTestBase { (com.sun.source.util.JavacTask) javaCompiler.getTask(null, null, d -> { throw new IllegalStateException(d.toString()); }, - Arrays.asList("-modulepath", modulePath.toString(), - "-classpath", cp.toString(), + Arrays.asList("--module-path", modulePath.toString(), + "--class-path", cp.toString(), "-sourcepath", src.toString()), null, fm.getJavaFileObjects(findJavaFiles(src))); @@ -245,7 +245,7 @@ public class QueryBeforeEnter extends ModuleTestBase { Files.createDirectories(modulePath); new JavacTask(tb) - .options("-modulesourcepath", modulePathSrc.toString()) + .options("--module-source-path", modulePathSrc.toString()) .outdir(modulePath) .files(findJavaFiles(modulePathSrc)) .run() @@ -289,9 +289,9 @@ public class QueryBeforeEnter extends ModuleTestBase { (com.sun.source.util.JavacTask) javaCompiler.getTask(null, null, d -> { throw new IllegalStateException(d.toString()); }, - Arrays.asList("-modulepath", modulePath.toString(), - "-classpath", cp.toString(), - "-modulesourcepath", moduleSrc.toString(), + Arrays.asList("--module-path", modulePath.toString(), + "--class-path", cp.toString(), + "--module-source-path", moduleSrc.toString(), "-d", out.toString()), null, fm.getJavaFileObjects(findJavaFiles(moduleSrc))); @@ -339,7 +339,7 @@ public class QueryBeforeEnter extends ModuleTestBase { (com.sun.source.util.JavacTask) javaCompiler.getTask(null, null, d -> { throw new IllegalStateException(d.toString()); }, - Arrays.asList("-processorpath", processorPath, + Arrays.asList("--processor-path", processorPath, "-processor", AP.class.getName(), "-Xplugin:test"), null, @@ -347,7 +347,7 @@ public class QueryBeforeEnter extends ModuleTestBase { task.call(); } - Main.compile(new String[] {"-processorpath", processorPath, + Main.compile(new String[] {"--processor-path", processorPath, "-Xplugin:test", testSource.toString()}); } diff --git a/langtools/test/tools/javac/modules/RequiresPublicTest.java b/langtools/test/tools/javac/modules/RequiresPublicTest.java index 7ce53d21fe3..68184db8f09 100644 --- a/langtools/test/tools/javac/modules/RequiresPublicTest.java +++ b/langtools/test/tools/javac/modules/RequiresPublicTest.java @@ -80,7 +80,7 @@ public class RequiresPublicTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics") .files(findJavaFiles(src)) - .outdir(classes.toString()) // should allow Path here + .outdir(classes) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); @@ -96,7 +96,7 @@ public class RequiresPublicTest extends ModuleTestBase { Files.createDirectories(classes); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .files(findJavaFiles(src)) .outdir(classes) .run() @@ -113,7 +113,7 @@ public class RequiresPublicTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulesourcepath", src.toString()) + "--module-source-path", src.toString()) .files(findJavaFiles(src)) .outdir(classes) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/ResolveTest.java b/langtools/test/tools/javac/modules/ResolveTest.java index 6b4fc51d7bd..91ba84af5de 100644 --- a/langtools/test/tools/javac/modules/ResolveTest.java +++ b/langtools/test/tools/javac/modules/ResolveTest.java @@ -93,7 +93,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -117,7 +117,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -143,7 +143,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -167,7 +167,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); String log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -191,7 +191,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run() @@ -211,7 +211,7 @@ public class ResolveTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run() diff --git a/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java b/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java index 60899853871..0abad978c56 100644 --- a/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java +++ b/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java @@ -90,7 +90,7 @@ public class ServiceProvidedButNotExportedOrUsedTest extends ModuleTestBase { Files.createDirectories(modules); List output = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/SingleModuleModeTest.java b/langtools/test/tools/javac/modules/SingleModuleModeTest.java index 319c8c20f36..e453d3bf8e4 100644 --- a/langtools/test/tools/javac/modules/SingleModuleModeTest.java +++ b/langtools/test/tools/javac/modules/SingleModuleModeTest.java @@ -128,7 +128,7 @@ public class SingleModuleModeTest extends ModuleTestBase{ new JavacTask(tb) .options("-processor", VerifyUsesProvides.class.getName(), - "-processorpath", System.getProperty("test.classes")) + "--processor-path", System.getProperty("test.classes")) .outdir(classes) .classpath(classes) .files(src.resolve("C.java")) @@ -147,7 +147,7 @@ public class SingleModuleModeTest extends ModuleTestBase{ new JavacTask(tb) .options("-processor", VerifyUsesProvides.class.getName(), - "-processorpath", System.getProperty("test.classes")) + "--processor-path", System.getProperty("test.classes")) .outdir(classes) .sourcepath(src) .classpath(classes) diff --git a/langtools/test/tools/javac/modules/SubpackageTest.java b/langtools/test/tools/javac/modules/SubpackageTest.java index 87e9fc9fd46..549d6ce2018 100644 --- a/langtools/test/tools/javac/modules/SubpackageTest.java +++ b/langtools/test/tools/javac/modules/SubpackageTest.java @@ -110,7 +110,7 @@ public class SubpackageTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run() diff --git a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java index d4b50d3ab7a..cd83ef49734 100644 --- a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java +++ b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java @@ -66,8 +66,8 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg2.E.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", modules.toString(), - "-upgrademodulepath", upgradeModules.toString()) + .options("--module-path", modules.toString(), + "--upgrade-module-path", upgradeModules.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -92,7 +92,7 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg2.E.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-upgrademodulepath", upgradeModule + File.pathSeparator + module) + .options("--upgrade-module-path", upgradeModule + File.pathSeparator + module) .files(findJavaFiles(src)) .run() .writeAll(); @@ -126,9 +126,9 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg2.E.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", module.toString(), - "-modulesourcepath", src + File.pathSeparator + s, - "-upgrademodulepath", upgradeModule + File.pathSeparator + upgradeModule3) + .options("--module-path", module.toString(), + "--module-source-path", src + File.pathSeparator + s, + "--upgrade-module-path", upgradeModule + File.pathSeparator + upgradeModule3) .outdir(module) .files(findJavaFiles(src)) .run() @@ -154,8 +154,8 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg2.E.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", upgradeModule + File.pathSeparator + module, - "-upgrademodulepath", upgradeModule.toString()) + .options("--module-path", upgradeModule + File.pathSeparator + module, + "--upgrade-module-path", upgradeModule.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -178,13 +178,13 @@ public class UpgradeModulePathTest extends ModuleTestBase { String output = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", module.toString(), - "-upgrademodulepath", dummy.toString()) + "--module-path", module.toString(), + "--upgrade-module-path", dummy.toString()) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!output.contains("compiler.err.illegal.argument.for.option: -upgrademodulepath, " + dummy)) { + if (!output.contains("compiler.err.illegal.argument.for.option: --upgrade-module-path, " + dummy)) { throw new Exception("Expected output was not found"); } } @@ -217,8 +217,8 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg1.A.class.getName(); pkg2.BC.class.getName(); pkg3.DC.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", module.toString(), - "-upgrademodulepath", upgradeModule.toString()) + .options("--module-path", module.toString(), + "--upgrade-module-path", upgradeModule.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -229,8 +229,8 @@ public class UpgradeModulePathTest extends ModuleTestBase { String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", module.toString(), - "-upgrademodulepath", upgradeModule.toString()) + "--module-path", module.toString(), + "--upgrade-module-path", upgradeModule.toString()) .files(findJavaFiles(src2)) .run(Task.Expect.FAIL) .writeAll() @@ -265,9 +265,9 @@ public class UpgradeModulePathTest extends ModuleTestBase { "package p; class A { void main() { pkg2.EC2.class.getName(); } }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", module.toString(), - "-upgrademodulepath", upgradeModule1.toString(), - "-upgrademodulepath", upgradeModule2.toString()) + .options("--module-path", module.toString(), + "--upgrade-module-path", upgradeModule1.toString(), + "--upgrade-module-path", upgradeModule2.toString()) .files(findJavaFiles(src)) .run() .writeAll(); @@ -278,9 +278,9 @@ public class UpgradeModulePathTest extends ModuleTestBase { final String log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", module.toString(), - "-upgrademodulepath", upgradeModule1.toString(), - "-upgrademodulepath", upgradeModule2.toString()) + "--module-path", module.toString(), + "--upgrade-module-path", upgradeModule1.toString(), + "--upgrade-module-path", upgradeModule2.toString()) .files(findJavaFiles(src2)) .run(Task.Expect.FAIL) .writeAll() diff --git a/langtools/test/tools/javac/modules/UsesTest.java b/langtools/test/tools/javac/modules/UsesTest.java index 5e8f0311c0d..a9920dfe5a5 100644 --- a/langtools/test/tools/javac/modules/UsesTest.java +++ b/langtools/test/tools/javac/modules/UsesTest.java @@ -154,7 +154,7 @@ public class UsesTest extends ModuleTestBase { Files.createDirectories(modules); new JavacTask(tb) - .options("-modulesourcepath", src.toString()) + .options("--module-source-path", src.toString()) .outdir(modules) .files(findJavaFiles(src)) .run(Task.Expect.SUCCESS) @@ -175,7 +175,7 @@ public class UsesTest extends ModuleTestBase { .write(modSrc); new JavacTask(tb) - .options("-mp", modules.toString()) + .options("-p", modules.toString()) .outdir(modules) .files(findJavaFiles(modSrc.resolve("m2"))) .run(Task.Expect.SUCCESS) @@ -196,7 +196,7 @@ public class UsesTest extends ModuleTestBase { .write(modSrc); new JavacTask(tb) - .options("-mp", modules.toString()) + .options("-p", modules.toString()) .outdir(modules) .files(findJavaFiles(modSrc.resolve("m2"))) .run(Task.Expect.SUCCESS) @@ -255,7 +255,7 @@ public class UsesTest extends ModuleTestBase { "module m2 { requires m1; uses p.C; }"); List output = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(Files.createDirectories(base.resolve("modules"))) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -279,7 +279,7 @@ public class UsesTest extends ModuleTestBase { "module m2 { requires m1; uses p.C; }"); List output = new JavacTask(tb) - .options("-XDrawDiagnostics", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) .outdir(Files.createDirectories(base.resolve("modules"))) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) diff --git a/langtools/test/tools/javac/modules/XModuleTest.java b/langtools/test/tools/javac/modules/XModuleTest.java index 7edd474ebab..b4f49f64d3d 100644 --- a/langtools/test/tools/javac/modules/XModuleTest.java +++ b/langtools/test/tools/javac/modules/XModuleTest.java @@ -112,7 +112,7 @@ public class XModuleTest extends ModuleTestBase { tb.createDirectories(classes); String log = new JavacTask(tb) - .options("-Xmodule:java.compiler", "-classpath", cpClasses.toString()) + .options("-Xmodule:java.compiler", "--class-path", cpClasses.toString()) .outdir(classes) .files(src.resolve("javax/lang/model/element/Extra.java")) .run() @@ -197,7 +197,7 @@ public class XModuleTest extends ModuleTestBase { tb.createDirectories(classes); List log = new JavacTask(tb) - .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "-modulesourcepath", src.toString()) + .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -229,7 +229,7 @@ public class XModuleTest extends ModuleTestBase { List expected = Arrays.asList("javac: option -Xmodule: can only be specified once", "Usage: javac ", - "use -help for a list of possible options"); + "use --help for a list of possible options"); if (!expected.equals(log)) throw new Exception("expected output not found: " + log); @@ -247,7 +247,7 @@ public class XModuleTest extends ModuleTestBase { tb.writeJavaFiles(src, "package p; interface A extends pkg1.E { }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", modules.toString(), + .options("--module-path", modules.toString(), "-Xmodule:m1") .files(findJavaFiles(src)) .run() @@ -263,7 +263,7 @@ public class XModuleTest extends ModuleTestBase { List log = new JavacTask(tb, Task.Mode.CMDLINE) .options("-XDrawDiagnostics", - "-modulepath", modules.toString(), + "--module-path", modules.toString(), "-Xmodule:m1") .files(findJavaFiles(src2)) .run(Task.Expect.FAIL) @@ -295,8 +295,8 @@ public class XModuleTest extends ModuleTestBase { tb.writeJavaFiles(src, "package p; interface A extends pkg1.D { }"); new JavacTask(tb, Task.Mode.CMDLINE) - .options("-modulepath", modules.toString(), - "-upgrademodulepath", upgrade.toString(), + .options("--module-path", modules.toString(), + "--upgrade-module-path", upgrade.toString(), "-Xmodule:m1") .files(findJavaFiles(src)) .run() diff --git a/langtools/test/tools/javac/platform/PlatformProviderTest.java b/langtools/test/tools/javac/platform/PlatformProviderTest.java index 891c2f20b07..52cb7e3bb4d 100644 --- a/langtools/test/tools/javac/platform/PlatformProviderTest.java +++ b/langtools/test/tools/javac/platform/PlatformProviderTest.java @@ -97,10 +97,9 @@ public class PlatformProviderTest implements PlatformProvider { Task.Result result = new JavacTask(tb, Task.Mode.EXEC) .outdir(".") - .options("-J-classpath", - "-J" + System.getProperty("test.classes"), - "-J-XaddExports:jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", - "-J-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + .options("-J--class-path=" + System.getProperty("test.classes"), + "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", + "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDrawDiagnostics", "-release", platformSpec, @@ -133,10 +132,9 @@ public class PlatformProviderTest implements PlatformProvider { Task.Result result = new JavacTask(tb, Task.Mode.EXEC) .outdir(".") - .options("-J-classpath", - "-J" + System.getProperty("test.classes"), - "-J-XaddExports:jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", - "-J-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + .options("-J--class-path=" + System.getProperty("test.classes"), + "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", + "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-release", "fail", System.getProperty("test.src") + "/PlatformProviderTestSource.java") diff --git a/langtools/test/tools/javac/processing/T8142931.java b/langtools/test/tools/javac/processing/T8142931.java index 59710439e8c..5abeac83687 100644 --- a/langtools/test/tools/javac/processing/T8142931.java +++ b/langtools/test/tools/javac/processing/T8142931.java @@ -54,12 +54,12 @@ public class T8142931 extends AbstractProcessor { try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) { Iterable files = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T8142931.class.getName()+".java"))); - Iterable opts = Arrays.asList("-XaddExports:" + - "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XDaccessInternalAPI", - "-proc:only", - "-processor", "T8142931", - "-processorpath", testClasses); + Iterable opts = Arrays.asList( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "-XDaccessInternalAPI", + "-proc:only", + "-processor", "T8142931", + "-processorpath", testClasses); StringWriter out = new StringWriter(); JavacTask task = (JavacTask)tool.getTask(out, fm, dl, opts, null, files); task.call(); diff --git a/langtools/test/tools/javac/processing/loader/testClose/TestClose.java b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java index bdcc87215de..c113210b921 100644 --- a/langtools/test/tools/javac/processing/loader/testClose/TestClose.java +++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java @@ -132,8 +132,8 @@ public class TestClose implements TaskListener { new MemFile("AnnoProc.java", annoProc), new MemFile("Callback.java", callback)); List options = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDaccessInternalAPI"); JavacTask task = tool.getTask(null, fm, null, options, null, files); check(task.call()); diff --git a/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java index ae590afd25c..ed3a8137ebc 100644 --- a/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java +++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java @@ -92,9 +92,9 @@ public class TestClose2 extends AbstractProcessor implements TaskListener { Iterable files = fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java")); List options = Arrays.asList( - "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-processor", TestClose2.class.getName()); JavacTask task = tool.getTask(null, fm, null, options, null, files); diff --git a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java index 4e31236f1c1..8a6547594bd 100644 --- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java +++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java @@ -64,7 +64,7 @@ public class Main { static JavacTask javac; static Elements elements; - static List addmods_ALL_SYSTEM = Arrays.asList("-addmods", "ALL-SYSTEM"); + static List addmods_ALL_SYSTEM = Arrays.asList("--add-modules", "ALL-SYSTEM"); public static void main(String[] args) throws Exception { JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); diff --git a/langtools/test/tools/javac/util/T6597678.java b/langtools/test/tools/javac/util/T6597678.java index 428f2ddb4af..5459e0be45a 100644 --- a/langtools/test/tools/javac/util/T6597678.java +++ b/langtools/test/tools/javac/util/T6597678.java @@ -59,8 +59,8 @@ public class T6597678 extends JavacTestingAbstractProcessor { PrintWriter pw = new PrintWriter(sw); compile(sw, pw, - "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", - "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDaccessInternalAPI", "-proc:only", "-processor", myName, diff --git a/langtools/test/tools/javadoc/6964914/TestStdDoclet.java b/langtools/test/tools/javadoc/6964914/TestStdDoclet.java index 2ab14c0124c..64e2b40a7f7 100644 --- a/langtools/test/tools/javadoc/6964914/TestStdDoclet.java +++ b/langtools/test/tools/javadoc/6964914/TestStdDoclet.java @@ -47,8 +47,6 @@ public class TestStdDoclet { */ void run() throws Exception { File javaHome = new File(System.getProperty("java.home")); - if (javaHome.getName().equals("jre")) - javaHome = javaHome.getParentFile(); File javadoc = new File(new File(javaHome, "bin"), "javadoc"); File testSrc = new File(System.getProperty("test.src")); @@ -57,11 +55,6 @@ public class TestStdDoclet { String thisClassName = TestStdDoclet.class.getName(); List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); - int i = 0; - String prop; - while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) { - cmdArgs.add("-J-Xpatch:" + prop); - } cmdArgs.addAll(Arrays.asList( "-classpath", ".", // insulates us from ambient classpath "-Xdoclint:none", diff --git a/langtools/test/tools/javadoc/6964914/TestUserDoclet.java b/langtools/test/tools/javadoc/6964914/TestUserDoclet.java index 7cb2041cfe6..28ab02b89f4 100644 --- a/langtools/test/tools/javadoc/6964914/TestUserDoclet.java +++ b/langtools/test/tools/javadoc/6964914/TestUserDoclet.java @@ -59,11 +59,6 @@ public class TestUserDoclet extends Doclet { String thisClassName = TestUserDoclet.class.getName(); List cmdArgs = new ArrayList<>(); cmdArgs.add(javadoc.getPath()); - int i = 0; - String prop; - while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) { - cmdArgs.add("-J-Xpatch:" + prop); - } cmdArgs.addAll(Arrays.asList( "-doclet", thisClassName, "-docletpath", testClasses.getPath(), diff --git a/langtools/test/tools/javadoc/CheckResourceKeys.java b/langtools/test/tools/javadoc/CheckResourceKeys.java index 7dbd163b256..a484f3055d3 100644 --- a/langtools/test/tools/javadoc/CheckResourceKeys.java +++ b/langtools/test/tools/javadoc/CheckResourceKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -121,7 +121,7 @@ public class CheckResourceKeys { if (codeKeys.contains(rk)) continue; - error("Resource key not found in code: " + rk); + error("Resource key not found in code: '" + rk + "'"); } } diff --git a/langtools/test/tools/javadoc/ReleaseOption.java b/langtools/test/tools/javadoc/ReleaseOption.java index 09c396b97fd..d786e36e512 100644 --- a/langtools/test/tools/javadoc/ReleaseOption.java +++ b/langtools/test/tools/javadoc/ReleaseOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -21,7 +21,7 @@ * questions. */ -import com.sun.tools.javadoc.Main; +import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; @@ -29,6 +29,8 @@ import java.util.Arrays; import java.util.List; import java.util.function.Predicate; +import com.sun.tools.javadoc.Main; + /** * @test * @bug 8086737 @@ -52,16 +54,16 @@ public class ReleaseOption { List options = new ArrayList<>(); options.addAll(Arrays.asList(args)); options.add("-XDrawDiagnostics"); - options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java"); + options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath()); StringWriter out = new StringWriter(); PrintWriter pw = new PrintWriter(out); int actualResult = Main.execute("javadoc", pw, pw, pw, "com.sun.tools.doclets.formats.html.HtmlDoclet", options.toArray(new String[0])); System.err.println("actual result=" + actualResult); System.err.println("actual output=" + out.toString()); if (actualResult != expectedResult) - throw new Error(); + throw new Error("Exit code not as expected"); if (!validate.test(out.toString())) { - throw new Error("Not an expected error output: " + out.toString()); + throw new Error("Output not as expected"); } } } diff --git a/langtools/test/tools/javap/T7004698.java b/langtools/test/tools/javap/T7004698.java index 2a2397672ee..2121899092f 100644 --- a/langtools/test/tools/javap/T7004698.java +++ b/langtools/test/tools/javap/T7004698.java @@ -42,7 +42,7 @@ public class T7004698 { File srcFile = new File(srcDir, T7004698.class.getSimpleName() + ".java"); File classesDir = new File("."); compile("-Xjcov", - "-XaddExports:jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED", + "--add-exports", "jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED", "-d", classesDir.getPath(), srcFile.getPath()); diff --git a/langtools/test/tools/jdeps/APIDeps.java b/langtools/test/tools/jdeps/APIDeps.java index 66c2e651780..78665f5b258 100644 --- a/langtools/test/tools/jdeps/APIDeps.java +++ b/langtools/test/tools/jdeps/APIDeps.java @@ -60,13 +60,13 @@ public class APIDeps { Path testsrc = Paths.get(System.getProperty("test.src")); List options = new ArrayList<>(); - // add -XaddExports + // add --add-exports String testModules = System.getProperty("test.modules", ""); List addExports = new ArrayList<>(); for (String s : testModules.split("\\s+")) { if (s.isEmpty()) continue; if (s.indexOf('/') != -1) - addExports.add("-XaddExports:" + s.trim() + "=ALL-UNNAMED"); + addExports.add("--add-exports=" + s.trim() + "=ALL-UNNAMED"); } options.addAll(addExports); diff --git a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java index c5fc541842f..dfe0f5f8a19 100644 --- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java +++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java @@ -64,7 +64,7 @@ public class ShowReplacement { assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"), CLASSES_DIR, "-cp", tmp.toString(), - "-XaddExports:java.base/sun.security.util=ALL-UNNAMED")); + "--add-exports=java.base/sun.security.util=ALL-UNNAMED")); } @Test diff --git a/langtools/test/tools/jdeps/lib/JdepsUtil.java b/langtools/test/tools/jdeps/lib/JdepsUtil.java index 3ec1ad75310..fc7427ea661 100644 --- a/langtools/test/tools/jdeps/lib/JdepsUtil.java +++ b/langtools/test/tools/jdeps/lib/JdepsUtil.java @@ -198,7 +198,7 @@ public final class JdepsUtil { } public ModuleAnalyzer getModuleAnalyzer(Set mods) throws IOException { - // if -check is set, add to the root set and all modules are observable + // if --check is set, add to the root set and all modules are observable addmods(mods); builder.allModules(); return new ModuleAnalyzer(configuration(), pw, mods); diff --git a/langtools/test/tools/jdeps/modules/CheckModuleTest.java b/langtools/test/tools/jdeps/modules/CheckModuleTest.java index 79fe8172d6e..2b7bea5fe90 100644 --- a/langtools/test/tools/jdeps/modules/CheckModuleTest.java +++ b/langtools/test/tools/jdeps/modules/CheckModuleTest.java @@ -78,7 +78,7 @@ public class CheckModuleTest { @Test(dataProvider = "javaBase") public void testJavaBase(String name, ModuleMetaData data) throws Exception { - String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR); + String cmd = String.format("jdeps --check %s --module-path %s%n", name, MODS_DIR); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { jdeps.appModulePath(MODS_DIR.toString()); @@ -137,7 +137,7 @@ public class CheckModuleTest { @Test(dataProvider = "modules") public void modularTest(String name, ModuleMetaData[] data) throws Exception { - String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR); + String cmd = String.format("jdeps --check %s --module-path %s%n", name, MODS_DIR); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { jdeps.appModulePath(MODS_DIR.toString()); diff --git a/langtools/test/tools/jdeps/modules/GenModuleInfo.java b/langtools/test/tools/jdeps/modules/GenModuleInfo.java index dc79bec8d27..b056c9405f8 100644 --- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java +++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java @@ -23,7 +23,7 @@ /* * @test - * @summary Tests jdeps -genmoduleinfo option + * @summary Tests jdeps --gen-module-info option * @library ../lib * @build CompilerUtils JdepsUtil * @modules jdk.jdeps/com.sun.tools.jdeps @@ -73,7 +73,7 @@ public class GenModuleInfo { CompilerUtils.cleanDir(NEW_MODS_DIR); assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED, - "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED)); + "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED)); Arrays.asList("m1", "m2", "m3") .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn))); @@ -106,7 +106,7 @@ public class GenModuleInfo { .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); - JdepsUtil.jdeps(Stream.concat(Stream.of("-genmoduleinfo", DEST_DIR.toString()), + JdepsUtil.jdeps(Stream.concat(Stream.of("--gen-module-info", DEST_DIR.toString()), files).toArray(String[]::new)); // check file exists @@ -132,11 +132,11 @@ public class GenModuleInfo { // compile new module-info.java assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR, UNSUPPORTED, - "-mp", NEW_MODS_DIR.toString(), "-verbose", - "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED)); + "-p", NEW_MODS_DIR.toString(), "-verbose", + "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED)); Arrays.asList("m1", "m2", "m3") .forEach(mn -> assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR, - mn, "-mp", NEW_MODS_DIR.toString()))); + mn, "-p", NEW_MODS_DIR.toString()))); for (String mn : modules) { Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); diff --git a/langtools/test/tools/jdeps/modules/InverseDeps.java b/langtools/test/tools/jdeps/modules/InverseDeps.java index df0b2ca668a..6ec3352692b 100644 --- a/langtools/test/tools/jdeps/modules/InverseDeps.java +++ b/langtools/test/tools/jdeps/modules/InverseDeps.java @@ -117,7 +117,7 @@ public class InverseDeps { @Test(dataProvider = "testrequires") public void testrequires(String name, String[][] expected) throws Exception { - String cmd1 = String.format("jdeps -inverse -modulepath %s -requires %s -addmods %s%n", + String cmd1 = String.format("jdeps -inverse --module-path %s -requires %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) { @@ -128,8 +128,8 @@ public class InverseDeps { runJdeps(jdeps, expected); } - String cmd2 = String.format("jdeps -inverse -modulepath %s -requires %s" + - " -addmods ALL-MODULE-PATH%n", LIBS_DIR, name); + String cmd2 = String.format("jdeps -inverse --module-path %s -requires %s" + + " --add-modules ALL-MODULE-PATH%n", LIBS_DIR, name); // automatic module try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) { @@ -164,7 +164,7 @@ public class InverseDeps { @Test(dataProvider = "testpackage") public void testpackage(String name, String[][] expected) throws Exception { - String cmd = String.format("jdeps -inverse -modulepath %s -package %s -addmods %s%n", + String cmd = String.format("jdeps -inverse --module-path %s -package %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { jdeps.appModulePath(MODS_DIR.toString()) @@ -195,7 +195,7 @@ public class InverseDeps { @Test(dataProvider = "testregex") public void testregex(String name, String[][] expected) throws Exception { - String cmd = String.format("jdeps -inverse -modulepath %s -regex %s -addmods %s%n", + String cmd = String.format("jdeps -inverse --module-path %s -regex %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { diff --git a/langtools/test/tools/jdeps/modules/ModuleTest.java b/langtools/test/tools/jdeps/modules/ModuleTest.java index f210dec8900..77c13672656 100644 --- a/langtools/test/tools/jdeps/modules/ModuleTest.java +++ b/langtools/test/tools/jdeps/modules/ModuleTest.java @@ -23,7 +23,7 @@ /* * @test - * @summary Tests jdeps -m and -mp options on named modules and unnamed modules + * @summary Tests jdeps -m and --module-path options on named modules and unnamed modules * @library ../lib * @build CompilerUtils JdepsUtil * @modules jdk.jdeps/com.sun.tools.jdeps @@ -68,12 +68,12 @@ public class ModuleTest { CompilerUtils.cleanDir(UNNAMED_DIR); assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED, - "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED)); + "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED)); // m4 is not referenced Arrays.asList("m1", "m2", "m3", "m4") .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn))); - assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-mp", MODS_DIR.toString())); + assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-p", MODS_DIR.toString())); Files.delete(UNNAMED_DIR.resolve("module-info.class")); } @@ -112,10 +112,10 @@ public class ModuleTest { @Test(dataProvider = "modules") public void modularTest(String name, ModuleMetaData data) throws IOException { - // jdeps -modulepath mods -m + // jdeps --module-path mods -m runTest(data, MODS_DIR.toString(), Set.of(name)); - // jdeps -modulepath libs/m1.jar:.... -m + // jdeps --module-path libs/m1.jar:.... -m String mp = Arrays.stream(modules) .filter(mn -> !mn.equals(name)) .map(mn -> MODS_DIR.resolve(mn).toString()) @@ -150,8 +150,8 @@ public class ModuleTest { Set roots, Path... paths) throws IOException { - // jdeps -modulepath -m root paths - String cmd = String.format("jdeps -modulepath %s -addmods %s %s%n", + // jdeps --module-path -m root paths + String cmd = String.format("jdeps --module-path %s --add-modules %s %s%n", MODS_DIR, roots.stream().collect(Collectors.joining(",")), paths); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { diff --git a/langtools/test/tools/jdeps/modules/SplitPackage.java b/langtools/test/tools/jdeps/modules/SplitPackage.java index b85aed96127..bc04ac88318 100644 --- a/langtools/test/tools/jdeps/modules/SplitPackage.java +++ b/langtools/test/tools/jdeps/modules/SplitPackage.java @@ -65,12 +65,12 @@ public class SplitPackage { public void runTest() throws Exception { // Test jdeps classes runTest(null); - // Test jdeps -addmods + // Test jdeps --add-modules runTest(JAVA_ANNOTATIONS_COMMON, SPLIT_PKG_NAME); } private void runTest(String root, String... splitPackages) throws Exception { - String cmd = String.format("jdeps -verbose:class -addmods %s %s%n", + String cmd = String.format("jdeps -verbose:class --add-modules %s %s%n", root, CLASSES_DIR); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { diff --git a/langtools/test/tools/jdeps/modules/TransitiveDeps.java b/langtools/test/tools/jdeps/modules/TransitiveDeps.java index 99533849aa1..2bc1f206adb 100644 --- a/langtools/test/tools/jdeps/modules/TransitiveDeps.java +++ b/langtools/test/tools/jdeps/modules/TransitiveDeps.java @@ -123,7 +123,7 @@ public class TransitiveDeps { public void testModulePath(String name, List data) throws IOException { Set roots = Set.of("m6", "unsafe"); - String cmd1 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", MODS_DIR, + String cmd1 = String.format("jdeps --module-path %s --add-modules %s -m %s%n", MODS_DIR, roots.stream().collect(Collectors.joining(",")), name); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) { jdeps.verbose("-verbose:class") @@ -136,7 +136,7 @@ public class TransitiveDeps { // run automatic modules roots = Set.of("ALL-MODULE-PATH", "jdk.unsupported"); - String cmd2 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", LIBS_DIR, + String cmd2 = String.format("jdeps --module-path %s --add-modules %s -m %s%n", LIBS_DIR, roots.stream().collect(Collectors.joining(",")), name); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) { diff --git a/langtools/test/tools/jdeps/modules/src/m3/module-info.java b/langtools/test/tools/jdeps/modules/src/m3/module-info.java index dd7b5303684..e58165da18d 100644 --- a/langtools/test/tools/jdeps/modules/src/m3/module-info.java +++ b/langtools/test/tools/jdeps/modules/src/m3/module-info.java @@ -24,7 +24,7 @@ module m3 { requires public java.sql; requires public m2; - requires java.logging; // TODO: genmoduleinfo to do transitive reduction + requires java.logging; // TODO: --gen-module-info to do transitive reduction requires public m1; exports p3; } diff --git a/langtools/test/tools/jdeps/modules/src/m5/module-info.java b/langtools/test/tools/jdeps/modules/src/m5/module-info.java index 2affe5a3125..ccdfccd37ac 100644 --- a/langtools/test/tools/jdeps/modules/src/m5/module-info.java +++ b/langtools/test/tools/jdeps/modules/src/m5/module-info.java @@ -22,7 +22,7 @@ */ module m5 { - // m4 requires public java.compilerr + // m4 requires public java.compiler requires public m4; requires public java.compiler; diff --git a/langtools/test/tools/lib/toolbox/Assert.java b/langtools/test/tools/lib/toolbox/Assert.java new file mode 100644 index 00000000000..b89cd002f02 --- /dev/null +++ b/langtools/test/tools/lib/toolbox/Assert.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2011, 2016, 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 toolbox; + +import java.util.function.Supplier; + +/** + * Simple facility for unconditional assertions. + * The methods in this class are described in terms of equivalent assert + * statements, assuming that assertions have been enabled. + */ +public class Assert { + /** Equivalent to + * assert cond; + */ + public static void check(boolean cond) { + if (!cond) + error(); + } + + /** Equivalent to + * assert (o == null); + */ + public static void checkNull(Object o) { + if (o != null) + error(); + } + + /** Equivalent to + * assert (t != null); return t; + */ + public static T checkNonNull(T t) { + if (t == null) + error(); + return t; + } + + /** Equivalent to + * assert cond : value; + */ + public static void check(boolean cond, int value) { + if (!cond) + error(String.valueOf(value)); + } + + /** Equivalent to + * assert cond : value; + */ + public static void check(boolean cond, long value) { + if (!cond) + error(String.valueOf(value)); + } + + /** Equivalent to + * assert cond : value; + */ + public static void check(boolean cond, Object value) { + if (!cond) + error(String.valueOf(value)); + } + + /** Equivalent to + * assert cond : msg; + */ + public static void check(boolean cond, String msg) { + if (!cond) + error(msg); + } + + /** Equivalent to + * assert cond : msg.get(); + * Note: message string is computed lazily. + */ + public static void check(boolean cond, Supplier msg) { + if (!cond) + error(msg.get()); + } + + /** Equivalent to + * assert (o == null) : value; + */ + public static void checkNull(Object o, Object value) { + if (o != null) + error(String.valueOf(value)); + } + + /** Equivalent to + * assert (o == null) : msg; + */ + public static void checkNull(Object o, String msg) { + if (o != null) + error(msg); + } + + /** Equivalent to + * assert (o == null) : msg.get(); + * Note: message string is computed lazily. + */ + public static void checkNull(Object o, Supplier msg) { + if (o != null) + error(msg.get()); + } + + /** Equivalent to + * assert (o != null) : msg; + */ + public static T checkNonNull(T t, String msg) { + if (t == null) + error(msg); + return t; + } + + /** Equivalent to + * assert (o != null) : msg.get(); + * Note: message string is computed lazily. + */ + public static T checkNonNull(T t, Supplier msg) { + if (t == null) + error(msg.get()); + return t; + } + + /** Equivalent to + * assert false; + */ + public static void error() { + throw new AssertionError(); + } + + /** Equivalent to + * assert false : msg; + */ + public static void error(String msg) { + throw new AssertionError(msg); + } + + /** Prevent instantiation. */ + private Assert() { } +} diff --git a/langtools/test/tools/lib/toolbox/JavaTask.java b/langtools/test/tools/lib/toolbox/JavaTask.java index f50667bad84..ec1b07cf092 100644 --- a/langtools/test/tools/lib/toolbox/JavaTask.java +++ b/langtools/test/tools/lib/toolbox/JavaTask.java @@ -66,6 +66,16 @@ public class JavaTask extends AbstractTask { return this; } + /** + * Sets the VM options. + * @param vmOptions the options + * @return this task object + */ + public JavaTask vmOptions(List vmOptions) { + this.vmOptions = vmOptions; + return this; + } + /** * Sets the name of the class to be executed. * @param className the name of the class @@ -86,6 +96,16 @@ public class JavaTask extends AbstractTask { return this; } + /** + * Sets the arguments for the class to be executed. + * @param classArgs the arguments + * @return this task object + */ + public JavaTask classArgs(List classArgs) { + this.classArgs = classArgs; + return this; + } + /** * Sets whether or not the standard VM and java options for the test should be passed * to the new VM instance. If this method is not called, the default behavior is that diff --git a/langtools/test/tools/lib/toolbox/JavacTask.java b/langtools/test/tools/lib/toolbox/JavacTask.java index 72ff269d69b..1b0a6d92780 100644 --- a/langtools/test/tools/lib/toolbox/JavacTask.java +++ b/langtools/test/tools/lib/toolbox/JavacTask.java @@ -175,6 +175,16 @@ public class JavacTask extends AbstractTask { return this; } + /** + * Sets the options. + * @param options the options + * @return this task object + */ + public JavacTask options(List options) { + this.options = options; + return this; + } + /** * Sets the classes to be analyzed. * @param classes the classes diff --git a/langtools/test/tools/lib/toolbox/TestRunner.java b/langtools/test/tools/lib/toolbox/TestRunner.java index 05839fdd321..da05e76ffad 100644 --- a/langtools/test/tools/lib/toolbox/TestRunner.java +++ b/langtools/test/tools/lib/toolbox/TestRunner.java @@ -117,7 +117,7 @@ public abstract class TestRunner { } } - public void error(String message) { + protected void error(String message) { out.println("Error: " + message); errorCount++; } diff --git a/langtools/test/tools/sjavac/ApiExtraction.java b/langtools/test/tools/sjavac/ApiExtraction.java index 23a8be5b62c..b9b57991cfd 100644 --- a/langtools/test/tools/sjavac/ApiExtraction.java +++ b/langtools/test/tools/sjavac/ApiExtraction.java @@ -29,10 +29,12 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap - * @build Wrapper toolbox.ToolBox + * jdk.compiler/com.sun.tools.sjavac.options + * jdk.compiler/com.sun.tools.sjavac.pubapi + * @build Wrapper toolbox.ToolBox toolbox.JavacTask * @run main Wrapper ApiExtraction */ + import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static javax.lang.model.element.Modifier.FINAL; @@ -56,6 +58,8 @@ import com.sun.tools.sjavac.pubapi.PubType; import com.sun.tools.sjavac.pubapi.PubVar; import com.sun.tools.sjavac.pubapi.ReferenceTypeDesc; +import toolbox.JavacTask; +import toolbox.ToolBox; public class ApiExtraction { public static void main(String[] args) throws IOException { @@ -86,7 +90,7 @@ public class ApiExtraction { "}"); // Create class file to extract API from - new ToolBox().new JavacTask().sources(testSrc).run(); + new JavacTask(new ToolBox()).sources(testSrc).run(); // Extract PubApi Options options = Options.parseArgs("-d", "bin", "--state-dir=bin", "-cp", "."); diff --git a/langtools/test/tools/sjavac/ClasspathDependencies.java b/langtools/test/tools/sjavac/ClasspathDependencies.java index 5a1eee481ad..a6bbadc7cbb 100644 --- a/langtools/test/tools/sjavac/ClasspathDependencies.java +++ b/langtools/test/tools/sjavac/ClasspathDependencies.java @@ -29,12 +29,10 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap - * @build Wrapper toolbox.ToolBox + * @build Wrapper toolbox.ToolBox toolbox.Assert * @run main Wrapper ClasspathDependencies */ -import static com.sun.tools.javac.util.Assert.check; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -45,6 +43,8 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; +import static toolbox.Assert.check; + public class ClasspathDependencies extends SjavacBase { public static void main(String... args) throws Exception { @@ -134,5 +134,4 @@ public class ClasspathDependencies extends SjavacBase { } }); } - } diff --git a/langtools/test/tools/sjavac/CompileCircularSources.java b/langtools/test/tools/sjavac/CompileCircularSources.java index 14fc4d31f55..b6ef3aa1b0b 100644 --- a/langtools/test/tools/sjavac/CompileCircularSources.java +++ b/langtools/test/tools/sjavac/CompileCircularSources.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper CompileCircularSources */ diff --git a/langtools/test/tools/sjavac/CompileExcludingDependency.java b/langtools/test/tools/sjavac/CompileExcludingDependency.java index 37b80848934..477b8d433c1 100644 --- a/langtools/test/tools/sjavac/CompileExcludingDependency.java +++ b/langtools/test/tools/sjavac/CompileExcludingDependency.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper CompileExcludingDependency */ @@ -49,7 +48,6 @@ public class CompileExcludingDependency extends SJavacTester { void test() throws Exception { Files.createDirectories(BIN); Map previous_bin_state = collectState(BIN); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), "package alfa.omega; public class A { beta.B b; }"); tb.writeFile(GENSRC.resolve("beta/B.java"), diff --git a/langtools/test/tools/sjavac/CompileWithAtFile.java b/langtools/test/tools/sjavac/CompileWithAtFile.java index a3190d4601b..57de47e40b9 100644 --- a/langtools/test/tools/sjavac/CompileWithAtFile.java +++ b/langtools/test/tools/sjavac/CompileWithAtFile.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper CompileWithAtFile */ diff --git a/langtools/test/tools/sjavac/CompileWithInvisibleSources.java b/langtools/test/tools/sjavac/CompileWithInvisibleSources.java index ceec5992937..39ebf45c700 100644 --- a/langtools/test/tools/sjavac/CompileWithInvisibleSources.java +++ b/langtools/test/tools/sjavac/CompileWithInvisibleSources.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper CompileWithInvisibleSources */ @@ -53,7 +52,6 @@ public class CompileWithInvisibleSources extends SJavacTester { Map previous_bin_state = collectState(BIN); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }"); tb.writeFile(GENSRC2.resolve("beta/B.java"), diff --git a/langtools/test/tools/sjavac/CompileWithOverrideSources.java b/langtools/test/tools/sjavac/CompileWithOverrideSources.java index aaa35ede211..b1c4124e753 100644 --- a/langtools/test/tools/sjavac/CompileWithOverrideSources.java +++ b/langtools/test/tools/sjavac/CompileWithOverrideSources.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper CompileWithOverrideSources */ @@ -51,7 +50,6 @@ public class CompileWithOverrideSources extends SJavacTester { Files.createDirectories(BIN); Map previous_bin_state = collectState(BIN); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }"); tb.writeFile(GENSRC.resolve("beta/B.java"), diff --git a/langtools/test/tools/sjavac/HiddenFiles.java b/langtools/test/tools/sjavac/HiddenFiles.java index 237146af29b..9af04ce8879 100644 --- a/langtools/test/tools/sjavac/HiddenFiles.java +++ b/langtools/test/tools/sjavac/HiddenFiles.java @@ -28,22 +28,23 @@ * @bug 8144226 * @summary Ensures that excluded files are inaccessible (even for implicit * compilation) - * - * @modules jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap + * @modules jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.sjavac + * jdk.compiler/com.sun.tools.sjavac.server * @library /tools/lib - * @build Wrapper toolbox.ToolBox + * @build Wrapper toolbox.ToolBox toolbox.Assert * @run main Wrapper HiddenFiles */ -import com.sun.tools.javac.main.Main.Result; -import com.sun.tools.javac.util.Assert; -import com.sun.tools.sjavac.server.Sjavac; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import com.sun.tools.javac.main.Main.Result; + +import toolbox.Assert; + public class HiddenFiles extends SjavacBase { public static void main(String[] ignore) throws Exception { diff --git a/langtools/test/tools/sjavac/IdleShutdown.java b/langtools/test/tools/sjavac/IdleShutdown.java index 334f03149c2..44ece83a1fe 100644 --- a/langtools/test/tools/sjavac/IdleShutdown.java +++ b/langtools/test/tools/sjavac/IdleShutdown.java @@ -25,10 +25,12 @@ * @test * @bug 8044131 * @summary Tests the hooks used for detecting idleness of the sjavac server. - * @modules jdk.compiler/com.sun.tools.sjavac.server + * @modules jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.sjavac.server * @build Wrapper * @run main Wrapper IdleShutdown */ + import java.util.concurrent.atomic.AtomicLong; import com.sun.tools.javac.main.Main.Result; diff --git a/langtools/test/tools/sjavac/IgnoreSymbolFile.java b/langtools/test/tools/sjavac/IgnoreSymbolFile.java index 922e65aad97..b204884024c 100644 --- a/langtools/test/tools/sjavac/IgnoreSymbolFile.java +++ b/langtools/test/tools/sjavac/IgnoreSymbolFile.java @@ -25,8 +25,7 @@ * @test * @bug 8047183 * @summary JDK build fails with sjavac enabled - * - * @modules jdk.compiler + * @modules jdk.compiler/com.sun.tools.sjavac * @build Wrapper * @run main Wrapper IgnoreSymbolFile */ diff --git a/langtools/test/tools/sjavac/IncCompInheritance.java b/langtools/test/tools/sjavac/IncCompInheritance.java index e3ef26c090d..509687f02b0 100644 --- a/langtools/test/tools/sjavac/IncCompInheritance.java +++ b/langtools/test/tools/sjavac/IncCompInheritance.java @@ -28,7 +28,7 @@ * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main - * jdk.jdeps/com.sun.tools.javap + * jdk.compiler/com.sun.tools.sjavac * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompInheritance */ diff --git a/langtools/test/tools/sjavac/IncCompileChangeNative.java b/langtools/test/tools/sjavac/IncCompileChangeNative.java index d5c97e28b98..644091abbaf 100644 --- a/langtools/test/tools/sjavac/IncCompileChangeNative.java +++ b/langtools/test/tools/sjavac/IncCompileChangeNative.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompileChangeNative */ @@ -48,7 +47,6 @@ public class IncCompileChangeNative extends SJavacTester { // Remember the previous bin and headers state here. Map previous_bin_state; Map previous_headers_state; - ToolBox tb = new ToolBox(); void test() throws Exception { Files.createDirectories(GENSRC); diff --git a/langtools/test/tools/sjavac/IncCompileDropClasses.java b/langtools/test/tools/sjavac/IncCompileDropClasses.java index de5a6dfa4d2..3ab781bc555 100644 --- a/langtools/test/tools/sjavac/IncCompileDropClasses.java +++ b/langtools/test/tools/sjavac/IncCompileDropClasses.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompileDropClasses */ @@ -48,7 +47,6 @@ public class IncCompileDropClasses extends SJavacTester { // Remember the previous bin and headers state here. Map previous_bin_state; Map previous_headers_state; - ToolBox tb = new ToolBox(); void test() throws Exception { Files.createDirectories(GENSRC); diff --git a/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java b/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java index d7802129956..b312888d9ea 100644 --- a/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java +++ b/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java @@ -48,7 +48,6 @@ public class IncCompileFullyQualifiedRef extends SJavacTester { void test() throws Exception { clean(TEST_ROOT); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), "package alfa.omega; public class A { "+ " public final static int DEFINITION = 18; "+ diff --git a/langtools/test/tools/sjavac/IncCompileNoChanges.java b/langtools/test/tools/sjavac/IncCompileNoChanges.java index 266910f01f5..14063420c7f 100644 --- a/langtools/test/tools/sjavac/IncCompileNoChanges.java +++ b/langtools/test/tools/sjavac/IncCompileNoChanges.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompileNoChanges */ diff --git a/langtools/test/tools/sjavac/IncCompileUpdateNative.java b/langtools/test/tools/sjavac/IncCompileUpdateNative.java index e652b6017f7..49cadbc1d13 100644 --- a/langtools/test/tools/sjavac/IncCompileUpdateNative.java +++ b/langtools/test/tools/sjavac/IncCompileUpdateNative.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompileUpdateNative */ @@ -48,7 +47,6 @@ public class IncCompileUpdateNative extends SJavacTester { // Remember the previous bin and headers state here. Map previous_bin_state; Map previous_headers_state; - ToolBox tb = new ToolBox(); void test() throws Exception { Files.createDirectories(GENSRC); diff --git a/langtools/test/tools/sjavac/IncCompileWithChanges.java b/langtools/test/tools/sjavac/IncCompileWithChanges.java index c03236042be..101e4ec1566 100644 --- a/langtools/test/tools/sjavac/IncCompileWithChanges.java +++ b/langtools/test/tools/sjavac/IncCompileWithChanges.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @ignore Requires dependency code to deal with in-method dependencies. * @build Wrapper toolbox.ToolBox * @run main Wrapper IncCompileWithChanges @@ -51,7 +50,6 @@ public class IncCompileWithChanges extends SJavacTester { // Remember the previous bin and headers state here. Map previous_bin_state; Map previous_headers_state; - ToolBox tb = new ToolBox(); void test() throws Exception { clean(TEST_ROOT); diff --git a/langtools/test/tools/sjavac/IncludeExcludePatterns.java b/langtools/test/tools/sjavac/IncludeExcludePatterns.java index 6e38aadc218..1c8b2ed299c 100644 --- a/langtools/test/tools/sjavac/IncludeExcludePatterns.java +++ b/langtools/test/tools/sjavac/IncludeExcludePatterns.java @@ -26,17 +26,14 @@ * @bug 8037085 * @summary Ensures that sjavac can handle various exclusion patterns. * - * @modules jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap + * @modules jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.sjavac + * jdk.compiler/com.sun.tools.sjavac.server * @library /tools/lib - * @build Wrapper toolbox.ToolBox + * @build Wrapper toolbox.ToolBox toolbox.Assert * @run main Wrapper IncludeExcludePatterns */ -import com.sun.tools.javac.main.Main.Result; -import com.sun.tools.javac.util.Assert; -import com.sun.tools.sjavac.server.Sjavac; - import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -49,6 +46,10 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.sun.tools.javac.main.Main.Result; + +import toolbox.Assert; + public class IncludeExcludePatterns extends SjavacBase { final Path SRC = Paths.get("src"); diff --git a/langtools/test/tools/sjavac/NoState.java b/langtools/test/tools/sjavac/NoState.java index e95abb50e3c..71596cacfb9 100644 --- a/langtools/test/tools/sjavac/NoState.java +++ b/langtools/test/tools/sjavac/NoState.java @@ -29,17 +29,16 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap - * @build Wrapper toolbox.ToolBox + * @build Wrapper toolbox.ToolBox toolbox.Assert * @run main Wrapper NoState */ -import com.sun.tools.javac.util.Assert; - import java.io.IOException; import java.nio.file.*; import java.util.stream.Stream; +import toolbox.Assert; + public class NoState extends SJavacTester { public static void main(String... args) throws Exception { new NoState().run(); diff --git a/langtools/test/tools/sjavac/OptionDecoding.java b/langtools/test/tools/sjavac/OptionDecoding.java index 423b56b32ea..6546f81cb19 100644 --- a/langtools/test/tools/sjavac/OptionDecoding.java +++ b/langtools/test/tools/sjavac/OptionDecoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -28,6 +28,7 @@ * * @modules jdk.compiler/com.sun.tools.sjavac * jdk.compiler/com.sun.tools.sjavac.client + * jdk.compiler/com.sun.tools.sjavac.comp * jdk.compiler/com.sun.tools.sjavac.options * @build Wrapper * @run main Wrapper OptionDecoding @@ -147,13 +148,13 @@ public class OptionDecoding { SourceLocation dir2 = new SourceLocation(Paths.get("dir2"), i, x); String dir1_PS_dir2 = "dir1" + File.pathSeparator + "dir2"; - Options options = Options.parseArgs("-sourcepath", dir1_PS_dir2); + Options options = Options.parseArgs("--source-path", dir1_PS_dir2); assertEquals(options.getSourceSearchPaths(), Arrays.asList(dir1, dir2)); - options = Options.parseArgs("-modulepath", dir1_PS_dir2); + options = Options.parseArgs("--module-path", dir1_PS_dir2); assertEquals(options.getModuleSearchPaths(), Arrays.asList(dir1, dir2)); - options = Options.parseArgs("-classpath", dir1_PS_dir2); + options = Options.parseArgs("--class-path", dir1_PS_dir2); assertEquals(options.getClassSearchPath(), Arrays.asList(dir1, dir2)); } diff --git a/langtools/test/tools/sjavac/OverlappingSrcDst.java b/langtools/test/tools/sjavac/OverlappingSrcDst.java index a5d1a450411..bf8c676acff 100644 --- a/langtools/test/tools/sjavac/OverlappingSrcDst.java +++ b/langtools/test/tools/sjavac/OverlappingSrcDst.java @@ -32,7 +32,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper OverlappingSrcDst */ @@ -40,6 +39,8 @@ import java.io.File; import java.nio.file.Paths; +import toolbox.ToolBox; + public class OverlappingSrcDst extends SJavacTester { public static void main(String... args) { new OverlappingSrcDst().run(); diff --git a/langtools/test/tools/sjavac/PackagePathMismatch.java b/langtools/test/tools/sjavac/PackagePathMismatch.java index daa73bae5e4..54ba1ee2b66 100644 --- a/langtools/test/tools/sjavac/PackagePathMismatch.java +++ b/langtools/test/tools/sjavac/PackagePathMismatch.java @@ -28,7 +28,7 @@ * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main - * jdk.jdeps/com.sun.tools.javap + * jdk.compiler/com.sun.tools.sjavac * @build Wrapper toolbox.ToolBox * @run main Wrapper PackagePathMismatch */ diff --git a/langtools/test/tools/sjavac/ParallelCompilations.java b/langtools/test/tools/sjavac/ParallelCompilations.java index 4e93804f626..db31b59a646 100644 --- a/langtools/test/tools/sjavac/ParallelCompilations.java +++ b/langtools/test/tools/sjavac/ParallelCompilations.java @@ -30,7 +30,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper ParallelCompilations */ @@ -45,8 +44,6 @@ class ParallelCompilations extends SJavacTester { } public void run() throws Exception { - ToolBox tb = new ToolBox(); - // Generate 10 files for (int i = 0; i < 10; i++) { String content = "package foo"+ i + ";\n" + diff --git a/langtools/test/tools/sjavac/PermittedArtifact.java b/langtools/test/tools/sjavac/PermittedArtifact.java index fba844587be..edb312faa3c 100644 --- a/langtools/test/tools/sjavac/PermittedArtifact.java +++ b/langtools/test/tools/sjavac/PermittedArtifact.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper PermittedArtifact */ @@ -51,7 +50,6 @@ public class PermittedArtifact extends SJavacTester { Map previous_bin_state = collectState(BIN); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC + "/alfa/omega/A.java", "package alfa.omega; public class A { }"); diff --git a/langtools/test/tools/sjavac/PooledExecution.java b/langtools/test/tools/sjavac/PooledExecution.java index bfa24b4fdcd..64c9e1fbaea 100644 --- a/langtools/test/tools/sjavac/PooledExecution.java +++ b/langtools/test/tools/sjavac/PooledExecution.java @@ -25,11 +25,13 @@ * @test * @bug 8044131 * @summary Makes sure sjavac poolsize option is honored. - * @modules jdk.compiler/com.sun.tools.sjavac.comp + * @modules jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.sjavac.comp * jdk.compiler/com.sun.tools.sjavac.server * @build Wrapper * @run main Wrapper PooledExecution */ + import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; diff --git a/langtools/test/tools/sjavac/SjavacBase.java b/langtools/test/tools/sjavac/SjavacBase.java index ab3f38dfe65..e10958e7b9d 100644 --- a/langtools/test/tools/sjavac/SjavacBase.java +++ b/langtools/test/tools/sjavac/SjavacBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -24,6 +24,8 @@ import java.lang.reflect.Method; import java.util.Arrays; +import toolbox.ToolBox; + public class SjavacBase { protected final static ToolBox toolbox = new ToolBox(); @@ -44,5 +46,4 @@ public class SjavacBase { int rc = (Integer) m.invoke(null, (Object) strArgs); return rc; } - } diff --git a/langtools/test/tools/sjavac/StateDir.java b/langtools/test/tools/sjavac/StateDir.java index 4b944a1df97..0e2c10bcd58 100644 --- a/langtools/test/tools/sjavac/StateDir.java +++ b/langtools/test/tools/sjavac/StateDir.java @@ -31,7 +31,6 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.sjavac - * jdk.jdeps/com.sun.tools.javap * @build Wrapper toolbox.ToolBox * @run main Wrapper StateDir */ @@ -53,7 +52,6 @@ public class StateDir extends SJavacTester { Map previous_bin_state = collectState(BIN); Map previous_bar_state = collectState(BAR); - ToolBox tb = new ToolBox(); tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), "package alfa.omega; public class A { }"); diff --git a/langtools/test/tools/sjavac/Wrapper.java b/langtools/test/tools/sjavac/Wrapper.java index b2d52ea1bb1..d79478fdb5f 100644 --- a/langtools/test/tools/sjavac/Wrapper.java +++ b/langtools/test/tools/sjavac/Wrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -21,10 +21,15 @@ * questions. */ -import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; - +import java.util.List; +import java.util.stream.Collectors; public class Wrapper { public static void main(String... args) throws Exception { @@ -36,16 +41,28 @@ public class Wrapper { String testClassName = args[0]; String[] testArgs = Arrays.copyOfRange(args, 1, args.length); - File srcDir = new File(System.getProperty("test.src")); - File clsDir = new File(System.getProperty("test.classes")); + Path srcDir = Paths.get(System.getProperty("test.src")); + Path clsDir = Paths.get(System.getProperty("test.classes")); + String clsPath = System.getProperty("test.class.path"); + String tstMdls = System.getProperty("test.modules"); - File src = new File(srcDir, testClassName + ".java"); - File cls = new File(clsDir, testClassName + ".class"); + Path src = srcDir.resolve(testClassName + ".java"); + Path cls = clsDir.resolve(testClassName + ".class"); - if (cls.lastModified() < src.lastModified()) { + if (isNewer(src, cls)) { System.err.println("Recompiling test class..."); - String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() }; - int rc = com.sun.tools.javac.Main.compile(javacArgs); + List javacArgs = new ArrayList<>(); + javacArgs.addAll(Arrays.asList("-d", clsDir.toString())); + javacArgs.addAll(Arrays.asList("-sourcepath", srcDir.toString())); + javacArgs.addAll(Arrays.asList("-classpath", clsPath)); + Arrays.stream(tstMdls.split("\\s+")) + .filter(s -> s.contains("/")) + .map(s -> "--add-exports=" + s + "=ALL-UNNAMED") + .collect(Collectors.toCollection(() -> javacArgs)); + javacArgs.add(src.toString()); + System.out.println("javac: " + javacArgs); + int rc = com.sun.tools.javac.Main.compile( + javacArgs.toArray(new String[javacArgs.size()])); if (rc != 0) throw new Exception("compilation failed"); } @@ -55,6 +72,12 @@ public class Wrapper { main.invoke(null, new Object[] { testArgs }); } + private static boolean isNewer(Path a, Path b) throws IOException { + if (Files.notExists(b)) + return true; + return Files.getLastModifiedTime(a).compareTo(Files.getLastModifiedTime(b)) > 0; + } + private static boolean isSJavacOnClassPath() { String cls = "com/sun/tools/sjavac/Main.class"; return Wrapper.class.getClassLoader().getResource(cls) != null; From d7ea24479be9c28be31e7a7a83f147d6289a1777 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 10 Aug 2016 15:48:04 -0700 Subject: [PATCH 22/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: coleenp, lfoltan, mchung --- .../src/jdk/vm/ci/services/Services.java | 2 +- .../src/share/vm/classfile/classLoader.cpp | 66 ++--- .../src/share/vm/classfile/classLoader.hpp | 16 +- hotspot/src/share/vm/memory/filemap.cpp | 4 +- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 41 ++- hotspot/src/share/vm/runtime/arguments.cpp | 277 ++++++++++++++---- hotspot/src/share/vm/runtime/arguments.hpp | 69 +++-- hotspot/src/share/vm/utilities/ostream.cpp | 14 +- hotspot/test/TEST.ROOT | 8 +- .../unsafe/UnsafeGetConstantField.java | 4 +- .../TestMaxMinHeapFreeRatioFlags.java | 4 +- .../gc/arguments/TestSurvivorRatioFlag.java | 2 +- .../TestTargetSurvivorRatioFlag.java | 2 +- .../test/gc/g1/TestShrinkAuxiliaryData.java | 2 +- .../BadObjectClass/BootstrapRedefine.java | 2 +- .../BootClassPathAppendProp.java | 2 +- .../ErrorHandling/CreateCoredumpOnCrash.java | 2 +- .../ErrorHandling/ProblematicFrameTest.java | 2 +- .../SharedArchiveFile/BootAppendTests.java | 14 +- .../SharedArchiveFile/SASymbolTableTest.java | 9 +- hotspot/test/runtime/Unsafe/RangeCheck.java | 4 +- .../runtime/getSysPackage/GetSysPkgTest.java | 2 +- .../modules/IgnoreModulePropertiesTest.java | 75 +++++ .../runtime/modules/ModuleOptionsTest.java | 54 ++++ .../runtime/modules/ModuleOptionsWarn.java | 60 ++++ .../ModuleStress/ExportModuleStressTest.java | 6 +- .../modules/ModuleStress/ModuleStressGC.java | 6 +- .../BasicJarBuilder.java | 0 .../PatchModule2Dirs.java} | 14 +- .../PatchModule2DirsMain.java} | 8 +- .../PatchModuleCDS.java} | 18 +- .../PatchModuleDupJavaBase.java} | 12 +- .../PatchModuleDupModule.java} | 11 +- .../PatchModuleJavaBase.java} | 12 +- .../PatchModuleMain.java} | 6 +- .../PatchModuleTest.java} | 12 +- .../PatchModuleTestJar.java} | 14 +- .../PatchModuleTestJarDir.java} | 14 +- .../PatchModuleTraceCL.java} | 28 +- ...bility.java => PatchModuleVisibility.java} | 20 +- .../Visibility/XbootcpNoVisibility.java | 2 +- .../java/lang/reflect/ModuleHelper.java | 4 +- .../sa/TestInstanceKlassSize.java | 7 +- .../sa/TestInstanceKlassSizeForInterface.java | 7 +- .../sa/jmap-hprof/JMapHProfLargeHeapTest.java | 2 +- hotspot/test/testlibrary/ctw/Makefile | 8 +- hotspot/test/testlibrary/jittester/Makefile | 8 +- 47 files changed, 668 insertions(+), 288 deletions(-) create mode 100644 hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java create mode 100644 hotspot/test/runtime/modules/ModuleOptionsTest.java create mode 100644 hotspot/test/runtime/modules/ModuleOptionsWarn.java rename hotspot/test/runtime/modules/{Xpatch => PatchModule}/BasicJarBuilder.java (100%) rename hotspot/test/runtime/modules/{Xpatch/Xpatch2Dirs.java => PatchModule/PatchModule2Dirs.java} (87%) rename hotspot/test/runtime/modules/{Xpatch/Xpatch2DirsMain.java => PatchModule/PatchModule2DirsMain.java} (80%) rename hotspot/test/runtime/modules/{XpatchCDS.java => PatchModule/PatchModuleCDS.java} (81%) rename hotspot/test/runtime/modules/{Xpatch/XpatchDupJavaBase.java => PatchModule/PatchModuleDupJavaBase.java} (87%) rename hotspot/test/runtime/modules/{Xpatch/XpatchDupModule.java => PatchModule/PatchModuleDupModule.java} (86%) rename hotspot/test/runtime/modules/{Xpatch/XpatchJavaBase.java => PatchModule/PatchModuleJavaBase.java} (88%) rename hotspot/test/runtime/modules/{Xpatch/XpatchMain.java => PatchModule/PatchModuleMain.java} (85%) rename hotspot/test/runtime/modules/{Xpatch/XpatchTest.java => PatchModule/PatchModuleTest.java} (87%) rename hotspot/test/runtime/modules/{Xpatch/XpatchTestJar.java => PatchModule/PatchModuleTestJar.java} (90%) rename hotspot/test/runtime/modules/{Xpatch/XpatchTestJarDir.java => PatchModule/PatchModuleTestJarDir.java} (93%) rename hotspot/test/runtime/modules/{Xpatch/XpatchTraceCL.java => PatchModule/PatchModuleTraceCL.java} (76%) rename hotspot/test/runtime/modules/Visibility/{XpatchVisibility.java => PatchModuleVisibility.java} (84%) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java index 83085fe08d2..81689cf00be 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java @@ -57,7 +57,7 @@ public final class Services { if (jvmci != requestorModule) { for (String pkg : jvmci.getPackages()) { // Export all JVMCI packages dynamically instead - // of requiring a long list of -XaddExports + // of requiring a long list of --add-exports // options on the JVM command line. if (!jvmci.isExported(pkg, requestorModule)) { jvmci.addExports(pkg, requestorModule); diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 92bf8fe4856..2cb586f1f54 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -140,7 +140,7 @@ PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL; PerfCounter* ClassLoader::_isUnsyncloadClass = NULL; PerfCounter* ClassLoader::_load_instance_class_failCounter = NULL; -GrowableArray* ClassLoader::_xpatch_entries = NULL; +GrowableArray* ClassLoader::_patch_mod_entries = NULL; GrowableArray* ClassLoader::_exploded_entries = NULL; ClassPathEntry* ClassLoader::_jrt_entry = NULL; ClassPathEntry* ClassLoader::_first_append_entry = NULL; @@ -685,27 +685,27 @@ bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) { } #endif -// Construct the array of module/path pairs as specified to -Xpatch +// Construct the array of module/path pairs as specified to --patch-module // for the boot loader to search ahead of the jimage, if the class being -// loaded is defined to a module that has been specified to -Xpatch. -void ClassLoader::setup_xpatch_entries() { +// loaded is defined to a module that has been specified to --patch-module. +void ClassLoader::setup_patch_mod_entries() { Thread* THREAD = Thread::current(); - GrowableArray* xpatch_args = Arguments::get_xpatchprefix(); - int num_of_entries = xpatch_args->length(); + GrowableArray* patch_mod_args = Arguments::get_patch_mod_prefix(); + int num_of_entries = patch_mod_args->length(); - assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with -Xpatch"); - assert(!UseSharedSpaces, "UseSharedSpaces not supported with -Xpatch"); + assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with --patch-module"); + assert(!UseSharedSpaces, "UseSharedSpaces not supported with --patch-module"); - // Set up the boot loader's _xpatch_entries list - _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, true); + // Set up the boot loader's _patch_mod_entries list + _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, true); for (int i = 0; i < num_of_entries; i++) { - const char* module_name = (xpatch_args->at(i))->module_name(); + const char* module_name = (patch_mod_args->at(i))->module_name(); Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK); assert(module_sym != NULL, "Failed to obtain Symbol for module name"); ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); - char* class_path = (xpatch_args->at(i))->path_string(); + char* class_path = (patch_mod_args->at(i))->path_string(); int len = (int)strlen(class_path); int end = 0; // Iterate over the module's class path entries @@ -735,10 +735,10 @@ void ClassLoader::setup_xpatch_entries() { } } - // Record the module into the list of -Xpatch entries only if + // Record the module into the list of --patch-module entries only if // valid ClassPathEntrys have been created if (module_cpl->module_first_entry() != NULL) { - _xpatch_entries->push(module_cpl); + _patch_mod_entries->push(module_cpl); } } } @@ -1020,9 +1020,9 @@ void ClassLoader::print_bootclasspath() { ClassPathEntry* e; tty->print("[bootclasspath= "); - // Print -Xpatch module/path specifications first - if (_xpatch_entries != NULL) { - print_module_entry_table(_xpatch_entries); + // Print --patch-module module/path specifications first + if (_patch_mod_entries != NULL) { + print_module_entry_table(_patch_mod_entries); } // [jimage | exploded modules build] @@ -1341,7 +1341,7 @@ const char* ClassLoader::file_name_for_class_name(const char* class_name, return file_name; } -// Search either the xpatch or exploded build entries for class +// Search either the patch-module or exploded build entries for class ClassFileStream* ClassLoader::search_module_entries(const GrowableArray* const module_list, const char* const class_name, const char* const file_name, TRAPS) { ClassFileStream* stream = NULL; @@ -1366,7 +1366,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArraylength(); const Symbol* class_module_name = mod_entry->name(); - // Loop through all the modules in either the xpatch or exploded entries looking for module + // Loop through all the modules in either the patch-module or exploded entries looking for module for (int i = 0; i < num_of_entries; i++) { ModuleClassPathList* module_cpl = module_list->at(i); Symbol* module_cpl_name = module_cpl->module_name(); @@ -1378,7 +1378,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArrayopen_stream(file_name, CHECK_NULL); // No context.check is required since CDS is not supported - // for an exploded modules build or if -Xpatch is specified. + // for an exploded modules build or if --patch-module is specified. if (NULL != stream) { return stream; } @@ -1420,32 +1420,32 @@ instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_onl // If DumpSharedSpaces is true boot loader visibility boundaries are set to: // - [jimage] + [_first_append_entry to _last_append_entry] (all path entries). - // No -Xpatch entries or exploded module builds are included since CDS - // is not supported if -Xpatch or exploded module builds are used. + // No --patch-module entries or exploded module builds are included since CDS + // is not supported if --patch-module or exploded module builds are used. // // If search_append_only is true, boot loader visibility boundaries are // set to be _first_append_entry to the end. This includes: // [-Xbootclasspath/a]; [jvmti appended entries] // // If both DumpSharedSpaces and search_append_only are false, boot loader - // visibility boundaries are set to be the -Xpatch entries plus the base piece. + // visibility boundaries are set to be the --patch-module entries plus the base piece. // This would include: - // [-Xpatch:=()*]; [jimage | exploded module build] + // [--patch-module==()*]; [jimage | exploded module build] // // DumpSharedSpaces and search_append_only are mutually exclusive and cannot // be true at the same time. assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true"); - // Load Attempt #1: -Xpatch - // Determine the class' defining module. If it appears in the _xpatch_entries, + // Load Attempt #1: --patch-module + // Determine the class' defining module. If it appears in the _patch_mod_entries, // attempt to load the class from those locations specific to the module. - // Specifications to -Xpatch can contain a partial number of classes + // Specifications to --patch-module can contain a partial number of classes // that are part of the overall module definition. So if a particular class is not // found within its module specification, the search should continue to Load Attempt #2. - // Note: The -Xpatch entries are never searched if the boot loader's + // Note: The --patch-module entries are never searched if the boot loader's // visibility boundary is limited to only searching the append entries. - if (_xpatch_entries != NULL && !search_append_only && !DumpSharedSpaces) { - stream = search_module_entries(_xpatch_entries, class_name, file_name, CHECK_NULL); + if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) { + stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL); } // Load Attempt #2: [jimage | exploded build] @@ -1650,11 +1650,11 @@ void ClassLoader::classLoader_init2(TRAPS) { // Create the moduleEntry for java.base create_javabase(); - // Setup the list of module/path pairs for -Xpatch processing + // Setup the list of module/path pairs for --patch-module processing // This must be done after the SymbolTable is created in order // to use fast_compare on module names instead of a string compare. - if (Arguments::get_xpatchprefix() != NULL) { - setup_xpatch_entries(); + if (Arguments::get_patch_mod_prefix() != NULL) { + setup_patch_mod_entries(); } // Setup the initial java.base/path pair for the exploded build entries. diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index 045bfab715c..e0d56862b95 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -150,7 +150,7 @@ public: // ModuleClassPathList contains a linked list of ClassPathEntry's // that have been specified for a specific module. Currently, -// the only way to specify a module/path pair is via the -Xpatch +// the only way to specify a module/path pair is via the --patch-module // command line option. class ModuleClassPathList : public CHeapObj { private: @@ -213,8 +213,8 @@ class ClassLoader: AllStatic { static PerfCounter* _load_instance_class_failCounter; // The boot class path consists of 3 ordered pieces: - // 1. the module/path pairs specified to -Xpatch - // -Xpatch:=()* + // 1. the module/path pairs specified to --patch-module + // --patch-module==()* // 2. the base piece // [jimage | build with exploded modules] // 3. boot loader append path @@ -223,8 +223,8 @@ class ClassLoader: AllStatic { // The boot loader must obey this order when attempting // to load a class. - // 1. Contains the module/path pairs specified to -Xpatch - static GrowableArray* _xpatch_entries; + // 1. Contains the module/path pairs specified to --patch-module + static GrowableArray* _patch_mod_entries; // 2. the base piece // Contains the ClassPathEntry of the modular java runtime image. @@ -256,11 +256,11 @@ class ClassLoader: AllStatic { // Initialization: // - setup the boot loader's system class path - // - setup the boot loader's xpatch entries, if present + // - setup the boot loader's patch mod entries, if present // - create the ModuleEntry for java.base static void setup_bootstrap_search_path(); static void setup_search_path(const char *class_path, bool setting_bootstrap); - static void setup_xpatch_entries(); + static void setup_patch_mod_entries(); static void create_javabase(); static void load_zip_library(); @@ -363,7 +363,7 @@ class ClassLoader: AllStatic { // Add a module's exploded directory to the boot loader's exploded module build list static void add_to_exploded_build_list(Symbol* module_name, TRAPS); - // Attempt load of individual class from either the xpatch or exploded modules build lists + // Attempt load of individual class from either the patched or exploded modules build lists static ClassFileStream* search_module_entries(const GrowableArray* const module_list, const char* const class_name, const char* const file_name, TRAPS); diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp index e4ec1c1a155..6dc7d1fb1c6 100644 --- a/hotspot/src/share/vm/memory/filemap.cpp +++ b/hotspot/src/share/vm/memory/filemap.cpp @@ -911,8 +911,8 @@ bool FileMapInfo::FileMapHeader::validate() { return false; } - if (Arguments::get_xpatchprefix() != NULL) { - FileMapInfo::fail_continue("The shared archive file cannot be used with -Xpatch."); + if (Arguments::get_patch_mod_prefix() != NULL) { + FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module."); return false; } diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index 2a5b202d93f..5b44ee01085 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -24,6 +24,8 @@ #include "precompiled.hpp" #include "classfile/classLoaderExt.hpp" +#include "classfile/javaClasses.inline.hpp" +#include "classfile/stringTable.hpp" #include "classfile/modules.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" @@ -224,6 +226,7 @@ JvmtiEnv::GetNamedModule(jobject class_loader, const char* package_name, jobject return JVMTI_ERROR_NONE; } /* end GetNamedModule */ + // // Class functions // @@ -3465,28 +3468,35 @@ jvmtiError JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) { jvmtiError err = JVMTI_ERROR_NONE; - *count_ptr = Arguments::PropertyList_count(Arguments::system_properties()); + // Get the number of readable properties. + *count_ptr = Arguments::PropertyList_readable_count(Arguments::system_properties()); + // Allocate memory to hold the exact number of readable properties. err = allocate(*count_ptr * sizeof(char *), (unsigned char **)property_ptr); if (err != JVMTI_ERROR_NONE) { return err; } - int i = 0 ; - for (SystemProperty* p = Arguments::system_properties(); p != NULL && i < *count_ptr; p = p->next(), i++) { - const char *key = p->key(); - char **tmp_value = *property_ptr+i; - err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value); - if (err == JVMTI_ERROR_NONE) { - strcpy(*tmp_value, key); - } else { - // clean up previously allocated memory. - for (int j=0; jnext()) { + if (p->is_readable()) { + const char *key = p->key(); + char **tmp_value = *property_ptr+readable_count; + readable_count++; + err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value); + if (err == JVMTI_ERROR_NONE) { + strcpy(*tmp_value, key); + } else { + // clean up previously allocated memory. + for (int j=0; j *Arguments::_xpatchprefix = NULL; +GrowableArray *Arguments::_patch_mod_prefix = NULL; PathString *Arguments::_system_boot_class_path = NULL; bool Arguments::_has_jimage = false; @@ -161,6 +161,30 @@ static void logOption(const char* opt) { } } +bool needs_module_property_warning = false; + +#define MODULE_PROPERTY_PREFIX "jdk.module" +#define MODULE_PROPERTY_PREFIX_LEN 10 +#define MODULE_MAIN_PROPERTY "jdk.module.main" +#define MODULE_MAIN_PROPERTY_LEN 15 + +// Return TRUE if option matches property, or property=, or property.. +static bool matches_property_prefix(const char* option, const char* property, size_t len) { + return (strncmp(option, property, len) == 0) && + (option[len] == '=' || option[len] == '.' || option[len] == '\0'); +} + +// Return true if the property is either "jdk.module" or starts with "jdk.module.", +// but does not start with "jdk.module.main". +// Return false if jdk.module.main because jdk.module.main and jdk.module.main.class +// are valid non-internal system properties. +// "property" should be passed without the leading "-D". +bool Arguments::is_internal_module_property(const char* property) { + assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D"); + return (matches_property_prefix(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) && + !matches_property_prefix(property, MODULE_MAIN_PROPERTY, MODULE_MAIN_PROPERTY_LEN)); +} + // Process java launcher properties. void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) { // See if sun.java.launcher, sun.java.launcher.is_altjvm or @@ -197,7 +221,7 @@ void Arguments::init_system_properties() { _system_boot_class_path = new PathString(NULL); PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name", - "Java Virtual Machine Specification", false)); + "Java Virtual Machine Specification", false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true)); @@ -1198,7 +1222,7 @@ const char* Arguments::get_property(const char* key) { return PropertyList_get_value(system_properties(), key); } -bool Arguments::add_property(const char* prop) { +bool Arguments::add_property(const char* prop, PropertyWriteable writeable, PropertyInternal internal) { const char* eq = strchr(prop, '='); const char* key; const char* value = ""; @@ -1228,7 +1252,9 @@ bool Arguments::add_property(const char* prop) { // private and are processed in process_sun_java_launcher_properties(); // the sun.java.launcher property is passed on to the java application } else if (strcmp(key, "sun.boot.library.path") == 0) { - PropertyList_unique_add(&_system_properties, key, value, true); + // append is true, writable is true, internal is false + PropertyList_unique_add(&_system_properties, key, value, AppendProperty, + WriteableProperty, ExternalProperty); } else { if (strcmp(key, "sun.java.command") == 0) { char *old_java_command = _java_command; @@ -1248,7 +1274,7 @@ bool Arguments::add_property(const char* prop) { } // Create new property and add at the end of the list - PropertyList_unique_add(&_system_properties, key, value); + PropertyList_unique_add(&_system_properties, key, value, AddProperty, writeable, internal); } if (key != prop) { @@ -1260,9 +1286,9 @@ bool Arguments::add_property(const char* prop) { return true; } -// sets or adds a module name to the jdk.launcher.addmods property +// sets or adds a module name to the jdk.module.addmods property bool Arguments::append_to_addmods_property(const char* module_name) { - const char* key = "jdk.launcher.addmods"; + const char* key = "jdk.module.addmods"; const char* old_value = Arguments::get_property(key); size_t buf_len = strlen(key) + strlen(module_name) + 2; if (old_value != NULL) { @@ -1277,7 +1303,7 @@ bool Arguments::append_to_addmods_property(const char* module_name) { } else { jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name); } - bool added = add_property(new_value); + bool added = add_property(new_value, UnwriteableProperty, InternalProperty); FreeHeap(new_value); return added; } @@ -1287,14 +1313,14 @@ void Arguments::check_unsupported_dumping_properties() { assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); const char* unsupported_properties[5] = { "jdk.module.main", "jdk.module.path", - "jdk.upgrade.module.path", - "jdk.launcher.addmods", - "jdk.launcher.limitmods" }; + "jdk.module.upgrade.path", + "jdk.module.addmods", + "jdk.module.limitmods" }; const char* unsupported_options[5] = { "-m", - "-modulepath", - "-upgrademodulepath", - "-addmods", - "-limitmods" }; + "--module-path", + "--upgrade-module-path", + "--add-modules", + "--limit-modules" }; SystemProperty* sp = system_properties(); while (sp != NULL) { for (int i = 0; i < 5; i++) { @@ -1326,7 +1352,7 @@ void Arguments::set_mode_flags(Mode mode) { // Ensure Agent_OnLoad has the correct initial values. // This may not be the final mode; mode may change later in onload phase. PropertyList_unique_add(&_system_properties, "java.vm.info", - VM_Version::vm_info_string(), false); + VM_Version::vm_info_string(), AddProperty, UnwriteableProperty, ExternalProperty); UseInterpreter = true; UseCompiler = true; @@ -2516,6 +2542,41 @@ bool Arguments::parse_uintx(const char* value, return false; } +unsigned int addreads_count = 0; +unsigned int addexports_count = 0; +unsigned int patch_mod_count = 0; +const char* add_modules_value = NULL; + +bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) { + size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2; + char* property = AllocateHeap(prop_len, mtArguments); + int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value); + if (ret < 0 || ret >= (int)prop_len) { + FreeHeap(property); + return false; + } + bool added = add_property(property, UnwriteableProperty, internal); + FreeHeap(property); + return added; +} + +bool Arguments::create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count) { + // Make sure count is < 1,000. Otherwise, memory allocation will be too small. + if (count < 1000) { + size_t prop_len = strlen(prop_base_name) + strlen(prop_value) + 5; + char* property = AllocateHeap(prop_len, mtArguments); + int ret = jio_snprintf(property, prop_len, "%s.%d=%s", prop_base_name, count, prop_value); + if (ret < 0 || ret >= (int)prop_len) { + FreeHeap(property); + return false; + } + bool added = add_property(property, UnwriteableProperty, InternalProperty); + FreeHeap(property); + return added; + } + return false; +} + Arguments::ArgsRange Arguments::parse_memory_size(const char* s, julong* long_arg, julong min_size) { @@ -2528,7 +2589,7 @@ Arguments::ArgsRange Arguments::parse_memory_size(const char* s, jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args) { - bool xpatch_javabase = false; + bool patch_mod_javabase = false; // Save default settings for some mode flags Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; @@ -2545,20 +2606,20 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, // Parse args structure generated from JAVA_TOOL_OPTIONS environment // variable (if present). - jint result = parse_each_vm_init_arg(java_tool_options_args, &xpatch_javabase, Flag::ENVIRON_VAR); + jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } // Parse args structure generated from the command line flags. - result = parse_each_vm_init_arg(cmd_line_args, &xpatch_javabase, Flag::COMMAND_LINE); + result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE); if (result != JNI_OK) { return result; } // Parse args structure generated from the _JAVA_OPTIONS environment // variable (if present) (mimics classic VM) - result = parse_each_vm_init_arg(java_options_args, &xpatch_javabase, Flag::ENVIRON_VAR); + result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } @@ -2617,7 +2678,35 @@ bool valid_jdwp_agent(char *name, bool is_path) { return false; } -jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin) { +int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase) { + // --patch-module==()* + assert(patch_mod_tail != NULL, "Unexpected NULL patch-module value"); + // Find the equal sign between the module name and the path specification + const char* module_equal = strchr(patch_mod_tail, '='); + if (module_equal == NULL) { + jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n"); + return JNI_ERR; + } else { + // Pick out the module name + size_t module_len = module_equal - patch_mod_tail; + char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments); + if (module_name != NULL) { + memcpy(module_name, patch_mod_tail, module_len); + *(module_name + module_len) = '\0'; + // The path piece begins one past the module_equal sign + add_patch_mod_prefix(module_name, module_equal + 1, patch_mod_javabase); + FREE_C_HEAP_ARRAY(char, module_name); + if (!create_numbered_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) { + return JNI_ENOMEM; + } + } else { + return JNI_ENOMEM; + } + } + return JNI_OK; +} + +jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) { // For match_option to return remaining or value part of option string const char* tail; @@ -2701,6 +2790,34 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_ #endif // !INCLUDE_JVMTI add_init_library(name, options); } + } else if (match_option(option, "--add-reads=", &tail)) { + if (!create_numbered_property("jdk.module.addreads", tail, addreads_count++)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--add-exports=", &tail)) { + if (!create_numbered_property("jdk.module.addexports", tail, addexports_count++)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--add-modules=", &tail)) { + add_modules_value = tail; + } else if (match_option(option, "--limit-modules=", &tail)) { + if (!create_property("jdk.module.limitmods", tail, InternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--module-path=", &tail)) { + if (!create_property("jdk.module.path", tail, ExternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--upgrade-module-path=", &tail)) { + if (!create_property("jdk.module.upgrade.path", tail, ExternalProperty)) { + return JNI_ENOMEM; + } + } else if (match_option(option, "--patch-module=", &tail)) { + // --patch-module==()* + int res = process_patch_mod_option(tail, patch_mod_javabase); + if (res != JNI_OK) { + return res; + } // -agentlib and -agentpath } else if (match_option(option, "-agentlib:", &tail) || (is_absolute_path = match_option(option, "-agentpath:", &tail))) { @@ -2992,6 +3109,13 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_ "-Djava.ext.dirs=%s is not supported. Use -classpath instead.\n", value); return JNI_EINVAL; } + // Check for module related properties. They must be set using the modules + // options. For example: use "--add-modules=java.sql", not + // "-Djdk.module.addmods=java.sql" + if (is_internal_module_property(option->optionString + 2)) { + needs_module_property_warning = true; + continue; + } if (!add_property(tail)) { return JNI_ENOMEM; @@ -3012,33 +3136,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_ return JNI_ERR; #endif } - if (match_option(option, "-Djdk.launcher.patch.", &tail)) { - // -Djdk.launcher.patch.#==()* - // The number, #, specified will be increasing with each -Xpatch - // specified on the command line. - // Pick up module name, following the -D property's equal sign. - const char* property_equal = strchr(tail, '='); - if (property_equal == NULL) { - jio_fprintf(defaultStream::output_stream(), "Missing '=' in -Xpatch specification\n"); - return JNI_ERR; - } else { - // Find the equal sign between the module name and the path specification - const char* module_equal = strchr(property_equal + 1, '='); - if (module_equal == NULL) { - jio_fprintf(defaultStream::output_stream(), "Bad value for -Xpatch, no module name specified\n"); - return JNI_ERR; - } else { - // Pick out the module name, in between the two equal signs - size_t module_len = module_equal - property_equal - 1; - char* module_name = NEW_C_HEAP_ARRAY(char, module_len+1, mtArguments); - memcpy(module_name, property_equal + 1, module_len); - *(module_name + module_len) = '\0'; - // The path piece begins one past the module_equal sign - Arguments::add_xpatchprefix(module_name, module_equal + 1, xpatch_javabase); - FREE_C_HEAP_ARRAY(char, module_name); - } - } - } // -Xint } else if (match_option(option, "-Xint")) { set_mode_flags(_int); @@ -3298,25 +3395,25 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_ return JNI_OK; } -void Arguments::add_xpatchprefix(const char* module_name, const char* path, bool* xpatch_javabase) { - // For java.base check for duplicate -Xpatch options being specified on the command line. +void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool* patch_mod_javabase) { + // For java.base check for duplicate --patch-module options being specified on the command line. // This check is only required for java.base, all other duplicate module specifications // will be checked during module system initialization. The module system initialization // will throw an ExceptionInInitializerError if this situation occurs. if (strcmp(module_name, "java.base") == 0) { - if (*xpatch_javabase) { - vm_exit_during_initialization("Cannot specify java.base more than once to -Xpatch"); + if (*patch_mod_javabase) { + vm_exit_during_initialization("Cannot specify java.base more than once to --patch-module"); } else { - *xpatch_javabase = true; + *patch_mod_javabase = true; } } - // Create GrowableArray lazily, only if -Xpatch has been specified - if (_xpatchprefix == NULL) { - _xpatchprefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, true); + // Create GrowableArray lazily, only if --patch-module has been specified + if (_patch_mod_prefix == NULL) { + _patch_mod_prefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, true); } - _xpatchprefix->push(new ModuleXPatchPath(module_name, path)); + _patch_mod_prefix->push(new ModulePatchPath(module_name, path)); } // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled) @@ -3441,6 +3538,15 @@ jint Arguments::finalize_vm_init_args() { return JNI_ERR; } + // Append the value of the last --add-modules option specified on the command line. + // This needs to be done here, to prevent overwriting possible values written + // to the jdk.module.addmods property by -javaagent and other options. + if (add_modules_value != NULL) { + if (!append_to_addmods_property(add_modules_value)) { + return JNI_ENOMEM; + } + } + // This must be done after all arguments have been processed. // java_compiler() true means set to "NONE" or empty. if (java_compiler() && !xdebug_mode()) { @@ -3795,9 +3901,9 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_ void Arguments::set_shared_spaces_flags() { if (DumpSharedSpaces) { - if (Arguments::get_xpatchprefix() != NULL) { + if (Arguments::get_patch_mod_prefix() != NULL) { vm_exit_during_initialization( - "Cannot use the following option when dumping the shared archive", "-Xpatch"); + "Cannot use the following option when dumping the shared archive: --patch-module"); } if (RequireSharedSpaces) { @@ -4180,6 +4286,11 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { hotspotrc, hotspotrc); } + if (needs_module_property_warning) { + warning("Ignoring system property options whose names start with '-Djdk.module'." + " They are reserved for internal use."); + } + #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX. UNSUPPORTED_OPTION(UseLargePages); #endif @@ -4404,6 +4515,18 @@ int Arguments::PropertyList_count(SystemProperty* pl) { return count; } +// Return the number of readable properties. +int Arguments::PropertyList_readable_count(SystemProperty* pl) { + int count = 0; + while(pl != NULL) { + if (pl->is_readable()) { + count++; + } + pl = pl->next(); + } + return count; +} + const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) { assert(key != NULL, "just checking"); SystemProperty* prop; @@ -4413,6 +4536,27 @@ const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* ke return NULL; } +// Return the value of the requested property provided that it is a readable property. +const char* Arguments::PropertyList_get_readable_value(SystemProperty *pl, const char* key) { + assert(key != NULL, "just checking"); + SystemProperty* prop; + // Return the property value if the keys match and the property is not internal or + // it's the special internal property "jdk.boot.class.path.append". + for (prop = pl; prop != NULL; prop = prop->next()) { + if (strcmp(key, prop->key()) == 0) { + if (!prop->internal()) { + return prop->value(); + } else if (strcmp(key, "jdk.boot.class.path.append") == 0) { + return prop->value(); + } else { + // Property is internal and not jdk.boot.class.path.append so return NULL. + return NULL; + } + } + } + return NULL; +} + const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) { int count = 0; const char* ret_val = NULL; @@ -4457,11 +4601,12 @@ void Arguments::PropertyList_add(SystemProperty** plist, SystemProperty *new_p) } } -void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v) { +void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v, + bool writeable, bool internal) { if (plist == NULL) return; - SystemProperty* new_p = new SystemProperty(k, v, true); + SystemProperty* new_p = new SystemProperty(k, v, writeable, internal); PropertyList_add(plist, new_p); } @@ -4470,7 +4615,9 @@ void Arguments::PropertyList_add(SystemProperty *element) { } // This add maintains unique property key in the list. -void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append) { +void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, + PropertyAppendable append, PropertyWriteable writeable, + PropertyInternal internal) { if (plist == NULL) return; @@ -4478,16 +4625,16 @@ void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, c SystemProperty* prop; for (prop = *plist; prop != NULL; prop = prop->next()) { if (strcmp(k, prop->key()) == 0) { - if (append) { + if (append == AppendProperty) { prop->append_value(v); } else { - prop->set_writeable_value(v); + prop->set_value(v); } return; } } - PropertyList_add(plist, k, v); + PropertyList_add(plist, k, v, writeable == WriteableProperty, internal == InternalProperty); } // Copies src into buf, replacing "%%" with "%" and "%p" with pid diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index e72c492e0b1..dbac4f710b0 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -43,7 +43,7 @@ extern "C" { // PathString is used as: // - the underlying value for a SystemProperty -// - the path portion of an -Xpatch module/path pair +// - the path portion of an --patch-module module/path pair // - the string that represents the system boot class path, Arguments::_system_boot_class_path. class PathString : public CHeapObj { protected: @@ -107,13 +107,13 @@ class PathString : public CHeapObj { } }; -// ModuleXPatchPath records the module/path pair as specified to -Xpatch. -class ModuleXPatchPath : public CHeapObj { +// ModulePatchPath records the module/path pair as specified to --patch-module. +class ModulePatchPath : public CHeapObj { private: char* _module_name; PathString* _path; public: - ModuleXPatchPath(const char* module_name, const char* path) { + ModulePatchPath(const char* module_name, const char* path) { assert(module_name != NULL && path != NULL, "Invalid module name or path value"); size_t len = strlen(module_name) + 1; _module_name = AllocateHeap(len, mtInternal); @@ -121,7 +121,7 @@ public: _path = new PathString(path); } - ~ModuleXPatchPath() { + ~ModulePatchPath() { if (_module_name != NULL) { FreeHeap(_module_name); _module_name = NULL; @@ -158,6 +158,10 @@ class SystemProperty : public PathString { SystemProperty* next() const { return _next; } void set_next(SystemProperty* next) { _next = next; } + bool is_readable() const { + return !_internal || strcmp(_key, "jdk.boot.class.path.append") == 0; + } + // A system property should only have its value set // via an external interface if it is a writeable property. // The internal, non-writeable property jdk.boot.class.path.append @@ -325,6 +329,21 @@ class Arguments : AllStatic { arg_in_range = 0 }; + enum PropertyAppendable { + AppendProperty, + AddProperty + }; + + enum PropertyWriteable { + WriteableProperty, + UnwriteableProperty + }; + + enum PropertyInternal { + InternalProperty, + ExternalProperty + }; + private: // a pointer to the flags file name if it is specified @@ -348,18 +367,18 @@ class Arguments : AllStatic { static SystemProperty *_java_class_path; static SystemProperty *_jdk_boot_class_path_append; - // -Xpatch:module=()* + // --patch-module=module=()* // Each element contains the associated module name, path - // string pair as specified to -Xpatch. - static GrowableArray* _xpatchprefix; + // string pair as specified to --patch-module. + static GrowableArray* _patch_mod_prefix; // The constructed value of the system class path after // argument processing and JVMTI OnLoad additions via // calls to AddToBootstrapClassLoaderSearch. This is the // final form before ClassLoader::setup_bootstrap_search(). - // Note: since -Xpatch is a module name/path pair, the system - // boot class path string no longer contains the "prefix" to - // the boot class path base piece as it did when + // Note: since --patch-module is a module name/path pair, the + // system boot class path string no longer contains the "prefix" + // to the boot class path base piece as it did when // -Xbootclasspath/p was supported. static PathString *_system_boot_class_path; @@ -462,7 +481,13 @@ class Arguments : AllStatic { static vfprintf_hook_t _vfprintf_hook; // System properties - static bool add_property(const char* prop); + static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty, + PropertyInternal internal=ExternalProperty); + + static bool create_property(const char* prop_name, const char* prop_value, PropertyInternal internal); + static bool create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count); + + static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase); // Miscellaneous system property setter static bool append_to_addmods_property(const char* module_name); @@ -500,7 +525,7 @@ class Arguments : AllStatic { static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args); - static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin); + static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin); static jint finalize_vm_init_args(); static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); @@ -708,16 +733,20 @@ class Arguments : AllStatic { // Property List manipulation static void PropertyList_add(SystemProperty *element); static void PropertyList_add(SystemProperty** plist, SystemProperty *element); - static void PropertyList_add(SystemProperty** plist, const char* k, const char* v); - static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v) { - PropertyList_unique_add(plist, k, v, false); - } - static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append); + static void PropertyList_add(SystemProperty** plist, const char* k, const char* v, bool writeable, bool internal); + + static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, + PropertyAppendable append, PropertyWriteable writeable, + PropertyInternal internal); static const char* PropertyList_get_value(SystemProperty* plist, const char* key); + static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key); static int PropertyList_count(SystemProperty* pl); + static int PropertyList_readable_count(SystemProperty* pl); static const char* PropertyList_get_key_at(SystemProperty* pl,int index); static char* PropertyList_get_value_at(SystemProperty* pl,int index); + static bool is_internal_module_property(const char* option); + // Miscellaneous System property value getter and setters. static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } static void set_java_home(const char *value) { _java_home->set_value(value); } @@ -725,7 +754,7 @@ class Arguments : AllStatic { static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); } // Set up the underlying pieces of the system boot class path - static void add_xpatchprefix(const char *module_name, const char *path, bool* xpatch_javabase); + static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase); static void set_sysclasspath(const char *value, bool has_jimage) { // During start up, set by os::set_boot_path() assert(get_sysclasspath() == NULL, "System boot class path previously set"); @@ -737,7 +766,7 @@ class Arguments : AllStatic { _jdk_boot_class_path_append->append_value(value); } - static GrowableArray* get_xpatchprefix() { return _xpatchprefix; } + static GrowableArray* get_patch_mod_prefix() { return _patch_mod_prefix; } static char* get_sysclasspath() { return _system_boot_class_path->value(); } static char* get_jdk_boot_class_path_append() { return _jdk_boot_class_path_append->value(); } static bool has_jimage() { return _has_jimage; } diff --git a/hotspot/src/share/vm/utilities/ostream.cpp b/hotspot/src/share/vm/utilities/ostream.cpp index e9cc5fc2f08..e909222cf23 100644 --- a/hotspot/src/share/vm/utilities/ostream.cpp +++ b/hotspot/src/share/vm/utilities/ostream.cpp @@ -703,13 +703,15 @@ void defaultStream::start_log() { // System properties don't generally contain newlines, so don't bother with unparsing. outputStream *text = xs->text(); for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { - // Print in two stages to avoid problems with long - // keys/values. assert(p->key() != NULL, "p->key() is NULL"); - text->print_raw(p->key()); - text->put('='); - assert(p->value() != NULL, "p->value() is NULL"); - text->print_raw_cr(p->value()); + if (p->is_readable()) { + // Print in two stages to avoid problems with long + // keys/values. + text->print_raw(p->key()); + text->put('='); + assert(p->value() != NULL, "p->value() is NULL"); + text->print_raw_cr(p->value()); + } } xs->tail("properties"); } diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT index d604c52e930..9074b149ea1 100644 --- a/hotspot/test/TEST.ROOT +++ b/hotspot/test/TEST.ROOT @@ -46,12 +46,12 @@ requires.properties= \ vm.gc.Parallel \ vm.gc.ConcMarkSweep -# Tests using jtreg 4.2 b02 features -requiredVersion=4.2 b02 +# Tests using jtreg 4.2 b03 features +requiredVersion=4.2 b03 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them external.lib.roots = ../../ -# Use new form of -Xpatch -useNewXpatch=true +# Use new module options +useNewOptions=true diff --git a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java index d897ba9370a..82661b28271 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java @@ -40,7 +40,7 @@ * -XX:CompileCommand=dontinline,compiler.unsafe.UnsafeGetConstantField::checkGetAddress * -XX:CompileCommand=dontinline,*::test* * -XX:+UseUnalignedAccesses - * -XaddReads:java.base=ALL-UNNAMED + * --add-reads=java.base=ALL-UNNAMED * compiler.unsafe.UnsafeGetConstantField * * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions @@ -50,7 +50,7 @@ * -XX:CompileCommand=dontinline,*::test* * -XX:CompileCommand=inline,*Unsafe::get* * -XX:-UseUnalignedAccesses - * -XaddReads:java.base=ALL-UNNAMED + * --add-reads=java.base=ALL-UNNAMED * compiler.unsafe.UnsafeGetConstantField */ diff --git a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 85d0fcd6031..3d26f946937 100644 --- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -88,7 +88,7 @@ public class TestMaxMinHeapFreeRatioFlags { (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), "-Xmx" + MAX_HEAP_SIZE, "-Xms" + HEAP_SIZE, - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:NewSize=" + NEW_SIZE, "-XX:MaxNewSize=" + MAX_NEW_SIZE, "-XX:" + (shrinkHeapInSteps ? '+' : '-') + "ShrinkHeapInSteps", @@ -120,7 +120,7 @@ public class TestMaxMinHeapFreeRatioFlags { Collections.addAll(vmOptions, (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio), (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-version" ); ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()])); diff --git a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java index 2891eb1daa5..b18da4b3cf6 100644 --- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java @@ -74,7 +74,7 @@ public class TestSurvivorRatioFlag { Collections.addAll(vmOptions, "-Xbootclasspath/a:.", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:GCLockerEdenExpansionPercent=0", diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java index e2df1d7e866..dd254e0e7a2 100644 --- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -132,7 +132,7 @@ public class TestTargetSurvivorRatioFlag { LinkedList vmOptions = new LinkedList<>(options); Collections.addAll(vmOptions, "-Xbootclasspath/a:.", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseAdaptiveSizePolicy", diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java index 83ef798f0bb..3b0907c6663 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java @@ -53,7 +53,7 @@ public class TestShrinkAuxiliaryData { "-Xlog:gc=debug", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-Xbootclasspath/a:.", }; diff --git a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java index e23a6920796..fe77452c4a5 100644 --- a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java +++ b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java @@ -48,7 +48,7 @@ public class BootstrapRedefine { "-Xmodule:java.base"), "mods/java.base"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base", "-version"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Incompatible definition of java.lang.Object") .shouldHaveExitValue(1); diff --git a/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java b/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java index 1d18c3ababd..0fd7830f46a 100644 --- a/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java +++ b/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java @@ -27,7 +27,7 @@ import java.io.File; * @test * @build BootClassPathAppendProp * @run main/othervm -Xbootclasspath/a:/usr/lib -showversion -Xbootclasspath/a:/i/dont/exist BootClassPathAppendProp - * @run main/othervm -Xpatch:/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp + * @run main/othervm --patch-module=no_module=/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp * @run main/othervm -Djdk.boot.class.path.append=newdir BootClassPathAppendProp * @run main/othervm BootClassPathAppendProp */ diff --git a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java index a864f4d3c90..e4f0f94bdb2 100644 --- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -56,7 +56,7 @@ public class CreateCoredumpOnCrash { public static OutputAnalyzer runTest(String option) throws Exception { return new OutputAnalyzer( ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) + "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) .start()); } } diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java index 117c4839207..3ee548d2575 100644 --- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java @@ -48,7 +48,7 @@ public class ProblematicFrameTest { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); + "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Exception in thread"); output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)"); diff --git a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java index 502adcf24be..b354fcbf355 100644 --- a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java +++ b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java @@ -160,10 +160,10 @@ public class BootAppendTests { // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules, // the class can be loaded from -Xbootclasspath/a when the module is excluded - // using -limitmods. Verify the behavior is the same at runtime when CDS is - // enabled. + // using --limit-modules. Verify the behavior is the same at runtime when CDS + // is enabled. // - // The java.desktop module is excluded using -limitmods at runtime, + // The java.desktop module is excluded using --limit-modules at runtime, // javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be // loaded from the archive at runtime. public static void testBootAppendExcludedModuleClass() throws Exception { @@ -174,7 +174,7 @@ public class BootAppendTests { "-XX:+TraceClassLoading", "-cp", appJar, "-Xbootclasspath/a:" + bootAppendJar, - "-limitmods", "java.base", + "--limit-modules=java.base", "-Xshare:" + mode, APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME); @@ -191,8 +191,8 @@ public class BootAppendTests { // Test #4: If a class on -Xbootclasspath/a has the same fully qualified // name as a class defined in boot modules, the class is loaded // from -Xbootclasspath/a when the boot module is excluded using - // -limitmods. Verify the behavior is the same at runtime when CDS is - // enabled. + // --limit-modules. Verify the behavior is the same at runtime + // when CDS is enabled. // // The org.omg.CORBA.Context is a boot module class. The class // on -Xbootclasspath/a that has the same fully-qualified name @@ -206,7 +206,7 @@ public class BootAppendTests { "-XX:+TraceClassLoading", "-cp", appJar, "-Xbootclasspath/a:" + bootAppendJar, - "-limitmods", "java.base", + "--limit-modules=java.base", "-Xshare:" + mode, APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME); diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java index b9f2e52ab46..2ba4f6d139d 100644 --- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java +++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java @@ -89,10 +89,11 @@ public class SASymbolTableTest { long pid = p.getPid(); System.out.println("Attaching agent " + pid); ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", + "--add-modules=jdk.hotspot.agent", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", "SASymbolTableTestAgent", Long.toString(pid)); OutputAnalyzer output = ProcessTools.executeProcess(tool); diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java index 0e9b914234b..172af2a467d 100644 --- a/hotspot/test/runtime/Unsafe/RangeCheck.java +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -44,7 +44,7 @@ public class RangeCheck { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( true, "-Xmx32m", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert diff --git a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java index 04916a3e7b8..cce37fa72ff 100644 --- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java +++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java @@ -98,7 +98,7 @@ public class GetSysPkgTest { ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir", - "-XaddExports:java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator + + "--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "GetSysPkgTest", "do_tests"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java new file mode 100644 index 00000000000..833182b09b3 --- /dev/null +++ b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8136930 + * @summary Test that the VM ignores explicitly specified module internal properties. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +// Test that the VM ignores module related properties such as "jdk.module.addmods" +// and jdk.module.addreads.0" that can only be set using module options. +public class IgnoreModulePropertiesTest { + + // Test that the specified property and its value are ignored. If the VM accepted + // the property and value then an exception would be thrown because the value is + // bogus for that property. But, since the property is ignored no exception is + // thrown. + public static void testProperty(String prop, String value) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-D" + prop + "=" + value, "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("java version "); + output.shouldHaveExitValue(0); + + // Ensure that the property and its value aren't available. + if (System.getProperty(prop) != null) { + throw new RuntimeException( + "Unexpected non-null value for property " + prop); + } + } + + // For options of the form "option=value", check that an exception gets thrown for + // the illegal value and then check that its corresponding property is handled + // correctly. + public static void testOption(String option, String value, + String prop, String result) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + option + "=" + value, "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain(result); + testProperty(prop, value); + } + + public static void main(String[] args) throws Exception { + testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException"); + testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException"); + testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException"); + testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException"); + testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException"); + } +} diff --git a/hotspot/test/runtime/modules/ModuleOptionsTest.java b/hotspot/test/runtime/modules/ModuleOptionsTest.java new file mode 100644 index 00000000000..2efb8bc0ad5 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleOptionsTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8136930 + * @summary Test that the VM only recognizes the last specified --add-modules + * and --list-modules options + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +// Test that the VM behaves correctly when processing module related options. +public class ModuleOptionsTest { + + public static void main(String[] args) throws Exception { + + // Test that last --add-modules is the only one recognized. No exception + // should be thrown. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "--add-modules=i_dont_exist", "--add-modules=java.base", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + + // Test that last --limit-modules is the only one recognized. No exception + // should be thrown. + pb = ProcessTools.createJavaProcessBuilder( + "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } +} diff --git a/hotspot/test/runtime/modules/ModuleOptionsWarn.java b/hotspot/test/runtime/modules/ModuleOptionsWarn.java new file mode 100644 index 00000000000..e595c555e17 --- /dev/null +++ b/hotspot/test/runtime/modules/ModuleOptionsWarn.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8162415 + * @summary Test warnings for ignored properties. + * @modules java.base/jdk.internal.misc + * @library /testlibrary + */ + +import jdk.test.lib.*; + +// Test that the VM behaves correctly when processing command line module system properties. +public class ModuleOptionsWarn { + + public static void main(String[] args) throws Exception { + + // Test that a warning is issued for module related properties that get ignored. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.ignored", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning can be suppressed for module related properties that get ignored. + pb = ProcessTools.createJavaProcessBuilder( + "-Djdk.module.ignored", "-XX:-PrintWarnings", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is not issued for properties of the form "jdk.module.main" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.main.ignored", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + } +} diff --git a/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java b/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java index 49c75b1d211..e170d5eabb1 100644 --- a/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java +++ b/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java @@ -62,8 +62,8 @@ public class ExportModuleStressTest { compiled = CompilerUtils.compile( SRC_DIR.resolve("jdk.translet"), MODS_DIR.resolve("jdk.translet"), - "-XaddExports:jdk.test/test=jdk.translet", - "-mp", MODS_DIR.toString()); + "--add-exports=jdk.test/test=jdk.translet", + "-p", MODS_DIR.toString()); if (!compiled) { throw new RuntimeException("Test failed to compile module jdk.translet"); } @@ -71,7 +71,7 @@ public class ExportModuleStressTest { // Sanity check that the test, jdk.test/test/Main.java // runs without error. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-mp", MODS_DIR.toString(), + "-p", MODS_DIR.toString(), "-m", "jdk.test/test.Main"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("failed: 0") diff --git a/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java b/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java index 1ebb198ba5c..8ee2fb8a6f3 100644 --- a/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java +++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java @@ -62,8 +62,8 @@ public class ModuleStressGC { compiled = CompilerUtils.compile( SRC_DIR.resolve("jdk.translet"), MODS_DIR.resolve("jdk.translet"), - "-XaddExports:jdk.test/test=jdk.translet", - "-mp", MODS_DIR.toString()); + "--add-exports=jdk.test/test=jdk.translet", + "-p", MODS_DIR.toString()); if (!compiled) { throw new RuntimeException("Test failed to compile module jdk.translet"); } @@ -74,7 +74,7 @@ public class ModuleStressGC { // GC safepoints. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xlog:modules=trace", - "-mp", MODS_DIR.toString(), + "-p", MODS_DIR.toString(), "-m", "jdk.test/test.MainGC"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("package test defined in module jdk.test, exports list being walked") diff --git a/hotspot/test/runtime/modules/Xpatch/BasicJarBuilder.java b/hotspot/test/runtime/modules/PatchModule/BasicJarBuilder.java similarity index 100% rename from hotspot/test/runtime/modules/Xpatch/BasicJarBuilder.java rename to hotspot/test/runtime/modules/PatchModule/BasicJarBuilder.java diff --git a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java b/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java similarity index 87% rename from hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java rename to hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java index d874d10fb04..8b04db22632 100644 --- a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java @@ -23,17 +23,17 @@ /* * @test - * @summary Make sure -Xpatch works with multiple directories. + * @summary Make sure --patch-module works with multiple directories. * @modules java.base/jdk.internal.misc * @library /testlibrary - * @compile Xpatch2DirsMain.java - * @run main Xpatch2Dirs + * @compile PatchModule2DirsMain.java + * @run main PatchModule2Dirs */ import jdk.test.lib.*; import java.io.File; -public class Xpatch2Dirs { +public class PatchModule2Dirs { public static void main(String[] args) throws Exception { String source1 = "package javax.naming.spi; " + @@ -58,9 +58,9 @@ public class Xpatch2Dirs { "mods2/java.desktop"); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.naming=mods/java.naming", - "-Xpatch:java.desktop=mods2/java.desktop", - "Xpatch2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder"); + "--patch-module=java.naming=mods/java.naming", + "--patch-module=java.desktop=mods2/java.desktop", + "PatchModule2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("I pass one!"); diff --git a/hotspot/test/runtime/modules/Xpatch/Xpatch2DirsMain.java b/hotspot/test/runtime/modules/PatchModule/PatchModule2DirsMain.java similarity index 80% rename from hotspot/test/runtime/modules/Xpatch/Xpatch2DirsMain.java rename to hotspot/test/runtime/modules/PatchModule/PatchModule2DirsMain.java index 9691156030b..466d11c9bcc 100644 --- a/hotspot/test/runtime/modules/Xpatch/Xpatch2DirsMain.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModule2DirsMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -21,9 +21,9 @@ * questions. */ -// This loads the class affected by the -Xpatch option. For the test to pass -// it must load both classes from the -Xpatch directory, not the jimage file. -public class Xpatch2DirsMain { +// This loads the class affected by the --patch-module option. For the test to pass +// it must load both classes from the --patch-module directory, not the jimage file. +public class PatchModule2DirsMain { public static void main(String[] args) throws Exception { Class.forName(args[0]); Class.forName(args[1]); diff --git a/hotspot/test/runtime/modules/XpatchCDS.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java similarity index 81% rename from hotspot/test/runtime/modules/XpatchCDS.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java index 53ef3cf74e6..3ad5dab8014 100644 --- a/hotspot/test/runtime/modules/XpatchCDS.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java @@ -25,22 +25,22 @@ * @test * @library /testlibrary * @modules java.base/jdk.internal.misc - * @run main XpatchCDS + * @run main PatchModuleCDS */ import java.io.File; import jdk.test.lib.*; -public class XpatchCDS { +public class PatchModuleCDS { public static void main(String args[]) throws Throwable { - System.out.println("Test that -Xpatch and -Xshare:dump are incompatibable"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", "-Xshare:dump"); + System.out.println("Test that --patch-module and -Xshare:dump are incompatibable"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xshare:dump"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Cannot use the following option when dumping the shared archive: -Xpatch"); + output.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); - System.out.println("Test that -Xpatch and -Xshare:on are incompatibable"); - String filename = "Xpatch.jsa"; + System.out.println("Test that --patch-module and -Xshare:on are incompatibable"); + String filename = "patch_module.jsa"; pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, @@ -52,10 +52,10 @@ public class XpatchCDS { "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:on", - "-Xpatch:java.naming=mods/java.naming", + "--patch-module=java.naming=mods/java.naming", "-version"); output = new OutputAnalyzer(pb.start()); - output.shouldContain("The shared archive file cannot be used with -Xpatch"); + output.shouldContain("The shared archive file cannot be used with --patch-module"); output.shouldHaveExitValue(1); } diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupJavaBase.java similarity index 87% rename from hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleDupJavaBase.java index 69448a62796..e1d29adfc8b 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupJavaBase.java @@ -23,23 +23,23 @@ /* * @test - * @summary VM exit initialization results if java.base is specificed more than once to Xpatch. + * @summary VM exit initialization results if java.base is specificed more than once to --patch-module. * @modules java.base/jdk.internal.misc * @library /testlibrary */ import jdk.test.lib.*; -public class XpatchDupJavaBase { +public class PatchModuleDupJavaBase { // The VM should exit initialization if java.base is specified - // more than once to -Xpatch. + // more than once to --patch-module. public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.base=javabase_dir", - "-Xpatch:java.base=javabase_dir", + "--patch-module=java.base=javabase_dir", + "--patch-module=java.base=javabase_dir", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Cannot specify java.base more than once to -Xpatch"); + output.shouldContain("Cannot specify java.base more than once to --patch-module"); output.shouldHaveExitValue(1); } } diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupModule.java similarity index 86% rename from hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleDupModule.java index 9fcffa4157a..2b56665de2b 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupModule.java @@ -23,26 +23,25 @@ /* * @test - * @summary Module system initialization exception results if a module is specificed twice to Xpatch. + * @summary Module system initialization exception results if a module is specificed twice to --patch-module. * @modules java.base/jdk.internal.misc * @library /testlibrary */ import jdk.test.lib.*; -public class XpatchDupModule { +public class PatchModuleDupModule { // The module system initialization should generate an ExceptionInInitializerError - // if -Xpatch is specified with the same module more than once. + // if --patch-module is specified with the same module more than once. public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xpatch:module1=module1_dir", - "-Xpatch:module1=module1_dir", + "--patch-module=module1=module1_dir", + "--patch-module=module1=module1_dir", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ExceptionInInitializerError"); output.shouldHaveExitValue(1); } } - diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java similarity index 88% rename from hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java index 3c0e50a58fb..c9d957f96f3 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java @@ -24,16 +24,16 @@ /* * @test * @bug 8130399 - * @summary Make sure -Xpatch works for java.base. + * @summary Make sure --patch-module works for java.base. * @modules java.base/jdk.internal.misc * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchJavaBase + * @compile PatchModuleMain.java + * @run main PatchModuleJavaBase */ import jdk.test.lib.*; -public class XpatchJavaBase { +public class PatchModuleJavaBase { public static void main(String[] args) throws Exception { String source = "package java.lang; " + @@ -47,8 +47,8 @@ public class XpatchJavaBase { InMemoryJavaCompiler.compile("java.lang.NewClass", source, "-Xmodule:java.base"), "mods/java.base"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base", - "XpatchMain", "java.lang.NewClass"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", + "PatchModuleMain", "java.lang.NewClass"); new OutputAnalyzer(pb.start()) .shouldContain("I pass!") diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchMain.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleMain.java similarity index 85% rename from hotspot/test/runtime/modules/Xpatch/XpatchMain.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleMain.java index 5509cbc7621..daa9001e72f 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchMain.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleMain.java @@ -21,9 +21,9 @@ * questions. */ -// This loads the class affected by the -Xpatch option. For the test to pass -// it must load the class from the -Xpatch directory, not the jimage file. -public class XpatchMain { +// This loads the class affected by the --patch-module option. For the test to pass +// it must load the class from the --patch-module directory, not the jimage file. +public class PatchModuleMain { public static void main(String[] args) throws Exception { Class.forName(args[0]); } diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java similarity index 87% rename from hotspot/test/runtime/modules/Xpatch/XpatchTest.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java index 6c67a4fe514..c85c88e99dd 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java @@ -24,16 +24,16 @@ /* * @test * @bug 8130399 - * @summary Make sure -Xpatch works for modules besides java.base. + * @summary Make sure --patch-module works for modules besides java.base. * @modules java.base/jdk.internal.misc * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchTest + * @compile PatchModuleMain.java + * @run main PatchModuleTest */ import jdk.test.lib.*; -public class XpatchTest { +public class PatchModuleTest { public static void main(String[] args) throws Exception { String source = "package javax.naming.spi; " + @@ -47,8 +47,8 @@ public class XpatchTest { InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), "mods/java.naming"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", - "XpatchMain", "javax.naming.spi.NamingManager"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + "PatchModuleMain", "javax.naming.spi.NamingManager"); new OutputAnalyzer(pb.start()) .shouldContain("I pass!") diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTestJar.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java similarity index 90% rename from hotspot/test/runtime/modules/Xpatch/XpatchTestJar.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java index ad1675a15f0..c9ed80939a5 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTestJar.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java @@ -23,18 +23,18 @@ /* * @test - * @summary Make sure -Xpatch works when a jar file is specified for a module + * @summary Make sure --patch-module works when a jar file is specified for a module * @library /testlibrary * @modules java.base/jdk.internal.misc * jdk.jartool/sun.tools.jar * @build BasicJarBuilder - * @compile XpatchMain.java - * @run main XpatchTestJar + * @compile PatchModuleMain.java + * @run main PatchModuleTestJar */ import jdk.test.lib.*; -public class XpatchTestJar { +public class PatchModuleTestJar { private static String moduleJar; public static void main(String[] args) throws Exception { @@ -72,9 +72,9 @@ public class XpatchTestJar { InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), System.getProperty("test.classes")); - // Supply -Xpatch with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" + moduleJar, - "XpatchMain", "javax.naming.spi.NamingManager"); + // Supply --patch-module with the name of the jar file for the module java.naming. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + moduleJar, + "PatchModuleMain", "javax.naming.spi.NamingManager"); new OutputAnalyzer(pb.start()) .shouldContain("I pass!") diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTestJarDir.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java similarity index 93% rename from hotspot/test/runtime/modules/Xpatch/XpatchTestJarDir.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java index a5329b6349d..4220816b322 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTestJarDir.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java @@ -23,20 +23,20 @@ /* * @test - * @summary Make sure -Xpatch works when a jar file and a directory is specified for a module + * @summary Make sure --patch-module works when a jar file and a directory is specified for a module * @library /testlibrary * @modules java.base/jdk.internal.misc * jdk.jartool/sun.tools.jar * @build BasicJarBuilder - * @compile Xpatch2DirsMain.java - * @run main XpatchTestJarDir + * @compile PatchModule2DirsMain.java + * @run main PatchModuleTestJarDir */ import java.io.File; import java.nio.file.Files; import jdk.test.lib.*; -public class XpatchTestJarDir { +public class PatchModuleTestJarDir { private static String moduleJar; public static void main(String[] args) throws Exception { @@ -88,12 +88,12 @@ public class XpatchTestJarDir { (System.getProperty("test.classes") + "/mods/java.naming")); - // Supply -Xpatch with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" + + // Supply --patch-module with the name of the jar file for the module java.naming. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + moduleJar + File.pathSeparator + System.getProperty("test.classes") + "/mods/java.naming", - "Xpatch2DirsMain", + "PatchModule2DirsMain", "javax.naming.spi.NamingManager1", "javax.naming.spi.NamingManager2"); diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java similarity index 76% rename from hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java rename to hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java index c3484971407..0d3bdeac0d1 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java @@ -25,17 +25,17 @@ * @test * @bug 8069469 * @summary Make sure -Xlog:classload=info works properly with "modules" jimage, - -Xpatch, and with -Xbootclasspath/a + --patch-module, and with -Xbootclasspath/a * @modules java.base/jdk.internal.misc * @library /testlibrary - * @compile XpatchMain.java - * @run main XpatchTraceCL + * @compile PatchModuleMain.java + * @run main PatchModuleTraceCL */ import java.io.File; import jdk.test.lib.*; -public class XpatchTraceCL { +public class PatchModuleTraceCL { public static void main(String[] args) throws Exception { String source = "package javax.naming.spi; " + @@ -45,39 +45,39 @@ public class XpatchTraceCL { " } " + "}"; - // Test -Xlog:classload=info output for -Xpatch + // Test -Xlog:classload=info output for --patch-module ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"), "mods/java.naming"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", - "-Xlog:class+load=info", "XpatchMain", "javax.naming.spi.NamingManager"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + "-Xlog:class+load=info", "PatchModuleMain", "javax.naming.spi.NamingManager"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); // "modules" jimage case. output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base"); - // -Xpatch case. + // --patch-module case. output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming"); // -cp case. - output.shouldContain("[class,load] XpatchMain source: file"); + output.shouldContain("[class,load] PatchModuleMain source: file"); // Test -Xlog:classload=info output for -Xbootclasspath/a - source = "package XpatchTraceCL_pkg; " + + source = "package PatchModuleTraceCL_pkg; " + "public class ItIsI { " + " static { " + " System.out.println(\"I also pass!\"); " + " } " + "}"; - ClassFileInstaller.writeClassToDisk("XpatchTraceCL_pkg/ItIsI", - InMemoryJavaCompiler.compile("XpatchTraceCL_pkg.ItIsI", source), + ClassFileInstaller.writeClassToDisk("PatchModuleTraceCL_pkg/ItIsI", + InMemoryJavaCompiler.compile("PatchModuleTraceCL_pkg.ItIsI", source), "xbcp"); pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp", - "-Xlog:class+load=info", "XpatchMain", "XpatchTraceCL_pkg.ItIsI"); + "-Xlog:class+load=info", "PatchModuleMain", "PatchModuleTraceCL_pkg.ItIsI"); output = new OutputAnalyzer(pb.start()); // -Xbootclasspath/a case. - output.shouldContain("[class,load] XpatchTraceCL_pkg.ItIsI source: xbcp"); + output.shouldContain("[class,load] PatchModuleTraceCL_pkg.ItIsI source: xbcp"); output.shouldHaveExitValue(0); } } diff --git a/hotspot/test/runtime/modules/Visibility/XpatchVisibility.java b/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java similarity index 84% rename from hotspot/test/runtime/modules/Visibility/XpatchVisibility.java rename to hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java index a49fd997515..89afde3376d 100644 --- a/hotspot/test/runtime/modules/Visibility/XpatchVisibility.java +++ b/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java @@ -23,13 +23,13 @@ /* * @test - * @summary Ensure that a newly introduced java.base package placed within the -Xpatch directory - * is considered part of the boot loader's visibility boundary + * @summary Ensure that a newly introduced java.base package placed within the --patch-module + * directory is considered part of the boot loader's visibility boundary * @requires !(os.family == "windows") * @library /testlibrary * @modules java.base/jdk.internal.misc * java.management - * @run main/othervm XpatchVisibility + * @run main/othervm PatchModuleVisibility */ import java.io.File; @@ -38,7 +38,7 @@ import java.nio.file.Paths; import jdk.test.lib.*; -public class XpatchVisibility { +public class PatchModuleVisibility { public static void main(String[] args) throws Throwable { @@ -55,19 +55,19 @@ public class XpatchVisibility { "public class Vis2_A {" + " public static void main(String args[]) throws Exception {" + // Try loading a class within a newly introduced java.base - // package. Make sure the class can be found via -Xpatch. + // package. Make sure the class can be found via --patch-module. " try {" + " p2.Vis2_B b = new p2.Vis2_B();" + " if (b.getClass().getClassLoader() != null) {" + - " throw new RuntimeException(\"XpatchVisibility FAILED - class B " + + " throw new RuntimeException(\"PatchModuleVisibility FAILED - class B " + "should be loaded by boot class loader\\n\");" + " }" + " b.m();" + " } catch (Throwable e) {" + - " throw new RuntimeException(\"XpatchVisibility FAILED - test " + + " throw new RuntimeException(\"PatchModuleVisibility FAILED - test " + "should not throw an error or exception\\n\");" + " }" + - " System.out.println(\"XpatchVisibility PASSED\\n\");" + + " System.out.println(\"PatchModuleVisibility PASSED\\n\");" + " }" + "}"; @@ -83,8 +83,8 @@ public class XpatchVisibility { "p2" + File.separator + "Vis2_B.class")); new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( - "-Xpatch:java.base=mods2/java.base", - "-XaddExports:java.base/p2=ALL-UNNAMED", + "--patch-module=java.base=mods2/java.base", + "--add-exports=java.base/p2=ALL-UNNAMED", "Vis2_A") .start()).shouldHaveExitValue(0); } diff --git a/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java b/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java index 70cfa71f25a..3f92fd3dfe1 100644 --- a/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java +++ b/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java @@ -50,7 +50,7 @@ public class XbootcpNoVisibility { // Try loading a class within a named package in a module which has been defined // to the boot loader. In this situation, the class should only be attempted // to be loaded from the boot loader's module path which consists of: - // [-Xpatch]; exploded build | "modules" jimage + // [--patch-module]; exploded build | "modules" jimage // // Since the class is located on the boot loader's append path via // -Xbootclasspath/a specification, it should not be found. diff --git a/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java b/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java index ca7977aee8d..19bbff48a76 100644 --- a/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java +++ b/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -27,7 +27,7 @@ import java.lang.module.ModuleDescriptor; /** * A helper class intended to be injected into java.lang.reflect using the - * java -Xpatch option. The helper class provides access to package private + * java --patch-module option. The helper class provides access to package private * methods in java.lang.reflect.Module. */ diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java index 5d13df401df..6ab0a921609 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java @@ -113,9 +113,10 @@ public class TestInstanceKlassSize { }; String[] toolArgs = { "-XX:+UnlockDiagnosticVMOptions", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-modules=jdk.hotspot.agent", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "TestInstanceKlassSize", Long.toString(app.getPid()) }; diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java index 085ac246664..c2c0c61b9a9 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -107,9 +107,10 @@ public class TestInstanceKlassSizeForInterface { // Grab the pid from the current java process and pass it String[] toolArgs = { "-XX:+UnlockDiagnosticVMOptions", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", - "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-modules=jdk.hotspot.agent", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "TestInstanceKlassSizeForInterface", Long.toString(ProcessTools.getProcessId()) }; diff --git a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index 459686ee71c..a1b297adc06 100644 --- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @@ -87,7 +87,7 @@ public class JMapHProfLargeHeapTest { String expectedFormat) throws Exception, IOException, InterruptedException, FileNotFoundException { ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder( - "-XaddExports:java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); + "--add-exports=java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process largeHeapProc = procBuilder.start(); diff --git a/hotspot/test/testlibrary/ctw/Makefile b/hotspot/test/testlibrary/ctw/Makefile index ed63271e91a..0c642c63256 100644 --- a/hotspot/test/testlibrary/ctw/Makefile +++ b/hotspot/test/testlibrary/ctw/Makefile @@ -58,10 +58,10 @@ cleantmp: ctw.jar: filelist wb.jar @mkdir -p $(OUTPUT_DIR) - $(JAVAC) -XaddExports:java.base/jdk.internal.jimage=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED \ - -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp wb.jar @filelist + $(JAVAC) --add-exports java.base/jdk.internal.jimage=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED \ + -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp wb.jar @filelist $(JAR) --create --file=$@ --main-class $(MAIN_CLASS) -C $(OUTPUT_DIR) . wb.jar: wb_filelist diff --git a/hotspot/test/testlibrary/jittester/Makefile b/hotspot/test/testlibrary/jittester/Makefile index 49470f7df71..4068d9d0af5 100644 --- a/hotspot/test/testlibrary/jittester/Makefile +++ b/hotspot/test/testlibrary/jittester/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2016, 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 @@ -95,10 +95,10 @@ manifest: @echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST) compile_testlib: INIT - $(JAVAC) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) + $(JAVAC) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) COMPILE: INIT filelist compile_testlib - $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist + $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist filelist: $(SRC_FILES) @rm -f $@ @@ -109,7 +109,7 @@ INIT: $(DIST_DIR) $(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi) install: clean_testbase testgroup testroot copytestlibrary JAR cleantmp - $(JAVA) -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS) + $(JAVA) --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS) clean_testbase: @rm -rf $(TESTBASE_DIR) From c5983e8f77515981b3d09cf1ff478a6cb9f1897b Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 10 Aug 2016 15:49:03 -0700 Subject: [PATCH 23/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar --- common/autoconf/boot-jdk.m4 | 2 +- common/autoconf/generated-configure.sh | 10 +- common/autoconf/spec.gmk.in | 2 +- common/conf/jib-profiles.js | 2 +- make/CompileJavaModules.gmk | 4 +- make/CreateJmods.gmk | 4 +- make/Images.gmk | 12 +-- make/InterimImage.gmk | 4 +- make/Javadoc.gmk | 132 ++++++++++++------------- make/common/MakeBase.gmk | 2 +- make/common/SetupJavaCompilers.gmk | 2 +- 11 files changed, 88 insertions(+), 88 deletions(-) diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4 index d3fd298d704..83ec28e39bb 100644 --- a/common/autoconf/boot-jdk.m4 +++ b/common/autoconf/boot-jdk.m4 @@ -305,7 +305,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], BOOT_JDK_SOURCETARGET="-source 8 -target 8" AC_SUBST(BOOT_JDK_SOURCETARGET) - ADD_JVM_ARG_IF_OK([-Xpatch:foo=bar], dummy, [$JAVA]) + ADD_JVM_ARG_IF_OK([--patch-module foo=bar], dummy, [$JAVA]) AC_MSG_CHECKING([if Boot JDK supports modules]) if test "x$JVM_ARG_OK" = "xtrue"; then AC_MSG_RESULT([yes]) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 02375c62e7f..92e055d9a12 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5095,7 +5095,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1470415803 +DATE_WHEN_GENERATED=1470863189 ############################################################################### # @@ -30596,13 +30596,13 @@ $as_echo "$tool_specified" >&6; } - $ECHO "Check if jvm arg is ok: -Xpatch:foo=bar" >&5 - $ECHO "Command: $JAVA -Xpatch:foo=bar -version" >&5 - OUTPUT=`$JAVA -Xpatch:foo=bar -version 2>&1` + $ECHO "Check if jvm arg is ok: --patch-module foo=bar" >&5 + $ECHO "Command: $JAVA --patch-module foo=bar -version" >&5 + OUTPUT=`$JAVA --patch-module foo=bar -version 2>&1` FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn` FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""` if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - dummy="$dummy -Xpatch:foo=bar" + dummy="$dummy --patch-module foo=bar" JVM_ARG_OK=true else $ECHO "Arg failed:" >&5 diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 510764002a2..e4d41e81b43 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -585,7 +585,7 @@ INTERIM_OVERRIDE_MODULES := java.compiler jdk.compiler \ jdk.jdeps jdk.javadoc jdk.rmic ifeq ($(BOOT_JDK_MODULAR), true) INTERIM_OVERRIDE_MODULES_ARGS = $(foreach m, $(INTERIM_OVERRIDE_MODULES), \ - -Xpatch:$m=$(BUILDTOOLS_OUTPUTDIR)/override_modules/$m) + --patch-module $m=$(BUILDTOOLS_OUTPUTDIR)/override_modules/$m) INTERIM_LANGTOOLS_ARGS = $(INTERIM_OVERRIDE_MODULES_ARGS) JAVAC_MAIN_CLASS = -m jdk.compiler/com.sun.tools.javac.Main JAVADOC_MAIN_CLASS = -m jdk.javadoc/jdk.javadoc.internal.tool.Main diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index 2fa29a7c634..e57bbf7e4bd 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -417,7 +417,7 @@ var getJibProfilesDependencies = function (input, common) { jtreg: { server: "javare", revision: "4.2", - build_number: "b02", + build_number: "b03", checksum_file: "MD5_VALUES", file: "jtreg_bin-4.2.zip", environment_name: "JT_HOME" diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index f377d6687c5..65e43933dec 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -502,8 +502,8 @@ $(eval $(call SetupJavaCompilation, $(MODULE), \ HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ ADD_JAVAC_FLAGS := \ $($(MODULE)_ADD_JAVAC_FLAGS) \ - -modulesourcepath $(MODULESOURCEPATH) \ - -modulepath $(MODULEPATH) \ + --module-source-path $(MODULESOURCEPATH) \ + --module-path $(MODULEPATH) \ -system none, \ )) diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 42ef85536da..c452f1b9cf1 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -77,7 +77,7 @@ ifeq ($(MODULE), java.base) EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES)))) - JMOD_FLAGS += --modulepath $(JMODS_DIR) \ + JMOD_FLAGS += --module-path $(JMODS_DIR) \ --hash-modules '^(?!$(EXCLUDE_PATTERN))' endif endif @@ -102,7 +102,7 @@ $(JMODS_DIR)/$(MODULE).jmod: $(DEPS) --os-name $(REQUIRED_OS_NAME) \ --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \ --os-version $(REQUIRED_OS_VERSION) \ - --modulepath $(JMODS_DIR) \ + --module-path $(JMODS_DIR) \ --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.pdb,*.map}' \ $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@ diff --git a/make/Images.gmk b/make/Images.gmk index a1b0a70b243..c7df894ceaf 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -127,7 +127,7 @@ JLINK_ORDER_RESOURCES += \ /jdk.localedata/** \ # -JLINK_TOOL := $(JLINK) --modulepath $(IMAGES_OUTPUTDIR)/jmods \ +JLINK_TOOL := $(JLINK) --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) \ --release-info $(BASE_RELEASE_FILE) \ --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ @@ -142,7 +142,7 @@ $(JDK_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(ECHO) Creating jdk jimage $(RM) -r $(JDK_IMAGE_DIR) $(JLINK_TOOL) --output $(JDK_IMAGE_DIR) \ - --addmods $(JDK_MODULES_LIST) $(JLINK_EXTRA_OPTS) + --add-modules $(JDK_MODULES_LIST) $(JLINK_EXTRA_OPTS) $(TOUCH) $@ $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ @@ -150,7 +150,7 @@ $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(ECHO) Creating jre jimage $(RM) -r $(JRE_IMAGE_DIR) $(JLINK_TOOL) --output $(JRE_IMAGE_DIR) \ - --addmods $(JRE_MODULES_LIST) + --add-modules $(JRE_MODULES_LIST) $(TOUCH) $@ JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1 @@ -161,7 +161,7 @@ $(JRE_COMPACT1_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE) $(ECHO) Creating jre compact1 jimage $(RM) -r $(JRE_COMPACT1_IMAGE_DIR) - $(JLINK_TOOL) --addmods $(JRE_COMPACT1_MODULES_LIST) \ + $(JLINK_TOOL) --add-modules $(JRE_COMPACT1_MODULES_LIST) \ --output $(JRE_COMPACT1_IMAGE_DIR) $(TOUCH) $@ @@ -169,7 +169,7 @@ $(JRE_COMPACT2_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(call DependOnVariable, JRE_COMPACT2_MODULES_LIST) $(BASE_RELEASE_FILE) $(ECHO) Creating jre compact2 jimage $(RM) -r $(JRE_COMPACT2_IMAGE_DIR) - $(JLINK_TOOL) --addmods $(JRE_COMPACT2_MODULES_LIST) \ + $(JLINK_TOOL) --add-modules $(JRE_COMPACT2_MODULES_LIST) \ --output $(JRE_COMPACT2_IMAGE_DIR) $(TOUCH) $@ @@ -177,7 +177,7 @@ $(JRE_COMPACT3_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(call DependOnVariable, JRE_COMPACT3_MODULES_LIST) $(BASE_RELEASE_FILE) $(ECHO) Creating jre compact3 jimage $(RM) -r $(JRE_COMPACT3_IMAGE_DIR) - $(JLINK_TOOL) --addmods $(JRE_COMPACT3_MODULES_LIST) \ + $(JLINK_TOOL) --add-modules $(JRE_COMPACT3_MODULES_LIST) \ --output $(JRE_COMPACT3_IMAGE_DIR) $(TOUCH) $@ diff --git a/make/InterimImage.gmk b/make/InterimImage.gmk index 6f05abe0b83..ba9f5622275 100644 --- a/make/InterimImage.gmk +++ b/make/InterimImage.gmk @@ -39,7 +39,7 @@ INTERIM_MODULES_LIST := $(call CommaList, $(INTERIM_IMAGE_MODULES)) JMODS := $(patsubst %, $(IMAGES_OUTPUTDIR)/jmods/%.jmod, $(INTERIM_IMAGE_MODULES)) JLINK_TOOL := $(JLINK) \ - --modulepath $(IMAGES_OUTPUTDIR)/jmods \ + --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ @@ -48,7 +48,7 @@ $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ $(RM) -r $(INTERIM_IMAGE_DIR) $(JLINK_TOOL) \ --output $(INTERIM_IMAGE_DIR) \ - --addmods $(INTERIM_MODULES_LIST) + --add-modules $(INTERIM_MODULES_LIST) $(TOUCH) $@ TARGETS += $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 866e3d711e3..8afd5514064 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -425,9 +425,9 @@ $(COREAPI_OPTIONS_FILE): $(COREAPI_OVERVIEW) $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:reference) ; \ $(call OptionOnly,-Xdoclint/package:-org.omg.*$(COMMA)jdk.internal.logging.*) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(COREAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(COREAPI_MODULES)) ; \ $(call OptionPair,-encoding,ISO-8859-1) ; \ $(call OptionOnly,-splitIndex) ; \ $(call OptionPair,-overview,$(COREAPI_OVERVIEW)) ; \ @@ -488,9 +488,9 @@ $(DOCLETAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(DOCLETAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(DOCLETAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-breakiterator) ; \ $(call OptionPair,-doctitle,$(DOCLETAPI_DOCTITLE)) ; \ @@ -550,9 +550,9 @@ $(OLD_DOCLETAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(OLD_DOCLETAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(OLD_DOCLETAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-breakiterator) ; \ $(call OptionPair,-doctitle,$(OLD_DOCLETAPI_DOCTITLE)) ; \ @@ -605,9 +605,9 @@ $(TAGLETAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(TAGLETAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(TAGLETAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-breakiterator) ; \ $(call OptionPair,-doctitle,$(TAGLETAPI_DOCTITLE)) ; \ @@ -667,9 +667,9 @@ $(DOMAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(DOMAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(DOMAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-splitIndex) ; \ $(call OptionPair,-doctitle,$(DOMAPI_DOCTITLE)) ; \ @@ -736,9 +736,9 @@ $(JDI_OPTIONS_FILE): $(JDI_OVERVIEW) @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JDI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JDI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-overview,$(JDI_OVERVIEW)) ; \ $(call OptionPair,-doctitle,$(JDI_DOCTITLE)) ; \ @@ -829,9 +829,9 @@ $(JAAS_OPTIONS_FILE): $(JAAS_OVERVIEW) @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JAAS_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JAAS_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-overview,$(JAAS_OVERVIEW)) ; \ $(call OptionPair,-doctitle,$(JAAS_DOCTITLE)) ; \ @@ -888,9 +888,9 @@ $(JGSS_OPTIONS_FILE): $(JGSS_OVERVIEW) @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JGSS_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JGSS_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-overview,$(JGSS_OVERVIEW)) ; \ @@ -947,9 +947,9 @@ $(SMARTCARDIO_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(SMARTCARDIO_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(SMARTCARDIO_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(SMARTCARDIO_DOCTITLE)) ; \ @@ -1004,9 +1004,9 @@ $(HTTPSERVER_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(HTTPSERVER_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(HTTPSERVER_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(HTTPSERVER_DOCTITLE)) ; \ @@ -1061,9 +1061,9 @@ $(JSOBJECT_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JSOBJECT_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JSOBJECT_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(JSOBJECT_DOCTITLE)) ; \ @@ -1121,9 +1121,9 @@ $(MGMT_OPTIONS_FILE): $(MGMT_OVERVIEW) @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(MGMT_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(MGMT_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-overview,$(MGMT_OVERVIEW)) ; \ @@ -1179,9 +1179,9 @@ $(ATTACH_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(ATTACH_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(ATTACH_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(ATTACH_DOCTITLE)) ; \ @@ -1236,9 +1236,9 @@ $(JCONSOLE_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JCONSOLE_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JCONSOLE_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(JCONSOLE_DOCTITLE)) ; \ @@ -1294,9 +1294,9 @@ $(JSHELLAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JSHELLAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JSHELLAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-overview,$(JSHELLAPI_OVERVIEW)) ; \ $(call OptionPair,-doctitle,$(JSHELLAPI_DOCTITLE)) ; \ @@ -1353,9 +1353,9 @@ $(TREEAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(TREEAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(TREEAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \ $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \ @@ -1412,9 +1412,9 @@ $(NASHORNAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(NASHORNAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(NASHORNAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-doctitle,$(NASHORNAPI_DOCTITLE)) ; \ $(call OptionPair,-windowtitle,$(NASHORNAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \ @@ -1471,9 +1471,9 @@ $(DYNALINKAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(DYNALINKAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(DYNALINKAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-doctitle,$(DYNALINKAPI_DOCTITLE)) ; \ $(call OptionPair,-windowtitle,$(DYNALINKAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \ @@ -1527,9 +1527,9 @@ $(SCTPAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(SCTPAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(SCTPAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(SCTPAPI_DOCTITLE)) ; \ @@ -1584,9 +1584,9 @@ $(JACCESSAPI_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JACCESSAPI_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JACCESSAPI_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(JACCESSAPI_DOCTITLE)) ; \ @@ -1641,9 +1641,9 @@ $(JDKNET_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JDKNET_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JDKNET_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(JDKNET_DOCTITLE)) ; \ @@ -1702,9 +1702,9 @@ $(JLINK_PLUGIN_OPTIONS_FILE): @($(call COMMON_JAVADOCFLAGS) ; \ $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ - $(call OptionPair,-system,none) ; \ - $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ - $(call OptionPair,-addmods,$(JLINK_PLUGIN_MODULES)) ; \ + $(call OptionPair,--system,none) ; \ + $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \ + $(call OptionPair,--add-modules,$(JLINK_PLUGIN_MODULES)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nodeprecatedlist) ; \ $(call OptionPair,-doctitle,$(JLINK_PLUGIN_DOCTITLE)) ; \ diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 15c6bc6254d..8a715b410fb 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -828,7 +828,7 @@ else endif ################################################################################ -# Return a string suitable for use after a -classpath or -modulepath option. It +# Return a string suitable for use after a -classpath or --module-path option. It # will be correct and safe to use on all platforms. Arguments are given as space # separate classpath entries. Safe for multiple nested calls. # param 1 : A space separated list of classpath entries diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk index 8100cdbeccb..52b2cc337fe 100644 --- a/make/common/SetupJavaCompilers.gmk +++ b/make/common/SetupJavaCompilers.gmk @@ -88,7 +88,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \ JVM := $(JAVA_SMALL), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := -upgrademodulepath $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \ + FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) From 00bf56a8f2cd8e067574b70f671a306002a7a631 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 10 Aug 2016 15:49:16 -0700 Subject: [PATCH 24/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar --- nashorn/buildtools/nasgen/project.properties | 4 +-- nashorn/make/BuildNashorn.gmk | 10 +++--- nashorn/make/build.xml | 12 +++---- nashorn/make/project.properties | 36 +++++++++---------- nashorn/test/TEST.ROOT | 6 ++-- .../script/currently-failing/JDK-8055034.js | 2 +- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/nashorn/buildtools/nasgen/project.properties b/nashorn/buildtools/nasgen/project.properties index 0f280a1e47f..2ad8b5956c6 100644 --- a/nashorn/buildtools/nasgen/project.properties +++ b/nashorn/buildtools/nasgen/project.properties @@ -40,8 +40,8 @@ dist.javadoc.dir=${dist.dir}/javadoc javac.debug=true nasgen.module.imports=\ - -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED meta.inf.dir=${src.dir}/META-INF run.classpath=\ diff --git a/nashorn/make/BuildNashorn.gmk b/nashorn/make/BuildNashorn.gmk index 595fad687a6..21b984f5edf 100644 --- a/nashorn/make/BuildNashorn.gmk +++ b/nashorn/make/BuildNashorn.gmk @@ -44,8 +44,8 @@ MODULESOURCEPATH := $(NASHORN_TOPDIR)/src/*/share/classes $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \ JVM := $(JAVA), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := -g -source 9 -target 9 -upgrademodulepath "$(JDK_OUTPUTDIR)/modules/" \ - -system none -modulesourcepath "$(MODULESOURCEPATH)", \ + FLAGS := -g -source 9 -target 9 --upgrade-module-path "$(JDK_OUTPUTDIR)/modules/" \ + --system none --module-source-path "$(MODULESOURCEPATH)", \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) @@ -76,9 +76,9 @@ NASGEN_RUN_FILE := $(NASHORN_CLASSES_DIR)/_the.nasgen.run ifeq ($(BOOT_JDK_MODULAR), true) NASGEN_OPTIONS := \ -cp $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \ - -Xpatch:java.base=$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED \ + --patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \ + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED \ # else NASGEN_OPTIONS := \ diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index b502e8bdd93..08b4e544696 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -178,7 +178,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -212,7 +212,7 @@ - + @@ -266,7 +266,7 @@ - + @@ -285,7 +285,7 @@ - + @@ -302,7 +302,7 @@ - + diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index b6c61b32480..e55fe3935c0 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -51,9 +51,9 @@ build.zip=${build.dir}/nashorn.zip build.gzip=${build.dir}/nashorn.tar.gz nashorn.override.option=\ - -Xpatch:jdk.scripting.nashorn=${build.classes.dir}/jdk.scripting.nashorn \ - -Xpatch:jdk.scripting.nashorn.shell=${build.classes.dir}/jdk.scripting.nashorn.shell \ - -Xpatch:jdk.dynalink=${build.classes.dir}/jdk.dynalink + --patch-module jdk.scripting.nashorn=${build.classes.dir}/jdk.scripting.nashorn \ + --patch-module jdk.scripting.nashorn.shell=${build.classes.dir}/jdk.scripting.nashorn.shell \ + --patch-module jdk.dynalink=${build.classes.dir}/jdk.dynalink # project directory of ant task nashorntask.dir=buildtools/nashorntask @@ -65,8 +65,8 @@ nashorn.shell.tool=jdk.nashorn.tools.Shell nasgen.tool=jdk.nashorn.internal.tools.nasgen.Main nasgen.module.imports=\ - -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED # parallel test runner tool parallel.test.runner=jdk.nashorn.internal.test.framework.ParallelTestRunner @@ -142,19 +142,19 @@ javac.test.classpath=\ ${file.reference.snakeyaml.jar} test.module.imports=\ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.ir=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.codegen=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.parser=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.objects=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.doubleconv=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.events=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.options=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp.joni=ALL-UNNAMED \ - -XaddExports:jdk.scripting.nashorn/jdk.nashorn.tools=ALL-UNNAMED \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.ir=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.codegen=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.parser=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.objects=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.doubleconv=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.events=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.options=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp.joni=ALL-UNNAMED \ + --add-exports jdk.scripting.nashorn/jdk.nashorn.tools=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED meta.inf.dir=${nashorn.module.src.dir}/META-INF diff --git a/nashorn/test/TEST.ROOT b/nashorn/test/TEST.ROOT index 95af63ccfa4..f8dabb221e1 100644 --- a/nashorn/test/TEST.ROOT +++ b/nashorn/test/TEST.ROOT @@ -8,7 +8,7 @@ keys=intermittent randomness groups=TEST.groups # Minimum jtreg version -requiredVersion=4.2 b02 +requiredVersion=4.2 b03 -# Use new form of -Xpatch -useNewXpatch=true +# Use new module options +useNewOptions=true diff --git a/nashorn/test/script/currently-failing/JDK-8055034.js b/nashorn/test/script/currently-failing/JDK-8055034.js index 0f905156b17..1a9cb518ff4 100644 --- a/nashorn/test/script/currently-failing/JDK-8055034.js +++ b/nashorn/test/script/currently-failing/JDK-8055034.js @@ -51,7 +51,7 @@ if (! new File(jjsCmd).isFile()) { jjsCmd = javahome + "/bin/jjs"; jjsCmd = jjsCmd.toString().replace(/\//g, File.separator); } -jjsCmd += " -J-Xpatch:" + nashornJar; +jjsCmd += " -J--patch-module=jdk.scripting.nashorn=" + nashornJar; $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin $EXEC(jjsCmd, "var x = Object.create(null);\nx;\nprint('PASSED');\nexit(0)"); From f29e118ce07644a084a5683b20636243d39895a5 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 10 Aug 2016 15:49:23 -0700 Subject: [PATCH 25/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar --- jaxp/test/TEST.ROOT | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jaxp/test/TEST.ROOT b/jaxp/test/TEST.ROOT index 190bdf5ccae..11ad18dbae6 100644 --- a/jaxp/test/TEST.ROOT +++ b/jaxp/test/TEST.ROOT @@ -23,4 +23,7 @@ modules=java.xml groups=TEST.groups # Minimum jtreg version -requiredVersion=4.2 b02 +requiredVersion=4.2 b03 + +# Use new module options +useNewOptions=true From f98fad3890c02f2e744abb4bab187b7a908a9a53 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 10 Aug 2016 15:49:27 -0700 Subject: [PATCH 26/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar --- .../classes/com/sun/tools/internal/jxc/SchemaGenerator.java | 2 +- .../classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java | 2 +- .../com/sun/tools/internal/ws/wscompile/WsimportTool.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java index 1fdf164f717..d19b7a70321 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java +++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java @@ -140,7 +140,7 @@ public class SchemaGenerator { aptargs.add("-cp"); aptargs.add(setClasspath(options.classpath)); // set original classpath + jaxb-api to be visible to annotation processor - aptargs.add("-addmods"); + aptargs.add("--add-modules"); aptargs.add("java.xml.bind"); if(options.targetDir!=null) { diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java index a325b3455a1..ebbaa2c8385 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java @@ -162,7 +162,7 @@ public class WsgenTool { boolean bootCP = useBootClasspath(EndpointReference.class) || useBootClasspath(XmlSeeAlso.class); List args = new ArrayList(6 + (bootCP ? 1 : 0) + (options.nocompile ? 1 : 0) + (options.encoding != null ? 2 : 0)); - args.add("-addmods"); + args.add("--add-modules"); args.add("java.xml.ws"); args.add("-d"); args.add(options.destDir.getAbsolutePath()); diff --git a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java index 410cf89904d..a1b18541291 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java +++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java @@ -525,7 +525,7 @@ public class WsimportTool { String classpathString = createClasspathString(); boolean bootCP = useBootClasspath(EndpointContext.class) || useBootClasspath(JAXBPermission.class); List args = new ArrayList(); - args.add("-addmods"); + args.add("--add-modules"); args.add("java.xml.ws"); args.add("-d"); args.add(classDir); From e2a0ff3e0d3332ac91f815a74f2fcf303eb35e6a Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 10 Aug 2016 15:51:25 -0700 Subject: [PATCH 27/66] 8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar --- jdk/make/GenerateModuleSummary.gmk | 2 +- jdk/make/ModuleTools.gmk | 4 +- jdk/make/Tools.gmk | 4 +- jdk/make/gendata/GendataBreakIterator.gmk | 10 +- jdk/make/launcher/Launcher-java.desktop.gmk | 2 +- jdk/make/launcher/Launcher-java.scripting.gmk | 2 +- jdk/make/launcher/Launcher-jdk.compiler.gmk | 2 +- jdk/make/launcher/Launcher-jdk.javadoc.gmk | 2 +- jdk/make/launcher/Launcher-jdk.jlink.gmk | 2 +- .../Launcher-jdk.scripting.nashorn.shell.gmk | 2 +- .../build/tools/jigsaw/ModuleSummary.java | 6 +- .../share/classes/java/lang/System.java | 11 +- .../java/lang/module/ModuleReference.java | 2 +- .../java/lang/module/ModuleReferences.java | 2 +- .../java/lang/module/SystemModuleFinder.java | 2 +- .../jdk/internal/module/ModuleBootstrap.java | 51 ++- .../jdk/internal/module/ModulePatcher.java | 34 +- .../classes/sun/launcher/LauncherHelper.java | 4 +- .../launcher/resources/launcher.properties | 51 ++- jdk/src/java.base/share/native/libjli/args.c | 29 +- jdk/src/java.base/share/native/libjli/java.c | 423 ++++++++++++------ jdk/src/java.base/share/native/libjli/java.h | 1 + .../sun/tools/jar/GNUStyleOptions.java | 4 +- .../sun/tools/jar/resources/jar.properties | 10 +- .../classes/jdk/tools/jimage/JImageTask.java | 4 +- .../tools/jimage/resources/jimage.properties | 8 +- .../jdk/tools/jlink/internal/JlinkTask.java | 19 +- .../jdk/tools/jlink/internal/TaskHelper.java | 2 +- .../tools/jlink/resources/jlink.properties | 25 +- .../tools/jlink/resources/plugins.properties | 6 +- .../classes/jdk/tools/jmod/JmodTask.java | 10 +- .../jdk/tools/jmod/resources/jmod.properties | 2 +- jdk/test/ProblemList.txt | 3 + jdk/test/TEST.ROOT | 8 +- .../com/sun/corba/5036554/TestCorbaBug.sh | 4 +- .../7130985/CorbaExceptionsCompileTest.java | 4 +- .../corba/se/impl/io/HookPutFieldsTest.java | 4 +- .../corba/se/impl/orb/SetDefaultORBTest.java | 4 +- jdk/test/com/sun/jdi/ImmutableResourceTest.sh | 4 +- .../com/sun/jndi/cosnaming/CNNameParser.java | 1 + .../com/sun/jndi/cosnaming/IiopUrlIPv6.java | 1 + .../HotSpotDiagnosticMXBean/CheckOrigin.java | 2 +- .../Gtk/GtkVersionTest/GtkVersionTest.java | 2 +- .../WrappedToolkitTest/WrappedToolkitTest.sh | 36 +- .../java/awt/xembed/server/RunTestXEmbed.java | 9 +- .../xembed/server/TestXEmbedServerJava.java | 8 +- .../8028054/TestConstructorFinder.java | 2 +- .../XMLDecoder/8028054/TestMethodFinder.java | 2 +- .../Class/forName/modules/TestDriver.java | 18 +- .../FieldSetAccessibleTest.java | 4 +- .../lang/Class/getResource/ResourcesTest.java | 12 +- .../getResource/modules/ResourcesTest.java | 14 +- .../modules/CustomSecurityManager.sh | 6 +- .../String/concat/WithSecurityManager.java | 14 +- jdk/test/java/lang/instrument/MakeJAR2.sh | 2 +- .../modules/ModuleAccessControlTest.java | 4 +- .../reflect/Layer/LayerAndLoadersTest.java | 4 +- .../reflect/Layer/src/m1/module-info.java | 2 +- .../lang/reflect/Module/AddExportsTest.java | 27 +- .../reflect/Module/access/AccessTest.java | 4 +- .../reflect/Proxy/ProxyClassAccessTest.java | 4 +- .../lang/reflect/Proxy/ProxyLayerTest.java | 2 +- .../reflect/Proxy/ProxyModuleMapping.java | 2 +- .../java/lang/reflect/Proxy/ProxyTest.java | 4 +- jdk/test/java/net/Authenticator/B4933582.sh | 2 +- .../java/net/SocketOption/OptionsTest.java | 2 +- .../SocketOption/UnsupportedOptionsTest.java | 2 +- .../net/httpclient/http2/HpackDriver.java | 14 +- .../DatagramChannel/SocketOptionTests.java | 2 +- .../SocketOptionTests.java | 2 +- .../SocketChannel/SocketOptionTests.java | 2 +- .../inheritedChannel/run_tests.sh | 2 +- .../Activatable/extLoadedImpl/ext.sh | 8 +- .../DownloadActivationGroup.java | 11 +- .../StubClassesPermitted.java | 10 +- .../InheritedChannelNotServerSocket.java | 2 +- .../RmidViaInheritedChannel.java | 2 +- jdk/test/java/rmi/module/ModuleTest.java | 14 +- .../java/rmi/registry/readTest/readTest.sh | 8 +- .../rmi/transport/checkFQDN/CheckFQDN.java | 8 +- .../transport/dgcDeadLock/DGCDeadLock.java | 8 +- .../Provider/SecurityProviderModularTest.java | 2 +- .../java/security/modules/ModularTest.java | 2 +- jdk/test/java/security/testlibrary/Proc.java | 13 +- .../util/Calendar/GenericTimeZoneNamesTest.sh | 2 +- jdk/test/java/util/Formatter/Basic.sh | 2 +- jdk/test/java/util/Locale/LocaleProviders.sh | 4 +- .../java/util/PluggableLocale/ExecTest.sh | 4 +- .../util/ResourceBundle/Bug6299235Test.sh | 2 +- .../modules/appbasic/appbasic.sh | 6 +- .../modules/appbasic2/appbasic2.sh | 6 +- .../ResourceBundle/modules/basic/basic.sh | 8 +- .../modules/modlocal/modlocal.sh | 6 +- .../modules/security/TestPermission.java | 4 +- .../ResourceBundle/modules/simple/simple.sh | 6 +- .../modules/visibility/visibility.sh | 66 +-- .../modules/xmlformat/xmlformat.sh | 6 +- .../ServiceLoader/modules/ServicesTest.java | 8 +- .../modules/GetResourceBundleTest.java | 12 +- .../crypto/Cipher/CipherStreamClose.java | 4 +- .../TestClassPathPlugin.sh | 4 +- .../stream/StreamCloserLeak/run_test.sh | 4 +- jdk/test/javax/naming/module/basic.sh | 16 +- .../8146975/RmiIiopReturnValueTest.java | 11 +- .../ConcurrentHashMapTest.java | 10 +- .../login/modules/JaasModularClientTest.java | 2 +- .../JaasModularDefaultHandlerTest.java | 2 +- .../javax/smartcardio/CommandAPDUTest.java | 4 +- .../javax/smartcardio/HistoricalBytes.java | 4 +- .../javax/smartcardio/ResponseAPDUTest.java | 4 +- jdk/test/javax/smartcardio/Serialize.java | 4 +- .../smartcardio/TerminalFactorySpiTest.java | 4 +- .../javax/smartcardio/TestCardPermission.java | 4 +- .../javax/smartcardio/TestCommandAPDU.java | 4 +- jdk/test/javax/transaction/testng/Driver.java | 10 +- .../JAXBContextWithAbstractFactory.java | 4 +- .../JAXBContextWithLegacyFactory.java | 4 +- .../JAXBContextWithSubclassedFactory.java | 4 +- .../jxc/8073872/SchemagenStackOverflow.java | 3 +- .../bind/marshal/8134111/UnmarshalTest.java | 5 +- .../xjc/8032884/XjcOptionalPropertyTest.java | 2 +- .../bind/xjc/8145039/JaxbMarshallTest.java | 2 +- jdk/test/javax/xml/jaxp/common/8035437/run.sh | 4 +- jdk/test/javax/xml/soap/XmlTest.java | 4 +- .../javax/xml/soap/spi/SAAJFactoryTest.java | 23 +- jdk/test/javax/xml/ws/8043129/MailTest.java | 3 +- .../javax/xml/ws/clientjar/TestWsImport.java | 4 +- jdk/test/javax/xml/ws/publish/WSTest.java | 3 +- jdk/test/javax/xml/ws/xsanymixed/Test.java | 3 +- .../internal/misc/VM/RuntimeArguments.java | 31 +- .../reflect/Reflection/GetCallerClassTest.sh | 2 +- .../modules/etc/VerifyModuleDelegation.java | 12 +- .../RunWithAutomaticModules.java | 12 +- .../scenarios/container/ContainerTest.java | 6 +- .../OverlappingPackagesTest.java | 14 +- .../sun/awt/shell/ShellFolderMemoryLeak.java | 2 +- .../bootstrap/CustomLauncherTest.java | 2 +- .../bootstrap/LocalManagementTest.java | 2 +- .../jmxremote/bootstrap/RmiBootstrapTest.sh | 4 +- .../bootstrap/RmiSslBootstrapTest.sh | 4 +- .../bootstrap/RmiSslNoKeyStoreTest.sh | 4 +- .../https/HttpsURLConnection/PostThruProxy.sh | 2 +- .../PostThruProxyWithAuth.sh | 2 +- .../net/www/protocol/jrt/OtherResources.java | 2 +- .../net/www/protocol/jrt/other_resources.sh | 4 +- .../rmic/iiopCompilation/IIOPCompilation.java | 3 +- .../runtime/Log/6409194/NoConsoleOutput.java | 8 +- .../sun/security/krb5/ccache/EmptyCC.java | 3 +- jdk/test/sun/security/krb5/tools/ktcheck.sh | 4 +- .../sun/security/mscapi/PublicKeyInterop.sh | 4 +- .../sun/security/mscapi/ShortRSAKey1024.sh | 4 +- .../security/provider/PolicyFile/Modules.java | 6 +- .../security/tools/jarsigner/AltProvider.java | 10 +- jdk/test/sun/security/tools/jarsigner/ts.sh | 8 +- .../sun/security/tools/keytool/autotest.sh | 6 +- .../sun/security/tools/keytool/standard.sh | 6 +- .../sun/security/validator/certreplace.sh | 2 +- jdk/test/sun/security/validator/samedn.sh | 2 +- .../sun/text/IntHashtable/Bug4170614Test.sh | 2 +- jdk/test/sun/tools/java/CFCTest.java | 4 +- .../sun/util/locale/provider/Bug8038436.java | 4 +- jdk/test/tools/jar/modularJar/Basic.java | 24 +- jdk/test/tools/jimage/VerifyJimage.java | 2 +- jdk/test/tools/jlink/CustomPluginTest.java | 3 +- jdk/test/tools/jlink/JLinkNegativeTest.java | 2 +- jdk/test/tools/jlink/JLinkTest.java | 4 +- jdk/test/tools/jlink/basic/BasicTest.java | 4 +- .../UserModuleTest.java | 6 +- jdk/test/tools/jmod/JmodNegativeTest.java | 12 +- jdk/test/tools/jmod/hashes/HashesTest.java | 16 +- jdk/test/tools/launcher/MiscTests.java | 2 +- jdk/test/tools/launcher/ToolsOpts.java | 2 +- .../modules/addexports/AddExportsTest.java | 60 +-- .../launcher/modules/addmods/AddModsTest.java | 62 +-- .../addmods/src/logger/logger/Logger.java | 2 +- .../modules/addmods/src/test/test/Main.java | 2 +- .../modules/addreads/AddReadsTest.java | 70 +-- .../launcher/modules/basic/BasicTest.java | 127 +++--- .../launcher/modules/dryrun/DryRunTest.java | 34 +- .../modules/limitmods/LimitModsTest.java | 54 +-- .../modules/listmods/ListModsTest.java | 38 +- .../modules/patch/basic/PatchTest.java | 40 +- .../patch/basic/src/test/jdk/test/Main.java | 2 +- .../systemmodules/PatchSystemModules.java | 30 +- .../jdk/internal/modules/SystemModules.java | 2 +- .../UpgradeModulePathTest.java | 20 +- jdk/test/tools/lib/tests/Helper.java | 2 +- jdk/test/tools/lib/tests/JImageGenerator.java | 16 +- jdk/test/tools/pack200/Utils.java | 4 +- .../pack200/pack200-verifier/make/build.xml | 2 +- 190 files changed, 1189 insertions(+), 1008 deletions(-) diff --git a/jdk/make/GenerateModuleSummary.gmk b/jdk/make/GenerateModuleSummary.gmk index 285de739088..171183886a2 100644 --- a/jdk/make/GenerateModuleSummary.gmk +++ b/jdk/make/GenerateModuleSummary.gmk @@ -42,6 +42,6 @@ $(GENGRAPHS_DIR)/technology-summary.html: $(TOOLS_MODULE_SRCDIR)/technology-summ $(GENGRAPHS_DIR)/module-summary.html: $(BUILD_JIGSAW_TOOLS) $(GENGRAPHS_DIR)/technology-summary.html $(MKDIR) -p $(@D) - $(TOOL_MODULESUMMARY) -o $@ -mp $(IMAGES_OUTPUTDIR)/jmods + $(TOOL_MODULESUMMARY) -o $@ --module-path $(IMAGES_OUTPUTDIR)/jmods all: $(GENGRAPHS_DIR)/jdk.dot $(GENGRAPHS_DIR)/module-summary.html diff --git a/jdk/make/ModuleTools.gmk b/jdk/make/ModuleTools.gmk index 2943b9c8d21..289f3e67bb7 100644 --- a/jdk/make/ModuleTools.gmk +++ b/jdk/make/ModuleTools.gmk @@ -36,12 +36,12 @@ $(eval $(call SetupJavaCompilation,BUILD_JIGSAW_TOOLS, \ INCLUDES := build/tools/deps \ build/tools/jigsaw, \ BIN := $(TOOLS_CLASSES_DIR), \ - ADD_JAVAC_FLAGS := -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED )) + ADD_JAVAC_FLAGS := --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED )) TOOL_GENGRAPHS := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \ build.tools.jigsaw.GenGraphs TOOL_MODULESUMMARY := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \ - -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ + --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ build.tools.jigsaw.ModuleSummary diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 384ca5931de..1034d34e15b 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -38,7 +38,7 @@ BUILD_TOOLS_JDK := $(call SetupJavaCompilationCompileTarget, \ ################################################################################ ifeq ($(BOOT_JDK_MODULAR), true) - COMPILEFONTCONFIG_ADD_EXPORTS := -XaddExports:java.desktop/sun.awt=ALL-UNNAMED + COMPILEFONTCONFIG_ADD_EXPORTS := --add-exports java.desktop/sun.awt=ALL-UNNAMED endif TOOL_COMPILEFONTCONFIG = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \ @@ -94,7 +94,7 @@ TOOL_SPP = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes build.too # Nimbus is used somewhere in the swing build. ifeq ($(BOOT_JDK_MODULAR), true) - COMPILENIMBUS_ADD_MODS := -addmods java.xml.bind + COMPILENIMBUS_ADD_MODS := --add-modules java.xml.bind endif TOOL_GENERATENIMBUS = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \ diff --git a/jdk/make/gendata/GendataBreakIterator.gmk b/jdk/make/gendata/GendataBreakIterator.gmk index 06d3c2ac490..a68786a413b 100644 --- a/jdk/make/gendata/GendataBreakIterator.gmk +++ b/jdk/make/gendata/GendataBreakIterator.gmk @@ -63,11 +63,11 @@ $(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR_LD, \ ifeq ($(BOOT_JDK_MODULAR), true) BREAK_ITERATOR_BOOTCLASSPATH := \ - -Xpatch:java.base=$(BREAK_ITERATOR_CLASSES)/java.base \ - -Xpatch:jdk.localedata=$(BREAK_ITERATOR_CLASSES)/jdk.localedata \ - -XaddExports:java.base/sun.text=ALL-UNNAMED \ - -XaddExports:java.base/sun.text.resources=ALL-UNNAMED \ - -XaddExports:jdk.localedata/sun.text.resources.ext=ALL-UNNAMED \ + --patch-module java.base=$(BREAK_ITERATOR_CLASSES)/java.base \ + --patch-module jdk.localedata=$(BREAK_ITERATOR_CLASSES)/jdk.localedata \ + --add-exports java.base/sun.text=ALL-UNNAMED \ + --add-exports java.base/sun.text.resources=ALL-UNNAMED \ + --add-exports jdk.localedata/sun.text.resources.ext=ALL-UNNAMED \ # else BREAK_ITERATOR_BOOTCLASSPATH := -Xbootclasspath/p:$(call PathList, \ diff --git a/jdk/make/launcher/Launcher-java.desktop.gmk b/jdk/make/launcher/Launcher-java.desktop.gmk index b6b95cb24ed..f9fa7d16c22 100644 --- a/jdk/make/launcher/Launcher-java.desktop.gmk +++ b/jdk/make/launcher/Launcher-java.desktop.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, jdk, launcher/Launcher-java.desktop.gmk)) ifndef BUILD_HEADLESS_ONLY $(eval $(call SetupBuildLauncher, appletviewer, \ MAIN_CLASS := sun.applet.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ LIBS_unix := $(X_LIBS), \ )) endif diff --git a/jdk/make/launcher/Launcher-java.scripting.gmk b/jdk/make/launcher/Launcher-java.scripting.gmk index 6f3f59da268..18b8ad46d45 100644 --- a/jdk/make/launcher/Launcher-java.scripting.gmk +++ b/jdk/make/launcher/Launcher-java.scripting.gmk @@ -27,5 +27,5 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, jrunscript, \ MAIN_CLASS := com.sun.tools.script.shell.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ )) diff --git a/jdk/make/launcher/Launcher-jdk.compiler.gmk b/jdk/make/launcher/Launcher-jdk.compiler.gmk index 0259eb0ff8c..9c85acecdcc 100644 --- a/jdk/make/launcher/Launcher-jdk.compiler.gmk +++ b/jdk/make/launcher/Launcher-jdk.compiler.gmk @@ -27,7 +27,7 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, javac, \ MAIN_CLASS := com.sun.tools.javac.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS \ -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \ )) diff --git a/jdk/make/launcher/Launcher-jdk.javadoc.gmk b/jdk/make/launcher/Launcher-jdk.javadoc.gmk index 365443618f2..04bc99baf7e 100644 --- a/jdk/make/launcher/Launcher-jdk.javadoc.gmk +++ b/jdk/make/launcher/Launcher-jdk.javadoc.gmk @@ -27,7 +27,7 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, javadoc, \ MAIN_CLASS := jdk.javadoc.internal.tool.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS \ -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \ )) diff --git a/jdk/make/launcher/Launcher-jdk.jlink.gmk b/jdk/make/launcher/Launcher-jdk.jlink.gmk index b1edcbc93c0..bd270b0dc0a 100644 --- a/jdk/make/launcher/Launcher-jdk.jlink.gmk +++ b/jdk/make/launcher/Launcher-jdk.jlink.gmk @@ -32,7 +32,7 @@ $(eval $(call SetupBuildLauncher, jimage,\ $(eval $(call SetupBuildLauncher, jlink,\ MAIN_CLASS := jdk.tools.jlink.internal.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ CFLAGS := -DENABLE_ARG_FILES \ -DEXPAND_CLASSPATH_WILDCARDS \ -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \ diff --git a/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk b/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk index b6349b56365..5cb872ae5cf 100644 --- a/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk +++ b/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk @@ -27,6 +27,6 @@ include LauncherCommon.gmk $(eval $(call SetupBuildLauncher, jjs, \ MAIN_CLASS := jdk.nashorn.tools.jjs.Main, \ - JAVA_ARGS := -addmods ALL-DEFAULT, \ + JAVA_ARGS := --add-modules ALL-DEFAULT, \ CFLAGS := -DENABLE_ARG_FILES, \ )) diff --git a/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java b/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java index f274afdc709..7fb8679a7e0 100644 --- a/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java +++ b/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java @@ -51,7 +51,7 @@ import static build.tools.jigsaw.ModuleSummary.HtmlDocument.Selector.*; import static build.tools.jigsaw.ModuleSummary.HtmlDocument.Division.*; public class ModuleSummary { - private static final String USAGE = "Usage: ModuleSummary -mp -o [-root mn]*"; + private static final String USAGE = "Usage: ModuleSummary --module-path -o [--root mn]*"; public static void main(String[] args) throws Exception { int i=0; @@ -61,13 +61,13 @@ public class ModuleSummary { while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; switch (arg) { - case "-mp": + case "--module-path": modpath = Paths.get(args[i++]); break; case "-o": outfile = Paths.get(args[i++]); break; - case "-root": + case "--root": roots.add(args[i++]); default: System.err.println(USAGE); diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java index f3ec4911131..4bce8bbb48d 100644 --- a/jdk/src/java.base/share/classes/java/lang/System.java +++ b/jdk/src/java.base/share/classes/java/lang/System.java @@ -644,23 +644,20 @@ public final class System { * getProperties operation, it may choose to permit the * {@link #getProperty(String)} operation. * - * @implNote In addition to the standard system properties, the {@code - * java} launcher may create the Java Virtual Machine with system - * properties that have the following keys: + * @implNote In addition to the standard system properties, the system + * properties may include the following keys: * * * * - * - * + * + * * * * * * *
KeyDescription of Associated Value
{@code jdk.module.path}Application module path
{@code jdk.upgrade.module.path}The application module path
{@code jdk.module.upgrade.path}The upgrade module path
{@code jdk.module.main}The module name of the initial/main module
{@code jdk.module.main.class}The main class name of the initial module
- * These properties may also be set by custom launchers that use the JNI - * invocation API to create the Java Virtual Machine. * * @return the system properties * @exception SecurityException if a security manager exists and its diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java index 10cce789949..34d13639736 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java @@ -169,7 +169,7 @@ public final class ModuleReference { /** - * Returns {@code true} if this module has been patched via -Xpatch. + * Returns {@code true} if this module has been patched via --patch-module. */ boolean isPatched() { return patched; diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java index 18caa15d71c..de245656364 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java @@ -68,7 +68,7 @@ class ModuleReferences { /** * Creates a ModuleReference to a module or to patched module when - * creating modules for the boot Layer and -Xpatch is specified. + * creating modules for the boot Layer and --patch-module is specified. */ private static ModuleReference newModule(ModuleDescriptor md, URI uri, diff --git a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java index 9dd6694267c..cf750edbece 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java +++ b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java @@ -178,7 +178,7 @@ class SystemModuleFinder implements ModuleFinder { ModuleReference mref = new ModuleReference(md, uri, readerSupplier, hash); - // may need a reference to a patched module if -Xpatch specified + // may need a reference to a patched module if --patch-module specified mref = ModulePatcher.interposeIfNeeded(mref); return mref; diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index 52d951250d4..b9b93b275ef 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java @@ -56,8 +56,8 @@ import jdk.internal.perf.PerfCounter; * The {@link #boot() boot} method is called early in the startup to initialize * the module system. In summary, the boot method creates a Configuration by * resolving a set of module names specified via the launcher (or equivalent) - * -m and -addmods options. The modules are located on a module path that is - * constructed from the upgrade module path, system modules, and application + * -m and --add-modules options. The modules are located on a module path that + * is constructed from the upgrade module path, system modules, and application * module path. The Configuration is instantiated as the boot Layer with each * module in the the configuration defined to one of the built-in class loaders. */ @@ -127,16 +127,16 @@ public final class ModuleBootstrap { long t2 = System.nanoTime(); - // -upgrademodulepath option specified to launcher + // --upgrade-module-path option specified to launcher ModuleFinder upgradeModulePath - = createModulePathFinder("jdk.upgrade.module.path"); + = createModulePathFinder("jdk.module.upgrade.path"); if (upgradeModulePath != null) systemModules = ModuleFinder.compose(upgradeModulePath, systemModules); - // -modulepath option specified to the launcher + // --module-path option specified to the launcher ModuleFinder appModulePath = createModulePathFinder("jdk.module.path"); - // The module finder: [-upgrademodulepath] system [-modulepath] + // The module finder: [--upgrade-module-path] system [--module-path] ModuleFinder finder = systemModules; if (appModulePath != null) finder = ModuleFinder.compose(finder, appModulePath); @@ -149,11 +149,11 @@ public final class ModuleBootstrap { if (mainModule != null) roots.add(mainModule); - // additional module(s) specified by -addmods + // additional module(s) specified by --add-modules boolean addAllDefaultModules = false; boolean addAllSystemModules = false; boolean addAllApplicationModules = false; - String propValue = System.getProperty("jdk.launcher.addmods"); + String propValue = getAndRemoveProperty("jdk.module.addmods"); if (propValue != null) { for (String mod: propValue.split(",")) { switch (mod) { @@ -172,8 +172,8 @@ public final class ModuleBootstrap { } } - // -limitmods - propValue = System.getProperty("jdk.launcher.limitmods"); + // --limit-modules + propValue = getAndRemoveProperty("jdk.module.limitmods"); if (propValue != null) { Set mods = new HashSet<>(); for (String mod: propValue.split(",")) { @@ -216,7 +216,7 @@ public final class ModuleBootstrap { } } - // If `-addmods ALL-SYSTEM` is specified then all observable system + // If `--add-modules ALL-SYSTEM` is specified then all observable system // modules will be resolved. if (addAllSystemModules) { ModuleFinder f = finder; // observable modules @@ -228,9 +228,9 @@ public final class ModuleBootstrap { .forEach(mn -> roots.add(mn)); } - // If `-addmods ALL-MODULE-PATH` is specified then all observable + // If `--add-modules ALL-MODULE-PATH` is specified then all observable // modules on the application module path will be resolved. - if (appModulePath != null && addAllApplicationModules) { + if (appModulePath != null && addAllApplicationModules) { ModuleFinder f = finder; // observable modules appModulePath.findAll() .stream() @@ -250,7 +250,7 @@ public final class ModuleBootstrap { if (baseUri.getScheme().equals("jrt") // toLowerCase not needed here && (upgradeModulePath == null) && (appModulePath == null) - && (System.getProperty("jdk.launcher.patch.0") == null)) { + && (!ModulePatcher.isBootLayerPatched())) { needPostResolutionChecks = false; } @@ -317,7 +317,7 @@ public final class ModuleBootstrap { PerfCounters.loadModulesTime.addElapsedTimeFrom(t5); - // -XaddReads and -XaddExports + // --add-reads and --add-exports addExtraReads(bootLayer); addExtraExports(bootLayer); @@ -394,13 +394,13 @@ public final class ModuleBootstrap { /** - * Process the -XaddReads options to add any additional read edges that + * Process the --add-reads options to add any additional read edges that * are specified on the command-line. */ private static void addExtraReads(Layer bootLayer) { // decode the command line options - Map> map = decode("jdk.launcher.addreads."); + Map> map = decode("jdk.module.addreads."); for (Map.Entry> e : map.entrySet()) { @@ -431,13 +431,13 @@ public final class ModuleBootstrap { /** - * Process the -XaddExports options to add any additional read edges that + * Process the --add-exports options to add any additional read edges that * are specified on the command-line. */ private static void addExtraExports(Layer bootLayer) { // decode the command line options - Map> map = decode("jdk.launcher.addexports."); + Map> map = decode("jdk.module.addexports."); for (Map.Entry> e : map.entrySet()) { @@ -483,13 +483,14 @@ public final class ModuleBootstrap { /** - * Decodes the values of -XaddReads or -XaddExports options + * Decodes the values of --add-reads or --add-exports options * * The format of the options is: $KEY=$MODULE(,$MODULE)* */ private static Map> decode(String prefix) { int index = 0; - String value = System.getProperty(prefix + index); + // the system property is removed after decoding + String value = getAndRemoveProperty(prefix + index); if (value == null) return Collections.emptyMap(); @@ -522,12 +523,18 @@ public final class ModuleBootstrap { } index++; - value = System.getProperty(prefix + index); + value = getAndRemoveProperty(prefix + index); } return map; } + /** + * Gets and remove the named system property + */ + private static String getAndRemoveProperty(String key) { + return (String)System.getProperties().remove(key); + } /** * Throws a RuntimeException with the given message diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java index 49104d8c242..ebc7d85a5e8 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java @@ -58,7 +58,7 @@ import sun.net.www.ParseUtil; /** - * Provides support for patching modules in the boot layer with -Xpatch. + * Provides support for patching modules in the boot layer with --patch-module. */ public final class ModulePatcher { @@ -66,28 +66,27 @@ public final class ModulePatcher { private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess(); - // the prefix of the system properties that encode the value of -Xpatch - private static final String PATCH_PROPERTY_PREFIX = "jdk.launcher.patch."; + // the prefix of the system properties that encode the value of --patch-module + private static final String PATCH_PROPERTY_PREFIX = "jdk.module.patch."; // module name -> sequence of patches (directories or JAR files) private static final Map> PATCH_MAP = decodeProperties(); private ModulePatcher() { } - /** - * Decodes the values of -Xpatch options, returning a Map of module name to - * list of file paths. + * Decodes the values of --patch-module options, returning a Map of module + * name to list of file paths. * * @throws IllegalArgumentException if the the module name is missing or - * -Xpatch is used more than once to patch the same module + * --patch-module is used more than once to patch the same module */ private static Map> decodeProperties() { int index = 0; - String value = System.getProperty(PATCH_PROPERTY_PREFIX + index); + String value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index); if (value == null) - return Collections.emptyMap(); // -Xpatch not specified + return Collections.emptyMap(); // --patch-module not specified Map> map = new HashMap<>(); while (value != null) { @@ -115,13 +114,21 @@ public final class ModulePatcher { } index++; - value = System.getProperty(PATCH_PROPERTY_PREFIX + index); + value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index); } return map; } + /** + * Returns {@code true} is --patch-module is specified to patch modules + * in the boot layer. + */ + static boolean isBootLayerPatched() { + return !PATCH_MAP.isEmpty(); + } + /** * Returns a module reference that interposes on the given module if * needed. If there are no patches for the given module then the module @@ -536,6 +543,13 @@ public final class ModulePatcher { } } + /** + * Gets and remove the named system property + */ + private static String getAndRemoveProperty(String key) { + return (String)System.getProperties().remove(key); + } + /** * Derives a package name from the name of an entry in a JAR file. */ diff --git a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java index aff3778c7ff..f19ed371e52 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java +++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java @@ -60,8 +60,6 @@ import java.nio.charset.Charset; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.Normalizer; import java.text.MessageFormat; import java.util.ResourceBundle; @@ -905,7 +903,7 @@ public final class LauncherHelper { ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder(); - int colon = optionFlag.indexOf(':'); + int colon = optionFlag.indexOf('='); if (colon == -1) { finder.findAll().stream() .sorted(Comparator.comparing(ModuleReference::descriptor)) diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 73cfc8af252..23fcac28865 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -27,7 +27,7 @@ java.launcher.opt.header = Usage: {0} [options] class [args...]\n\ \ (to execute a class)\n or {0} [options] -jar jarfile [args...]\n\ \ (to execute a jar file)\n\ -\ or {0} [options] -mp -m [/] [args...]\n\ +\ or {0} [options] -p -m [/] [args...]\n\ \ (to execute the main class in a module)\n\ where options include:\n @@ -41,24 +41,28 @@ java.launcher.ergo.message2 =\ because you are running on a se # Translators please note do not translate the options themselves java.launcher.opt.footer =\ -cp \n\ \ -classpath \n\ +\ --class-path \n\ \ A {0} separated list of directories, JAR archives,\n\ \ and ZIP archives to search for class files.\n\ -\ -mp \n\ -\ -modulepath ...\n\ +\ -p \n\ +\ --module-path ...\n\ \ A {0} separated list of directories, each directory\n\ \ is a directory of modules.\n\ -\ -upgrademodulepath ...\n\ +\ --upgrade-module-path ...\n\ \ A {0} separated list of directories, each directory\n\ \ is a directory of modules that replace upgradeable\n\ \ modules in the runtime image\n\ -\ -m [/]\n\ +\ -m [/]\n\ +\ --module [/]\n\ \ the initial module to resolve, and the name of the main class\n\ \ to execute if not specified by the module\n\ -\ -addmods [,...]\n\ -\ root modules to resolve in addition to the initial module\n\ -\ -limitmods [,...]\n\ +\ --add-modules [,...]\n\ +\ root modules to resolve in addition to the initial module.\n\ +\ can also be ALL-DEFAULT, ALL-SYSTEM,\n\ +\ ALL-MODULE-PATH.\n\ +\ --limit-modules [,...]\n\ \ limit the universe of observable modules\n\ -\ -listmods[:[,...]]\n\ +\ --list-modules [[,...]]\n\ \ list the observable modules and exit\n\ \ --dry-run create VM but do not execute main method.\n\ \ This --dry-run option may be useful for validating the\n\ @@ -69,7 +73,8 @@ java.launcher.opt.footer =\ -cp ...|:]\n\ \ -enableassertions[:...|:]\n\ @@ -91,6 +96,8 @@ java.launcher.opt.footer =\ -cp \n\ \ show splash screen with specified image\n\ \ @ read options from the specified file\n\ +\To specify an argument for a long option, you can use --= or\n\ +\-- .\n\ See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details. @@ -123,17 +130,21 @@ java.launcher.X.usage=\ \ show all property settings and continue\n\ \ -XshowSettings:locale\n\ \ show all locale related settings and continue\n\ -\ -XaddReads:=(,)*\n\ -\ reads other modules,\n\ -\ regardless of module declaration\n\ -\ -XaddExports:/=(,)*\n\ -\ exports to other modules,\n\ -\ regardless of module declaration\n\ -\ -Xpatch:=({0})*\n\ +\ -Xdisable-@files disable further argument file expansion\n\ +\ --add-reads =(,)*\n\ +\ updates to read , regardless\n\ +\ of module declaration. \n\ +\ can be ALL-UNNAMED to read all unnamed\n\ +\ modules.\n\ +\ --add-exports /=(,)*\n\ +\ updates to export to ,\n\ +\ regardless of module declaration.\n\ +\ can be ALL-UNNAMED to export to all\n\ +\ unnamed modules.\n\ +\ --patch-module =({0})*\n\ \ Override or augment a module with classes and resources\n\ -\ in JAR files or directories\n\ -\ -Xdisable-@files disable further argument file expansion\n\n\ -The -X options are non-standard and subject to change without notice.\n +\ in JAR files or directories.\n\n\ +These options are non-standard and subject to change without notice.\n # Translators please note do not translate the options themselves java.launcher.X.macosx.usage=\ diff --git a/jdk/src/java.base/share/native/libjli/args.c b/jdk/src/java.base/share/native/libjli/args.c index 55f67f355ce..ac8774e08af 100644 --- a/jdk/src/java.base/share/native/libjli/args.c +++ b/jdk/src/java.base/share/native/libjli/args.c @@ -102,24 +102,21 @@ static void checkArg(const char *arg) { // All arguments arrive here must be a launcher argument, // ie. by now, all argfile expansions must have been performed. - if (*arg++ == '-') { + if (*arg == '-') { expectingNoDashArg = JNI_FALSE; - if (JLI_StrCmp(arg, "cp") == 0 || - JLI_StrCmp(arg, "classpath") == 0 || - JLI_StrCmp(arg, "addmods") == 0 || - JLI_StrCmp(arg, "limitmods") == 0 || - JLI_StrCmp(arg, "mp") == 0 || - JLI_StrCmp(arg, "modulepath") == 0 || - JLI_StrCmp(arg, "upgrademodulepath") == 0) { + if (IsWhiteSpaceOption(arg)) { + // expect an argument expectingNoDashArg = JNI_TRUE; - } else if (JLI_StrCmp(arg, "jar") == 0 || - JLI_StrCmp(arg, "m") == 0) { - // This is tricky, we do expect NoDashArg - // But that is considered main class to stop expansion - expectingNoDashArg = JNI_FALSE; - // We can not just update the idx here because if -jar @file - // still need expansion of @file to get the argument for -jar - } else if (JLI_StrCmp(arg, "Xdisable-@files") == 0) { + + if (JLI_StrCmp(arg, "-jar") == 0 || + JLI_StrCmp(arg, "-m") == 0) { + // This is tricky, we do expect NoDashArg + // But that is considered main class to stop expansion + expectingNoDashArg = JNI_FALSE; + // We can not just update the idx here because if -jar @file + // still need expansion of @file to get the argument for -jar + } + } else if (JLI_StrCmp(arg, "-Xdisable-@files") == 0) { stopExpansion = JNI_TRUE; } } else { diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 5a5e8deac23..12ca2b2c656 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -69,7 +69,7 @@ static jboolean showVersion = JNI_FALSE; /* print but continue */ static jboolean printUsage = JNI_FALSE; /* print and exit*/ static jboolean printXUsage = JNI_FALSE; /* print and exit*/ static jboolean dryRun = JNI_FALSE; /* initialize VM and exit */ -static char *showSettings = NULL; /* print but continue */ +static char *showSettings = NULL; /* print but continue */ static char *listModules = NULL; static const char *_program_name; @@ -99,17 +99,9 @@ static int numOptions, maxOptions; * Prototypes for functions internal to launcher. */ static void SetClassPath(const char *s); -static void SetModulePath(const char *s); -static void SetUpgradeModulePath(const char *s); static void SetMainModule(const char *s); -static void SetAddModulesProp(const char *mods); -static void SetLimitModulesProp(const char *mods); -static void SetAddReadsProp(const jint n, const char *s); -static void SetAddExportsProp(const jint n, const char *s); -static void SetPatchProp(const jint n, const char *s); static void SelectVersion(int argc, char **argv, char **main_class); static void SetJvmEnvironment(int argc, char **argv); -static jboolean IsWhiteSpaceOptionArgument(const char* name); static jboolean ParseArguments(int *pargc, char ***pargv, int *pmode, char **pwhat, int *pret, const char *jrepath); @@ -133,6 +125,18 @@ static void SetPaths(int argc, char **argv); static void DumpState(); static jboolean RemovableOption(char *option); +enum OptionKind { + LAUNCHER_OPTION = 0, + LAUNCHER_OPTION_WITH_ARGUMENT, + LAUNCHER_MAIN_OPTION, + VM_LONG_OPTION, + VM_LONG_OPTION_WITH_ARGUMENT, + VM_OPTION +}; + +static int GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue); +static jboolean IsOptionWithArgument(int argc, char **argv); + /* Maximum supported entries from jvm.cfg. */ #define INIT_MAX_KNOWN_VMS 10 @@ -162,6 +166,19 @@ static int KnownVMIndex(const char* name); static void FreeKnownVMs(); static jboolean IsWildCardEnabled(); +/* + * This reports error. VM will not be created and no usage is printed. + */ +#define REPORT_ERROR(AC_ok, AC_failure_message, AC_questionable_arg) \ + do { \ + if (!AC_ok) { \ + JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \ + printUsage = JNI_FALSE; \ + *pret = 1; \ + return JNI_FALSE; \ + } \ + } while (JNI_FALSE) + #define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \ do { \ if (AC_arg_count < 1) { \ @@ -511,17 +528,73 @@ JavaMain(void * _args) } /* - * Test if the given option name has a whitespace separated argument. + * Test if the given name is one of the class path options. */ -jboolean -IsWhiteSpaceOptionArgument(const char* name) { +static jboolean +IsClassPathOption(const char* name) { return JLI_StrCmp(name, "-classpath") == 0 || JLI_StrCmp(name, "-cp") == 0 || - JLI_StrCmp(name, "-modulepath") == 0 || - JLI_StrCmp(name, "-mp") == 0 || - JLI_StrCmp(name, "-upgrademodulepath") == 0 || - JLI_StrCmp(name, "-addmods") == 0 || - JLI_StrCmp(name, "-limitmods") == 0; + JLI_StrCmp(name, "--class-path") == 0; +} + +/* + * Test if the given name is a launcher option taking the main entry point. + */ +static jboolean +IsLauncherMainOption(const char* name) { + return JLI_StrCmp(name, "--module") == 0 || + JLI_StrCmp(name, "-m") == 0; +} + +/* + * Test if the given name is a white-space launcher option. + */ +static jboolean +IsLauncherOption(const char* name) { + return IsClassPathOption(name) || + IsLauncherMainOption(name) || + JLI_StrCmp(name, "--list-modules") == 0; +} + +#ifndef OLD_MODULE_OPTIONS +/* + * Old module options for transition + */ +static jboolean +IsOldModuleOption(const char* name) { + return JLI_StrCmp(name, "-modulepath") == 0 || + JLI_StrCmp(name, "-mp") == 0 || + JLI_StrCmp(name, "-upgrademodulepath") == 0 || + JLI_StrCmp(name, "-addmods") == 0 || + JLI_StrCmp(name, "-limitmods") == 0; +} +#endif + +/* + * Test if the given name is a module-system white-space option that + * will be passed to the VM with its corresponding long-form option + * name and "=" delimiter. + */ +static jboolean +IsModuleOption(const char* name) { + return JLI_StrCmp(name, "--module-path") == 0 || + JLI_StrCmp(name, "-p") == 0 || + JLI_StrCmp(name, "--upgrade-module-path") == 0 || + JLI_StrCmp(name, "--add-modules") == 0 || + JLI_StrCmp(name, "--limit-modules") == 0 || + JLI_StrCmp(name, "--add-exports") == 0 || + JLI_StrCmp(name, "--add-reads") == 0 || + JLI_StrCmp(name, "--patch-module") == 0 || + IsOldModuleOption(name); +} + +/* + * Test if the given name has a white space option. + */ +jboolean +IsWhiteSpaceOption(const char* name) { + return IsModuleOption(name) || + IsLauncherOption(name); } /* @@ -559,7 +632,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { continue; } } else { - if (IsWhiteSpaceOptionArgument(arg)) { + if (IsWhiteSpaceOption(arg)) { newArgv[newArgvIdx++] = arg; argi++; if (argi < argc) { @@ -701,7 +774,7 @@ SetJvmEnvironment(int argc, char **argv) { if (i > 0) { char *prev = argv[i - 1]; // skip non-dash arg preceded by class path specifiers - if (*arg != '-' && IsWhiteSpaceOptionArgument(prev)) { + if (*arg != '-' && IsWhiteSpaceOption(prev)) { continue; } @@ -709,6 +782,7 @@ SetJvmEnvironment(int argc, char **argv) { || JLI_StrCmp(arg, "-version") == 0 || JLI_StrCmp(arg, "-fullversion") == 0 || JLI_StrCmp(arg, "-help") == 0 + || JLI_StrCmp(arg, "--help") == 0 || JLI_StrCmp(arg, "-?") == 0 || JLI_StrCmp(arg, "-jar") == 0 || JLI_StrCmp(arg, "-X") == 0) { @@ -882,39 +956,16 @@ SetClassPath(const char *s) } static void -SetModulePath(const char *s) +AddLongFormOption(const char *option, const char *arg) { + static const char format[] = "%s=%s"; char *def; - const char *orig = s; - static const char format[] = "-Djdk.module.path=%s"; - if (s == NULL) - return; - s = JLI_WildcardExpandClasspath(s); - def = JLI_MemAlloc(sizeof(format) - - 2 /* strlen("%s") */ - + JLI_StrLen(s)); - sprintf(def, format, s); - AddOption(def, NULL); - if (s != orig) - JLI_MemFree((char *) s); -} + size_t def_len; -static void -SetUpgradeModulePath(const char *s) -{ - char *def; - const char *orig = s; - static const char format[] = "-Djdk.upgrade.module.path=%s"; - if (s == NULL) - return; - s = JLI_WildcardExpandClasspath(s); - def = JLI_MemAlloc(sizeof(format) - - 2 /* strlen("%s") */ - + JLI_StrLen(s)); - sprintf(def, format, s); + def_len = JLI_StrLen(option) + 1 + JLI_StrLen(arg) + 1; + def = JLI_MemAlloc(def_len); + JLI_Snprintf(def, def_len, format, option, arg); AddOption(def, NULL); - if (s != orig) - JLI_MemFree((char *) s); } static void @@ -939,46 +990,6 @@ SetMainModule(const char *s) AddOption(def, NULL); } -static void -SetAddModulesProp(const char *mods) { - size_t buflen = JLI_StrLen(mods) + 40; - char *prop = (char *)JLI_MemAlloc(buflen); - JLI_Snprintf(prop, buflen, "-Djdk.launcher.addmods=%s", mods); - AddOption(prop, NULL); -} - -static void -SetLimitModulesProp(const char *mods) { - size_t buflen = JLI_StrLen(mods) + 40; - char *prop = (char *)JLI_MemAlloc(buflen); - JLI_Snprintf(prop, buflen, "-Djdk.launcher.limitmods=%s", mods); - AddOption(prop, NULL); -} - -static void -SetAddReadsProp(const jint n, const char *s) { - size_t buflen = JLI_StrLen(s) + 40; - char *prop = (char *)JLI_MemAlloc(buflen); - JLI_Snprintf(prop, buflen, "-Djdk.launcher.addreads.%d=%s", n, s); - AddOption(prop, NULL); -} - -static void -SetAddExportsProp(const jint n, const char *s) { - size_t buflen = JLI_StrLen(s) + 40; - char *prop = (char *)JLI_MemAlloc(buflen); - JLI_Snprintf(prop, buflen, "-Djdk.launcher.addexports.%d=%s", n, s); - AddOption(prop, NULL); -} - -static void -SetPatchProp(const jint n, const char *s) { - size_t buflen = JLI_StrLen(s) + 40; - char *prop = (char *)JLI_MemAlloc(buflen); - JLI_Snprintf(prop, buflen, "-Djdk.launcher.patch.%d=%s", n, s); - AddOption(prop, NULL); -} - /* * The SelectVersion() routine ensures that an appropriate version of * the JRE is running. The specification for the appropriate version @@ -1003,6 +1014,7 @@ SelectVersion(int argc, char **argv, char **main_class) char *splash_jar_name = NULL; char *env_in; int res; + jboolean has_arg; /* * If the version has already been selected, set *main_class @@ -1033,9 +1045,11 @@ SelectVersion(int argc, char **argv, char **main_class) * This capability is no longer available with JRE versions 1.9 and later. * These command line options are reported as errors. */ + argc--; argv++; while ((arg = *argv) != 0 && *arg == '-') { + has_arg = IsOptionWithArgument(argc, argv); if (JLI_StrCCmp(arg, "-version:") == 0) { JLI_ReportErrorMessage(SPC_ERROR1); } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) { @@ -1045,10 +1059,12 @@ SelectVersion(int argc, char **argv, char **main_class) } else { if (JLI_StrCmp(arg, "-jar") == 0) jarflag = 1; - if (IsWhiteSpaceOptionArgument(arg) && (argc >= 2)) { - argc--; - argv++; - arg = *argv; + if (IsWhiteSpaceOption(arg)) { + if (has_arg) { + argc--; + argv++; + arg = *argv; + } } /* @@ -1139,6 +1155,108 @@ SelectVersion(int argc, char **argv, char **main_class) } +/* + * Test if the current argv is an option, i.e. with a leading `-` + * and followed with an argument without a leading `-`. + */ +static jboolean +IsOptionWithArgument(int argc, char** argv) { + char* option; + char* arg; + + if (argc <= 1) + return JNI_FALSE; + + option = *argv; + arg = *(argv+1); + return *option == '-' && *arg != '-'; +} + +/* + * Gets the option, and its argument if the option has an argument. + * It will update *pargc, **pargv to the next option. + */ +static int +GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) { + int argc = *pargc; + char** argv = *pargv; + char* arg = *argv; + + char* option = arg; + char* value = NULL; + char* equals = NULL; + int kind = LAUNCHER_OPTION; + jboolean has_arg = JNI_FALSE; + + // check if this option may be a white-space option with an argument + has_arg = IsOptionWithArgument(argc, argv); + + argv++; --argc; + if (IsLauncherOption(arg)) { + if (has_arg) { + value = *argv; + argv++; --argc; + } + kind = IsLauncherMainOption(arg) ? LAUNCHER_MAIN_OPTION + : LAUNCHER_OPTION_WITH_ARGUMENT; + } else if (IsModuleOption(arg)) { + kind = VM_LONG_OPTION_WITH_ARGUMENT; + if (has_arg) { + value = *argv; + argv++; --argc; + } + + /* + * Support short form alias + */ + if (JLI_StrCmp(arg, "-p") == 0) { + option = "--module-path"; + } + + } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) { + value = equals+1; + if (JLI_StrCCmp(arg, "--list-modules=") == 0 || + JLI_StrCCmp(arg, "--module=") == 0 || + JLI_StrCCmp(arg, "--class-path=") == 0) { + kind = LAUNCHER_OPTION_WITH_ARGUMENT; + } else { + kind = VM_LONG_OPTION; + } + } + +#ifndef OLD_MODULE_OPTIONS + // for transition to support both old and new syntax + if (JLI_StrCmp(arg, "-modulepath") == 0 || + JLI_StrCmp(arg, "-mp") == 0) { + option = "--module-path"; + } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) { + option = "--upgrade-module-path"; + } else if (JLI_StrCmp(arg, "-addmods") == 0) { + option = "--add-modules"; + } else if (JLI_StrCmp(arg, "-limitmods") == 0) { + option = "--limit-modules"; + } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) { + option = "--add-exports"; + value = arg + 13; + kind = VM_LONG_OPTION_WITH_ARGUMENT; + } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) { + option = "--add-reads"; + value = arg + 11; + kind = VM_LONG_OPTION_WITH_ARGUMENT; + } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) { + option = "--patch-module"; + value = arg + 8; + kind = VM_LONG_OPTION_WITH_ARGUMENT; + } +#endif + + *pargc = argc; + *pargv = argv; + *poption = option; + *pvalue = value; + return kind; +} + /* * Parses command line arguments. Returns JNI_FALSE if launcher * should exit without starting vm, returns JNI_TRUE if vm needs @@ -1158,52 +1276,85 @@ ParseArguments(int *pargc, char ***pargv, *pret = 0; while ((arg = *argv) != 0 && *arg == '-') { - argv++; --argc; - if (JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) { - ARG_CHECK (argc, ARG_ERROR1, arg); - SetClassPath(*argv); - mode = LM_CLASS; - argv++; --argc; - } else if (JLI_StrCmp(arg, "-modulepath") == 0 || JLI_StrCmp(arg, "-mp") == 0) { - ARG_CHECK (argc, ARG_ERROR4, arg); - SetModulePath(*argv); - argv++; --argc; - } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - ARG_CHECK (argc, ARG_ERROR4, arg); - SetUpgradeModulePath(*argv); - argv++; --argc; - } else if (JLI_StrCmp(arg, "-jar") == 0) { - ARG_CHECK (argc, ARG_ERROR2, arg); + char *option = NULL; + char *value = NULL; + int kind = GetOpt(&argc, &argv, &option, &value); + jboolean has_arg = value != NULL; + +/* + * Option to set main entry point + */ + if (JLI_StrCmp(arg, "-jar") == 0) { + ARG_CHECK(argc, ARG_ERROR2, arg); mode = LM_JAR; - } else if (JLI_StrCmp(arg, "-m") == 0) { - ARG_CHECK (argc, ARG_ERROR5, arg); - SetMainModule(*argv); + } else if (JLI_StrCmp(arg, "--module") == 0 || + JLI_StrCCmp(arg, "--module=") == 0 || + JLI_StrCmp(arg, "-m") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR5, arg); + SetMainModule(value); mode = LM_MODULE; - } else if (JLI_StrCmp(arg, "-addmods") == 0) { - ARG_CHECK (argc, ARG_ERROR6, arg); - SetAddModulesProp(*argv); - argv++; --argc; - } else if (JLI_StrCmp(arg, "-limitmods") == 0) { - ARG_CHECK (argc, ARG_ERROR6, arg); - SetLimitModulesProp(*argv); - argv++; --argc; - } else if (JLI_StrCmp(arg, "-listmods") == 0 || - JLI_StrCCmp(arg, "-listmods:") == 0) { + if (has_arg) { + *pwhat = value; + break; + } + } else if (JLI_StrCmp(arg, "--class-path") == 0 || + JLI_StrCCmp(arg, "--class-path=") == 0 || + JLI_StrCmp(arg, "-classpath") == 0 || + JLI_StrCmp(arg, "-cp") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR1, arg); + SetClassPath(value); + mode = LM_CLASS; + } else if (JLI_StrCmp(arg, "--list-modules") == 0 || + JLI_StrCCmp(arg, "--list-modules=") == 0) { listModules = arg; + + // set listModules to --list-modules= if argument is specified + if (JLI_StrCmp(arg, "--list-modules") == 0 && has_arg) { + static const char format[] = "%s=%s"; + size_t buflen = JLI_StrLen(option) + 2 + JLI_StrLen(value); + listModules = JLI_MemAlloc(buflen); + JLI_Snprintf(listModules, buflen, format, option, value); + } return JNI_TRUE; - } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) { - static jint n; - char *value = arg + 11; - SetAddReadsProp(n++, value); - } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) { - static jint n; - char *value = arg + 13; - SetAddExportsProp(n++, value); - } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) { - static jint n; - char *value = arg + 8; - SetPatchProp(n++, value); - } else if (JLI_StrCmp(arg, "-help") == 0 || +/* + * Parse white-space options + */ + } else if (has_arg) { + if (kind == VM_LONG_OPTION) { + AddOption(option, NULL); + } else if (kind == VM_LONG_OPTION_WITH_ARGUMENT) { + AddLongFormOption(option, value); + } +/* + * Error missing argument + */ + } else if (!has_arg && IsWhiteSpaceOption(arg)) { + if (JLI_StrCmp(arg, "--module-path") == 0 || + JLI_StrCmp(arg, "-p") == 0 || + JLI_StrCmp(arg, "--upgrade-module-path") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR4, arg); + } else if (JLI_StrCmp(arg, "--add-modules") == 0 || + JLI_StrCmp(arg, "--limit-modules") == 0 || + JLI_StrCmp(arg, "--add-exports") == 0 || + JLI_StrCmp(arg, "--add-reads") == 0 || + JLI_StrCmp(arg, "--patch-module") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR6, arg); + } +#ifndef OLD_MODULE_OPTIONS + else if (JLI_StrCmp(arg, "-modulepath") == 0 || + JLI_StrCmp(arg, "-mp") == 0 || + JLI_StrCmp(arg, "-upgrademodulepath") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR4, arg); + } else if (JLI_StrCmp(arg, "-addmods") == 0 || + JLI_StrCmp(arg, "-limitmods") == 0) { + REPORT_ERROR (has_arg, ARG_ERROR6, arg); + } +#endif +/* + * The following cases will cause the argument parsing to stop + */ + } else if (JLI_StrCmp(arg, "--help") == 0 || + JLI_StrCmp(arg, "-help") == 0 || JLI_StrCmp(arg, "-h") == 0 || JLI_StrCmp(arg, "-?") == 0) { printUsage = JNI_TRUE; @@ -1282,7 +1433,7 @@ ParseArguments(int *pargc, char ***pargv, } } - if (--argc >= 0) { + if (*pwhat == NULL && --argc >= 0) { *pwhat = *argv++; } @@ -1692,7 +1843,7 @@ static void ListModules(JNIEnv *env, char *optString) { jmethodID listModulesID; - jstring joptString; + jstring joptString = NULL; jclass cls = GetLauncherHelperClass(env); NULL_CHECK(cls); NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls, diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h index a4cecaa5545..c18c66e5b51 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -161,6 +161,7 @@ void SetJavaLauncherProp(void); jint ReadKnownVMs(const char *jvmcfg, jboolean speculative); char *CheckJvmType(int *argc, char ***argv, jboolean speculative); void AddOption(char *str, void *info); +jboolean IsWhiteSpaceOption(const char* name); enum ergo_policy { DEFAULT_POLICY = 0, diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java index 49781d7561d..165a424d9ca 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java @@ -91,7 +91,7 @@ class GNUStyleOptions { tool.xflag = true; } }, - new Option(false, OptionType.MAIN_OPERATION, "--print-module-descriptor", "-p") { + new Option(false, OptionType.MAIN_OPERATION, "--print-module-descriptor", "-d") { void process(Main tool, String opt, String arg) throws BadArgs { if (tool.cflag || tool.iflag || tool.tflag || tool.uflag || tool.xflag) throw new BadArgs("error.multiple.main.operations").showUsage(true); @@ -145,7 +145,7 @@ class GNUStyleOptions { } } }, - new Option(true, OptionType.CREATE_UPDATE, "--modulepath", "--mp") { + new Option(true, OptionType.CREATE_UPDATE, "--module-path", "-p") { void process(Main jartool, String opt, String arg) { String[] dirs = arg.split(File.pathSeparator); Path[] paths = new Path[dirs.length]; diff --git a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties index 9c570c7ded8..783ef1570cd 100644 --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties @@ -201,7 +201,7 @@ main.help.opt.main.update=\ main.help.opt.main.extract=\ \ -x, --extract Extract named (or all) files from the archive main.help.opt.main.print-module-descriptor=\ -\ -p, --print-module-descriptor Print the module descriptor +\ -d, --print-module-descriptor Print the module descriptor main.help.opt.any=\ \ Operation modifiers valid in any mode:\n\ \n\ @@ -232,8 +232,8 @@ main.help.opt.create.update.hash-modules=\ \ matched by the given pattern and that depend upon\n\ \ directly or indirectly on a modular jar being\n\ \ created or a non-modular jar being updated -main.help.opt.create.update.modulepath=\ -\ --modulepath Location of module dependence for generating +main.help.opt.create.update.module-path=\ +\ -p, --module-path Location of module dependence for generating\n\ \ the hash main.help.opt.create.update.index=\ \ Operation modifiers valid only in create, update, and generate-index mode:\n @@ -250,7 +250,7 @@ main.help.postopt=\ \ located in the root of the given directories, or the root of the jar archive\n\ \ itself. The following operations are only valid when creating a modular jar,\n\ \ or updating an existing non-modular jar: '--module-version',\n\ -\ '--hash-modules', and '--modulepath'.\n\ +\ '--hash-modules', and '--module-path'.\n\ \n\ \ Mandatory or optional arguments to long options are also mandatory or optional\n\ -\ for any corresponding short options. \ No newline at end of file +\ for any corresponding short options. diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java index 2069b0774cb..5b19b2e3e2b 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java @@ -61,11 +61,11 @@ class JImageTask { new Option(false, (task, option, arg) -> { task.options.fullVersion = true; - }, true, "--fullversion"), + }, true, "--full-version"), new Option(false, (task, option, arg) -> { task.options.help = true; - }, "--help"), + }, "--help", "-h"), new Option(false, (task, option, arg) -> { task.options.verbose = true; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties index b429a11c9dd..24bffe3e1a5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties @@ -25,7 +25,7 @@ main.usage.summary=\ Usage: {0} jimage...\n\ -use --help for a list of possible options. +use -h or --help for a list of possible options. main.usage=\ Usage: {0} jimage...\n\ @@ -76,11 +76,11 @@ main.opt.footer=\ \ used, one pattern per line\n\ -main.opt.fullversion=\ -\ --fullversion Print full version information +main.opt.full-version=\ +\ --full-version Print full version information main.opt.help=\ -\ --help Print usage message +\ -h, --help Print usage message main.opt.verbose=\ \ --verbose Listing prints entry size and offset attributes diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java index 0e973677376..1190a64abd7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java @@ -84,31 +84,32 @@ public class JlinkTask { private static final Option[] recognizedOptions = { new Option(false, (task, opt, arg) -> { task.options.help = true; - }, "--help"), + }, "--help", "-h"), new Option(true, (task, opt, arg) -> { String[] dirs = arg.split(File.pathSeparator); + int i = 0; Arrays.stream(dirs) .map(Paths::get) .forEach(task.options.modulePath::add); - }, "--modulepath", "--mp"), + }, "--module-path", "-p"), new Option(true, (task, opt, arg) -> { for (String mn : arg.split(",")) { if (mn.isEmpty()) { throw taskHelper.newBadArgs("err.mods.must.be.specified", - "--limitmods"); + "--limit-modules"); } task.options.limitMods.add(mn); } - }, "--limitmods"), + }, "--limit-modules"), new Option(true, (task, opt, arg) -> { for (String mn : arg.split(",")) { if (mn.isEmpty()) { throw taskHelper.newBadArgs("err.mods.must.be.specified", - "--addmods"); + "--add-modules"); } task.options.addMods.add(mn); } - }, "--addmods"), + }, "--add-modules"), new Option(true, (task, opt, arg) -> { Path path = Paths.get(arg); task.options.output = path; @@ -134,10 +135,10 @@ public class JlinkTask { }, true, "--keep-packaged-modules"), new Option(true, (task, opt, arg) -> { task.options.saveoptsfile = arg; - }, "--saveopts"), + }, "--save-opts"), new Option(false, (task, opt, arg) -> { task.options.fullVersion = true; - }, true, "--fullversion"),}; + }, true, "--full-version"),}; private static final String PROGNAME = "jlink"; private final OptionsValues options = new OptionsValues(); @@ -294,7 +295,7 @@ public class JlinkTask { try { options.addMods = checkAddMods(options.addMods); } catch (IllegalArgumentException ex) { - throw taskHelper.newBadArgs("err.mods.must.be.specified", "--addmods") + throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules") .showUsage(true); } // First create the image provider diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java index 01c15f5ec2e..4524f199725 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java @@ -196,7 +196,7 @@ public final class TaskHelper { // This option is handled prior // to have the options parsed. }, - "--plugins-modulepath")); + "--plugin-module-path")); mainOptions.add(new PlugOption(true, (task, opt, arg) -> { Path path = Paths.get(arg); if (!Files.exists(path) || !Files.isDirectory(path)) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index e7714e6e884..832304b48bb 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -24,30 +24,31 @@ # main.usage.summary=\ -Usage: {0} --modulepath --addmods --output \n\ +Usage: {0} --module-path --add-modules --output \n\ use --help for a list of possible options main.usage=\ -Usage: {0} --modulepath --addmods --output \n\ +Usage: {0} --module-path --add-modules --output \n\ \Possible options include: error.prefix=Error: warn.prefix=Warning: main.opt.help=\ -\ --help Print this help message +\ -h, --help Print this help message main.opt.version=\ \ --version Version information -main.opt.modulepath=\ -\ --modulepath Module path +main.opt.module-path=\ +\ -p \n\ +\ --module-path Module path -main.opt.addmods=\ -\ --addmods [,...] Root modules to resolve +main.opt.add-modules=\ +\ --add-modules [,...] Root modules to resolve -main.opt.limitmods=\ -\ --limitmods [,...] Limit the universe of observable modules +main.opt.limit-modules=\ +\ --limit-modules [,...] Limit the universe of observable modules main.opt.output=\ \ --output Location of output path @@ -58,8 +59,8 @@ main.command.files=\ main.opt.endian=\ \ --endian Byte order of generated jimage (default:native) -main.opt.saveopts=\ -\ --saveopts Save jlink options in the given file +main.opt.save-opts=\ +\ --save-opts Save jlink options in the given file main.msg.bug=\ An exception has occurred in jlink. \ @@ -83,7 +84,7 @@ main.extended.help.footer=\ err.unknown.byte.order:unknown byte order {0} err.output.must.be.specified:--output must be specified -err.modulepath.must.be.specified:--modulepath must be specified +err.modulepath.must.be.specified:--module-path must be specified err.mods.must.be.specified:no modules specified to {0} err.path.not.found=path not found: {0} err.path.not.valid=invalid path: {0} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 285600e2c77..50b958fa85d 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -115,7 +115,7 @@ include-locales.invalidtag=\ Invalid language tag: %s include-locales.localedatanotfound=\ -jdk.localedata module was not specified with --addmods option +jdk.localedata module was not specified with --add-modules option main.status.ok=Functional. @@ -133,8 +133,8 @@ plugin.opt.post-process-path=\ plugin.opt.resources-last-sorter=\ \ --resources-last-sorter The last plugin allowed to sort resources -plugin.opt.plugins-modulepath=\ -\ --plugin-module-path Custom plugins module path +plugin.opt.plugin-module-path=\ +\ --plugin-module-path Custom plugin module path plugin.opt.c=\ \ -c, --compress=2 Enable compression of resources (level 2) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java index 9a50cbbe542..a799ce3ebd3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java @@ -1181,7 +1181,7 @@ public class JmodTask { } } - private final OptionParser parser = new OptionParser(); + private final OptionParser parser = new OptionParser("hp"); private void handleOptions(String[] args) { parser.formatHelpWith(new JmodHelpFormatter()); @@ -1218,7 +1218,7 @@ public class JmodTask { .withValuesConvertedBy(new PatternConverter()); OptionSpec help - = parser.accepts("help", getMessage("main.opt.help")) + = parser.acceptsAll(Set.of("h", "help"), getMessage("main.opt.help")) .forHelp(); OptionSpec libs @@ -1232,9 +1232,9 @@ public class JmodTask { .withRequiredArg() .describedAs(getMessage("main.opt.main-class.arg")); - OptionSpec modulePath // TODO: short version of --mp ?? - = parser.acceptsAll(Arrays.asList("mp", "modulepath"), - getMessage("main.opt.modulepath")) + OptionSpec modulePath + = parser.acceptsAll(Set.of("p", "module-path"), + getMessage("main.opt.module-path")) .withRequiredArg() .withValuesSeparatedBy(File.pathSeparatorChar) .withValuesConvertedBy(DirPathConverter.INSTANCE); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties index 301037e264d..d6531f70ca4 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties @@ -63,7 +63,7 @@ main.opt.os-arch=Operating system architecture main.opt.os-arch.arg=os-arch main.opt.os-version=Operating system version main.opt.os-version.arg=os-version -main.opt.modulepath=Module path +main.opt.module-path=Module path main.opt.hash-modules=Compute and record hashes to tie a packaged module\ \ with modules matching the given and depending upon it directly\ \ or indirectly. The hashes are recorded in the JMOD file being created, or\ diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index a6af75c47bb..657e62cc0e7 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -343,6 +343,9 @@ com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows- com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all +com/sun/jdi/ClassesByName2Test.java 8160833 generic-all +com/sun/jdi/RedefineCrossEvent.java 8160833 generic-all + ############################################################################ # jdk_time diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT index 3c75542592c..8a4164133fe 100644 --- a/jdk/test/TEST.ROOT +++ b/jdk/test/TEST.ROOT @@ -26,12 +26,12 @@ groups=TEST.groups [closed/TEST.groups] # Allow querying of various System properties in @requires clauses requires.properties=sun.arch.data.model java.runtime.name -# Tests using jtreg 4.2 b02 features -requiredVersion=4.2 b02 +# Tests using jtreg 4.2 b03 features +requiredVersion=4.2 b03 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them external.lib.roots = ../../ -# Use new form of -Xpatch -useNewXpatch=true +# Use new module options +useNewOptions=true diff --git a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh index 0ecd30a4de5..214b6e1fb65 100644 --- a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh +++ b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh @@ -81,9 +81,9 @@ cp ${TESTSRC}${FS}JavaBug.java bug chmod -fR 777 bug -${COMPILEJAVA}${FS}bin${FS}javac -addmods java.corba -d . bug${FS}*.java +${COMPILEJAVA}${FS}bin${FS}javac --add-modules java.corba -d . bug${FS}*.java -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -addmods java.corba -cp . bug/JavaBug > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} --add-modules java.corba -cp . bug/JavaBug > test.out 2>&1 grep "NullPointerException" test.out diff --git a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java index ccc84df74bc..15397206330 100644 --- a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java +++ b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java @@ -27,8 +27,8 @@ * @summary Four helper classes missing in Sun JDK * @library /lib/testlibrary * @build jdk.testlibrary.* - * @compile -addmods java.corba CorbaExceptionsCompileTest.java - * @run main/othervm -addmods java.corba CorbaExceptionsCompileTest + * @modules java.corba + * @run main CorbaExceptionsCompileTest */ import java.io.*; diff --git a/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java b/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java index 4791c63f2ef..73592c4287d 100644 --- a/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java +++ b/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java @@ -25,8 +25,8 @@ * @test * @bug 7095856 * @summary OutputStreamHook doesn't handle null values - * @compile -addmods java.corba HookPutFieldsTest.java - * @run main/othervm -addmods java.corba HookPutFieldsTest + * @modules java.corba + * @run main HookPutFieldsTest */ import java.net.InetAddress; diff --git a/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java b/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java index 49b0a5d9f6f..1ed35fbc677 100644 --- a/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java +++ b/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java @@ -25,8 +25,8 @@ * @test * @bug 8028215 * @summary SetDefaultORBTest setting ORB impl via properties test - * @compile -addmods java.corba SetDefaultORBTest.java - * @run main/othervm -addmods java.corba SetDefaultORBTest + * @modules java.corba + * @run main SetDefaultORBTest * */ diff --git a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh index b38e538b431..133925e4b19 100644 --- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh +++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh @@ -99,11 +99,11 @@ env set -vx # # Compile test class -${TESTJAVA}/bin/javac -XaddExports:jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \ +${TESTJAVA}/bin/javac --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \ -d "${TESTCLASSES}" ${CP} -g "${TESTSRC}"/"${TARGETCLASS}".java # # Run the test class, again with the classpath we need: -${TESTJAVA}/bin/java -XaddExports:jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \ +${TESTJAVA}/bin/java --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \ ${CP} ${TARGETCLASS} status=$? echo "test status was: $status" diff --git a/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java b/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java index 1c429b29100..4d18093317e 100644 --- a/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java +++ b/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java @@ -26,6 +26,7 @@ * @summary Tests that JNDI/COS naming parser supports the syntax * defined in the new INS standard. * @modules java.corba/com.sun.jndi.cosnaming + * @run main/othervm CNNameParser */ import javax.naming.*; diff --git a/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java b/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java index ebaf6d8761c..a23d419e247 100644 --- a/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java +++ b/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java @@ -25,6 +25,7 @@ * @bug 5042453 * @summary Ipv6 address throws Non-numeric port number error * @modules java.corba/com.sun.jndi.cosnaming + * @run main/othervm IiopUrlIPv6 */ import com.sun.jndi.cosnaming.*; diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 546bf8a7051..1f98e2b6709 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -61,7 +61,7 @@ public class CheckOrigin { ProcessBuilder pb = ProcessTools. createJavaProcessBuilder( - "-XaddExports:jdk.attach/sun.tools.attach=ALL-UNNAMED", + "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED", "-XX:+UseConcMarkSweepGC", // this will cause UseParNewGC to be FLAG_SET_ERGO "-XX:+UseCodeAging", "-XX:+UseCerealGC", // Should be ignored. diff --git a/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java b/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java index cc327e34e12..8dc6a46d659 100644 --- a/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java +++ b/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java @@ -55,7 +55,7 @@ public class GtkVersionTest { "/bin/java " + (version == null ? "" : "-Djdk.gtk.version=" + version) + " -Djdk.gtk.verbose=true " + - "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED " + + "--add-exports=java.desktop/sun.awt=ALL-UNNAMED " + "-cp " + System.getProperty("java.class.path", ".") + " GtkVersionTest$LoadGtk"); p.waitFor(); diff --git a/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh index b1930f0a728..1683ba94a58 100644 --- a/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh +++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh @@ -113,8 +113,8 @@ fi case "$OS" in Windows* | CYGWIN* ) ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ *.java status=$? if [ ! $status -eq "0" ]; then @@ -124,8 +124,8 @@ case "$OS" in SunOS | Linux ) ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ *.java status=$? if [ ! $status -eq "0" ]; then @@ -135,8 +135,8 @@ case "$OS" in Darwin) ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ *.java status=$? if [ ! $status -eq "0" ]; then @@ -154,16 +154,16 @@ chmod 777 ./* case "$OS" in Windows* | CYGWIN* ) ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ TestWrapped sun.awt.windows.WToolkit status=$? if [ ! $status -eq "0" ]; then fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit"; fi ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \ -Dawt.toolkit=sun.awt.windows.WToolkit \ TestWrapped sun.awt.windows.WToolkit status=$? @@ -174,8 +174,8 @@ case "$OS" in SunOS | Linux ) ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ -Dawt.toolkit=sun.awt.X11.XToolkit \ TestWrapped sun.awt.X11.XToolkit status=$? @@ -183,8 +183,8 @@ case "$OS" in fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit"; fi AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java ${TESTVMOPTS} \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \ -Djava.awt.headless=true \ TestWrapped sun.awt.X11.XToolkit status=$? @@ -195,16 +195,16 @@ case "$OS" in Darwin) ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ TestWrapped sun.lwawt.macosx.LWCToolkit status=$? if [ ! $status -eq "0" ]; then fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.lwawt.macosx.LWCToolkit"; fi ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \ - -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \ - -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ + --add-exports java.desktop/sun.awt=ALL-UNNAMED \ + --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \ -Dawt.toolkit=sun.lwawt.macosx.LWCToolkit \ TestWrapped sun.lwawt.macosx.LWCToolkit status=$? diff --git a/jdk/test/java/awt/xembed/server/RunTestXEmbed.java b/jdk/test/java/awt/xembed/server/RunTestXEmbed.java index fb8314bc679..97179a073a6 100644 --- a/jdk/test/java/awt/xembed/server/RunTestXEmbed.java +++ b/jdk/test/java/awt/xembed/server/RunTestXEmbed.java @@ -73,10 +73,11 @@ public class RunTestXEmbed extends TestXEmbedServer { enva[ind++] = "AWT_TOOLKIT=sun.awt.X11.XToolkit"; } } - Process proc = Runtime.getRuntime().exec(java_home + - "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED -Dawt.toolkit=sun.awt.X11.XToolkit TesterClient " - + test.getName() + " " + window + buf, - enva); + Process proc = Runtime.getRuntime(). + exec(java_home + + "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED -Dawt.toolkit=sun.awt.X11.XToolkit TesterClient " + + test.getName() + " " + window + buf, + enva); System.err.println("Test for " + test.getName() + " has started."); log.fine("Test for " + test.getName() + " has started."); new InputReader(proc.getInputStream()); diff --git a/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java b/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java index 8e0c3d6774e..8a953c3acf7 100644 --- a/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java +++ b/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java @@ -84,11 +84,11 @@ public class TestXEmbedServerJava extends TestXEmbedServer { } if (hasModules) { System.out.println(java_home + - "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+ - "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window); + "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED "+ + "--add-exports java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window); return Runtime.getRuntime().exec(java_home + - "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+ - "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window); + "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED "+ + "--add-exports java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window); }else{ System.out.println(java_home + "/bin/java JavaClient " + window); return Runtime.getRuntime().exec(java_home + "/bin/java JavaClient " + window); diff --git a/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java b/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java index 1609bb1486f..5a97ade252a 100644 --- a/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java +++ b/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java @@ -39,7 +39,7 @@ import java.util.List; * java.corba * java.xml.bind * @compile -XDignore.symbol.file TestConstructorFinder.java - * @run main/othervm -addmods java.activation -addmods java.transaction -addmods java.corba -addmods java.xml.bind TestConstructorFinder + * @run main/othervm --add-modules=java.activation,java.transaction,java.corba,java.xml.bind TestConstructorFinder */ public class TestConstructorFinder { diff --git a/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java b/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java index ad7ca0bd944..8dfbd202c69 100644 --- a/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java +++ b/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java @@ -39,7 +39,7 @@ import java.util.List; * java.corba * java.xml.bind * @compile -XDignore.symbol.file TestMethodFinder.java - * @run main/othervm -addmods java.activation -addmods java.transaction -addmods java.corba -addmods java.xml.bind TestMethodFinder + * @run main/othervm --add-modules=java.activation,java.transaction,java.corba,java.xml.bind TestMethodFinder */ public class TestMethodFinder { diff --git a/jdk/test/java/lang/Class/forName/modules/TestDriver.java b/jdk/test/java/lang/Class/forName/modules/TestDriver.java index 690849b7c2a..7ab1f636c9e 100644 --- a/jdk/test/java/lang/Class/forName/modules/TestDriver.java +++ b/jdk/test/java/lang/Class/forName/modules/TestDriver.java @@ -65,7 +65,7 @@ public class TestDriver { public void setup() throws Exception { assertTrue(CompilerUtils.compile( MOD_SRC_DIR, MOD_DEST_DIR, - "-modulesourcepath", + "--module-source-path", MOD_SRC_DIR.toString())); copyDirectories(MOD_DEST_DIR.resolve("m1"), Paths.get("mods1")); @@ -76,8 +76,8 @@ public class TestDriver { public void test() throws Exception { String[] options = new String[] { "-cp", TEST_CLASSES, - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "-m", "m2/p2.test.Main" }; runTest(options); @@ -87,8 +87,8 @@ public class TestDriver { public void testUnnamedModule() throws Exception { String[] options = new String[] { "-cp", TEST_CLASSES, - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "TestMain" }; runTest(options); @@ -107,8 +107,8 @@ public class TestDriver { @Test public void testDeniedClassLoaderAccess() throws Exception { String[] options = new String[] { - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "-m", "m3/p3.NoGetClassLoaderAccess" }; assertTrue(executeTestJava(options) @@ -124,8 +124,8 @@ public class TestDriver { String[] options = new String[] { "-Djava.security.manager", "-Djava.security.policy=" + policyFile.toString(), - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "-m", "m3/p3.NoAccess" }; assertTrue(executeTestJava(options) diff --git a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java index 9052737aad5..5f4dcea191e 100644 --- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java +++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java @@ -63,8 +63,8 @@ import jdk.internal.module.Modules; * loads all the classes in the BCL, get their declared fields, * and call setAccessible(false) followed by setAccessible(true); * @modules java.base/jdk.internal.module - * @run main/othervm -Djdk.launcher.addmods=ALL-SYSTEM FieldSetAccessibleTest UNSECURE - * @run main/othervm -Djdk.launcher.addmods=ALL-SYSTEM FieldSetAccessibleTest SECURE + * @run main/othervm --add-modules=ALL-SYSTEM FieldSetAccessibleTest UNSECURE + * @run main/othervm --add-modules=ALL-SYSTEM FieldSetAccessibleTest SECURE * * @author danielfuchs */ diff --git a/jdk/test/java/lang/Class/getResource/ResourcesTest.java b/jdk/test/java/lang/Class/getResource/ResourcesTest.java index a78e3353f45..97fdae6f575 100644 --- a/jdk/test/java/lang/Class/getResource/ResourcesTest.java +++ b/jdk/test/java/lang/Class/getResource/ResourcesTest.java @@ -60,15 +60,15 @@ public class ResourcesTest { compiled = CompilerUtils .compile(SRC_DIR, MODS_DIR, - "-modulesourcepath", SRC_DIR.toString()); + "--module-source-path", SRC_DIR.toString()); assertTrue(compiled); - // javac -mp mods -d classes Main.java + // javac --module-path mods -d classes Main.java compiled = CompilerUtils .compile(Paths.get(TEST_SRC, "Main.java"), CLASSES_DIR, - "-mp", MODS_DIR.toString(), - "-addmods", "m1,m2,m3"); + "--module-path", MODS_DIR.toString(), + "--add-modules", "m1,m2,m3"); assertTrue(compiled); } @@ -79,8 +79,8 @@ public class ResourcesTest { public void runTest() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "m1,m2,m3", + = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "m1,m2,m3", "-cp", CLASSES_DIR.toString(), "Main") .outputTo(System.out) diff --git a/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java b/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java index c6e1bcf764d..3eafa822766 100644 --- a/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java +++ b/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java @@ -56,19 +56,19 @@ public class ResourcesTest { public void compileAll() throws Exception { boolean compiled; - // javac -modulesource mods -d mods src/** + // javac --module-source-path mods -d mods src/** compiled = CompilerUtils .compile(SRC_DIR, MODS_DIR, - "-modulesourcepath", SRC_DIR.toString()); + "--module-source-path", SRC_DIR.toString()); assertTrue(compiled); - // javac -mp mods -d classes Main.java + // javac --module-path mods -d classes Main.java compiled = CompilerUtils .compile(Paths.get(TEST_SRC, "Main.java"), CLASSES_DIR, - "-mp", MODS_DIR.toString(), - "-addmods", "m1,m2,m3"); + "--module-path", MODS_DIR.toString(), + "--add-modules", "m1,m2,m3"); assertTrue(compiled); } @@ -77,8 +77,8 @@ public class ResourcesTest { */ public void runTest() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "m1,m2,m3", + = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "m1,m2,m3", "-cp", CLASSES_DIR.toString(), "Main") .outputTo(System.out) diff --git a/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh b/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh index e722677fd3f..37b527e34d3 100644 --- a/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh +++ b/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh @@ -51,15 +51,15 @@ JAVAC="$COMPILEJAVA/bin/javac" JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}" mkdir -p mods -$JAVAC -d mods -modulesourcepath ${TESTSRC} `find ${TESTSRC}/m -name "*.java"` +$JAVAC -d mods --module-source-path ${TESTSRC} `find ${TESTSRC}/m -name "*.java"` mkdir -p classes $JAVAC -d classes ${TESTSRC}/Test.java -$JAVA -cp classes -mp mods -addmods m \ +$JAVA -cp classes --module-path mods --add-modules m \ -Djava.security.manager \ -Djava.security.policy=${TESTSRC}/test.policy Test -$JAVA -cp classes -mp mods -addmods m \ +$JAVA -cp classes --module-path mods --add-modules m \ -Djava.security.manager=p.CustomSecurityManager \ -Djava.security.policy=${TESTSRC}/test.policy Test diff --git a/jdk/test/java/lang/String/concat/WithSecurityManager.java b/jdk/test/java/lang/String/concat/WithSecurityManager.java index d4aaeeaf131..9359d29fbb1 100644 --- a/jdk/test/java/lang/String/concat/WithSecurityManager.java +++ b/jdk/test/java/lang/String/concat/WithSecurityManager.java @@ -38,13 +38,13 @@ import java.security.Permission; * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager * - * @run main/othervm -Xverify:all -limitmods java.base WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager - * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT WithSecurityManager + * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT WithSecurityManager */ public class WithSecurityManager { public static void main(String[] args) throws Throwable { diff --git a/jdk/test/java/lang/instrument/MakeJAR2.sh b/jdk/test/java/lang/instrument/MakeJAR2.sh index ec76b820472..9568be6eda4 100644 --- a/jdk/test/java/lang/instrument/MakeJAR2.sh +++ b/jdk/test/java/lang/instrument/MakeJAR2.sh @@ -87,7 +87,7 @@ ${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} bootreporter/*.java cd .. ${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED ${AGENT}.java asmlib/*.java + --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED ${AGENT}.java asmlib/*.java ${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath .${PATHSEP}bootpath ${APP}.java echo "Manifest-Version: 1.0" > ${AGENT}.mf diff --git a/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java b/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java index d76513e17a7..32adfd9d5e0 100644 --- a/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java +++ b/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java @@ -60,7 +60,7 @@ public class ModuleAccessControlTest { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); assertTrue(CompilerUtils - .compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + .compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } } @@ -69,7 +69,7 @@ public class ModuleAccessControlTest { */ @Test public void runTest() throws Exception { - int exitValue = executeTestJava("-mp", MODS_DIR.toString(), + int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), "-m", "m1/p1.Main") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java index a7dea9961cc..a3305d521ac 100644 --- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java +++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java @@ -63,9 +63,9 @@ public class LayerAndLoadersTest { @BeforeTest public void setup() throws Exception { - // javac -d mods -modulesourcepath src src/** + // javac -d mods --module-source-path src src/** assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR, - "-modulesourcepath", SRC_DIR.toString())); + "--module-source-path", SRC_DIR.toString())); } diff --git a/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java b/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java index d989339e3f9..1cfeb4bf177 100644 --- a/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java +++ b/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/reflect/Module/AddExportsTest.java b/jdk/test/java/lang/reflect/Module/AddExportsTest.java index 0ac990677a4..3f4453614e8 100644 --- a/jdk/test/java/lang/reflect/Module/AddExportsTest.java +++ b/jdk/test/java/lang/reflect/Module/AddExportsTest.java @@ -23,29 +23,44 @@ /** * @test - * @modules java.desktop - * @run main/othervm -XaddExports:java.desktop/sun.awt=java.base AddExportsTest - * @run main/othervm -XaddExports:java.desktop/sun.awt=ALL-UNNAMED AddExportsTest + * @modules java.base/jdk.internal.misc + * java.desktop + * @run main/othervm --add-exports=java.desktop/sun.awt=java.base AddExportsTest + * @run main/othervm --add-exports=java.desktop/sun.awt=ALL-UNNAMED AddExportsTest * @summary Test Module isExported methods with exports changed by -AddExportsTest */ import java.lang.reflect.Layer; import java.lang.reflect.Module; import java.util.Optional; +import java.util.stream.Stream; + +import jdk.internal.misc.VM; public class AddExportsTest { + /* + * jtreg sets -Dtest.modules system property to the internal APIs + * specified at @modules tag. The test will exclude --add-exports set + * for @modules. + */ + private static final String TEST_MODULES = System.getProperty("test.modules"); public static void main(String[] args) { - String addExports = System.getProperty("jdk.launcher.addexports.0"); - assertTrue(addExports != null, "Expected to be run with -XaddExports"); + Optional oaddExports = Stream.of(VM.getRuntimeArguments()) + .filter(arg -> arg.startsWith("--add-exports=")) + .filter(arg -> !arg.equals("--add-exports=" + TEST_MODULES + "=ALL-UNNAMED")) + .map(arg -> arg.substring("--add-exports=".length(), arg.length())) + .findFirst(); + + assertTrue(oaddExports.isPresent()); Layer bootLayer = Layer.boot(); Module unnamedModule = AddExportsTest.class.getModule(); assertFalse(unnamedModule.isNamed()); - for (String expr : addExports.split(",")) { + for (String expr : oaddExports.get().split(",")) { String[] s = expr.split("="); assertTrue(s.length == 2); diff --git a/jdk/test/java/lang/reflect/Module/access/AccessTest.java b/jdk/test/java/lang/reflect/Module/access/AccessTest.java index 5e5ee037156..1e6e98a2cc6 100644 --- a/jdk/test/java/lang/reflect/Module/access/AccessTest.java +++ b/jdk/test/java/lang/reflect/Module/access/AccessTest.java @@ -72,8 +72,8 @@ public class AccessTest { */ public void runTest() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "target", + = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "target", "-m", "test/test.Main") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java index fcc673909fa..55e11f1b3ec 100644 --- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java +++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java @@ -64,7 +64,7 @@ public class ProxyClassAccessTest { public void compileAll() throws Exception { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); - assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } } @@ -73,7 +73,7 @@ public class ProxyClassAccessTest { */ @Test public void runTest() throws Exception { - int exitValue = executeTestJava("-mp", MODS_DIR.toString(), + int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), "-m", "test/jdk.test.ProxyClassAccess") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java index 37c0bd59b23..5b04c93596b 100644 --- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java +++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java @@ -65,7 +65,7 @@ public class ProxyLayerTest { public void compileAll() throws Exception { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); - assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } } diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java index db3af7d5e6f..bd8d1b042b3 100644 --- a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java +++ b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java @@ -38,7 +38,7 @@ public class ProxyModuleMapping { Module unnamed = ld.getUnnamedModule(); new ProxyModuleMapping(unnamed, Runnable.class).test(); - // unnamed module gets access to sun.invoke package (e.g. via -XaddExports) + // unnamed module gets access to sun.invoke package (e.g. via --add-exports) new ProxyModuleMapping(sun.invoke.WrapperInstance.class).test(); Class modulePrivateIntf = Class.forName("sun.net.ProgressListener"); diff --git a/jdk/test/java/lang/reflect/Proxy/ProxyTest.java b/jdk/test/java/lang/reflect/Proxy/ProxyTest.java index 80c8b76ae9a..2a7945bb5e9 100644 --- a/jdk/test/java/lang/reflect/Proxy/ProxyTest.java +++ b/jdk/test/java/lang/reflect/Proxy/ProxyTest.java @@ -61,7 +61,7 @@ public class ProxyTest { public void compileAll() throws Exception { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); - assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } } @@ -71,7 +71,7 @@ public class ProxyTest { @Test public void runTest() throws Exception { int exitValue = executeTestJava("-cp", CPATH_DIR.toString(), - "-mp", MODS_DIR.toString(), + "--module-path", MODS_DIR.toString(), "-m", "test/jdk.test.Main") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/net/Authenticator/B4933582.sh b/jdk/test/java/net/Authenticator/B4933582.sh index a9cff3e6a62..e1cca0200b6 100644 --- a/jdk/test/java/net/Authenticator/B4933582.sh +++ b/jdk/test/java/net/Authenticator/B4933582.sh @@ -44,7 +44,7 @@ case "$OS" in ;; esac -EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED -XaddExports:java.base/sun.net.www.protocol.http=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED --add-exports java.base/sun.net.www.protocol.http=ALL-UNNAMED" export EXTRAOPTS ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . \ diff --git a/jdk/test/java/net/SocketOption/OptionsTest.java b/jdk/test/java/net/SocketOption/OptionsTest.java index f1309f11b50..232873372ee 100644 --- a/jdk/test/java/net/SocketOption/OptionsTest.java +++ b/jdk/test/java/net/SocketOption/OptionsTest.java @@ -26,7 +26,7 @@ * @bug 8036979 8072384 8044773 * @run main/othervm -Xcheck:jni OptionsTest * @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest - * @run main/othervm -limitmods java.base OptionsTest + * @run main/othervm --limit-modules=java.base OptionsTest */ import java.lang.reflect.Method; diff --git a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java index 488960c4bb3..5af84fdfdd9 100644 --- a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java +++ b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java @@ -33,7 +33,7 @@ import java.util.List; * @summary Test checks that UnsupportedOperationException for unsupported * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods. * @run main UnsupportedOptionsTest - * @run main/othervm -limitmods java.base UnsupportedOptionsTest + * @run main/othervm --limit-modules=java.base UnsupportedOptionsTest */ public class UnsupportedOptionsTest { diff --git a/jdk/test/java/net/httpclient/http2/HpackDriver.java b/jdk/test/java/net/httpclient/http2/HpackDriver.java index 3bf1bc39a4b..366b04c3c97 100644 --- a/jdk/test/java/net/httpclient/http2/HpackDriver.java +++ b/jdk/test/java/net/httpclient/http2/HpackDriver.java @@ -29,12 +29,12 @@ * @compile/module=java.httpclient sun/net/httpclient/hpack/SpecHelper.java * @compile/module=java.httpclient sun/net/httpclient/hpack/TestHelper.java * @compile/module=java.httpclient sun/net/httpclient/hpack/BuffersTestingKit.java - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.BinaryPrimitivesTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.CircularBufferTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.DecoderTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.EncoderTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.HeaderTableTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.HuffmanTest - * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.TestHelper + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.BinaryPrimitivesTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.CircularBufferTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.DecoderTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.EncoderTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HeaderTableTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HuffmanTest + * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.TestHelper */ public class HpackDriver { } diff --git a/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java index 270efce9126..abb8b174979 100644 --- a/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java +++ b/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java @@ -25,7 +25,7 @@ * @bug 4640544 8044773 * @summary Unit test for setOption/getOption/options methods * @run main SocketOptionTests - * @run main/othervm -limitmods java.base SocketOptionTests + * @run main/othervm --limit-modules=java.base SocketOptionTests */ import java.nio.*; diff --git a/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java index b8c7c327bcb..1687b73f04a 100644 --- a/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java +++ b/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java @@ -26,7 +26,7 @@ * @summary Unit test for ServerSocketChannel setOption/getOption/options * methods. * @run main SocketOptionTests - * @run main/othervm -limitmods java.base SocketOptionTests + * @run main/othervm --limit-modules=java.base SocketOptionTests */ import java.nio.*; diff --git a/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java b/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java index 38a4e9c170e..5e75ad9a93a 100644 --- a/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java +++ b/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java @@ -26,7 +26,7 @@ * @summary Unit test to check SocketChannel setOption/getOption/options * methods. * @run main SocketOptionTests - * @run main/othervm -limitmods java.base SocketOptionTests + * @run main/othervm --limit-modules=java.base SocketOptionTests */ import java.nio.*; diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh index 371b62fa5f7..46ecc310161 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh @@ -109,7 +109,7 @@ failures=0 go() { echo '' - sh -xc "$JAVA ${TESTVMOPTS} -XaddExports:java.base/sun.nio.ch=ALL-UNNAMED $DFLAG \ + sh -xc "$JAVA ${TESTVMOPTS} --add-exports java.base/sun.nio.ch=ALL-UNNAMED $DFLAG \ $1 $2 $3 $4 $5 $6 $7 $8" 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi } diff --git a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh index ce870264855..546d693b962 100644 --- a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh +++ b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh @@ -52,9 +52,9 @@ mkdir -p ext $COMPILEJAVA/bin/jar ${TESTTOOLVMOPTS} cf ext/ext.jar -C $TESTCLASSES ExtLoadedImpl.class -C $TESTCLASSES ExtLoadedImpl_Stub.class -C $TESTCLASSES CheckLoader.class TESTVMOPTS="${TESTVMOPTS} \ - -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" $TESTJAVA/bin/java ${TESTVMOPTS} -cp classes -Dtest.src=$TESTSRC -Dtest.classes=$TESTCLASSES -Djava.security.policy=$TESTSRC/security.policy -Djava.ext.dirs=ext ExtLoadedImplTest diff --git a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java index 8560b070c0c..815bb22e17b 100644 --- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java +++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2015, 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 @@ -24,7 +24,6 @@ /* * @test * @bug 4510355 - * @key intermittent * @summary ActivationGroup implementations cannot be downloaded by default; * Creates a custom activation group without setting a security manager * in activation group's descriptor. The custom activation group @@ -140,10 +139,10 @@ public class DownloadActivationGroup CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment( null, new String[] { - "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); + "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); ActivationGroupDesc groupDesc = new ActivationGroupDesc("MyActivationGroupImpl", diff --git a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java index 393db7ee6fc..5099ab175bf 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java @@ -121,11 +121,11 @@ public class StubClassesPermitted System.err.println("Create activation group, in a new VM"); CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(null, new String[] { - "-XaddExports:java.base/sun.security.provider=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED", - "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); + "--add-exports=java.base/sun.security.provider=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED", + "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" }); ActivationGroupDesc groupDesc = new ActivationGroupDesc(p, cmd); diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java index 72911b95b67..721ecf84f6f 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java @@ -106,7 +106,7 @@ public class InheritedChannelNotServerSocket { rmid = RMID.createRMID(System.out, System.err, true, true, TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT); rmid.addOptions( - "-XaddExports:java.base/sun.nio.ch=ALL-UNNAMED", + "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED", "-Djava.nio.channels.spi.SelectorProvider=InheritedChannelNotServerSocket$SP"); rmid.start(); diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java index 25018495faa..272f9f42321 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java @@ -93,7 +93,7 @@ public class RmidViaInheritedChannel implements Callback { rmid = RMID.createRMID(System.out, System.err, true, false, TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT); rmid.addOptions( - "-XaddExports:java.base/sun.nio.ch=ALL-UNNAMED", + "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED", "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider"); if (System.getProperty("os.name").startsWith("Windows") && System.getProperty("os.version").startsWith("5.")) diff --git a/jdk/test/java/rmi/module/ModuleTest.java b/jdk/test/java/rmi/module/ModuleTest.java index ad19a71b9f4..be0b2184d28 100644 --- a/jdk/test/java/rmi/module/ModuleTest.java +++ b/jdk/test/java/rmi/module/ModuleTest.java @@ -97,8 +97,8 @@ public class ModuleTest { */ @Test public void testAllInModule() throws Exception { - assertEquals(executeTestJava("-mp", pathJoin(MTEST_JAR, CLIENT_JAR, SERVER_JAR), - "-addmods", "mclient,mserver", + assertEquals(executeTestJava("--module-path", pathJoin(MTEST_JAR, CLIENT_JAR, SERVER_JAR), + "--add-modules", "mclient,mserver", "-m", "mtest/" + DUMMY_MAIN) .outputTo(System.out) .errorTo(System.out) @@ -113,7 +113,7 @@ public class ModuleTest { */ @Test public void testAppInModule() throws Exception { - assertEquals(executeTestJava("-mp", MTEST_JAR, + assertEquals(executeTestJava("--module-path", MTEST_JAR, "-cp", pathJoin(CLIENT_JAR, SERVER_JAR), "-m", "mtest/" + DUMMY_MAIN) .outputTo(System.out) @@ -129,8 +129,8 @@ public class ModuleTest { */ @Test public void testAppInUnnamedModule() throws Exception { - assertEquals(executeTestJava("-mp", pathJoin(CLIENT_JAR, SERVER_JAR), - "-addmods", "mclient,mserver", + assertEquals(executeTestJava("--module-path", pathJoin(CLIENT_JAR, SERVER_JAR), + "--add-modules", "mclient,mserver", "-cp", MTEST_JAR, DUMMY_MAIN) .outputTo(System.out) @@ -146,8 +146,8 @@ public class ModuleTest { */ @Test public void testClientInUnamedModule() throws Exception { - assertEquals(executeTestJava("-mp", pathJoin(MTEST_JAR, SERVER_JAR), - "-addmods", "mserver", + assertEquals(executeTestJava("--module-path", pathJoin(MTEST_JAR, SERVER_JAR), + "--add-modules", "mserver", "-cp", CLIENT_JAR, "-m", "mtest/" + DUMMY_MAIN) .outputTo(System.out) diff --git a/jdk/test/java/rmi/registry/readTest/readTest.sh b/jdk/test/java/rmi/registry/readTest/readTest.sh index 3bee78b65e4..8e4a8339cd7 100644 --- a/jdk/test/java/rmi/registry/readTest/readTest.sh +++ b/jdk/test/java/rmi/registry/readTest/readTest.sh @@ -99,10 +99,10 @@ case "$OS" in esac # trailing / after code base is important for rmi codebase property. TESTVMOPTS="${TESTVMOPTS} \ - -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED \ - -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \ + --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 & TEST_PID=$! #bulk of testcase - let it run for a while diff --git a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java index 289772a3782..19d4d6cc808 100644 --- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java +++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java @@ -123,10 +123,10 @@ public class CheckFQDN extends UnicastRemoteObject propOption + property + equal + propertyValue + extraProp + - " -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + " -Drmi.registry.port=" + REGISTRY_PORT, ""); diff --git a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java index 07ff7e8368b..181b1d0256e 100644 --- a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java +++ b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java @@ -75,10 +75,10 @@ public class DGCDeadLock implements Runnable { try { String options = " -Djava.security.policy=" + TestParams.defaultPolicy + - " -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED" + - " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + + " --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED" + + " --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED" + + " --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED" + + " --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + " -Djava.rmi.dgc.leaseValue=500000" + " -Dsun.rmi.dgc.checkInterval=" + (HOLD_TARGET_TIME - 5000) + diff --git a/jdk/test/java/security/Provider/SecurityProviderModularTest.java b/jdk/test/java/security/Provider/SecurityProviderModularTest.java index 7a2e7ecbff6..d35162ba4f9 100644 --- a/jdk/test/java/security/Provider/SecurityProviderModularTest.java +++ b/jdk/test/java/security/Provider/SecurityProviderModularTest.java @@ -317,7 +317,7 @@ public class SecurityProviderModularTest extends ModularTest { vmArgs.put("-Duser.language=", "en"); vmArgs.put("-Duser.region=", "US"); if (addModName != null && sModuletype == MODULE_TYPE.AUTO) { - vmArgs.put("-addmods ", addModName); + vmArgs.put("--add-modules=", addModName); } // If mechanism selected to find the provider through // Security.getProvider() then use providerName/ProviderClassName based diff --git a/jdk/test/java/security/modules/ModularTest.java b/jdk/test/java/security/modules/ModularTest.java index 227f8d47f2f..356bb0882cd 100644 --- a/jdk/test/java/security/modules/ModularTest.java +++ b/jdk/test/java/security/modules/ModularTest.java @@ -137,7 +137,7 @@ public abstract class ModularTest { final StringJoiner command = new StringJoiner(SPACE, SPACE, SPACE); vmArgs.forEach((key, value) -> command.add(key + value)); if (modulePath != null) { - command.add("-mp").add(modulePath.toFile().getCanonicalPath()); + command.add("--module-path").add(modulePath.toFile().getCanonicalPath()); } if (classPath != null && classPath.length() > 0) { command.add("-cp").add(classPath); diff --git a/jdk/test/java/security/testlibrary/Proc.java b/jdk/test/java/security/testlibrary/Proc.java index 6f9fa5d6b2d..92efc7fdba8 100644 --- a/jdk/test/java/security/testlibrary/Proc.java +++ b/jdk/test/java/security/testlibrary/Proc.java @@ -25,19 +25,19 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.Permission; import java.util.ArrayList; +import java.util.Arrays; import java.util.Base64; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.stream.Stream; /** * This is a test library that makes writing a Java test that spawns multiple @@ -184,12 +184,9 @@ public class Proc { "java").getPath()); } - int n = 0; - String addexports; - while ((addexports = System.getProperty("jdk.launcher.addexports." + n)) != null) { - prop("jdk.launcher.addexports." + n, addexports); - n++; - } + Stream.of(jdk.internal.misc.VM.getRuntimeArguments()) + .filter(arg -> arg.startsWith("--add-exports=")) + .forEach(cmd::add); Collections.addAll(cmd, splitProperty("test.vm.opts")); Collections.addAll(cmd, splitProperty("test.java.opts")); diff --git a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh index 5d722c3dd55..24e6a25da37 100644 --- a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh +++ b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh @@ -31,7 +31,7 @@ # This test is locale data-dependent and assumes that both JRE and CLDR # have the same geneic time zone names in English. -EXTRAOPTS="-XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.util.locale.provider=ALL-UNNAMED" STATUS=0 echo "Locale providers: default" if ! ${TESTJAVA}/bin/java -esa ${TESTVMOPTS} ${EXTRAOPTS} -cp "${TESTCLASSES}" GenericTimeZoneNamesTest en-US; then diff --git a/jdk/test/java/util/Formatter/Basic.sh b/jdk/test/java/util/Formatter/Basic.sh index 0bf4162f17b..b0fe162a5f6 100644 --- a/jdk/test/java/util/Formatter/Basic.sh +++ b/jdk/test/java/util/Formatter/Basic.sh @@ -23,7 +23,7 @@ # -EXTRAOPTS="-XaddExports:java.base/jdk.internal.math=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/jdk.internal.math=ALL-UNNAMED" ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -cp ${TESTSRC} -d . \ ${TESTSRC}/Basic.java diff --git a/jdk/test/java/util/Locale/LocaleProviders.sh b/jdk/test/java/util/Locale/LocaleProviders.sh index 07f8f00eae2..cb8a7c6b9fd 100644 --- a/jdk/test/java/util/Locale/LocaleProviders.sh +++ b/jdk/test/java/util/Locale/LocaleProviders.sh @@ -122,8 +122,8 @@ tznp tznp8013086 EOF -EXTRAOPTS="-XaddExports:java.base/sun.util.locale=ALL-UNNAMED \ - -XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.util.locale=ALL-UNNAMED \ + --add-exports java.base/sun.util.locale.provider=ALL-UNNAMED" ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${SPIDIR}${FS}dest \ ${SPIDIR}${FS}src${FS}tznp.java \ diff --git a/jdk/test/java/util/PluggableLocale/ExecTest.sh b/jdk/test/java/util/PluggableLocale/ExecTest.sh index 643895ed75f..7c7df1ceec2 100644 --- a/jdk/test/java/util/PluggableLocale/ExecTest.sh +++ b/jdk/test/java/util/PluggableLocale/ExecTest.sh @@ -93,8 +93,8 @@ case "$1" in esac -EXTRA_OPTS="-XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED \ - -XaddExports:java.base/sun.util.resources=ALL-UNNAMED" +EXTRA_OPTS="--add-exports java.base/sun.util.locale.provider=ALL-UNNAMED \ + --add-exports java.base/sun.util.resources=ALL-UNNAMED" # compile cp ${TESTSRC}${FS}ProviderTest.java . diff --git a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh index c2ce46ec3c3..354093c4f4b 100644 --- a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh +++ b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh @@ -68,7 +68,7 @@ cd ${PATCHDIR}/java.desktop ${TESTJAVA}/bin/jar xf ${TESTSRC}/awtres.jar echo -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xpatch:java.desktop=${PATCHDIR}/java.desktop \ +${TESTJAVA}/bin/java ${TESTVMOPTS} --patch-module java.desktop=${PATCHDIR}/java.desktop \ -cp ${TESTCLASSES} Bug6299235Test if [ $? -ne 0 ] diff --git a/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh b/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh index a22b825318a..634324be4e8 100644 --- a/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh +++ b/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh @@ -47,7 +47,7 @@ do mkdir -p mods/$B CLASSES="`find $TESTSRC/src/$B -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src -cp mods/test $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES fi PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" if [ "x$PROPS" != x ]; then @@ -61,8 +61,8 @@ do done mkdir -p mods/test -$JAVAC -g -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` +$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` -$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de +$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de exit $? diff --git a/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh b/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh index 51c0f4a15d2..d6096833ebf 100644 --- a/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh +++ b/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh @@ -47,7 +47,7 @@ do mkdir -p mods/$B CLASSES="`find $TESTSRC/src/$B -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src -cp mods/test $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES fi PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" if [ "x$PROPS" != x ]; then @@ -61,8 +61,8 @@ do done mkdir -p mods/test -$JAVAC -g -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` +$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` -$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de +$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de exit $? diff --git a/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh b/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh index 86fd0fde0cc..95f0c5bd0ad 100644 --- a/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh +++ b/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh @@ -52,7 +52,7 @@ do mkdir -p mods/$B CLASSES="`find $TESTSRC/src/$B -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CP $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src $CP $CLASSES fi PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" if [ "x$PROPS" != x ]; then @@ -67,7 +67,7 @@ do done mkdir -p mods/test -$JAVAC -g -cp mods/mainbundles -d mods -modulesourcepath $TESTSRC/src \ +$JAVAC -g -cp mods/mainbundles -d mods --module-source-path $TESTSRC/src \ `find $TESTSRC/src/test -name "*.java"` # Create a jar to be added to the class path. Expected only properties files are @@ -81,9 +81,9 @@ $JAR -cf extra.jar -C classes jdk/test/resources/eu \ STATUS=0 echo "jdk.test.Main should load bundles using ResourceBundleProviders." -$JAVA -mp mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1 +$JAVA -p mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1 echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path." -$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main es vi && STATUS=1 +$JAVA -cp extra.jar -p mods -m test/jdk.test.Main es vi && STATUS=1 exit $STATUS diff --git a/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh b/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh index e87e05c4f5a..e4a58121087 100644 --- a/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh +++ b/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh @@ -57,7 +57,7 @@ if [ "x$PROPS" != x ]; then done fi -$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \ +$JAVAC -g -d mods --module-source-path $TESTSRC/src \ -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` # Create a jar to be added to the class path. Expected properties files are @@ -69,9 +69,9 @@ $JAR -cf extra.jar -C $TESTSRC/src/extra jdk/test/resources STATUS=0 echo 'jdk.test.Main should load bundles local to named module "test".' -$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1 +$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1 echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path." -$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main vi && STATUS=1 +$JAVA -cp extra.jar -p mods -m test/jdk.test.Main vi && STATUS=1 exit $STATUS diff --git a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java index 68eb09ec928..4e68a347af8 100644 --- a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java +++ b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java @@ -59,7 +59,7 @@ public class TestPermission { public void compileAll() throws Exception { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); - assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } } @@ -68,7 +68,7 @@ public class TestPermission { */ @Test public void runTest() throws Exception { - int exitValue = executeTestJava("-mp", MODS_DIR.toString(), + int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), "-m", "test/jdk.test.Main") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh b/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh index 9975d1caf5c..08f3a945ce6 100644 --- a/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh +++ b/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh @@ -50,7 +50,7 @@ B=bundles mkdir -p mods/$B CLASSES="`find $TESTSRC/src/$B -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES fi PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" if [ "x$PROPS" != x ]; then @@ -62,9 +62,9 @@ if [ "x$PROPS" != x ]; then done fi -$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \ +$JAVAC -g -d mods --module-source-path $TESTSRC/src \ -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` -$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de +$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de exit $? diff --git a/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh b/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh index 02ca3c43793..c37949e0255 100644 --- a/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh +++ b/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh @@ -57,7 +57,7 @@ do mkdir -p mods/$M CLASSES="`find $TESTSRC/src/$M -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES fi PROPS="`(cd $TESTSRC/src/$M; find . -name '*.properties')`" if [ "x$PROPS" != x ]; then @@ -96,23 +96,23 @@ done # jdk.test.resources.{classes,props}.* are available only to named module "test" # by ResourceBundleProvider. -runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.classes.MyResources true -runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.props.MyResources true -runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.classes.MyResources false -runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.props.MyResources false # Add mods/named.bundles to the class path. -runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.classes.MyResources true -runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.props.MyResources true -runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.classes.MyResources false -runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.props.MyResources false # Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg @@ -120,37 +120,37 @@ runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleA # jdk.test.resources.classes is exported to named module "test". # IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.classes.MyResources false # jdk.test.resources.props is exported to named module "test". # loader.getResource() doesn't find jdk.test.resources.props.MyResources. -runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.props.MyResources false # IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.classes.MyResources false # jdk.test.resources.props is exported to named module "test". # loader.getResource() doesn't find jdk.test.resources.props.MyResources. -runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.props.MyResources false # Add mods/named.bundles to the class path # IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.classes.MyResources false # loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.props.MyResources true # jdk.test.resources.exported.classes.MyResources is treated # as if the class is in an unnamed module. -runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.classes.MyResources true # loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.props.MyResources true ################################################# @@ -160,23 +160,23 @@ runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedMo # neither of which specifies an unnamed module with ResourceBundle.getBundle. # None of jdk.test.resources.exported.** is available to the named modules. -runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.exported.classes.MyResources false -runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.exported.props.MyResources false -runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.exported.classes.MyResources false -runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.exported.props.MyResources false # Add mods/exported.named.bundles to the class path. -runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.exported.classes.MyResources false -runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ jdk.test.resources.exported.props.MyResources false -runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.exported.classes.MyResources false -runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ jdk.test.resources.exported.props.MyResources false # Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg @@ -184,36 +184,36 @@ runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWith # loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources # and throws a ClassNotFoundException. -runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.exported.classes.MyResources false # The properties files in jdk.test.resources.exported.props are not found with loader.getResource(). -runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.exported.props.MyResources false # loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources # and throws a ClassNotFoundException. -runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.exported.classes.MyResources false # The properties files in jdk.test.resources.exported.props are not found # with loader.getResource(). -runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.exported.props.MyResources false # Add mods/exported.named.bundles to the class path. # jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false. -runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.exported.classes.MyResources true # loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ jdk.test.resources.exported.props.MyResources true # jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false. -runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.exported.classes.MyResources true # loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ +runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ jdk.test.resources.exported.props.MyResources true ####################################### diff --git a/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh b/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh index 849523229a5..4c5c7b13843 100644 --- a/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh +++ b/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh @@ -48,7 +48,7 @@ B=bundles mkdir -p mods/$B CLASSES="`find $TESTSRC/src/$B -name '*.java'`" if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES + $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES fi PROPS="`(cd $TESTSRC/src/$B; find . -name '*.xml')`" if [ "x$PROPS" != x ]; then @@ -60,9 +60,9 @@ if [ "x$PROPS" != x ]; then done fi -$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \ +$JAVAC -g -d mods --module-source-path $TESTSRC/src \ -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` -$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de +$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de exit $? diff --git a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java index 55d4c2f1453..a9084f3437b 100644 --- a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java +++ b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java @@ -105,13 +105,13 @@ public class ServicesTest { /** - * Run test with -modulepath. + * Run test with --module-path. * * BananaScriptEngine should be found. */ public void runWithModulePath() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), + = executeTestJava("--module-path", MODS_DIR.toString(), "-m", "test/test.Main", "BananaScriptEngine") .outputTo(System.out) @@ -123,13 +123,13 @@ public class ServicesTest { /** - * Run test with -modulepath and -classpath. + * Run test with --module-path and -classpath. * * Both BananaScriptEngine and PearScriptEngine should be found */ public void runWithModulePathAndClassPath() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), + = executeTestJava("--module-path", MODS_DIR.toString(), "-cp", CLASSES_DIR.toString(), "-m", "test/test.Main", "BananaScriptEngine", "PearScriptEngine") diff --git a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java index c049613e552..8bf01eb654d 100644 --- a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java +++ b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java @@ -66,10 +66,10 @@ public class GetResourceBundleTest { for (String mn : modules) { Path msrc = MOD_SRC_DIR.resolve(mn); assertTrue(CompilerUtils.compile(msrc, MOD_DEST_DIR, - "-modulesourcepath", MOD_SRC_DIR.toString())); + "--module-source-path", MOD_SRC_DIR.toString())); } assertTrue(CompilerUtils.compile(PKG_SRC_DIR, PKG_DEST_DIR, - "-modulepath", MOD_DEST_DIR.toString(), "-addmods", String.join(",", modules))); + "--module-path", MOD_DEST_DIR.toString(), "--add-modules", String.join(",", modules))); // copy resource files String[] files = { "m1/p1/resource/p.properties", "m2/p2/resource/p.properties" }; @@ -84,8 +84,8 @@ public class GetResourceBundleTest { public void runWithoutSecurityManager() throws Exception { int exitValue = executeTestJava( "-cp", PKG_DEST_DIR.toString(), - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "p3.test.ResourceBundleTest") .outputTo(System.out) .errorTo(System.err) @@ -98,8 +98,8 @@ public class GetResourceBundleTest { int exitValue = executeTestJava( "-Djava.security.manager", "-cp", PKG_DEST_DIR.toString(), - "-mp", MOD_DEST_DIR.toString(), - "-addmods", String.join(",", modules), + "--module-path", MOD_DEST_DIR.toString(), + "--add-modules", String.join(",", modules), "p3.test.ResourceBundleTest") .outputTo(System.out) .errorTo(System.err) diff --git a/jdk/test/javax/crypto/Cipher/CipherStreamClose.java b/jdk/test/javax/crypto/Cipher/CipherStreamClose.java index 304c887dea1..98f45b08bfe 100644 --- a/jdk/test/javax/crypto/Cipher/CipherStreamClose.java +++ b/jdk/test/javax/crypto/Cipher/CipherStreamClose.java @@ -27,8 +27,8 @@ * @summary Make sure Cipher IO streams doesn't call extra doFinal if close() * is called multiple times. Additionally, verify the input and output streams * match with encryption and decryption with non-stream crypto. - * @compile -addmods java.xml.bind CipherStreamClose.java - * @run main/othervm -addmods java.xml.bind CipherStreamClose + * @modules java.xml.bind + * @run main CipherStreamClose */ import java.io.*; diff --git a/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh b/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh index 60e8fc04b2a..e11e0957b12 100644 --- a/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh +++ b/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh @@ -86,7 +86,7 @@ fi # expect to find SimpReader on module path echo "Test modular jar .. " -$JAVA -mp $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin +$JAVA --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin if [ $? -ne 0 ]; then exception=1 @@ -94,7 +94,7 @@ if [ $? -ne 0 ]; then fi echo "Test modular jar with security manager .." -$JAVA -Djava.security.manager -mp $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin +$JAVA -Djava.security.manager --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin if [ $? -ne 0 ]; then exception=1 echo "modular jar with security manager test failed: exception thrown!" diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh index 071550eed45..16ccd27f363 100644 --- a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh +++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh @@ -199,14 +199,14 @@ if [ $? -ne 0 ] ; then fi # Verify that all classloaders are destroyed -${TESTJAVA}/bin/java -XaddExports:java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} -cp Test.jar test.Main +${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} -cp Test.jar test.Main if [ $? -ne 0 ] ; then fail "Test FAILED: some classloaders weren't destroyed." fi # Verify that ImageIO shutdown hook works correcly -${TESTJAVA}/bin/java -XaddExports:java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} \ +${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} \ -cp Test.jar -DforgetSomeStreams=true test.Main if [ $? -ne 0 ] ; then fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed." diff --git a/jdk/test/javax/naming/module/basic.sh b/jdk/test/javax/naming/module/basic.sh index b48fefb4daa..6f7d672b5db 100644 --- a/jdk/test/javax/naming/module/basic.sh +++ b/jdk/test/javax/naming/module/basic.sh @@ -78,27 +78,27 @@ $JAVAC -d mods/ldapv4 `find $TESTSRC/src/ldapv4 -name "*.java"` echo "\nPreparing the 'test' module..." mkdir -p mods/test -$JAVAC -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` +$JAVAC -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` echo "\nRunning with the 'java.desktop' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreObject ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreObject ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'person' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StorePerson ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StorePerson ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'fruit' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreFruit ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreFruit ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'hello' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreRemote ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreRemote ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'foo' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ConnectWithFoo ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithFoo ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'authz' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ConnectWithAuthzId ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithAuthzId ldap://localhost/dc=ie,dc=oracle,dc=com echo "\nRunning with the 'ldapv4' module..." -$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ReadByUrl ldap://localhost/dc=ie,dc=oracle,dc=com +$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ReadByUrl ldap://localhost/dc=ie,dc=oracle,dc=com diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java index 147fcd14e72..87f5d866507 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java @@ -25,18 +25,19 @@ * @test * @bug 8146975 * @summary test RMI-IIOP with value object return + * @modules java.corba * @library /lib/testlibrary * @build jdk.testlibrary.* - * @compile -addmods java.corba Test.java Test3.java Test4.java + * @compile Test.java Test3.java Test4.java * HelloInterface.java HelloServer.java * HelloClient.java HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java * RmiIiopReturnValueTest.java - * @run main/othervm -addmods java.corba + * @run main/othervm * -Djava.naming.provider.url=iiop://localhost:5050 * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory * RmiIiopReturnValueTest -port 5049 * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy - * -addmods java.corba -Djava.naming.provider.url=iiop://localhost:5050 + * -Djava.naming.provider.url=iiop://localhost:5050 * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory * RmiIiopReturnValueTest -port 5049 */ @@ -102,12 +103,12 @@ public class RmiIiopReturnValueTest { static void startRmiIiopServer() throws Exception { System.out.println("\nStarting RmiIiopServer"); - // java -addmods java.corba -cp . + // java --add-modules java.corba -cp . // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory // -Djava.naming.provider.url=iiop://localhost:5050 HelloServer -port 5049 List commands = new ArrayList<>(); commands.add(RmiIiopReturnValueTest.JAVA); - commands.add("-addmods"); + commands.add("--add-modules"); commands.add("java.corba"); commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory"); commands.add("-Djava.naming.provider.url=iiop://localhost:5050"); diff --git a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java index 2155d646543..4d2d279c995 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java +++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java @@ -28,12 +28,12 @@ * @library /lib/testlibrary * @modules java.corba * @build jdk.testlibrary.* - * @compile -addmods java.corba Test.java HelloInterface.java HelloServer.java HelloClient.java + * @compile Test.java HelloInterface.java HelloServer.java HelloClient.java * HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java ConcurrentHashMapTest.java - * @run main/othervm -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050 + * @run main/othervm -Djava.naming.provider.url=iiop://localhost:1050 * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy - * -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050 + * -Djava.naming.provider.url=iiop://localhost:1050 * -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest * @key intermittent */ @@ -98,12 +98,12 @@ public class ConcurrentHashMapTest { static void startRmiIiopServer() throws Exception { System.out.println("\nStarting RmiServer"); - // java -cp . -addmods java.corba + // java -cp . --add-modules java.corba // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory // -Djava.naming.provider.url=iiop://localhost:1050 HelloServer List commands = new ArrayList<>(); commands.add(ConcurrentHashMapTest.JAVA); - commands.add("-addmods"); + commands.add("--add-modules"); commands.add("java.corba"); commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory"); commands.add("-Djava.naming.provider.url=iiop://localhost:1050"); diff --git a/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java b/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java index ff5225f6df7..20763ba4e45 100644 --- a/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java +++ b/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java @@ -291,7 +291,7 @@ public class JaasModularClientTest extends ModularTest { vmArgs.put("-Djava.security.auth.login.config=", SRC.resolve( "jaas.conf").toFile().getCanonicalPath()); if (addModName != null && sModuletype == MODULE_TYPE.AUTO) { - vmArgs.put("-addmods ", addModName); + vmArgs.put("--add-modules ", addModName); } return vmArgs; } diff --git a/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java b/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java index 83a77f3177a..14dc31e14db 100644 --- a/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java +++ b/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java @@ -247,7 +247,7 @@ public class JaasModularDefaultHandlerTest extends ModularTest { if (addModName != null && !(cModuleType == MODULE_TYPE.EXPLICIT && sModuletype == MODULE_TYPE.EXPLICIT)) { - vmArgs.put("-addmods ", addModName); + vmArgs.put("--add-modules=", addModName); } return vmArgs; } diff --git a/jdk/test/javax/smartcardio/CommandAPDUTest.java b/jdk/test/javax/smartcardio/CommandAPDUTest.java index 72c5a474590..f34a2ea381a 100644 --- a/jdk/test/javax/smartcardio/CommandAPDUTest.java +++ b/jdk/test/javax/smartcardio/CommandAPDUTest.java @@ -26,8 +26,8 @@ * @bug 8049021 * @summary Test different constructors for CommandAPDU and check CLA,INS,NC,NE, * P1,and P2 - * @compile -addmods java.smartcardio CommandAPDUTest.java - * @run testng/othervm -addmods java.smartcardio CommandAPDUTest + * @compile --add-modules=java.smartcardio CommandAPDUTest.java + * @run testng/othervm --add-modules=java.smartcardio CommandAPDUTest */ import java.nio.ByteBuffer; import javax.smartcardio.CommandAPDU; diff --git a/jdk/test/javax/smartcardio/HistoricalBytes.java b/jdk/test/javax/smartcardio/HistoricalBytes.java index eebaf8dd671..c44bbe0c681 100644 --- a/jdk/test/javax/smartcardio/HistoricalBytes.java +++ b/jdk/test/javax/smartcardio/HistoricalBytes.java @@ -26,8 +26,8 @@ * @bug 6445367 * @summary Verify that ATR.getHistoricalBytes() works * @author Andreas Sterbenz - * @compile -addmods java.smartcardio HistoricalBytes.java - * @run main/othervm -addmods java.smartcardio HistoricalBytes + * @compile --add-modules=java.smartcardio HistoricalBytes.java + * @run main/othervm --add-modules=java.smartcardio HistoricalBytes */ import java.util.Arrays; diff --git a/jdk/test/javax/smartcardio/ResponseAPDUTest.java b/jdk/test/javax/smartcardio/ResponseAPDUTest.java index c885c2b827c..470002d23f0 100644 --- a/jdk/test/javax/smartcardio/ResponseAPDUTest.java +++ b/jdk/test/javax/smartcardio/ResponseAPDUTest.java @@ -25,8 +25,8 @@ * @test * @bug 8049021 * @summary Construct ResponseAPDU from byte array and check NR< SW, SW1 and SW2 - * @compile -addmods java.smartcardio ResponseAPDUTest.java - * @run testng/othervm -addmods java.smartcardio ResponseAPDUTest + * @compile --add-modules=java.smartcardio ResponseAPDUTest.java + * @run testng/othervm --add-modules=java.smartcardio ResponseAPDUTest */ import javax.smartcardio.ResponseAPDU; import static org.testng.Assert.*; diff --git a/jdk/test/javax/smartcardio/Serialize.java b/jdk/test/javax/smartcardio/Serialize.java index a7eac0e242c..7becee4dd9d 100644 --- a/jdk/test/javax/smartcardio/Serialize.java +++ b/jdk/test/javax/smartcardio/Serialize.java @@ -26,8 +26,8 @@ * @bug 6445367 * @summary make sure serialization works * @author Andreas Sterbenz - * @compile -addmods java.smartcardio Serialize.java - * @run main/othervm -addmods java.smartcardio Serialize + * @compile --add-modules=java.smartcardio Serialize.java + * @run main/othervm --add-modules=java.smartcardio Serialize */ import java.io.*; diff --git a/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java b/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java index 692f111e24d..853ce2dd1ce 100644 --- a/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java +++ b/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java @@ -25,8 +25,8 @@ * @test * @bug 8049021 * @summary Test if we can write new provider for smart card - * @compile -addmods java.smartcardio TerminalFactorySpiTest.java - * @run main/othervm/java.security.policy=policy -addmods java.smartcardio TerminalFactorySpiTest + * @compile --add-modules=java.smartcardio TerminalFactorySpiTest.java + * @run main/othervm/java.security.policy=policy --add-modules=java.smartcardio TerminalFactorySpiTest */ import java.security.Provider; import java.security.Security; diff --git a/jdk/test/javax/smartcardio/TestCardPermission.java b/jdk/test/javax/smartcardio/TestCardPermission.java index 7c31da6a9d7..b737722dceb 100644 --- a/jdk/test/javax/smartcardio/TestCardPermission.java +++ b/jdk/test/javax/smartcardio/TestCardPermission.java @@ -26,8 +26,8 @@ * @bug 6293767 * @summary Test for the CardPermission class * @author Andreas Sterbenz - * @compile -addmods java.smartcardio TestCardPermission.java - * @run main/othervm -addmods java.smartcardio TestCardPermission + * @compile --add-modules=java.smartcardio TestCardPermission.java + * @run main/othervm --add-modules=java.smartcardio TestCardPermission */ import javax.smartcardio.*; diff --git a/jdk/test/javax/smartcardio/TestCommandAPDU.java b/jdk/test/javax/smartcardio/TestCommandAPDU.java index 34421590dcb..d8374e17671 100644 --- a/jdk/test/javax/smartcardio/TestCommandAPDU.java +++ b/jdk/test/javax/smartcardio/TestCommandAPDU.java @@ -27,8 +27,8 @@ * @summary Test for the CommandAPDU class * @author Andreas Sterbenz * @key randomness - * @compile -addmods java.smartcardio TestCommandAPDU.java - * @run main/othervm -addmods java.smartcardio TestCommandAPDU + * @compile --add-modules=java.smartcardio TestCommandAPDU.java + * @run main/othervm --add-modules=java.smartcardio TestCommandAPDU */ import java.util.*; diff --git a/jdk/test/javax/transaction/testng/Driver.java b/jdk/test/javax/transaction/testng/Driver.java index 1a890651bfb..08cb2d9f325 100644 --- a/jdk/test/javax/transaction/testng/Driver.java +++ b/jdk/test/javax/transaction/testng/Driver.java @@ -24,14 +24,14 @@ /** * @test * @modules java.sql java.transaction - * @compile -addmods java.transaction + * @compile * test/transaction/InvalidTransactionExceptionTests.java * test/transaction/TransactionRequiredExceptionTests.java * test/transaction/TransactionRolledbackExceptionTests.java * test/transaction/XAExceptionTests.java * util/SerializedTransactionExceptions.java - * @run testng/othervm -addmods java.transaction test.transaction.InvalidTransactionExceptionTests - * @run testng/othervm -addmods java.transaction test.transaction.TransactionRequiredExceptionTests - * @run testng/othervm -addmods java.transaction test.transaction.TransactionRolledbackExceptionTests - * @run testng/othervm -addmods java.transaction util.SerializedTransactionExceptions + * @run testng/othervm test.transaction.InvalidTransactionExceptionTests + * @run testng/othervm test.transaction.TransactionRequiredExceptionTests + * @run testng/othervm test.transaction.TransactionRolledbackExceptionTests + * @run testng/othervm util.SerializedTransactionExceptions */ diff --git a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java index f442875b55f..9407fbf526b 100644 --- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java @@ -33,8 +33,8 @@ import javax.xml.bind.JAXBException; * @bug 8150173 * @summary Verifies that a factory which inherit its createContext method * from an abstract subclass of JAXBContextFactory can be instantiated. - * @compile -addmods java.xml.bind JAXBContextWithAbstractFactory.java - * @run main/othervm -addmods java.xml.bind JAXBContextWithAbstractFactory + * @modules java.xml.bind + * @run main/othervm JAXBContextWithAbstractFactory */ public class JAXBContextWithAbstractFactory { private static JAXBContext tmp; diff --git a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java index aa886ef9c7d..972e5fae573 100644 --- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java @@ -35,8 +35,8 @@ import javax.xml.bind.Validator; * @bug 8150173 * @summary Verifies that a JAXBContext can be created with a legacy * factory class that has static createContext methods. - * @compile -addmods java.xml.bind JAXBContextWithLegacyFactory.java - * @run main/othervm -addmods java.xml.bind JAXBContextWithLegacyFactory + * @modules java.xml.bind + * @run main/othervm JAXBContextWithLegacyFactory */ public class JAXBContextWithLegacyFactory { private static JAXBContext tmp; diff --git a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java index 6ab7520eea3..a9c7066d7c7 100644 --- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java +++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java @@ -36,8 +36,8 @@ import javax.xml.bind.Validator; * @bug 8150173 * @summary Verifies that a factory which inherit its createContext method * from a concrete subclass of JAXBContextFactory is be instantiated. - * @compile -addmods java.xml.bind JAXBContextWithSubclassedFactory.java - * @run main/othervm -addmods java.xml.bind JAXBContextWithSubclassedFactory + * @modules java.xml.bind + * @run main/othervm JAXBContextWithSubclassedFactory */ public class JAXBContextWithSubclassedFactory { static JAXBContext tmp; diff --git a/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java b/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java index f1f143de529..82ed2025636 100644 --- a/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java +++ b/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java @@ -26,9 +26,8 @@ * @bug 8073872 * @summary test that stackoverflow is not observable when element * references containing class - * @modules java.xml * @modules java.xml.bind - * @compile Foo.java + * @compile SchemagenStackOverflow.java Foo.java * @run testng/othervm SchemagenStackOverflow */ diff --git a/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java b/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java index c95f85bb0e0..a068445f30d 100644 --- a/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java +++ b/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java @@ -26,9 +26,10 @@ * @bug 8134111 * @summary test that elements without namespace is ignored by unmarshaller * when elementFormDefault is set to QUALIFIED. - * @compile testTypes/package-info.java testTypes/Root.java - * testTypes/WhenType.java testTypes/ObjectFactory.java * @modules java.xml.bind + * @compile UnmarshalTest.java + * testTypes/package-info.java testTypes/Root.java + * testTypes/WhenType.java testTypes/ObjectFactory.java * @run testng/othervm UnmarshalTest */ diff --git a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java index 9cc57cfcdae..5c5e8706a81 100644 --- a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java +++ b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java @@ -100,7 +100,7 @@ public class XjcOptionalPropertyTest { // Compile java classes with javac tool void compileXjcGeneratedClasses() throws Exception { JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac"); - javacLauncher.addToolArg("-addmods"); + javacLauncher.addToolArg("--add-modules"); javacLauncher.addToolArg("java.xml.bind"); javacLauncher.addToolArg(xjcResultDir.resolve("Foo.java").toString()); System.out.println("Compiling xjc generated class: " + Arrays.asList(javacLauncher.getCommand())); diff --git a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java index cc1be256343..c7abbac9176 100644 --- a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java +++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java @@ -127,7 +127,7 @@ public class JaxbMarshallTest { // Compile java classes with javac tool void compileXjcGeneratedClasses() throws Exception { JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac"); - javacLauncher.addToolArg("-addmods"); + javacLauncher.addToolArg("--add-modules"); javacLauncher.addToolArg("java.xml.bind"); javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString()); javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString()); diff --git a/jdk/test/javax/xml/jaxp/common/8035437/run.sh b/jdk/test/javax/xml/jaxp/common/8035437/run.sh index 5dbcff7f18a..ea377c67281 100644 --- a/jdk/test/javax/xml/jaxp/common/8035437/run.sh +++ b/jdk/test/javax/xml/jaxp/common/8035437/run.sh @@ -34,12 +34,12 @@ $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ -d compile/java.xml -Xmodule:java.xml $TESTSRC/Document.java $TESTSRC/Node.java || exit 1 $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ - -d exec/java.xml -Xpatch:java.xml=compile/java.xml -Xmodule:java.xml $TESTSRC/DocumentImpl.java || exit 2 + -d exec/java.xml --patch-module java.xml=compile/java.xml -Xmodule:java.xml $TESTSRC/DocumentImpl.java || exit 2 $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ $TESTSRC/AbstractMethodErrorTest.java -d exec || exit 3 -$TESTJAVA/bin/java ${TESTVMOPTS} -Xpatch:java.xml=exec -cp exec AbstractMethodErrorTest || exit 4 +$TESTJAVA/bin/java ${TESTVMOPTS} --patch-module java.xml=exec -cp exec AbstractMethodErrorTest || exit 4 exit 0 diff --git a/jdk/test/javax/xml/soap/XmlTest.java b/jdk/test/javax/xml/soap/XmlTest.java index 37aed906037..c99f5d6a2ae 100644 --- a/jdk/test/javax/xml/soap/XmlTest.java +++ b/jdk/test/javax/xml/soap/XmlTest.java @@ -38,8 +38,8 @@ import java.util.Iterator; /* * @test - * @compile -addmods java.xml.ws XmlTest.java - * @run main/othervm -addmods java.xml.ws XmlTest + * @modules java.xml.ws + * @run main XmlTest * @summary tests JAF DataHandler can be instantiated; test serialize and * deserialize SOAP message containing xml attachment */ diff --git a/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java b/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java index 07f66dcbc51..e9c81180416 100644 --- a/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java +++ b/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java @@ -50,28 +50,28 @@ import java.nio.file.StandardOpenOption; * scenario14 javax.xml.soap.MessageFactory=saaj.factory.Valid saaj.factory.Valid2 - * * @modules java.xml.ws - * @compile -addmods java.xml.ws saaj/factory/Invalid.java saaj/factory/Valid.java + * @compile saaj/factory/Invalid.java saaj/factory/Valid.java * saaj/factory/Valid2.java saaj/factory/Valid3.java SAAJFactoryTest.java * - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl - scenario2 - - - * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.Valid + * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.Valid * SAAJFactoryTest saaj.factory.Valid - scenario5 - - - * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.NonExisting + * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.NonExisting * SAAJFactoryTest - javax.xml.soap.SOAPException scenario6 - - - * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.Invalid + * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.Invalid * SAAJFactoryTest - javax.xml.soap.SOAPException scenario7 - - - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest saaj.factory.Valid - scenario8 - saaj.factory.Valid - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest saaj.factory.Valid - scenario9 - saaj.factory.Valid - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest - javax.xml.soap.SOAPException scenario10 - saaj.factory.NonExisting - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest - javax.xml.soap.SOAPException scenario11 - saaj.factory.Invalid scenario11 - saaj.factory.Invalid - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl - scenario12 - - - * @run main/othervm -addmods java.xml.ws + * @run main/othervm * SAAJFactoryTest saaj.factory.Valid - scenario15 - saaj.factory.Valid */ public class SAAJFactoryTest { @@ -207,4 +207,3 @@ public class SAAJFactoryTest { } } - diff --git a/jdk/test/javax/xml/ws/8043129/MailTest.java b/jdk/test/javax/xml/ws/8043129/MailTest.java index c65247a9edc..1884316e667 100644 --- a/jdk/test/javax/xml/ws/8043129/MailTest.java +++ b/jdk/test/javax/xml/ws/8043129/MailTest.java @@ -28,8 +28,7 @@ * @author mkos * @library javax.mail.jar * @modules java.xml.ws - * @compile -addmods java.xml.ws MailTest.java - * @run main/othervm -addmods java.xml.ws MailTest + * @run main MailTest */ import javax.activation.CommandMap; diff --git a/jdk/test/javax/xml/ws/clientjar/TestWsImport.java b/jdk/test/javax/xml/ws/clientjar/TestWsImport.java index bc048e84b08..05f9d67dc40 100644 --- a/jdk/test/javax/xml/ws/clientjar/TestWsImport.java +++ b/jdk/test/javax/xml/ws/clientjar/TestWsImport.java @@ -25,8 +25,8 @@ * @test * @bug 8016271 8026405 * @summary wsimport -clientjar does not create portable jar on windows due to hardcoded '\' - * @compile -addmods java.xml.ws TestWsImport.java - * @run main/othervm -addmods java.xml.ws TestWsImport + * @modules java.xml.ws + * @run main TestWsImport */ import javax.xml.namespace.QName; diff --git a/jdk/test/javax/xml/ws/publish/WSTest.java b/jdk/test/javax/xml/ws/publish/WSTest.java index 8d15a739d9d..34ea7674bd8 100644 --- a/jdk/test/javax/xml/ws/publish/WSTest.java +++ b/jdk/test/javax/xml/ws/publish/WSTest.java @@ -26,8 +26,7 @@ * @bug 8146086 * @summary Publishing two webservices on same port fails with "java.net.BindException: Address already in use" * @modules java.xml.ws - * @compile -addmods java.xml.ws WSTest.java - * @run main/othervm -addmods java.xml.ws WSTest + * @run main/othervm WSTest */ import javax.jws.WebMethod; import javax.jws.WebService; diff --git a/jdk/test/javax/xml/ws/xsanymixed/Test.java b/jdk/test/javax/xml/ws/xsanymixed/Test.java index d62f03ae425..a3f8157c692 100644 --- a/jdk/test/javax/xml/ws/xsanymixed/Test.java +++ b/jdk/test/javax/xml/ws/xsanymixed/Test.java @@ -28,8 +28,7 @@ * no white space changes and no changes to namespace prefixes * @modules java.xml.ws * @run shell compile-wsdl.sh - * @compile -addmods java.xml.ws Test.java - * @run main/othervm -addmods java.xml.ws Test + * @run main/othervm Test */ import com.sun.net.httpserver.HttpServer; diff --git a/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java b/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java index cde316e58a4..754b2ada4ee 100644 --- a/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java +++ b/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java @@ -26,6 +26,8 @@ * @summary Basic test of VM::getRuntimeArguments * @library /lib/testlibrary * @modules java.base/jdk.internal.misc + * java.compact3 + * jdk.zipfs * @run testng RuntimeArguments */ @@ -45,21 +47,28 @@ public class RuntimeArguments { public Object[][] options() { return new Object[][] { { // CLI options - List.of("-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", - "-XaddExports:java.base/jdk.internal.perf=ALL-UNNAMED", - "-addmods", "jdk.zipfs"), + List.of("--add-exports", + "java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports", + "java.base/jdk.internal.perf=ALL-UNNAMED", + "--add-modules", + "jdk.zipfs"), // expected runtime arguments - List.of("-Djdk.launcher.addexports.0=java.base/jdk.internal.misc=ALL-UNNAMED", - "-Djdk.launcher.addexports.1=java.base/jdk.internal.perf=ALL-UNNAMED", - "-Djdk.launcher.addmods=jdk.zipfs") + List.of("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED", + "--add-modules=jdk.zipfs") }, { // CLI options - List.of("-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", - "-addmods", "jdk.zipfs", - "-limitmods", "java.compact3"), + List.of("--add-exports", + "java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-modules", + "jdk.zipfs", + "--limit-modules", + "java.compact3"), // expected runtime arguments - List.of("-Djdk.launcher.addexports.0=java.base/jdk.internal.misc=ALL-UNNAMED", - "-Djdk.launcher.addmods=jdk.zipfs", "-Djdk.launcher.limitmods=java.compact3") + List.of("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + "--add-modules=jdk.zipfs", + "--limit-modules=java.compact3"), }, }; }; diff --git a/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh index e2aa6f9f8d9..51ebb10b381 100644 --- a/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh +++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh @@ -55,7 +55,7 @@ BCP=${TESTCLASSES}/bcp rm -rf ${BCP} mkdir ${BCP} -EXTRAOPTS="-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED" # Compile GetCallerClass in bootclasspath ${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \ diff --git a/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java b/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java index 4c40455cf62..613a854faa2 100644 --- a/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java +++ b/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java @@ -26,7 +26,7 @@ * @summary Verify the defining class loader of each module never delegates * to its child class loader. Also sanity check java.compact2 * requires. - * @run testng/othervm -Djdk.launcher.addmods=ALL-SYSTEM VerifyModuleDelegation + * @run testng/othervm --add-modules=ALL-SYSTEM VerifyModuleDelegation */ import java.lang.module.ModuleDescriptor; @@ -51,11 +51,11 @@ public class VerifyModuleDelegation { private static final ModuleDescriptor COMPACT2 = new ModuleDescriptor.Builder(JAVA_COMPACT2) - .requires(MANDATED, JAVA_BASE) - .requires(PUBLIC, JAVA_COMPACT1) - .requires(PUBLIC, "java.rmi") - .requires(PUBLIC, "java.sql") - .requires(PUBLIC, "java.xml") + .requires(Set.of(MANDATED), JAVA_BASE) + .requires(Set.of(PUBLIC), JAVA_COMPACT1) + .requires(Set.of(PUBLIC), "java.rmi") + .requires(Set.of(PUBLIC), "java.sql") + .requires(Set.of(PUBLIC), "java.xml") .build(); private static final Set MREFS diff --git a/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java b/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java index 4d1ebcf322d..56bd84b154d 100644 --- a/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java +++ b/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java @@ -100,15 +100,15 @@ public class RunWithAutomaticModules { compiled = CompilerUtils .compile(SRC_DIR.resolve(testModule), MODS_DIR.resolve(testModule), - "-mp", MODS_DIR.toString()); + "--module-path", MODS_DIR.toString()); assertTrue(compiled); - // launch the test. Need -addmods because nothing explicitly depends on logging + // launch the test. Need --add-mdoules because nothing explicitly depends on logging int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "logging", + = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "logging", "-m", testModule + "/" + mainClass) .outputTo(System.out) .errorTo(System.out) @@ -159,7 +159,7 @@ public class RunWithAutomaticModules { compiled = CompilerUtils .compile(SRC_DIR.resolve(testModule), MODS_DIR.resolve(testModule), - "-mp", MODS_DIR.toString()); + "--module-path", MODS_DIR.toString()); assertTrue(compiled); @@ -167,7 +167,7 @@ public class RunWithAutomaticModules { // launch the test int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), + = executeTestJava("--module-path", MODS_DIR.toString(), "-m", testModule + "/" + mainClass) .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/jdk/modules/scenarios/container/ContainerTest.java b/jdk/test/jdk/modules/scenarios/container/ContainerTest.java index 36a7ac2c219..1ad5f352080 100644 --- a/jdk/test/jdk/modules/scenarios/container/ContainerTest.java +++ b/jdk/test/jdk/modules/scenarios/container/ContainerTest.java @@ -98,7 +98,7 @@ public class ContainerTest { compiled = CompilerUtils.compile(SRC_DIR.resolve("app1"), dir.resolve("app1"), - "-upgrademodulepath", dir.toString()); + "--upgrade-module-path", dir.toString()); assertTrue(compiled); } @@ -116,7 +116,7 @@ public class ContainerTest { compiled = CompilerUtils.compile(SRC_DIR.resolve("app2"), dir.resolve("app2"), - "-mp", dir.toString()); + "--module-path", dir.toString()); assertTrue(compiled); } @@ -134,7 +134,7 @@ public class ContainerTest { public void testContainer() throws Exception { int exitValue - = executeTestJava("-mp", MLIB_DIR.toString(), + = executeTestJava("--module-path", MLIB_DIR.toString(), "-m", CONTAINER_MODULE) .outputTo(System.out) .errorTo(System.err) diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java index 529996e8e7d..8dc2060bfee 100644 --- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java +++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java @@ -74,7 +74,7 @@ public class OverlappingPackagesTest { */ public void testNoOverlappingPackages() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), + = executeTestJava("--module-path", MODS_DIR.toString(), "-m", "test/test.Main") .outputTo(System.out) .errorTo(System.err) @@ -85,13 +85,13 @@ public class OverlappingPackagesTest { /** - * Run the test with "-addmods misc", the misc module has package + * Run the test with "--add-modules misc", the misc module has package * jdk.internal.misc and so should overlap with the base module. */ public void testOverlapWithBaseModule() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "misc", + = executeTestJava("--module-path", MODS_DIR.toString(), + "-add-modules", "misc", "-m", "test/test.Main") .outputTo(System.out) .errorTo(System.err) @@ -101,12 +101,12 @@ public class OverlappingPackagesTest { } /** - * Run the test with "-addmods m1,m2". Both modules have package p. + * Run the test with "--add-modules m1,m2". Both modules have package p. */ public void testOverlap() throws Exception { int exitValue - = executeTestJava("-mp", MODS_DIR.toString(), - "-addmods", "m1,m2", + = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "m1,m2", "-m", "test/test.Main") .outputTo(System.out) .errorTo(System.err) diff --git a/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java b/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java index 69b39bfb7e7..148b8e043bd 100644 --- a/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java +++ b/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java @@ -93,7 +93,7 @@ public class ShellFolderMemoryLeak { String command = javaPath + File.separator + "bin" + File.separator + "java -Xmx256M" + arg1 + " -cp " + classPathDir - + " -XaddExports:java.desktop/sun.awt.shell=ALL-UNNAMED" + + " --add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED" + " ShellFolderMemoryLeak " + arg2; process = Runtime.getRuntime().exec(command); BufferedReader input = null; diff --git a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index 75f3cdbba08..482e93e9128 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -150,7 +150,7 @@ public class CustomLauncherTest { ProcessBuilder client = ProcessTools.createJavaProcessBuilder( "-cp", TEST_CLASSPATH, - "-XaddExports:java.management/sun.management=ALL-UNNAMED", + "--add-exports", "java.management/sun.management=ALL-UNNAMED", "TestManager", String.valueOf(serverPrc.getPid()), port.get(), diff --git a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java index 2dd35555af1..28f5cb34661 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java @@ -131,7 +131,7 @@ public class LocalManagementTest { ProcessBuilder client = ProcessTools.createJavaProcessBuilder( "-cp", TEST_CLASSPATH, - "-XaddExports:java.management/sun.management=ALL-UNNAMED", + "--add-exports", "java.management/sun.management=ALL-UNNAMED", "TestManager", String.valueOf(serverPrc.getPid()), port.get(), diff --git a/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh b/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh index f0a93a6f78a..5b564809d08 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh +++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh @@ -51,8 +51,8 @@ chmod -R 777 ${TESTCLASSES}/ssl DEBUGOPTIONS="" export DEBUGOPTIONS -EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \ - -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED" +EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \ + --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED" export EXTRAOPTIONS # Call the common generic test diff --git a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh index 30f3a179149..539328e659a 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh +++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh @@ -49,8 +49,8 @@ chmod -R 777 ${TESTCLASSES}/ssl DEBUGOPTIONS="" export DEBUGOPTIONS -EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \ - -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED" +EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \ + --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED" export EXTRAOPTIONS # Call the common generic test diff --git a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh index 8cccc837ba0..6152efc59e1 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh +++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh @@ -48,8 +48,8 @@ chmod -R 777 ${TESTCLASSES}/ssl DEBUGOPTIONS="" export DEBUGOPTIONS -EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \ - -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED" +EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \ + --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED" export EXTRAOPTIONS # Call the common generic test diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh index c3b45f10a64..f079dac88ea 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh @@ -51,7 +51,7 @@ case "$OS" in ;; esac -EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED" ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . \ ${TESTSRC}${FS}OriginServer.java \ diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh index 79b99f0478e..1726d7092f0 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh @@ -51,7 +51,7 @@ case "$OS" in ;; esac -EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED" ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} \ -d . ${TESTSRC}${FS}OriginServer.java \ ${TESTSRC}${FS}ProxyTunnelServer.java \ diff --git a/jdk/test/sun/net/www/protocol/jrt/OtherResources.java b/jdk/test/sun/net/www/protocol/jrt/OtherResources.java index 9717d4dd4c2..4ba707dd05e 100644 --- a/jdk/test/sun/net/www/protocol/jrt/OtherResources.java +++ b/jdk/test/sun/net/www/protocol/jrt/OtherResources.java @@ -36,7 +36,7 @@ public class OtherResources { // check that java.desktop is not in the set of readable modules try { Class.forName("java.awt.Component"); - throw new RuntimeException("Need to run with -limitmods java.base"); + throw new RuntimeException("Need to run with --limit-modules java.base"); } catch (ClassNotFoundException expected) { } // access resource in the java.desktop module diff --git a/jdk/test/sun/net/www/protocol/jrt/other_resources.sh b/jdk/test/sun/net/www/protocol/jrt/other_resources.sh index 260891cf519..79903759092 100644 --- a/jdk/test/sun/net/www/protocol/jrt/other_resources.sh +++ b/jdk/test/sun/net/www/protocol/jrt/other_resources.sh @@ -26,7 +26,7 @@ # @run shell other_resources.sh # @summary Access a jrt:/ resource in an observable module that is not in # the boot layer and hence not known to the built-in class loaders. This -# test is a shell test because the run tag doesn't support -limitmods. +# test is a shell test because the run tag doesn't support --limit-modules. set -e @@ -39,7 +39,7 @@ if [ -z "$TESTJAVA" ]; then fi JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}" -$JAVA -limitmods java.base -cp $TESTCLASSES OtherResources +$JAVA --limit-modules java.base -cp $TESTCLASSES OtherResources exit 0 diff --git a/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java b/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java index eb591a5443d..96f30e96e15 100644 --- a/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java +++ b/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java @@ -30,8 +30,9 @@ * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp * @build TestLibrary - * @summary Compiles a PortableRemoteObject with rmic -iiop and ensures that stub and tie classes are generated. * @run main IIOPCompilation + * + * @summary Compiles a PortableRemoteObject with rmic -iiop and ensures that stub and tie classes are generated. * @author Felix Yang * */ diff --git a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java index a75a0420678..2c89e2b16b3 100644 --- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java +++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java @@ -68,10 +68,10 @@ public class NoConsoleOutput { // (neither on standard output, nor on standard err streams). JavaVM vm = new JavaVM( DoRMIStuff.class.getName(), - "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED" - + " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED" - + " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED" - + " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED" + + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" + " -Djava.util.logging.config.file=" + loggingPropertiesFile, "", out, err); vm.execute(); diff --git a/jdk/test/sun/security/krb5/ccache/EmptyCC.java b/jdk/test/sun/security/krb5/ccache/EmptyCC.java index 28281584f16..d5cfc4d557f 100644 --- a/jdk/test/sun/security/krb5/ccache/EmptyCC.java +++ b/jdk/test/sun/security/krb5/ccache/EmptyCC.java @@ -27,7 +27,8 @@ * @bug 8001208 * @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds() * @library ../../../../java/security/testlibrary/ - * @modules java.security.jgss/sun.security.krb5 + * @modules java.base/jdk.internal.misc + * java.security.jgss/sun.security.krb5 * java.security.jgss/sun.security.krb5.internal.ccache * @compile -XDignore.symbol.file EmptyCC.java * @run main EmptyCC tmpcc diff --git a/jdk/test/sun/security/krb5/tools/ktcheck.sh b/jdk/test/sun/security/krb5/tools/ktcheck.sh index e7077b42e89..a2759b72c2e 100644 --- a/jdk/test/sun/security/krb5/tools/ktcheck.sh +++ b/jdk/test/sun/security/krb5/tools/ktcheck.sh @@ -61,8 +61,8 @@ rm $KEYTAB EXTRA_OPTIONS="-Djava.security.krb5.conf=${TESTSRC}${FS}onlythree.conf" KTAB="${TESTJAVA}${FS}bin${FS}ktab -J${EXTRA_OPTIONS} -k $KEYTAB -f" CHECK="${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} ${TESTVMOPTS} ${EXTRA_OPTIONS} \ - -XaddExports:java.security.jgss/sun.security.krb5.internal.ktab=ALL-UNNAMED \ - -XaddExports:java.security.jgss/sun.security.krb5=ALL-UNNAMED \ + --add-exports java.security.jgss/sun.security.krb5.internal.ktab=ALL-UNNAMED \ + --add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED \ KtabCheck $KEYTAB" echo ${EXTRA_OPTIONS} diff --git a/jdk/test/sun/security/mscapi/PublicKeyInterop.sh b/jdk/test/sun/security/mscapi/PublicKeyInterop.sh index 5110a4b50c5..fc1550f9ab4 100644 --- a/jdk/test/sun/security/mscapi/PublicKeyInterop.sh +++ b/jdk/test/sun/security/mscapi/PublicKeyInterop.sh @@ -62,9 +62,9 @@ case "$OS" in echo echo "Running the test..." - ${TESTJAVA}/bin/javac -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ + ${TESTJAVA}/bin/javac --add-exports java.base/sun.security.util=ALL-UNNAMED \ ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . ${TESTSRC}\\PublicKeyInterop.java - ${TESTJAVA}/bin/java -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ + ${TESTJAVA}/bin/java --add-exports java.base/sun.security.util=ALL-UNNAMED \ ${TESTVMOPTS} PublicKeyInterop rc=$? diff --git a/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh b/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh index 091f3d9ba34..6cad1821ff6 100644 --- a/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh +++ b/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh @@ -88,10 +88,10 @@ case "$OS" in echo echo "Running the test..." - ${TESTJAVA}${FS}bin${FS}javac -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ + ${TESTJAVA}${FS}bin${FS}javac --add-exports java.base/sun.security.util=ALL-UNNAMED \ ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . \ ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java - ${TESTJAVA}${FS}bin${FS}java -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ + ${TESTJAVA}${FS}bin${FS}java --add-exports java.base/sun.security.util=ALL-UNNAMED \ ${TESTVMOPTS} ShortRSAKeyWithinTLS 7106773.$BITS $BITS \ TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA diff --git a/jdk/test/sun/security/provider/PolicyFile/Modules.java b/jdk/test/sun/security/provider/PolicyFile/Modules.java index 914ef05790d..fa7d33a8fd9 100644 --- a/jdk/test/sun/security/provider/PolicyFile/Modules.java +++ b/jdk/test/sun/security/provider/PolicyFile/Modules.java @@ -33,14 +33,14 @@ * java.sql * java.xml * java.xml.bind + * java.xml.ws * jdk.attach * jdk.jdi * jdk.net * jdk.security.auth * jdk.security.jgss - * @compile -addmods java.xml.ws,java.smartcardio Modules.java - * @run main/othervm/java.security.policy==modules.policy - * -addmods java.xml.ws,java.smartcardio Modules + * @compile --add-modules=java.xml.ws,java.smartcardio Modules.java + * @run main/othervm/java.security.policy==modules.policy Modules */ import java.security.AccessController; diff --git a/jdk/test/sun/security/tools/jarsigner/AltProvider.java b/jdk/test/sun/security/tools/jarsigner/AltProvider.java index 5c7e5a286c0..b93455670b9 100644 --- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java +++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java @@ -55,7 +55,7 @@ public class AltProvider { // Compile the provider CompilerUtils.compile( MOD_SRC_DIR, MOD_DEST_DIR, - "-modulesourcepath", + "--module-source-path", MOD_SRC_DIR.toString()); // Create a keystore @@ -102,22 +102,22 @@ public class AltProvider { 0, "loadProviderByClass: org.test.dummy.DummyProvider"); // name in a module - testBoth("-J-mp -Jmods " + + testBoth("-J--module-path=mods " + "-addprovider Dummy -providerArg full", 0, "loadProviderByName: Dummy"); // -providerClass does not work - testBoth("-J-mp -Jmods " + + testBoth("-J--module-path=mods " + "-providerClass org.test.dummy.DummyProvider -providerArg full", 1, "Provider \"org.test.dummy.DummyProvider\" not found"); // -addprovider with class does not work - testBoth("-J-mp -Jmods " + + testBoth("-J--module-path=mods " + "-addprovider org.test.dummy.DummyProvider -providerArg full", 1, "Provider named \"org.test.dummy.DummyProvider\" not found"); // -addprovider without arg does not work - testBoth("-J-mp -Jmods " + + testBoth("-J--module-path=mods " + "-addprovider Dummy", 1, "DUMMYKS not found"); } diff --git a/jdk/test/sun/security/tools/jarsigner/ts.sh b/jdk/test/sun/security/tools/jarsigner/ts.sh index 386e0507b66..925377ca999 100644 --- a/jdk/test/sun/security/tools/jarsigner/ts.sh +++ b/jdk/test/sun/security/tools/jarsigner/ts.sh @@ -94,10 +94,10 @@ $KT -alias tsbad3 -certreq | \ $KT -alias ca -gencert -ext eku:critical=cs | \ $KT -alias tsbad3 -importcert -EXTRAOPTS="-XaddExports:java.base/sun.security.pkcs=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.timestamp=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.x509=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.util=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.security.pkcs=ALL-UNNAMED \ + --add-exports java.base/sun.security.timestamp=ALL-UNNAMED \ + --add-exports java.base/sun.security.x509=ALL-UNNAMED \ + --add-exports java.base/sun.security.util=ALL-UNNAMED" $JAVAC ${EXTRAOPTS} -d . ${TESTSRC}/TimestampCheck.java $JAVA ${TESTVMOPTS} ${EXTRAOPTS} "-Dtest.tool.vm.opts=${TESTTOOLVMOPTS}" TimestampCheck diff --git a/jdk/test/sun/security/tools/keytool/autotest.sh b/jdk/test/sun/security/tools/keytool/autotest.sh index de8d94ffa5d..b97310ecc64 100644 --- a/jdk/test/sun/security/tools/keytool/autotest.sh +++ b/jdk/test/sun/security/tools/keytool/autotest.sh @@ -100,9 +100,9 @@ fi echo "Using NSS lib at $LIBNAME" -EXTRAOPTS="-XaddExports:java.base/sun.security.tools.keytool=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.x509=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED \ + --add-exports java.base/sun.security.util=ALL-UNNAMED \ + --add-exports java.base/sun.security.x509=ALL-UNNAMED" ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file \ ${TESTSRC}${FS}KeyToolTest.java || exit 10 diff --git a/jdk/test/sun/security/tools/keytool/standard.sh b/jdk/test/sun/security/tools/keytool/standard.sh index 3c3d86718e7..38fadb8c495 100644 --- a/jdk/test/sun/security/tools/keytool/standard.sh +++ b/jdk/test/sun/security/tools/keytool/standard.sh @@ -58,9 +58,9 @@ case "$OS" in ;; esac -EXTRAOPTS="-XaddExports:java.base/sun.security.tools.keytool=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.util=ALL-UNNAMED \ - -XaddExports:java.base/sun.security.x509=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED \ + --add-exports java.base/sun.security.util=ALL-UNNAMED \ + --add-exports java.base/sun.security.x509=ALL-UNNAMED" ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . -XDignore.symbol.file ${TESTSRC}${FS}KeyToolTest.java || exit 10 diff --git a/jdk/test/sun/security/validator/certreplace.sh b/jdk/test/sun/security/validator/certreplace.sh index e32d638f0f9..78b27e8f99f 100644 --- a/jdk/test/sun/security/validator/certreplace.sh +++ b/jdk/test/sun/security/validator/certreplace.sh @@ -83,6 +83,6 @@ $KT -delete -alias user # 5. Build and run test -EXTRAOPTS="-XaddExports:java.base/sun.security.validator=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.security.validator=ALL-UNNAMED" $JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . ${TESTSRC}${FS}CertReplace.java $JAVA ${TESTVMOPTS} ${EXTRAOPTS} CertReplace certreplace.jks certreplace.certs diff --git a/jdk/test/sun/security/validator/samedn.sh b/jdk/test/sun/security/validator/samedn.sh index acfa49e0914..6a30b147157 100644 --- a/jdk/test/sun/security/validator/samedn.sh +++ b/jdk/test/sun/security/validator/samedn.sh @@ -79,7 +79,7 @@ $KT -delete -alias user # 5. Build and run test. Make sure the CA certs are ignored for validity check. # Check both, one of them might be dropped out of map in old codes. -EXTRAOPTS="-XaddExports:java.base/sun.security.validator=ALL-UNNAMED" +EXTRAOPTS="--add-exports java.base/sun.security.validator=ALL-UNNAMED" $JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . ${TESTSRC}${FS}CertReplace.java $JAVA ${TESTVMOPTS} ${EXTRAOPTS} CertReplace samedn.jks samedn1.certs || exit 1 $JAVA ${TESTVMOPTS} ${EXTRAOPTS} CertReplace samedn.jks samedn2.certs || exit 2 diff --git a/jdk/test/sun/text/IntHashtable/Bug4170614Test.sh b/jdk/test/sun/text/IntHashtable/Bug4170614Test.sh index b8dad0084a6..0c31934d01c 100644 --- a/jdk/test/sun/text/IntHashtable/Bug4170614Test.sh +++ b/jdk/test/sun/text/IntHashtable/Bug4170614Test.sh @@ -63,7 +63,7 @@ ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ -Xmodule:java.base \ -d ${TEST_JAVABASE} Bug4170614Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xpatch:java.base=${TEST_JAVABASE} java.text.Bug4170614Test +${TESTJAVA}/bin/java ${TESTVMOPTS} --patch-module java.base=${TEST_JAVABASE} java.text.Bug4170614Test result=$? diff --git a/jdk/test/sun/tools/java/CFCTest.java b/jdk/test/sun/tools/java/CFCTest.java index 4dea1a57bc8..bae7d735461 100644 --- a/jdk/test/sun/tools/java/CFCTest.java +++ b/jdk/test/sun/tools/java/CFCTest.java @@ -24,9 +24,11 @@ /* * @test * @bug 8011805 - * @modules jdk.rmic/sun.tools.java jdk.rmic/sun.rmi.rmic * @summary Update sun.tools.java class file reading/writing support to include * the new constant pool entries (including invokedynamic) + * @modules jdk.rmic/sun.rmi.rmic + * jdk.rmic/sun.tools.java + * @run main CFCTest */ import java.io.DataInputStream; diff --git a/jdk/test/sun/util/locale/provider/Bug8038436.java b/jdk/test/sun/util/locale/provider/Bug8038436.java index 3f8179ba0d2..e112ed51804 100644 --- a/jdk/test/sun/util/locale/provider/Bug8038436.java +++ b/jdk/test/sun/util/locale/provider/Bug8038436.java @@ -28,7 +28,7 @@ * @modules java.base/sun.util.locale.provider * java.base/sun.util.spi * @compile -XDignore.symbol.file Bug8038436.java - * @run main/othervm -limitmods java.base Bug8038436 security + * @run main/othervm --limit-modules java.base Bug8038436 security * @run main/othervm -Djava.locale.providers=COMPAT Bug8038436 availlocs */ @@ -69,7 +69,7 @@ public class Bug8038436 { /* * Check only English/ROOT locales are returned if the jdk.localedata - * module is not loaded (implied by "-limitmods java.base"). + * module is not loaded (implied by "--limit-modules java.base"). */ List nonEnglishLocales= (Arrays.stream(Locale.getAvailableLocales()) .filter(l -> (l != Locale.ROOT && !(l.getLanguage() == "en" && (l.getCountry() == "US" || l.getCountry() == "" )))) diff --git a/jdk/test/tools/jar/modularJar/Basic.java b/jdk/test/tools/jar/modularJar/Basic.java index 396a5fa9f8f..073eabc9896 100644 --- a/jdk/test/tools/jar/modularJar/Basic.java +++ b/jdk/test/tools/jar/modularJar/Basic.java @@ -460,7 +460,7 @@ public class Basic { "--no-manifest", "-C", barModInfo.toString(), "module-info.class") // stuff in bar's info .assertSuccess(); - jar("-p", + jar("-d", "--file=" + modularJar.toString()) .assertSuccess() .resultChecker(r -> { @@ -499,14 +499,14 @@ public class Basic { "--file=" + modularJar.toString(), "--main-class=" + FOO.mainClass, "--module-version=" + FOO.version, - "--modulepath=" + mp.toString(), + "--module-path=" + mp.toString(), "--hash-modules=" + "bar", "--no-manifest", "-C", modClasses.toString(), ".") .assertSuccess(); java(mp, BAR.moduleName + "/" + BAR.mainClass, - "-XaddExports:java.base/jdk.internal.module=bar") + "--add-exports", "java.base/jdk.internal.module=bar") .assertSuccess() .resultChecker(r -> { assertModuleData(r, BAR); @@ -535,7 +535,7 @@ public class Basic { "--file=" + fooJar.toString(), "--main-class=" + FOO.mainClass, "--module-version=" + FOO.version, - "--modulepath=" + mp.toString(), + "-p", mp.toString(), // test short-form "--hash-modules=" + "bar", "--no-manifest", "-C", fooClasses.toString(), ".").assertSuccess(); @@ -550,7 +550,7 @@ public class Basic { "-C", barClasses.toString(), ".").assertSuccess(); java(mp, BAR.moduleName + "/" + BAR.mainClass, - "-XaddExports:java.base/jdk.internal.module=bar") + "--add-exports", "java.base/jdk.internal.module=bar") .assertFailure() .resultChecker(r -> { // Expect similar output: "java.lang.module.ResolutionException: Hash @@ -684,7 +684,7 @@ public class Basic { "-C", modClasses.toString(), ".") .assertSuccess(); - for (String option : new String[] {"--print-module-descriptor", "-p" }) { + for (String option : new String[] {"--print-module-descriptor", "-d" }) { jar(option, "--file=" + modularJar.toString()) .assertSuccess() @@ -711,7 +711,7 @@ public class Basic { "-C", modClasses.toString(), ".") .assertSuccess(); - for (String option : new String[] {"--print-module-descriptor", "-p" }) { + for (String option : new String[] {"--print-module-descriptor", "-d" }) { jarWithStdin(modularJar.toFile(), option) .assertSuccess() @@ -815,10 +815,12 @@ public class Basic { } commands.add("-d"); commands.add(dest.toString()); - if (dest.toString().contains("bar")) - commands.add("-XaddExports:java.base/jdk.internal.module=bar"); + if (dest.toString().contains("bar")) { + commands.add("--add-exports"); + commands.add("java.base/jdk.internal.module=bar"); + } if (modulePath != null) { - commands.add("-mp"); + commands.add("--module-path"); commands.add(modulePath.toString()); } Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x)); @@ -838,7 +840,7 @@ public class Basic { commands.addAll(Arrays.asList(JAVA_OPTIONS.split("\\s+", -1))); } Stream.of(args).forEach(x -> commands.add(x)); - commands.add("-mp"); + commands.add("--module-path"); commands.add(modulePath.toString()); commands.add("-m"); commands.add(entryPoint); diff --git a/jdk/test/tools/jimage/VerifyJimage.java b/jdk/test/tools/jimage/VerifyJimage.java index 5056e6322a5..30628ad9921 100644 --- a/jdk/test/tools/jimage/VerifyJimage.java +++ b/jdk/test/tools/jimage/VerifyJimage.java @@ -49,7 +49,7 @@ import jdk.internal.jimage.ImageLocation; * @test * @summary Verify jimage * @modules java.base/jdk.internal.jimage - * @run main/othervm -Djdk.launcher.addmods=ALL-SYSTEM VerifyJimage + * @run main/othervm --add-modules=ALL-SYSTEM VerifyJimage */ /** diff --git a/jdk/test/tools/jlink/CustomPluginTest.java b/jdk/test/tools/jlink/CustomPluginTest.java index 34e4d4b1a5e..dc7a774ca51 100644 --- a/jdk/test/tools/jlink/CustomPluginTest.java +++ b/jdk/test/tools/jlink/CustomPluginTest.java @@ -93,7 +93,8 @@ public class CustomPluginTest { String name = "customplugin"; Path src = Paths.get(System.getProperty("test.src")).resolve(name); Path classes = helper.getJmodClassesDir().resolve(name); - JImageGenerator.compile(src, classes, "-XaddExports:jdk.jlink/jdk.tools.jlink.internal=customplugin"); + JImageGenerator.compile(src, classes, + "--add-exports", "jdk.jlink/jdk.tools.jlink.internal=customplugin"); return JImageGenerator.getJModTask() .addClassPath(classes) .jmod(helper.getJmodDir().resolve(name + ".jmod")) diff --git a/jdk/test/tools/jlink/JLinkNegativeTest.java b/jdk/test/tools/jlink/JLinkNegativeTest.java index 4a1dcf117fe..9213626dfeb 100644 --- a/jdk/test/tools/jlink/JLinkNegativeTest.java +++ b/jdk/test/tools/jlink/JLinkNegativeTest.java @@ -95,7 +95,7 @@ public class JLinkNegativeTest { } public void testNotExistInAddMods() { - // cannot find jmod from --addmods + // cannot find jmod from --add-modules JImageGenerator.getJLinkTask() .modulePath(".") .addMods("not_exist") diff --git a/jdk/test/tools/jlink/JLinkTest.java b/jdk/test/tools/jlink/JLinkTest.java index 189be842854..620d5c85e84 100644 --- a/jdk/test/tools/jlink/JLinkTest.java +++ b/jdk/test/tools/jlink/JLinkTest.java @@ -118,7 +118,7 @@ public class JLinkTest { .output(helper.createNewImageDir(moduleName)) .addMods("leaf1") .option("") - .call().assertFailure("Error: no value given for --modulepath"); + .call().assertFailure("Error: no value given for --module-path"); } { @@ -250,7 +250,7 @@ public class JLinkTest { // @file { Path path = Paths.get("embedded.properties"); - Files.write(path, Collections.singletonList("--strip-debug --addmods " + + Files.write(path, Collections.singletonList("--strip-debug --add-modules " + "toto.unknown --compress UNKNOWN\n")); String[] userOptions = {"@", path.toAbsolutePath().toString()}; String moduleName = "configembeddednocompresscomposite2"; diff --git a/jdk/test/tools/jlink/basic/BasicTest.java b/jdk/test/tools/jlink/basic/BasicTest.java index 4135f4a2141..780cbca9cbc 100644 --- a/jdk/test/tools/jlink/basic/BasicTest.java +++ b/jdk/test/tools/jlink/basic/BasicTest.java @@ -106,8 +106,8 @@ public class BasicTest { private void runJlink(Path image, String modName, String... options) { List args = new ArrayList<>(); Collections.addAll(args, - "--modulepath", jdkMods + File.pathSeparator + jmods, - "--addmods", modName, + "--module-path", jdkMods + File.pathSeparator + jmods, + "--add-modules", modName, "--output", image.toString()); Collections.addAll(args, options); int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out)); diff --git a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java index ae0a32e8436..a56da486ba0 100644 --- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java +++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java @@ -73,7 +73,7 @@ public class UserModuleTest { for (String mn : modules) { Path msrc = SRC_DIR.resolve(mn); - assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); + assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); } if (Files.exists(IMAGE)) { @@ -87,8 +87,8 @@ public class UserModuleTest { Path jlink = Paths.get(JAVA_HOME, "bin", "jlink"); String mp = JMODS.toString() + File.pathSeparator + MODS_DIR.toString(); assertTrue(executeProcess(jlink.toString(), "--output", outputDir.toString(), - "--addmods", Arrays.stream(modules).collect(Collectors.joining(",")), - "--modulepath", mp) + "--add-modules", Arrays.stream(modules).collect(Collectors.joining(",")), + "--module-path", mp) .outputTo(System.out) .errorTo(System.out) .getExitValue() == 0); diff --git a/jdk/test/tools/jmod/JmodNegativeTest.java b/jdk/test/tools/jmod/JmodNegativeTest.java index bb75c3cae65..317587f5fb5 100644 --- a/jdk/test/tools/jmod/JmodNegativeTest.java +++ b/jdk/test/tools/jmod/JmodNegativeTest.java @@ -314,7 +314,7 @@ public class JmodNegativeTest { jmod("create", "--class-path", cp, "--hash-modules", ".*", - "--modulepath", emptyDir.toString(), + "--module-path", emptyDir.toString(), jmod.toString()) .resultChecker(r -> assertContains(r.output, "No hashes recorded: " + @@ -335,7 +335,7 @@ public class JmodNegativeTest { jmod("create", "--class-path", cp, "--hash-modules", ".*", - "--modulepath", MODS_DIR.toString(), + "--module-path", MODS_DIR.toString(), jmod.toString()) .assertFailure(); } finally { @@ -353,7 +353,7 @@ public class JmodNegativeTest { jmod("create", "--hash-modules", ".*", - "--modulepath", file.toString(), + "--module-path", file.toString(), jmod.toString()) .assertFailure() .resultChecker(r -> @@ -370,7 +370,7 @@ public class JmodNegativeTest { List> tasks = Arrays.asList( () -> jmod("create", "--hash-modules", "anyPattern", - "--modulepath", "doesNotExist", + "--module-path", "doesNotExist", "output.jmod"), () -> jmod("create", "--class-path", "doesNotExist", @@ -418,7 +418,7 @@ public class JmodNegativeTest { List> tasks = Arrays.asList( () -> jmod("create", "--hash-modules", "anyPattern", - "--modulepath","empty" + pathSeparator + "doesNotExist", + "--module-path","empty" + pathSeparator + "doesNotExist", "output.jmod"), () -> jmod("create", "--class-path", "empty" + pathSeparator + "doesNotExist", @@ -467,7 +467,7 @@ public class JmodNegativeTest { "--class-path", "aFile.txt", "output.jmod"), () -> jmod("create", - "--modulepath", "aFile.txt", + "--module-path", "aFile.txt", "output.jmod"), () -> jmod("create", "--cmds", "aFile.txt", diff --git a/jdk/test/tools/jmod/hashes/HashesTest.java b/jdk/test/tools/jmod/hashes/HashesTest.java index 243ecbd8190..616d393b97a 100644 --- a/jdk/test/tools/jmod/hashes/HashesTest.java +++ b/jdk/test/tools/jmod/hashes/HashesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -88,7 +88,7 @@ public class HashesTest { // build m1 compileModule("m1", modSrc); // no hash is recorded since m1 has outgoing edges - jmod("m1", "--modulepath", jmods.toString(), "--hash-modules", ".*"); + jmod("m1", "--module-path", jmods.toString(), "--hash-modules", ".*"); // compile org.bar and org.foo compileModule("org.bar", modSrc); @@ -109,17 +109,17 @@ public class HashesTest { } // hash m1 in m2 - jmod("m2", "--modulepath", jmods.toString(), "--hash-modules", "m1"); + jmod("m2", "--module-path", jmods.toString(), "--hash-modules", "m1"); checkHashes(hashes("m2").get(), "m1"); // hash m1 in m2 - jmod("m2", "--modulepath", jmods.toString(), "--hash-modules", ".*"); + jmod("m2", "--module-path", jmods.toString(), "--hash-modules", ".*"); checkHashes(hashes("m2").get(), "m1"); // create m2.jmod with no hash jmod("m2"); // run jmod hash command to hash m1 in m2 and m3 - runJmod(Arrays.asList("hash", "--modulepath", jmods.toString(), + runJmod(Arrays.asList("hash", "--module-path", jmods.toString(), "--hash-modules", ".*")); checkHashes(hashes("m2").get(), "m1"); checkHashes(hashes("m3").get(), "m1"); @@ -127,10 +127,10 @@ public class HashesTest { jmod("org.bar"); jmod("org.foo"); - jmod("org.bar", "--modulepath", jmods.toString(), "--hash-modules", "org.*"); + jmod("org.bar", "--module-path", jmods.toString(), "--hash-modules", "org.*"); checkHashes(hashes("org.bar").get(), "org.foo"); - jmod("m3", "--modulepath", jmods.toString(), "--hash-modules", ".*"); + jmod("m3", "--module-path", jmods.toString(), "--hash-modules", ".*"); checkHashes(hashes("m3").get(), "org.foo", "org.bar", "m1"); } @@ -185,7 +185,7 @@ public class HashesTest { private void compileModule(String moduleName, Path src) throws IOException { Path msrc = src.resolve(moduleName); - assertTrue(CompilerUtils.compile(msrc, mods, "-modulesourcepath", src.toString())); + assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString())); } private void jmod(String moduleName, String... options) throws IOException { diff --git a/jdk/test/tools/launcher/MiscTests.java b/jdk/test/tools/launcher/MiscTests.java index 7b82abc4f48..e9a71e5f224 100644 --- a/jdk/test/tools/launcher/MiscTests.java +++ b/jdk/test/tools/launcher/MiscTests.java @@ -70,7 +70,7 @@ public class MiscTests extends TestHelper { final String mainClass = "Foo6856415"; final String exportOpts - = "-XaddExports:jdk.crypto.pkcs11/sun.security.pkcs11=ALL-UNNAMED"; + = "--add-exports=jdk.crypto.pkcs11/sun.security.pkcs11=ALL-UNNAMED"; List scratch = new ArrayList<>(); scratch.add("public class Foo6856415 {"); diff --git a/jdk/test/tools/launcher/ToolsOpts.java b/jdk/test/tools/launcher/ToolsOpts.java index 4b4a32bde2b..f8920c6acd7 100644 --- a/jdk/test/tools/launcher/ToolsOpts.java +++ b/jdk/test/tools/launcher/ToolsOpts.java @@ -151,7 +151,7 @@ public class ToolsOpts extends TestHelper { init(); TestResult tr; int jpos = -1; - String xPatch = "-J-Xpatch:jdk.compiler=jdk.compiler"; + String xPatch = "-J--patch-module=jdk.compiler=jdk.compiler"; for (String arg[] : optionPatterns) { jpos = indexOfJoption(arg); //Build a cmd string for output in results reporting. diff --git a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java index 414e0d99f1e..8142c4af193 100644 --- a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java +++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java @@ -27,7 +27,7 @@ * @modules jdk.compiler * @build AddExportsTest CompilerUtils jdk.testlibrary.* * @run testng AddExportsTest - * @summary Basic tests for java -XaddExports + * @summary Basic tests for java --add-exports */ import java.nio.file.Path; @@ -71,7 +71,7 @@ public class AddExportsTest { boolean compiled = CompilerUtils.compile( SRC_DIR.resolve(TEST1_MODULE), MODS_DIR.resolve(TEST1_MODULE), - "-XaddExports:java.base/jdk.internal.misc=m1"); + "--add-exports", "java.base/jdk.internal.misc=m1"); assertTrue(compiled, "module " + TEST1_MODULE + " did not compile"); // javac -d upgrademods/java.transaction src/java.transaction/** @@ -80,12 +80,12 @@ public class AddExportsTest { UPGRADE_MODS_DIRS.resolve("java.transaction")); assertTrue(compiled, "module java.transaction did not compile"); - // javac -upgrademodulepath upgrademods -d mods/m2 src/m2/** + // javac --upgrade-module-path upgrademods -d mods/m2 src/m2/** compiled = CompilerUtils.compile( SRC_DIR.resolve(TEST2_MODULE), MODS_DIR.resolve(TEST2_MODULE), - "-upgrademodulepath", UPGRADE_MODS_DIRS.toString(), - "-XaddExports:java.transaction/javax.transaction.internal=m2"); + "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), + "--add-exports", "java.transaction/javax.transaction.internal=m2"); assertTrue(compiled, "module " + TEST2_MODULE + " did not compile"); // javac -d mods/m3 src/m3/** @@ -107,7 +107,7 @@ public class AddExportsTest { public void testSanity() throws Exception { int exitValue - = executeTestJava("-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED", + = executeTestJava("--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", "-version") .outputTo(System.out) .errorTo(System.out) @@ -122,12 +122,12 @@ public class AddExportsTest { */ public void testUnnamedModule() throws Exception { - // java -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED \ + // java --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ // -cp mods/$TESTMODULE jdk.test.UsesUnsafe String classpath = MODS_DIR.resolve(TEST1_MODULE).toString(); int exitValue - = executeTestJava("-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", + = executeTestJava("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "-cp", classpath, TEST1_MAIN_CLASS) .outputTo(System.out) @@ -143,13 +143,13 @@ public class AddExportsTest { */ public void testNamedModule() throws Exception { - // java -XaddExports:java.base/jdk.internal.misc=test \ - // -mp mods -m $TESTMODULE/$MAIN_CLASS + // java --add-exports java.base/jdk.internal.misc=test \ + // --module-path mods -m $TESTMODULE/$MAIN_CLASS String mid = TEST1_MODULE + "/" + TEST1_MAIN_CLASS; int exitValue = - executeTestJava("-XaddExports:java.base/jdk.internal.misc=" + TEST1_MODULE, - "-mp", MODS_DIR.toString(), + executeTestJava("--add-exports", "java.base/jdk.internal.misc=" + TEST1_MODULE, + "--module-path", MODS_DIR.toString(), "-m", mid) .outputTo(System.out) .errorTo(System.out) @@ -160,17 +160,17 @@ public class AddExportsTest { /** - * Test -XaddExports with upgraded module + * Test --add-exports with upgraded module */ public void testWithUpgradedModule() throws Exception { - // java -XaddExports:java.transaction/javax.transaction.internal=m2 - // -upgrademodulepath upgrademods -mp mods -m ... + // java --add-exports java.transaction/javax.transaction.internal=m2 + // --upgrade-module-path upgrademods --module-path mods -m ... String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS; int exitValue = executeTestJava( - "-XaddExports:java.transaction/javax.transaction.internal=m2", - "-upgrademodulepath", UPGRADE_MODS_DIRS.toString(), - "-mp", MODS_DIR.toString(), + "--add-exports", "java.transaction/javax.transaction.internal=m2", + "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), + "--module-path", MODS_DIR.toString(), "-m", mid) .outputTo(System.out) .errorTo(System.out) @@ -181,17 +181,17 @@ public class AddExportsTest { /** - * Test -XaddExports with module that is added to the set of root modules - * with -addmods. + * Test --add-exports with module that is added to the set of root modules + * with --add-modules. */ public void testWithAddMods() throws Exception { - // java -XaddExports:m4/jdk.test4=m3 -mp mods -m ... + // java --add-exports m4/jdk.test4=m3 --module-path mods -m ... String mid = TEST3_MODULE + "/" + TEST3_MAIN_CLASS; int exitValue = executeTestJava( - "-XaddExports:m4/jdk.test4=m3", - "-mp", MODS_DIR.toString(), - "-addmods", TEST4_MODULE, + "--add-exports", "m4/jdk.test4=m3", + "--module-path", MODS_DIR.toString(), + "--add-modules", TEST4_MODULE, "-m", mid) .outputTo(System.out) .errorTo(System.out) @@ -202,13 +202,13 @@ public class AddExportsTest { /** - * -XaddExports can only be specified once + * --add-exports can only be specified once */ public void testWithDuplicateOption() throws Exception { int exitValue - = executeTestJava("-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED", - "-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED", + = executeTestJava("--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", + "--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", "-version") .outputTo(System.out) .errorTo(System.out) @@ -220,14 +220,14 @@ public class AddExportsTest { /** - * Exercise -XaddExports with bad values + * Exercise --add-exports with bad values */ @Test(dataProvider = "badvalues") public void testWithBadValue(String value, String ignore) throws Exception { - // -XaddExports:$VALUE -version + // --add-exports $VALUE -version int exitValue = - executeTestJava("-XaddExports:" + value, + executeTestJava("--add-exports", value, "-version") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/tools/launcher/modules/addmods/AddModsTest.java b/jdk/test/tools/launcher/modules/addmods/AddModsTest.java index b1fe43c9a29..3ace33457bc 100644 --- a/jdk/test/tools/launcher/modules/addmods/AddModsTest.java +++ b/jdk/test/tools/launcher/modules/addmods/AddModsTest.java @@ -28,7 +28,7 @@ * jdk.compiler * @build AddModsTest CompilerUtils jdk.testlibrary.* * @run testng AddModsTest - * @summary Basic test for java -addmods + * @summary Basic test for java --add-modules */ import java.nio.file.Path; @@ -78,15 +78,15 @@ public class AddModsTest { /** - * Basic test of -addmods ALL-DEFAULT. Module java.sql should be + * Basic test of --add-modules ALL-DEFAULT. Module java.sql should be * resolved and the types in that module should be visible. */ public void testAddDefaultModules1() throws Exception { - // java -addmods ALL-DEFAULT -mp mods1 -m test ... + // java --add-modules ALL-DEFAULT --module-path mods1 -m test ... int exitValue - = executeTestJava("-mp", MODS1_DIR.toString(), - "-addmods", "ALL-DEFAULT", + = executeTestJava("--module-path", MODS1_DIR.toString(), + "--add-modules", "ALL-DEFAULT", "-m", TEST_MID, "java.sql.Connection") .outputTo(System.out) @@ -97,16 +97,16 @@ public class AddModsTest { } /** - * Basic test of -addmods ALL-DEFAULT. Module java.annotations.common + * Basic test of --add-modules ALL-DEFAULT. Module java.annotations.common * should not resolved and so the types in that module should not be * visible. */ public void testAddDefaultModules2() throws Exception { - // java -addmods ALL-DEFAULT -mp mods1 -m test ... + // java --add-modules ALL-DEFAULT --module-path mods1 -m test ... int exitValue - = executeTestJava("-mp", MODS1_DIR.toString(), - "-addmods", "ALL-DEFAULT", + = executeTestJava("--module-path", MODS1_DIR.toString(), + "--add-modules", "ALL-DEFAULT", "-m", TEST_MID, "javax.annotation.Generated") .outputTo(System.out) @@ -118,15 +118,15 @@ public class AddModsTest { } /** - * Basic test of -addmods ALL-SYSTEM. All system modules should be resolved + * Basic test of --add-modules ALL-SYSTEM. All system modules should be resolved * and thus all types in those modules should be visible. */ public void testAddSystemModules() throws Exception { - // java -addmods ALL-SYSTEM -mp mods1 -m test ... + // java --add-modules ALL-SYSTEM --module-path mods1 -m test ... int exitValue - = executeTestJava("-mp", MODS1_DIR.toString(), - "-addmods", "ALL-SYSTEM", + = executeTestJava("--module-path", MODS1_DIR.toString(), + "--add-modules", "ALL-SYSTEM", "-m", TEST_MID, "java.sql.Connection", "javax.annotation.Generated") @@ -140,16 +140,16 @@ public class AddModsTest { /** * Run test on class path to load a type in a module on the application - * module path, uses {@code -addmods logger}. + * module path, uses {@code --add-modules logger}. */ public void testRunWithAddMods() throws Exception { - // java -mp mods -addmods logger -cp classes test.Main + // java --module-path mods --add-modules logger -cp classes test.Main String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); String modulepath = MODS2_DIR.toString(); int exitValue - = executeTestJava("-mp", modulepath, - "-addmods", LOGGER_MODULE, + = executeTestJava("--module-path", modulepath, + "--add-modules", LOGGER_MODULE, "-cp", classpath, TEST_MAIN_CLASS, "logger.Logger") @@ -162,16 +162,16 @@ public class AddModsTest { /** * Run application on class path that makes use of module on the - * application module path. Does not use -addmods and so should + * application module path. Does not use --add-modules and so should * fail at run-time. */ public void testRunMissingAddMods() throws Exception { - // java -mp mods -cp classes test.Main + // java --module-path mods -cp classes test.Main String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); String modulepath = MODS1_DIR.toString(); int exitValue - = executeTestJava("-mp", modulepath, + = executeTestJava("--module-path", modulepath, "-cp", classpath, TEST_MAIN_CLASS, "logger.Logger") @@ -186,16 +186,16 @@ public class AddModsTest { /** * Run test on class path to load a type in a module on the application - * module path, uses {@code -addmods ALL-MODULE-PATH}. + * module path, uses {@code --add-modules ALL-MODULE-PATH}. */ public void testAddAllModulePath() throws Exception { - // java -mp mods -addmods ALL-MODULE-PATH -cp classes test.Main + // java --module-path mods --add-modules ALL-MODULE-PATH -cp classes test.Main String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); String modulepath = MODS1_DIR.toString(); int exitValue - = executeTestJava("-mp", modulepath, - "-addmods", "ALL-MODULE-PATH", + = executeTestJava("--module-path", modulepath, + "--add-modules", "ALL-MODULE-PATH", "-cp", classpath, TEST_MAIN_CLASS) .outputTo(System.out) @@ -207,13 +207,13 @@ public class AddModsTest { /** - * Test {@code -addmods ALL-MODULE-PATH} without {@code -modulepath}. + * Test {@code --add-modules ALL-MODULE-PATH} without {@code --module-path}. */ public void testAddAllModulePathWithNoModulePath() throws Exception { - // java -addmods ALL-MODULE-PATH -version + // java --add-modules ALL-MODULE-PATH -version int exitValue - = executeTestJava("-addmods", "ALL-MODULE-PATH", + = executeTestJava("--add-modules", "ALL-MODULE-PATH", "-version") .outputTo(System.out) .errorTo(System.out) @@ -224,14 +224,14 @@ public class AddModsTest { /** - * Attempt to run with a bad module name specified to -addmods + * Attempt to run with a bad module name specified to --add-modules */ public void testRunWithBadAddMods() throws Exception { - // java -mp mods -addmods DoesNotExist -m test ... + // java --module-path mods --add-modules DoesNotExist -m test ... int exitValue - = executeTestJava("-mp", MODS1_DIR.toString(), - "-addmods", "DoesNotExist", + = executeTestJava("--module-path", MODS1_DIR.toString(), + "--add-modules", "DoesNotExist", "-m", TEST_MID) .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/tools/launcher/modules/addmods/src/logger/logger/Logger.java b/jdk/test/tools/launcher/modules/addmods/src/logger/logger/Logger.java index 0cb0c293263..85fffdb75ce 100644 --- a/jdk/test/tools/launcher/modules/addmods/src/logger/logger/Logger.java +++ b/jdk/test/tools/launcher/modules/addmods/src/logger/logger/Logger.java @@ -24,7 +24,7 @@ package logger; /** - * No-op user module for use by the {@code java -addmods} tests. + * No-op user module for use by the {@code java --add-modules} tests. */ public class Logger { } diff --git a/jdk/test/tools/launcher/modules/addmods/src/test/test/Main.java b/jdk/test/tools/launcher/modules/addmods/src/test/test/Main.java index c6ca7a1be1b..edbbc6d642e 100644 --- a/jdk/test/tools/launcher/modules/addmods/src/test/test/Main.java +++ b/jdk/test/tools/launcher/modules/addmods/src/test/test/Main.java @@ -24,7 +24,7 @@ package test; /** - * Invoked by tests for the {@code java -addmods} option to check that types + * Invoked by tests for the {@code java --add-modules} option to check that types * are visible. */ public class Main { diff --git a/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java b/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java index 82d0c383f7a..24e5dbbf110 100644 --- a/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java +++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java @@ -27,7 +27,7 @@ * @modules jdk.compiler * @build AddReadsTest CompilerUtils JarUtils jdk.testlibrary.* * @run testng AddReadsTest - * @summary Basic tests for java -XaddReads + * @summary Basic tests for java --add-reads */ import java.nio.file.Path; @@ -45,7 +45,7 @@ import static org.testng.Assert.*; * The tests consists of two modules: m1 and junit. * Code in module m1 calls into code in module junit but the module-info.java * does not have a 'requires'. Instead a read edge is added via the command - * line option -XaddReads. + * line option --add-reads. */ @Test @@ -72,7 +72,7 @@ public class AddReadsTest { .compile(SRC_DIR.resolve("m1"), MODS_DIR.resolve("m1"), "-cp", CLASSES_DIR.toString(), - "-XaddReads:m1=ALL-UNNAMED")); + "--add-reads", "m1=ALL-UNNAMED")); // jar cf mods/junit.jar -C classes . JarUtils.createJarFile(MODS_DIR.resolve("junit.jar"), CLASSES_DIR); @@ -91,11 +91,11 @@ public class AddReadsTest { */ public void testJUnitOnModulePath() throws Exception { - // java -mp mods -addmods junit -XaddReads:m1=junit -m .. + // java --module-path mods --add-modules junit --add-reads m1=junit -m .. int exitValue - = run("-mp", MODS_DIR.toString(), - "-addmods", "junit", - "-XaddReads:m1=junit", + = run("--module-path", MODS_DIR.toString(), + "--add-modules", "junit", + "--add-reads", "m1=junit", "-m", MAIN) .getExitValue(); @@ -104,17 +104,17 @@ public class AddReadsTest { /** - * Exercise -XaddReads:m1=ALL-UNNAMED by running with junit on the + * Exercise --add-reads m1=ALL-UNNAMED by running with junit on the * class path. */ public void testJUnitOnClassPath() throws Exception { - // java -mp mods -cp mods/junit.jar -XaddReads:m1=ALL-UNNAMED -m .. + // java --module-path mods -cp mods/junit.jar --add-reads m1=ALL-UNNAMED -m .. String cp = MODS_DIR.resolve("junit.jar").toString(); int exitValue - = run("-mp", MODS_DIR.toString(), + = run("--module-path", MODS_DIR.toString(), "-cp", cp, - "-XaddReads:m1=ALL-UNNAMED", + "--add-reads", "m1=ALL-UNNAMED", "-m", MAIN) .getExitValue(); @@ -123,14 +123,14 @@ public class AddReadsTest { /** - * Run with junit as a module on the module path but without -XaddReads. + * Run with junit as a module on the module path but without --add-reads. */ public void testJUnitOnModulePathMissingAddReads() throws Exception { - // java -mp mods -addmods junit -m .. + // java --module-path mods --add-modules junit --module .. int exitValue - = run("-mp", MODS_DIR.toString(), - "-addmods", "junit", - "-m", MAIN) + = run("--module-path", MODS_DIR.toString(), + "--add-modules", "junit", + "--module", MAIN) .shouldContain("IllegalAccessError") .getExitValue(); @@ -139,13 +139,13 @@ public class AddReadsTest { /** - * Run with junit on the class path but without -XaddReads. + * Run with junit on the class path but without --add-reads. */ public void testJUnitOnClassPathMissingAddReads() throws Exception { - // java -mp mods -cp mods/junit.jar -m .. + // java --module-path mods -cp mods/junit.jar -m .. String cp = MODS_DIR.resolve("junit.jar").toString(); int exitValue - = run("-mp", MODS_DIR.toString(), + = run("--module-path", MODS_DIR.toString(), "-cp", cp, "-m", MAIN) .shouldContain("IllegalAccessError") @@ -156,15 +156,15 @@ public class AddReadsTest { /** - * Exercise -XaddReads with a more than one source module. + * Exercise --add-reads with a more than one source module. */ public void testJUnitWithMultiValueOption() throws Exception { int exitValue - = run("-mp", MODS_DIR.toString(), - "-addmods", "java.xml,junit", - "-XaddReads:m1=java.xml,junit", - "-m", MAIN) + = run("--module-path", MODS_DIR.toString(), + "--add-modules", "java.xml,junit", + "--add-reads", "m1=java.xml,junit", + "--module", MAIN) .getExitValue(); assertTrue(exitValue == 0); @@ -172,31 +172,31 @@ public class AddReadsTest { /** - * Exercise -XaddReads where the target module is specified more than once + * Exercise --add-reads where the target module is specified more than once */ public void testWithTargetSpecifiedManyTimes() throws Exception { int exitValue - = run("-mp", MODS_DIR.toString(), - "-addmods", "java.xml,junit", - "-XaddReads:m1=java.xml", - "-XaddReads:m1=junit", - "-m", MAIN) - .shouldContain("specified more than once") - .getExitValue(); + = run("--module-path", MODS_DIR.toString(), + "--add-modules", "java.xml,junit", + "--add-reads", "m1=java.xml", + "--add-reads", "m1=junit", + "-m", MAIN) + .shouldContain("specified more than once") + .getExitValue(); assertTrue(exitValue != 0); } /** - * Exercise -XaddReads with bad values + * Exercise --add-reads with bad values */ @Test(dataProvider = "badvalues") public void testWithBadValue(String value, String ignore) throws Exception { - // -XaddExports:$VALUE -version - assertTrue(run("-XaddReads:" + value, "-version").getExitValue() != 0); + // --add-exports $VALUE -version + assertTrue(run("--add-reads", value, "-version").getExitValue() != 0); } @DataProvider(name = "badvalues") diff --git a/jdk/test/tools/launcher/modules/basic/BasicTest.java b/jdk/test/tools/launcher/modules/basic/BasicTest.java index 1c2cf2352c9..233fa29e00b 100644 --- a/jdk/test/tools/launcher/modules/basic/BasicTest.java +++ b/jdk/test/tools/launcher/modules/basic/BasicTest.java @@ -37,7 +37,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import static jdk.testlibrary.ProcessTools.*; +import jdk.testlibrary.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -72,6 +72,16 @@ public class BasicTest { assertTrue(compiled, "test module did not compile"); } + /** + * Execute "java" with the given arguments, returning the exit code. + */ + private int exec(String... args) throws Exception { + return ProcessTools.executeTestJava(args) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + } + /** * The initial module is loaded from an exploded module @@ -81,20 +91,28 @@ public class BasicTest { String subdir = MODS_DIR.resolve(TEST_MODULE).toString(); String mid = TEST_MODULE + "/" + MAIN_CLASS; - // java -mp mods -m $TESTMODULE/$MAINCLASS - int exitValue - = executeTestJava("-mp", dir, "-m", mid) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); + // java --module-path mods -module $TESTMODULE/$MAINCLASS + int exitValue = exec("--module-path", dir, "--module", mid); assertTrue(exitValue == 0); - // java -mp mods/$TESTMODULE -m $TESTMODULE/$MAINCLASS - exitValue - = executeTestJava("-mp", subdir, "-m", mid) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); + // java --module-path mods/$TESTMODULE --module $TESTMODULE/$MAINCLASS + exitValue = exec("--module-path", subdir, "--module", mid); + assertTrue(exitValue == 0); + + // java --module-path=mods --module=$TESTMODULE/$MAINCLASS + exitValue = exec("--module-path=" + dir, "--module=" + mid); + assertTrue(exitValue == 0); + + // java --module-path=mods/$TESTMODULE --module=$TESTMODULE/$MAINCLASS + exitValue = exec("--module-path=" + subdir, "--module=" + mid); + assertTrue(exitValue == 0); + + // java -p mods -m $TESTMODULE/$MAINCLASS + exitValue = exec("-p", dir, "-m", mid); + assertTrue(exitValue == 0); + + // java -p mods/$TESTMODULE -m $TESTMODULE/$MAINCLASS + exitValue = exec("-p", subdir, "-m", mid); assertTrue(exitValue == 0); } @@ -119,22 +137,14 @@ public class BasicTest { .run(args); assertTrue(success); - // java -mp mlib -m $TESTMODULE - int exitValue - = executeTestJava("-mp", dir.toString(), - "-m", TEST_MODULE) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); + // java --module-path mlib -module $TESTMODULE + int exitValue = exec("--module-path", dir.toString(), + "--module", TEST_MODULE); assertTrue(exitValue == 0); - // java -mp mlib/m.jar -m $TESTMODULE - exitValue - = executeTestJava("-mp", jar.toString(), - "-m", TEST_MODULE) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); + // java --module-path mlib/m.jar -module $TESTMODULE + exitValue = exec("--module-path", jar.toString(), + "--module", TEST_MODULE); assertTrue(exitValue == 0); } @@ -157,14 +167,9 @@ public class BasicTest { jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask(); assertEquals(task.run(args), 0); - // java -mp mods -m $TESTMODULE - int exitValue - = executeTestJava("-mp", dir.toString(), - "-m", TEST_MODULE) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); - + // java --module-path mods --module $TESTMODULE + int exitValue = exec("--module-path", dir.toString(), + "--module", TEST_MODULE); assertTrue(exitValue != 0); } @@ -177,14 +182,8 @@ public class BasicTest { String mp = "DoesNotExist" + File.pathSeparator + MODS_DIR.toString(); String mid = TEST_MODULE + "/" + MAIN_CLASS; - // java -mp mods -m $TESTMODULE/$MAINCLASS - int exitValue - = executeTestJava("-mp", mp, - "-m", mid) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); - + // java --module-path mods --module $TESTMODULE/$MAINCLASS + int exitValue = exec("--module-path", mp, "--module", mid); assertTrue(exitValue == 0); } @@ -195,15 +194,8 @@ public class BasicTest { public void testTryRunWithBadModule() throws Exception { String modulepath = MODS_DIR.toString(); - // java -mp mods -m $TESTMODULE - int exitValue - = executeTestJava("-mp", modulepath, - "-m", "rhubarb") - .outputTo(System.out) - .errorTo(System.out) - .shouldContain("not found") - .getExitValue(); - + // java --module-path mods -m $TESTMODULE + int exitValue = exec("--module-path", modulepath, "-m", "rhubarb"); assertTrue(exitValue != 0); } @@ -216,14 +208,8 @@ public class BasicTest { String modulepath = MODS_DIR.toString(); String mid = TEST_MODULE + "/p.rhubarb"; - // java -mp mods -m $TESTMODULE/$MAINCLASS - int exitValue - = executeTestJava("-mp", modulepath, - "-m", mid) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); - + // java --module-path mods -m $TESTMODULE/$MAINCLASS + int exitValue = exec("--module-path", modulepath, "-m", mid); assertTrue(exitValue != 0); } @@ -248,15 +234,8 @@ public class BasicTest { .run(args); assertTrue(success); - // java -mp mods -m $TESTMODULE - int exitValue - = executeTestJava("-mp", dir.toString(), - "-m", TEST_MODULE) - .outputTo(System.out) - .errorTo(System.out) - .shouldContain("does not have a MainClass attribute") - .getExitValue(); - + // java --module-path mods -m $TESTMODULE + int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE); assertTrue(exitValue != 0); } @@ -269,14 +248,8 @@ public class BasicTest { String modulepath = MODS_DIR.toString(); String mid = "java.base/" + MAIN_CLASS; - // java -mp mods -m $TESTMODULE/$MAINCLASS - int exitValue - = executeTestJava("-mp", modulepath, - "-m", mid) - .outputTo(System.out) - .errorTo(System.out) - .getExitValue(); - + // java --module-path mods --module $TESTMODULE/$MAINCLASS + int exitValue = exec("--module-path", modulepath, "--module", mid); assertTrue(exitValue != 0); } diff --git a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java index ca127d642d8..acf65bc1475 100644 --- a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java +++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java @@ -69,11 +69,11 @@ public class DryRunTest { // javac -d mods/$TESTMODULE src/$TESTMODULE/** assertTrue(CompilerUtils.compile(SRC_DIR.resolve(M_MODULE), MODS_DIR, - "-modulesourcepath", SRC_DIR.toString())); + "--module-source-path", SRC_DIR.toString())); assertTrue(CompilerUtils.compile(SRC_DIR.resolve(TEST_MODULE), MODS_DIR, - "-modulesourcepath", SRC_DIR.toString())); + "--module-source-path", SRC_DIR.toString())); Files.createDirectories(LIBS_DIR); @@ -101,7 +101,7 @@ public class DryRunTest { String mid = TEST_MODULE + "/" + MAIN_CLASS; // no resolution failure - int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid); + int exitValue = exec("--dry-run", "--module-path", dir, "-m", mid); assertTrue(exitValue == 0); } @@ -112,23 +112,23 @@ public class DryRunTest { String dir = MODS_DIR.toString(); String mid = TEST_MODULE + "/" + MAIN_CLINIT_CLASS; - int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid); + int exitValue = exec("--dry-run", "--module-path", dir, "-m", mid); assertTrue(exitValue == 0); // expect the test to fail if main class is initialized - exitValue = exec("-modulepath", dir, "-m", mid); + exitValue = exec("--module-path", dir, "-m", mid); assertTrue(exitValue != 0); } /** - * Test non-existence module in -addmods + * Test non-existence module in --add-modules */ public void testNonExistAddModules() throws Exception { String dir = MODS_DIR.toString(); String mid = TEST_MODULE + "/" + MAIN_CLASS; - int exitValue = exec("--dry-run", "-modulepath", dir, - "-addmods", "non.existence", + int exitValue = exec("--dry-run", "--module-path", dir, + "--add-modules", "non.existence", "-m", mid); assertTrue(exitValue != 0); } @@ -163,24 +163,24 @@ public class DryRunTest { LIBS_DIR.resolve(TEST_MODULE + ".jar").toString(); String mid = TEST_MODULE + "/" + MAIN_CLASS; - // test main method with and without -addmods mm - int exitValue = exec("-modulepath", LIBS_DIR.toString(), + // test main method with and without --add-modules mm + int exitValue = exec("--module-path", LIBS_DIR.toString(), "-m", mid); assertTrue(exitValue != 0); - exitValue = exec("-modulepath", LIBS_DIR.toString(), - "-addmods", M_MODULE, + exitValue = exec("--module-path", LIBS_DIR.toString(), + "--add-modules", M_MODULE, "-m", mid); assertTrue(exitValue == 0); - // test dry run with and without -addmods m + // test dry run with and without --add-modules m // no resolution failure - exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(), + exitValue = exec("--dry-run", "--module-path", LIBS_DIR.toString(), "-m", mid); assertTrue(exitValue == 0); - exitValue = exec("--dry-run", "-modulepath", LIBS_DIR.toString(), - "-addmods", M_MODULE, + exitValue = exec("--dry-run", "--module-path", LIBS_DIR.toString(), + "--add-modules", M_MODULE, "-m", mid); assertTrue(exitValue == 0); } @@ -193,7 +193,7 @@ public class DryRunTest { String mid = TEST_MODULE + "/" + MAIN_CLASS; // resolution failure - int exitValue = exec("--dry-run", "-modulepath", subdir, "-m", mid); + int exitValue = exec("--dry-run", "--module-path", subdir, "-m", mid); assertTrue(exitValue != 0); } diff --git a/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java b/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java index 0cafaf42e66..2618fbab45b 100644 --- a/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java +++ b/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java @@ -27,7 +27,7 @@ * @modules java.desktop java.compact1 jdk.compiler * @build LimitModsTest CompilerUtils jdk.testlibrary.* * @run testng LimitModsTest - * @summary Basic tests for java -limitmods + * @summary Basic tests for java --limit-modules */ import java.nio.file.Path; @@ -66,13 +66,13 @@ public class LimitModsTest { /** - * Basic test of -limitmods to limit which platform modules are observable. + * Basic test of --limit-modules to limit which platform modules are observable. */ public void testLimitingPlatformModules() throws Exception { int exitValue; - // java -limitmods java.base -listmods - exitValue = executeTestJava("-limitmods", "java.base", "-listmods") + // java --limit-modules java.base --list-modules + exitValue = executeTestJava("--limit-modules", "java.base", "--list-modules") .outputTo(System.out) .errorTo(System.out) .shouldContain("java.base") @@ -83,8 +83,8 @@ public class LimitModsTest { assertTrue(exitValue == 0); - // java -limitmods java.compact1 -listmods - exitValue = executeTestJava("-limitmods", "java.compact1", "-listmods") + // java --limit-modules java.compact1 --list-modules + exitValue = executeTestJava("--limit-modules", "java.compact1", "--list-modules") .outputTo(System.out) .errorTo(System.out) .shouldContain("java.base") @@ -98,15 +98,15 @@ public class LimitModsTest { /** - * Test -limitmods with -addmods + * Test --limit-modules with --add-modules */ public void testWithAddMods() throws Exception { int exitValue; - // java -limitmods java.base -addmods java.logging -listmods - exitValue = executeTestJava("-limitmods", "java.base", - "-addmods", "java.logging", - "-listmods") + // java --limit-modules java.base --add-modules java.logging --list-modules + exitValue = executeTestJava("--limit-modules", "java.base", + "--add-modules", "java.logging", + "--list-modules") .outputTo(System.out) .errorTo(System.out) .shouldContain("java.base") @@ -117,11 +117,11 @@ public class LimitModsTest { assertTrue(exitValue == 0); - // java -limitmods java.base -addmods java.sql -listmods + // java --limit-modules java.base --add-modules java.sql --list-modules // This should fail because java.sql has dependences beyond java.base - exitValue = executeTestJava("-limitmods", "java.base", - "-addmods", "java.sql", - "-listmods") + exitValue = executeTestJava("--limit-modules", "java.base", + "--add-modules", "java.sql", + "--list-modules") .outputTo(System.out) .errorTo(System.out) .getExitValue(); @@ -131,14 +131,14 @@ public class LimitModsTest { /** - * Run class path application with -limitmods + * Run class path application with --limit-modules */ public void testUnnamedModule() throws Exception { String classpath = MODS_DIR.resolve(TEST_MODULE).toString(); - // java -limitmods java.base -cp mods/$TESTMODULE ... + // java --limit-modules java.base -cp mods/$TESTMODULE ... int exitValue1 - = executeTestJava("-limitmods", "java.base", + = executeTestJava("--limit-modules", "java.base", "-cp", classpath, MAIN_CLASS) .outputTo(System.out) @@ -149,9 +149,9 @@ public class LimitModsTest { assertTrue(exitValue1 != 0); - // java -limitmods java.base -cp mods/$TESTMODULE ... + // java --limit-modules java.base -cp mods/$TESTMODULE ... int exitValue2 - = executeTestJava("-limitmods", "java.desktop", + = executeTestJava("--limit-modules", "java.desktop", "-cp", classpath, MAIN_CLASS) .outputTo(System.out) @@ -163,16 +163,16 @@ public class LimitModsTest { /** - * Run named module with -limitmods + * Run named module with --limit-modules */ public void testNamedModule() throws Exception { String modulepath = MODS_DIR.toString(); String mid = TEST_MODULE + "/" + MAIN_CLASS; - // java -limitmods java.base -mp mods -m $TESTMODULE/$MAINCLASS - int exitValue = executeTestJava("-limitmods", "java.base", - "-mp", modulepath, + // java --limit-modules java.base --module-path mods -m $TESTMODULE/$MAINCLASS + int exitValue = executeTestJava("--limit-modules", "java.base", + "--module-path", modulepath, "-m", mid) .outputTo(System.out) .errorTo(System.out) @@ -180,9 +180,9 @@ public class LimitModsTest { assertTrue(exitValue != 0); - // java -limitmods java.desktop -mp mods -m $TESTMODULE/$MAINCLASS - exitValue = executeTestJava("-limitmods", "java.desktop", - "-mp", modulepath, + // java --limit-modules java.desktop --module-path mods -m $TESTMODULE/$MAINCLASS + exitValue = executeTestJava("--limit-modules", "java.desktop", + "--module-path", modulepath, "-m", mid) .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/tools/launcher/modules/listmods/ListModsTest.java b/jdk/test/tools/launcher/modules/listmods/ListModsTest.java index bd57d38d98f..793e12efe57 100644 --- a/jdk/test/tools/launcher/modules/listmods/ListModsTest.java +++ b/jdk/test/tools/launcher/modules/listmods/ListModsTest.java @@ -27,7 +27,7 @@ * @modules java.se * @build ListModsTest CompilerUtils jdk.testlibrary.* * @run testng ListModsTest - * @summary Basic test for java -listmods + * @summary Basic test for java --list-modules */ import java.nio.file.Path; @@ -41,7 +41,7 @@ import org.testng.annotations.Test; import static org.testng.Assert.*; /** - * Basic tests for java -listmods + * Basic tests for java --list-modules */ public class ListModsTest { @@ -55,13 +55,13 @@ public class ListModsTest { public void setup() throws Exception { boolean compiled; - // javac -d mods/m1 -mp mods src/m1/** + // javac -d mods/m1 --module-path mods src/m1/** compiled = CompilerUtils.compile( SRC_DIR.resolve("m1"), MODS_DIR.resolve("m1")); assertTrue(compiled); - // javac -d upgrademods/java.transaction -mp mods src/java.transaction/** + // javac -d upgrademods/java.transaction --module-path mods src/java.transaction/** compiled = CompilerUtils.compile( SRC_DIR.resolve("java.transaction"), UPGRADEMODS_DIR.resolve("java.transaction")); @@ -73,7 +73,7 @@ public class ListModsTest { @Test public void testListAll() throws Exception { OutputAnalyzer output - = executeTestJava("-listmods") + = executeTestJava("--list-modules") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); @@ -85,7 +85,7 @@ public class ListModsTest { @Test public void testListOneModule() throws Exception { OutputAnalyzer output - = executeTestJava("-listmods:java.base") + = executeTestJava("--list-modules=java.base") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); @@ -97,7 +97,7 @@ public class ListModsTest { @Test public void testListTwoModules() throws Exception { OutputAnalyzer output - = executeTestJava("-listmods:java.base,java.xml") + = executeTestJava("--list-modules", "java.base,java.xml") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); @@ -111,7 +111,7 @@ public class ListModsTest { @Test public void testListUnknownModule() throws Exception { OutputAnalyzer output - = executeTestJava("-listmods:java.rhubarb") + = executeTestJava("--list-modules", "java.rhubarb") .outputTo(System.out) .errorTo(System.out); output.shouldNotContain("java.base"); @@ -123,7 +123,7 @@ public class ListModsTest { @Test public void testListWithModulePath() throws Exception { OutputAnalyzer output - = executeTestJava("-mp", MODS_DIR.toString(), "-listmods") + = executeTestJava("--module-path", MODS_DIR.toString(), "--list-modules") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); @@ -135,8 +135,8 @@ public class ListModsTest { @Test public void testListWithUpgradeModulePath() throws Exception { OutputAnalyzer output - = executeTestJava("-upgrademodulepath", UPGRADEMODS_DIR.toString(), - "-listmods:java.transaction") + = executeTestJava("--upgrade-module-path", UPGRADEMODS_DIR.toString(), + "--list-modules", "java.transaction") .outputTo(System.out) .errorTo(System.out); output.shouldContain("exports javax.transaction.atomic"); @@ -147,7 +147,7 @@ public class ListModsTest { @Test public void testListWithLimitMods1() throws Exception { OutputAnalyzer output - = executeTestJava("-limitmods", "java.compact1", "-listmods") + = executeTestJava("--limit-modules", "java.compact1", "--list-modules") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.compact1"); @@ -160,9 +160,9 @@ public class ListModsTest { @Test public void testListWithLimitMods2() throws Exception { OutputAnalyzer output - = executeTestJava("-mp", MODS_DIR.toString(), - "-limitmods", "java.compact1", - "-listmods") + = executeTestJava("--module-path", MODS_DIR.toString(), + "--limit-modules", "java.compact1", + "--list-modules") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); @@ -172,12 +172,12 @@ public class ListModsTest { /** - * java -version -listmods => should print version and exit + * java -version --list-modules => should print version and exit */ @Test public void testListWithPrintVersion1() throws Exception { OutputAnalyzer output - = executeTestJava("-version", "-listmods") + = executeTestJava("-version", "--list-modules") .outputTo(System.out) .errorTo(System.out); output.shouldNotContain("java.base"); @@ -187,12 +187,12 @@ public class ListModsTest { /** - * java -listmods -version => should list modules and exit + * java --list-modules -version => should list modules and exit */ @Test public void testListWithPrintVersion2() throws Exception { OutputAnalyzer output - = executeTestJava("-listmods", "-version") + = executeTestJava("--list-modules", "-version") .outputTo(System.out) .errorTo(System.out); output.shouldContain("java.base"); diff --git a/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java index 8b8290c7b6b..968336ae8aa 100644 --- a/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java +++ b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java @@ -27,7 +27,7 @@ * @modules jdk.compiler * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.* * @run testng PatchTest - * @summary Basic test for -Xpatch + * @summary Basic test for --patch-module */ import java.io.File; @@ -45,13 +45,13 @@ import static org.testng.Assert.*; /** - * Compiles and launches a test that uses -Xpatch with two directories of - * classes to override existing and add new classes to modules in the - * boot layer. + * Compiles and launches a test that uses --patch-module with two directories + * of classes to override existing classes and add new classes to modules in + * the boot layer. * - * The classes overridden or added via -Xpatch all define a public no-arg - * constructor and override toString to return "hi". This allows the launched - * test to check that the overridden classes are loaded. + * The classes overridden or added via --patch-module all define a public + * no-arg constructor and override toString to return "hi". This allows the + * launched test to check that the overridden classes are loaded. */ @Test @@ -76,7 +76,7 @@ public class PatchTest { private static final Path PATCHES_DIR = Paths.get("patches"); - // the classes overridden or added with -Xpatch + // the classes overridden or added with --patch-module private static final String[] CLASSES = { // java.base = boot loader @@ -137,15 +137,15 @@ public class PatchTest { String arg = Stream.of(CLASSES).collect(Collectors.joining(",")); int exitValue - = executeTestJava("-Xpatch:java.base=" + basePatches, - "-Xpatch:jdk.naming.dns=" + dnsPatches, - "-Xpatch:jdk.compiler=" + compilerPatches, - "-XaddExports:java.base/java.lang2=test", - "-XaddExports:jdk.naming.dns/com.sun.jndi.dns=test", - "-XaddExports:jdk.naming.dns/com.sun.jndi.dns2=test", - "-XaddExports:jdk.compiler/com.sun.tools.javac2=test", - "-addmods", "jdk.naming.dns,jdk.compiler", - "-mp", MODS_DIR.toString(), + = executeTestJava("--patch-module", "java.base=" + basePatches, + "--patch-module", "jdk.naming.dns=" + dnsPatches, + "--patch-module", "jdk.compiler=" + compilerPatches, + "--add-exports", "java.base/java.lang2=test", + "--add-exports", "jdk.naming.dns/com.sun.jndi.dns=test", + "--add-exports", "jdk.naming.dns/com.sun.jndi.dns2=test", + "--add-exports", "jdk.compiler/com.sun.tools.javac2=test", + "--add-modules", "jdk.naming.dns,jdk.compiler", + "--module-path", MODS_DIR.toString(), "-m", "test/jdk.test.Main", arg) .outputTo(System.out) .errorTo(System.out) @@ -156,7 +156,7 @@ public class PatchTest { /** - * Run test with -Xpatch and exploded patches + * Run test with ---patch-module and exploded patches */ public void testWithExplodedPatches() throws Exception { @@ -175,7 +175,7 @@ public class PatchTest { /** - * Run test with -Xpatch and patches in JAR files + * Run test with ---patch-module and patches in JAR files */ public void testWithJarPatches() throws Exception { @@ -195,7 +195,7 @@ public class PatchTest { /** - * Run test with -Xpatch and patches in JAR files and exploded patches + * Run test with ---patch-module and patches in JAR files and exploded patches */ public void testWithJarAndExplodedPatches() throws Exception { diff --git a/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java index 88e09856710..f274a17ad2a 100644 --- a/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java +++ b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java @@ -22,7 +22,7 @@ */ /** - * Used with -Xpatch to exercise the replacement or addition of classes + * Used with --patch-module to exercise the replacement or addition of classes * in modules that are linked into the runtime image. */ diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java index 0e5345aefb3..9a5c84cad99 100644 --- a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java @@ -69,7 +69,7 @@ public class PatchSystemModules { for (String name : modules) { assertTrue(CompilerUtils.compile(src.resolve(name), MODS_DIR, - "-modulesourcepath", src.toString())); + "--module-source-path", src.toString())); } // compile patched source @@ -93,16 +93,16 @@ public class PatchSystemModules { Path home = Paths.get(JAVA_HOME); runTest(home, - "-mp", MODS_DIR.toString(), + "--module-path", MODS_DIR.toString(), "-m", "m1/p1.Main", "1"); runTest(home, - "-Xpatch:java.base=" + patchedJavaBase.toString(), - "-mp", MODS_DIR.toString(), + "--patch-module", "java.base=" + patchedJavaBase, + "--module-path", MODS_DIR.toString(), "-m", "m1/p1.Main", "1"); runTest(home, - "-Xpatch:m2=" + patchedM2.toString(), - "-mp", MODS_DIR.toString(), + "--patch-module", "m2=" + patchedM2.toString(), + "--module-path", MODS_DIR.toString(), "-m", "m1/p1.Main", "2"); } @@ -117,10 +117,10 @@ public class PatchSystemModules { runTest(IMAGE, "-m", "m1/p1.Main", "1"); runTest(IMAGE, - "-Xpatch:java.base=" + patchedJavaBase.toString(), + "--patch-module", "java.base=" + patchedJavaBase, "-m", "m1/p1.Main", "1"); runTest(IMAGE, - "-Xpatch:m2=" + patchedM2.toString(), + "--patch-module", "m2=" + patchedM2.toString(), "-m", "m1/p1.Main", "2"); } @@ -138,12 +138,12 @@ public class PatchSystemModules { // Fail to upgrade m1.jar with mismatched hash runTestWithExitCode(getJava(IMAGE), - "-upgrademodulepath", m1.toString(), + "--upgrade-module-path", m1.toString(), "-m", "m1/p1.Main"); runTestWithExitCode(getJava(IMAGE), - "-Xpatch:java.base=" + PATCH_DIR.resolve(JAVA_BASE).toString(), - "-upgrademodulepath", m1.toString(), + "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE), + "--upgrade-module-path", m1.toString(), "-m", "m1/p1.Main", "1"); } @@ -185,14 +185,14 @@ public class PatchSystemModules { jar("--create", "--file=" + m2.toString(), - "--modulepath", JARS_DIR.toString(), + "--module-path", JARS_DIR.toString(), "--hash-modules", "m1", "-C", MODS_DIR.resolve("m2").toString(), "."); String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString(); - execTool("jlink", "--modulepath", mpath, - "--addmods", "m1", + execTool("jlink", "--module-path", mpath, + "--add-modules", "m1", "--output", IMAGE.toString()); } @@ -216,7 +216,7 @@ public class PatchSystemModules { } static String getJava(Path image) { - boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win"); + boolean isWindows = System.getProperty("os.name").startsWith("Windows"); Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java"); if (Files.notExists(java)) throw new RuntimeException(java + " not found"); diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java index e30761204e1..a56c8dda67c 100644 --- a/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java @@ -24,7 +24,7 @@ package jdk.internal.module; /* - * Test -Xpatch:java.base=jdk/modules/java.base to override + * Test --patch-module java.base=jdk/modules/java.base to override * java.base with an exploded image */ public final class SystemModules { diff --git a/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java b/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java index 31351b53f8d..3655281427a 100644 --- a/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java +++ b/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java @@ -27,7 +27,7 @@ * @modules jdk.compiler * @build UpgradeModulePathTest CompilerUtils jdk.testlibrary.* * @run testng UpgradeModulePathTest - * @summary Basic test for java -upgrademodulepath + * @summary Basic test for java --upgrade-module-path */ import java.io.File; @@ -65,19 +65,19 @@ public class UpgradeModulePathTest { MODS_DIR.resolve("java.enterprise")); assertTrue(compiled); - // javac -d upgrademods/java.transaction -mp mods src/java.transaction/** + // javac -d upgrademods/java.transaction --module-path mods src/java.transaction/** compiled = CompilerUtils.compile( SRC_DIR.resolve("java.transaction"), UPGRADEDMODS_DIR.resolve("java.transaction"), - "-mp", MODS_DIR.toString()); + "--module-path", MODS_DIR.toString()); assertTrue(compiled); - // javac -d mods -upgrademodulepath upgrademods -mp mods src/test/** + // javac -d mods --upgrade-module-path upgrademods --module-path mods src/test/** compiled = CompilerUtils.compile( SRC_DIR.resolve("test"), MODS_DIR.resolve("test"), - "-upgrademodulepath", UPGRADEDMODS_DIR.toString(), - "-mp", MODS_DIR.toString()); + "--upgrade-module-path", UPGRADEDMODS_DIR.toString(), + "--module-path", MODS_DIR.toString()); assertTrue(compiled); } @@ -92,8 +92,8 @@ public class UpgradeModulePathTest { int exitValue = executeTestJava( - "-upgrademodulepath", UPGRADEDMODS_DIR.toString(), - "-mp", MODS_DIR.toString(), + "--upgrade-module-path", UPGRADEDMODS_DIR.toString(), + "--module-path", MODS_DIR.toString(), "-m", mid) .outputTo(System.out) .errorTo(System.out) @@ -116,8 +116,8 @@ public class UpgradeModulePathTest { int exitValue = executeTestJava( - "-upgrademodulepath", upgrademodulepath, - "-mp", MODS_DIR.toString(), + "--upgrade-module-path", upgrademodulepath, + "--module-path", MODS_DIR.toString(), "-m", mid) .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/tools/lib/tests/Helper.java b/jdk/test/tools/lib/tests/Helper.java index c134cef25ac..5ab2eff8451 100644 --- a/jdk/test/tools/lib/tests/Helper.java +++ b/jdk/test/tools/lib/tests/Helper.java @@ -164,7 +164,7 @@ public class Helper { Path srcMod = src.resolve(moduleName); JImageGenerator.generateModuleInfo(srcMod, packages, dependencies); Path destination = classes.resolve(moduleName); - if (!JImageGenerator.compile(srcMod, destination, "-modulepath", modulePath, "-g")) { + if (!JImageGenerator.compile(srcMod, destination, "--module-path", modulePath, "-g")) { throw new AssertionError("Compilation failure"); } return destination; diff --git a/jdk/test/tools/lib/tests/JImageGenerator.java b/jdk/test/tools/lib/tests/JImageGenerator.java index a836e818243..ca79ba086c3 100644 --- a/jdk/test/tools/lib/tests/JImageGenerator.java +++ b/jdk/test/tools/lib/tests/JImageGenerator.java @@ -106,10 +106,10 @@ public class JImageGenerator { private static final String POST_PROCESS_OPTION = "--post-process-path"; private static final String MAIN_CLASS_OPTION = "--main-class"; private static final String CLASS_PATH_OPTION = "--class-path"; - private static final String MODULE_PATH_OPTION = "--modulepath"; - private static final String ADD_MODS_OPTION = "--addmods"; - private static final String LIMIT_MODS_OPTION = "--limitmods"; - private static final String PLUGINS_MODULE_PATH = "--plugin-module-path"; + private static final String MODULE_PATH_OPTION = "--module-path"; + private static final String ADD_MODULES_OPTION = "--add-modules"; + private static final String LIMIT_MODULES_OPTION = "--limit-modules"; + private static final String PLUGIN_MODULE_PATH = "--plugin-module-path"; private static final String CMDS_OPTION = "--cmds"; private static final String CONFIG_OPTION = "--config"; @@ -534,7 +534,7 @@ public class JImageGenerator { options.add(dir.toString()); } if (!pluginModulePath.isEmpty()) { - options.add(PLUGINS_MODULE_PATH); + options.add(PLUGIN_MODULE_PATH); options.add(toPath(pluginModulePath)); } options.addAll(this.options); @@ -632,11 +632,11 @@ public class JImageGenerator { options.add(output.toString()); } if (!addMods.isEmpty()) { - options.add(ADD_MODS_OPTION); + options.add(ADD_MODULES_OPTION); options.add(addMods.stream().collect(Collectors.joining(","))); } if (!limitMods.isEmpty()) { - options.add(LIMIT_MODS_OPTION); + options.add(LIMIT_MODULES_OPTION); options.add(limitMods.stream().collect(Collectors.joining(","))); } if (!jars.isEmpty() || !jmods.isEmpty()) { @@ -648,7 +648,7 @@ public class JImageGenerator { options.add(modulePath); } if (!pluginModulePath.isEmpty()) { - options.add(PLUGINS_MODULE_PATH); + options.add(PLUGIN_MODULE_PATH); options.add(toPath(pluginModulePath)); } options.addAll(this.options); diff --git a/jdk/test/tools/pack200/Utils.java b/jdk/test/tools/pack200/Utils.java index 45e09c37abc..20b18b6fff9 100644 --- a/jdk/test/tools/pack200/Utils.java +++ b/jdk/test/tools/pack200/Utils.java @@ -111,7 +111,7 @@ class Utils { compiler("-d", XCLASSES.getName(), - "-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", + "--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", "@" + tmpFile.getAbsolutePath()); jar("cvfe", @@ -148,7 +148,7 @@ class Utils { init(); List cmds = new ArrayList(); cmds.add(getJavaCmd()); - cmds.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); + cmds.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); cmds.add("-cp"); cmds.add(VerifierJar.getName()); cmds.add("sun.tools.pack.verify.Main"); diff --git a/jdk/test/tools/pack200/pack200-verifier/make/build.xml b/jdk/test/tools/pack200/pack200-verifier/make/build.xml index 2bb786b8e87..b0874f21306 100644 --- a/jdk/test/tools/pack200/pack200-verifier/make/build.xml +++ b/jdk/test/tools/pack200/pack200-verifier/make/build.xml @@ -27,7 +27,7 @@ destdir="${build}/classes" verbose="no" debug="on"> - + From ea4535a524b09c9cc24671e7986f49f992338515 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Wed, 10 Aug 2016 15:52:26 -0700 Subject: [PATCH 28/66] 8163817: JShell tests: disable minor failing editor tool cases: 8161276, 8163816, 8159229 Reviewed-by: jlahoda, psandoz, darcy --- langtools/test/ProblemList.txt | 1 + langtools/test/jdk/jshell/EditorTestBase.java | 4 ++-- langtools/test/jdk/jshell/ExternalEditorTest.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index e2f9fcfe039..1fcde6cb41f 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -54,6 +54,7 @@ jdk/javadoc/tool/varArgs/Main.java # # jshell +jdk/jshell/EditorPadTest.java 8161276 windows-all Test set-up cannot press buttons jdk/jshell/ToolBasicTest.java 8139873 generic-all JShell tests failing ########################################################################### diff --git a/langtools/test/jdk/jshell/EditorTestBase.java b/langtools/test/jdk/jshell/EditorTestBase.java index 12ff3c842a5..067bbb9da99 100644 --- a/langtools/test/jdk/jshell/EditorTestBase.java +++ b/langtools/test/jdk/jshell/EditorTestBase.java @@ -125,7 +125,7 @@ public abstract class EditorTestBase extends ReplToolTesting { ); } - @Test + @Test(enabled = false) // TODO 8163816 public void testEditClass1() { testEditor( a -> assertClass(a, "class A {}", "class", "A"), @@ -163,7 +163,7 @@ public abstract class EditorTestBase extends ReplToolTesting { ); } - @Test + @Test(enabled = false) // TODO 8163816 public void testEditMethod1() { testEditor( a -> assertMethod(a, "void f() {}", "()void", "f"), diff --git a/langtools/test/jdk/jshell/ExternalEditorTest.java b/langtools/test/jdk/jshell/ExternalEditorTest.java index af6dae955ec..cd3d70f442b 100644 --- a/langtools/test/jdk/jshell/ExternalEditorTest.java +++ b/langtools/test/jdk/jshell/ExternalEditorTest.java @@ -201,7 +201,7 @@ public class ExternalEditorTest extends EditorTestBase { ); } - @Test + @Test(enabled = false) // TODO 8159229 public void testRemoveTempFile() { test(new String[]{"-nostartup"}, a -> assertCommandCheckOutput(a, "/set editor " + executionScript, From b620ed93e661f283721eee9fc1175e4d28a5aad9 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Wed, 10 Aug 2016 16:19:09 -0700 Subject: [PATCH 29/66] 8152054: fix @ignored langtools/test/jdk/javadoc/tool/ tests Reviewed-by: jjg --- langtools/test/ProblemList.txt | 25 +- .../test/jdk/javadoc/tool/8025693/Test.java | 6 +- langtools/test/jdk/javadoc/tool/T4696488.java | 10 +- .../jdk/javadoc/tool/badSuper/BadSuper.java | 6 +- .../javadoc/tool/enum/docComments/Main.java | 4 +- .../jdk/javadoc/tool/enum/enumType/Main.java | 4 +- .../tool/generics/genericClass/Main.java | 58 --- .../tool/generics/genericClass/expected.out | 16 - .../tool/generics/genericClass/pkg1/A.java | 34 -- .../generics/genericInnerAndOuter/Main.java | 63 ---- .../genericInnerAndOuter/expected.out | 53 --- .../generics/genericInnerAndOuter/pkg1/X.java | 32 -- .../tool/generics/genericInterface/Main.java | 58 --- .../generics/genericInterface/expected.out | 6 - .../generics/genericInterface/pkg1/A.java | 28 -- .../tool/generics/genericMethod/Main.java | 61 ---- .../tool/generics/genericMethod/expected.out | 20 -- .../tool/generics/genericMethod/pkg1/A.java | 30 -- .../tool/generics/genericSuper/Main.java | 63 ---- .../tool/generics/genericSuper/expected.out | 27 -- .../tool/generics/genericSuper/pkg1/A.java | 33 -- .../tool/generics/supertypes/Main.java | 81 ----- .../tool/generics/supertypes/expected.out | 16 - .../tool/generics/supertypes/pkg1/A.java | 29 -- .../tool/generics/supertypes/pkg1/B.java | 29 -- .../tool/generics/throwsGeneric/Main.java | 59 ---- .../tool/generics/throwsGeneric/expected.out | 16 - .../tool/generics/throwsGeneric/pkg1/A.java | 29 -- .../tool/generics/tparamCycle/Main.java | 64 ---- .../generics/tparamCycle/pkg1/LikeEnum.java | 27 -- .../tool/generics/tparamTagOnMethod/Main.java | 60 ---- .../generics/tparamTagOnMethod/expected.out | 12 - .../generics/tparamTagOnMethod/pkg1/A.java | 34 -- .../tool/generics/tparamTagOnType/Main.java | 58 --- .../generics/tparamTagOnType/expected.out | 5 - .../tool/generics/tparamTagOnType/pkg1/A.java | 30 -- .../javadoc/tool/generics/wildcards/Main.java | 58 --- .../tool/generics/wildcards/expected.out | 16 - .../tool/generics/wildcards/pkg1/A.java | 34 -- .../test/jdk/javadoc/tool/imports/I.java | 29 -- .../javadoc/tool/imports/MissingImport.java | 83 ----- .../test/jdk/javadoc/tool/lib/Tester.java | 331 ------------------ .../jdk/javadoc/tool/sourceOnly/Test.java | 22 +- .../O.java => sourceOnly/p/NonSource.jasm} | 16 +- .../javadoc/tool/sourceOnly/p/SourceOnly.java | 25 +- .../tool/sourceOption/SourceOption.java | 39 ++- .../subpackageIgnore/SubpackageIgnore.java | 32 +- .../test/jdk/javadoc/tool/varArgs/Main.java | 4 +- 48 files changed, 101 insertions(+), 1774 deletions(-) delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java delete mode 100644 langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out delete mode 100644 langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java delete mode 100644 langtools/test/jdk/javadoc/tool/imports/I.java delete mode 100644 langtools/test/jdk/javadoc/tool/imports/MissingImport.java delete mode 100644 langtools/test/jdk/javadoc/tool/lib/Tester.java rename langtools/test/jdk/javadoc/tool/{generics/genericInnerAndOuter/pkg1/O.java => sourceOnly/p/NonSource.jasm} (76%) diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index 0a398513451..9a85f8b3d9e 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -26,29 +26,10 @@ ########################################################################### # # javadoc - -jdk/javadoc/tool/6176978/T6176978.java 8152049 generic-all no longer applicable, should delete -jdk/javadoc/tool/InlineTagsWithBraces.java 8152050 generic-all API, re-evaluate @bold, @maybe causes doclint to throw up. -jdk/javadoc/tool/LangVers.java 8152051 generic-all API, re-evaluate, unsure of this test. jdk/javadoc/tool/VerifyLocale.java 8149565 generic-all -locale option issues -jdk/javadoc/tool/enum/docComments/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/enum/enumType/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/genericClass/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/genericInterface/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/genericMethod/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/genericSuper/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/supertypes/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/throwsGeneric/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/tparamCycle/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/tparamTagOnType/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/generics/wildcards/Main.java 8152054 generic-all API modifications -jdk/javadoc/tool/imports/MissingImport.java 8152054 generic-all API modifications, testing deprecated APIs. -jdk/javadoc/tool/sourceOnly/Test.java 8152054 generic-all API modifications -jdk/javadoc/tool/sourceOption/SourceOption.java 8152054 generic-all API modifications -jdk/javadoc/tool/subpackageIgnore/SubpackageIgnore.java 8152054 generic-all API modifications -jdk/javadoc/tool/varArgs/Main.java 8152054 generic-all API modifications +jdk/javadoc/tool/enum/docComments/Main.java 8152313 generic-all convert to doclet test framework +jdk/javadoc/tool/enum/enumType/Main.java 8152313 generic-all convert to doclet test framework +jdk/javadoc/tool/varArgs/Main.java 8152313 generic-all convert to doclet test framework ########################################################################### # diff --git a/langtools/test/jdk/javadoc/tool/8025693/Test.java b/langtools/test/jdk/javadoc/tool/8025693/Test.java index e2bf1859a52..56e505a2f9b 100644 --- a/langtools/test/jdk/javadoc/tool/8025693/Test.java +++ b/langtools/test/jdk/javadoc/tool/8025693/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -25,7 +25,7 @@ * @test * @bug 8025693 * @summary javadoc should ignore methods found in classes on classpath - * @modules jdk.javadoc + * @modules jdk.javadoc/jdk.javadoc.internal.tool */ import java.io.*; @@ -69,7 +69,7 @@ public class Test { PrintStream prev = System.err; System.setErr(ps); try { - int rc = com.sun.tools.javadoc.Main.execute(args); + int rc = jdk.javadoc.internal.tool.Main.execute(args); } finally { System.err.flush(); System.setErr(prev); diff --git a/langtools/test/jdk/javadoc/tool/T4696488.java b/langtools/test/jdk/javadoc/tool/T4696488.java index 220244b833c..12ef6df19b0 100644 --- a/langtools/test/jdk/javadoc/tool/T4696488.java +++ b/langtools/test/jdk/javadoc/tool/T4696488.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -21,16 +21,17 @@ * questions. */ -import com.sun.tools.doclets.internal.toolkit.Configuration; - /** * @test * @bug 4696488 * @summary javadoc doesn't handle UNC paths for destination directory * @author Jesse Glick - * @modules jdk.javadoc/com.sun.tools.doclets.internal.toolkit + * @modules jdk.javadoc/jdk.javadoc.internal.doclets.toolkit * @run main T4696488 T4696488.java */ + +import jdk.javadoc.internal.doclets.toolkit.Configuration; + public class T4696488 { public static void main(String... args) { @@ -53,5 +54,4 @@ public class T4696488 { throw new Error("expected " + expectedOutput + " but was " + output); } } - } diff --git a/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java index e9a715042db..4e77bc8ef2e 100644 --- a/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java +++ b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 @@ -25,7 +25,7 @@ * @test * @bug 4983023 * @summary A bad superclass shouldn't throw the standard doclet into a loop - * @modules jdk.javadoc + * @modules jdk.javadoc/jdk.javadoc.internal.tool */ public class BadSuper { @@ -33,7 +33,7 @@ public class BadSuper { public static void main(String[] args) { String srcpath = System.getProperty("test.src", "."); - if (com.sun.tools.javadoc.Main.execute( + if (jdk.javadoc.internal.tool.Main.execute( new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0) throw new Error("Javadoc encountered warnings or errors."); } diff --git a/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java b/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java index 9238e5bd9bc..1abd5317350 100644 --- a/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java +++ b/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -25,7 +25,7 @@ * @test * @bug 4421066 * @summary Verify the comments in an enum type. - * @ignore API modifications + * @ignore 8152313 convert to doclet test framework * @library ../../lib * @modules jdk.javadoc * @compile ../../lib/Tester.java Main.java diff --git a/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java b/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java index 8f1f89bc726..b6f1a4bfd01 100644 --- a/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java +++ b/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -25,7 +25,7 @@ * @test * @bug 4421066 * @summary Verify the contents of an enum type. - * @ignore API modifications + * @ignore 8152313 convert to doclet test framework * @library ../../lib * @modules jdk.javadoc * @compile ../../lib/Tester.java Main.java diff --git a/langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java b/langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java deleted file mode 100644 index db947562e66..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the contents of the ClassDoc of a generic class. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out b/langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out deleted file mode 100644 index 968b6ee9dc0..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out +++ /dev/null @@ -1,16 +0,0 @@ -class pkg1.A - name: A / A / pkg1.A - type parameters: - T - superclass: - java.lang.Object - fields: - T t - pkg1.A at - pkg1.A as - constructors: - A() - methods: - void m1(T) - void m2(A) - void m3(A) diff --git a/langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java deleted file mode 100644 index 28206a29e4d..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public class A { - public T t; - public A at; - public A as; - - public void m1(T t) {} - public void m2(A at) {} - public void m3(A as) {} -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java b/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java deleted file mode 100644 index 3b78c863d0f..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the contents of the ClassDoc of - * a generic class with a generic inner class. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import java.util.Arrays; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - ClassDoc[] cds = root.classes(); - Arrays.sort(cds); - for (ClassDoc cd : cds) { - tester.printClass(cd); - tester.println(); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out b/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out deleted file mode 100644 index 1c0040ee6a0..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out +++ /dev/null @@ -1,53 +0,0 @@ -class pkg1.O - name: O / O / pkg1.O - type parameters: - T - superclass: - java.lang.Object - constructors: - O() - -class pkg1.O.I - name: I / O.I / pkg1.O.I - type parameters: - S - nested in: - pkg1.O - superclass: - java.lang.Object - constructors: - I() - methods: - void m1(O.I) - -class pkg1.X - name: X / X / pkg1.X - type parameters: - T - superclass: - java.lang.Object - constructors: - X() - -class pkg1.X.Y - name: Y / X.Y / pkg1.X.Y - nested in: - pkg1.X - superclass: - java.lang.Object - constructors: - Y() - -class pkg1.X.Y.Z - name: Z / X.Y.Z / pkg1.X.Y.Z - type parameters: - S - nested in: - pkg1.X.Y - superclass: - java.lang.Object - constructors: - Z() - methods: - void m1(X.Y.Z) - diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java b/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java deleted file mode 100644 index c3beb828a99..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public class X { - public class Y { - public class Z { - public void m1(X.Y.Z a) {} - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java b/langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java deleted file mode 100644 index ef5377a294a..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the contents of the ClassDoc of a generic interface. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out b/langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out deleted file mode 100644 index 2332f210b65..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out +++ /dev/null @@ -1,6 +0,0 @@ -interface pkg1.A - name: A / A / pkg1.A - type parameters: - T - methods: - void m1(T) diff --git a/langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java deleted file mode 100644 index d20c2435a26..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public interface A { - void m1(T t); -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java b/langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java deleted file mode 100644 index 7a114a0a826..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the reading of generic methods and constructors. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - for (ConstructorDoc c : cd.constructors()) - tester.printConstructor(c); - for (MethodDoc m : cd.methods()) - tester.printMethod(m); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out b/langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out deleted file mode 100644 index 8b051a1e669..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out +++ /dev/null @@ -1,20 +0,0 @@ -constructor pkg1.A() - signature: () - () - type parameters: - T -method pkg1.A.m1(T) - signature: (T) - (T) - type parameters: - T - returns: - void -method pkg1.A.m2(T, U) - signature: (T, U) - (T, U) - type parameters: - T extends java.lang.Number - U - returns: - void diff --git a/langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java deleted file mode 100644 index 4a7749c4bf2..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public class A { - public A() {} - public void m1(T t) {} - public void m2(T t, U u) {} -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java b/langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java deleted file mode 100644 index 02deea9c66d..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the contents of the ClassDoc of a generic class. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import java.util.Arrays; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = - new Tester("Main", "pkg1", "-package"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - ClassDoc[] cds = root.classes(); - Arrays.sort(cds); - for (ClassDoc cd : cds) { - tester.printClass(cd); - tester.println(); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out b/langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out deleted file mode 100644 index 2faad58662d..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out +++ /dev/null @@ -1,27 +0,0 @@ -class pkg1.A - name: A / A / pkg1.A - type parameters: - V - W - superclass: - pkg1.S - interfaces: - pkg1.I - constructors: - A() - -interface pkg1.I - name: I / I / pkg1.I - type parameters: - R - -class pkg1.S - name: S / S / pkg1.S - type parameters: - T - U - superclass: - java.lang.Object - constructors: - S() - diff --git a/langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java deleted file mode 100644 index c12caf96f51..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -class S { -} - -interface I { -} - -public class A extends S implements I { -} diff --git a/langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java b/langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java deleted file mode 100644 index 4078c906da1..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4922918 - * @summary Check supertypes and superinterfaces of parameterized types. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import java.util.Comparator; -import java.util.Arrays; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - ClassDoc[] cds = root.classes(); - Arrays.sort(cds); - for (ClassDoc cd : cds) { - ParameterizedType arrayList = - cd.superclassType().asParameterizedType(); - tester.println(arrayList); - tester.println(); - - tester.println(arrayList.superclassType()); - Type[] interfaces = arrayList.interfaceTypes(); - // Sort interfaces by type name, for consistent output. - Arrays.sort(interfaces, - new Comparator() { - public int compare(Type t1, Type t2) { - String name1 = t1.qualifiedTypeName(); - String name2 = t2.qualifiedTypeName(); - return name1.compareTo(name2); - } - }); - for (Type t : interfaces) { - tester.println(t); - } - tester.println(); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out b/langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out deleted file mode 100644 index d3dd3ce697d..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out +++ /dev/null @@ -1,16 +0,0 @@ -java.util.ArrayList - -java.util.AbstractList -java.io.Serializable -java.lang.Cloneable -java.util.List -java.util.RandomAccess - -java.util.ArrayList - -java.util.AbstractList -java.io.Serializable -java.lang.Cloneable -java.util.List -java.util.RandomAccess - diff --git a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java deleted file mode 100644 index 202d8452035..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -import java.util.ArrayList; - -public class A extends ArrayList { -} diff --git a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java b/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java deleted file mode 100644 index 3991e7cd3f6..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -import java.util.ArrayList; - -public class B extends ArrayList { -} diff --git a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java b/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java deleted file mode 100644 index 1f8dd4b74c8..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the reading of generic methods and constructors. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - for (MethodDoc m : cd.methods()) - tester.printMethod(m); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out b/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out deleted file mode 100644 index 99e65992a33..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out +++ /dev/null @@ -1,16 +0,0 @@ -method pkg1.A.m1() - signature: () - () - throws: - T extends java.lang.Throwable - returns: - void -method pkg1.A.m2() - signature: () - () - type parameters: - U extends java.lang.Throwable - throws: - U extends java.lang.Throwable - returns: - void diff --git a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java deleted file mode 100644 index 083d718d173..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public interface A { - void m1() throws T; - void m2() throws U; -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java b/langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java deleted file mode 100644 index cd187215d09..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Check a type parameter whose bound cycles back on itself. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - } - - public static boolean run(DocletEnvironment root) { - ClassDoc cd = root.classes()[0]; - System.out.println("*** " + cd); - TypeVariable E = cd.typeParameters()[0]; - System.out.println("*** " + E); - Type bound = E.bounds()[0]; - System.out.println("*** " + bound); - - // Verify that we have an instantiation of Enum, and not - // the generic interface. - ParameterizedType enumE = (ParameterizedType)bound; - - if (enumE.asClassDoc() != cd) { - throw new Error("Type declaration and type use don't match up."); - } else { - return true; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java b/langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java deleted file mode 100644 index 2369640e650..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public interface LikeEnum> { -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java deleted file mode 100644 index a081046f68b..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the reading of type parameter tags on methods. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - for (MethodDoc m : cd.methods()) { - tester.printMethod(m); - } - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out deleted file mode 100644 index 1d8c7ec9a55..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out +++ /dev/null @@ -1,12 +0,0 @@ -method pkg1.A.m1(T, U) - signature: (T, U) - (T, U) - @param the kind of thing - @param the other kind of thing - @param t the thing itself - @param u the other thing - type parameters: - T - U - returns: - void diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java deleted file mode 100644 index a289efa7bd2..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public interface A { - /** - * @param the kind of thing - * @param the other kind of thing - * @param t the thing itself - * @param u the other thing - */ - public void m1(T t, U u); -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java deleted file mode 100644 index 2e65e5ae586..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the reading of a type parameter tag on an interface. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out deleted file mode 100644 index 1b4da64b8cc..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out +++ /dev/null @@ -1,5 +0,0 @@ -interface pkg1.A - name: A / A / pkg1.A - type parameters: - T - @param the type parameter diff --git a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java deleted file mode 100644 index 22f18693043..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -/** - * @param the type parameter - */ -public interface A { -} diff --git a/langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java b/langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java deleted file mode 100644 index db947562e66..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 4421066 - * @summary Verify the contents of the ClassDoc of a generic class. - * @ignore API modifications - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out b/langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out deleted file mode 100644 index 686997b5a72..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out +++ /dev/null @@ -1,16 +0,0 @@ -class pkg1.A - name: A / A / pkg1.A - type parameters: - T - superclass: - java.lang.Object - fields: - pkg1.A f1 - pkg1.A f2 - pkg1.A f3 - constructors: - A() - methods: - void m1(A) - void m2(A) - void m3(A) diff --git a/langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java b/langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java deleted file mode 100644 index 8c832ad5fef..00000000000 --- a/langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2003, 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. - * - * 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 pkg1; - -public class A { - public A f1; - public A f2; - public A f3; - - public void m1(A p1) {} - public void m2(A p2) {} - public void m3(A p3) {} -} diff --git a/langtools/test/jdk/javadoc/tool/imports/I.java b/langtools/test/jdk/javadoc/tool/imports/I.java deleted file mode 100644 index 49768d4b916..00000000000 --- a/langtools/test/jdk/javadoc/tool/imports/I.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 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. - * - * 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. - */ - -// The following imported class is bogus, but should still be returned -// when inquired of. -import bo.o.o.o.Gus; - -public interface I { -} diff --git a/langtools/test/jdk/javadoc/tool/imports/MissingImport.java b/langtools/test/jdk/javadoc/tool/imports/MissingImport.java deleted file mode 100644 index ad61b3c314a..00000000000 --- a/langtools/test/jdk/javadoc/tool/imports/MissingImport.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2004, 2015, 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. - * - * 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. - */ - -/* - * @test - * @bug 5012972 - * @summary ClassDoc.getImportedClasses should return a class even if - * it's not in the classpath. - * @ignore API modifications, testing deprecated APIs. - * @modules jdk.javadoc - */ - -import java.util.Collections; -import java.util.Set; -import javax.lang.model.SourceVersion; -import jdk.javadoc.doclet.Doclet; -import jdk.javadoc.doclet.Doclet.Option; -import jdk.javadoc.doclet.DocletEnvironment; - - -public class MissingImport implements Doclet { - - public static void main(String[] args) { - String thisFile = "" + - new java.io.File(System.getProperty("test.src", "."), - "I.java"); - String[] toolargs = { - "-doclet", "MissingImport", - "-docletpath", System.getProperty("test.classes", "."), - thisFile - }; - if (com.sun.tools.javadoc.Main.execute(toolargs) != 0) - throw new Error("Javadoc encountered warnings or errors."); - } - - /* - * The world's simplest doclet. - */ - public static boolean run(DocletEnvironment root) { - ClassDoc c = root.classNamed("I"); - ClassDoc[] imps = c.importedClasses(); - if (imps.length == 0 || - !imps[0].qualifiedName().equals("bo.o.o.o.Gus")) { - throw new Error("Import bo.o.o.o.Gus not found"); - } - return true; - } - - @Override - public String getName() { - return "Test"; - } - - @Override - public Set