From fdd75a4bbbd318b9cd0fe268845221709461e710 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 8 Jul 2008 16:59:27 -0700 Subject: [PATCH 01/22] 6715251: javap should be consistent with javac and return 2 if given no arguments Reviewed-by: ksrini --- .../com/sun/tools/javap/JavapTask.java | 43 +++++++---- langtools/test/tools/javap/T4876942.java | 4 +- langtools/test/tools/javap/T6715251.java | 74 +++++++++++++++++++ 3 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 langtools/test/tools/javap/T6715251.java diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index a9031371a52..4da923e8846 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -306,14 +306,32 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { }; } + /** Result codes. + */ + static final int + EXIT_OK = 0, // Compilation completed with no errors. + EXIT_ERROR = 1, // Completed but reported errors. + EXIT_CMDERR = 2, // Bad command-line arguments + EXIT_SYSERR = 3, // System error or resource exhaustion. + EXIT_ABNORMAL = 4; // Compiler terminated abnormally + int run(String[] args) { try { handleOptions(args); + + // the following gives consistent behavior with javac + if (classes == null || classes.size() == 0) { + if (options.help || options.version || options.fullVersion) + return EXIT_OK; + else + return EXIT_CMDERR; + } + boolean ok = run(); - return ok ? 0 : 1; + return ok ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { diagnosticListener.report(createDiagnostic(e.key, e.args)); - return 1; + return EXIT_CMDERR; } catch (InternalError e) { Object[] e_args; if (e.getCause() == null) @@ -324,7 +342,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { System.arraycopy(e.args, 0, e_args, 1, e.args.length); } diagnosticListener.report(createDiagnostic("err.internal.error", e_args)); - return 1; + return EXIT_ABNORMAL; } finally { log.flush(); } @@ -349,8 +367,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { fileManager = getDefaultFileManager(diagnosticListener, log); Iterator iter = args.iterator(); - if (!iter.hasNext()) - options.help = true; + boolean noArgs = !iter.hasNext(); while (iter.hasNext()) { String arg = iter.next(); @@ -370,9 +387,15 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { ((JavapFileManager) fileManager).setIgnoreSymbolFile(true); if ((classes == null || classes.size() == 0) && - !(options.help || options.version || options.fullVersion)) { + !(noArgs || options.help || options.version || options.fullVersion)) { throw new BadArgs("err.no.classes.specified"); } + + if (noArgs || options.help) + showHelp(); + + if (options.version || options.fullVersion) + showVersion(options.fullVersion); } private void handleOption(String name, Iterator rest) throws BadArgs { @@ -405,14 +428,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { } public boolean run() { - if (options.help) - showHelp(); - - if (options.version || options.fullVersion) - showVersion(options.fullVersion); - if (classes == null || classes.size() == 0) - return true; + return false; context.put(PrintWriter.class, log); ClassWriter classWriter = ClassWriter.instance(context); diff --git a/langtools/test/tools/javap/T4876942.java b/langtools/test/tools/javap/T4876942.java index 49a4d71589f..186a5e075ee 100644 --- a/langtools/test/tools/javap/T4876942.java +++ b/langtools/test/tools/javap/T4876942.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4876942 + * @bug 4876942 6715251 * @summary javap invoked without args does not print help screen */ @@ -48,7 +48,7 @@ public class T4876942 { PrintWriter out = new PrintWriter(sw); //sun.tools.javap.Main.entry(args); int rc = com.sun.tools.javap.Main.run(args, out); - if (rc != 0) + if (rc != (args.length == 0 ? 2 : 0)) throw new Error("javap failed. rc=" + rc); out.close(); return sw.toString(); diff --git a/langtools/test/tools/javap/T6715251.java b/langtools/test/tools/javap/T6715251.java new file mode 100644 index 00000000000..357a83c3190 --- /dev/null +++ b/langtools/test/tools/javap/T6715251.java @@ -0,0 +1,74 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; +import java.util.*; + +/* + * @test + * @bug 6715251 + * @summary javap should be consistent with javac and return 2 if given no arguments + */ + +public class T6715251 { + public static void main(String... args) throws Exception { + new T6715251().run(); + } + + void run() throws Exception { + String testClasses = System.getProperty("test.classes", "."); + + test(2); + test(0, "-help"); + test(0, "-version"); + test(0, "-fullversion"); + test(0, "-classpath", testClasses, "T6715251"); + + if (errors > 0) + throw new Exception(errors + " errors received"); + } + + void test(int expect, String ... args) { + int rc = javap(args); + if (rc != expect) + error("bad result: expected: " + expect + ", found " + rc + "\n" + + log); + + } + + int javap(String... args) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args, pw); + log = sw.toString(); + return rc; + } + + void error(String msg) { + System.err.println(msg); + errors++; + } + + String log; + int errors; +} \ No newline at end of file From 23aea10d3edf801424e9eeaf9def15d10a5d30a4 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 8 Jul 2008 17:14:22 -0700 Subject: [PATCH 02/22] 6715757: javap does not print "extends java.lang.Object" Reviewed-by: ksrini --- .../classes/com/sun/tools/classfile/Type.java | 13 ++----------- .../classes/com/sun/tools/javap/ClassWriter.java | 14 +++++--------- langtools/test/tools/javap/4870651/T4870651.java | 9 ++++++--- langtools/test/tools/javap/T4880663.java | 5 +++-- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Type.java b/langtools/src/share/classes/com/sun/tools/classfile/Type.java index aaf6cb81a46..98fd099b341 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Type.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Type.java @@ -36,10 +36,6 @@ import java.util.List; public class Type { protected Type() { } - public boolean isObject() { - return false; - } - protected static void append(StringBuilder sb, String prefix, List types, String suffix) { sb.append(prefix); String sep = ""; @@ -66,11 +62,6 @@ public class Type { return name; } - @Override - public boolean isObject() { - return name.equals("java.lang.Object"); - } - public final String name; } @@ -129,7 +120,7 @@ public class Type { public String toString() { StringBuilder sb = new StringBuilder(); appendIfNotEmpty(sb, "<", typeArgTypes, ">"); - if (superclassType != null && !superclassType.isObject()) { + if (superclassType != null) { sb.append(" extends "); sb.append(superclassType); } @@ -188,7 +179,7 @@ public class Type { StringBuilder sb = new StringBuilder(); sb.append(name); String sep = " extends "; - if (classBound != null && !classBound.isObject()) { + if (classBound != null) { sb.append(sep); sb.append(classBound); sep = " & "; diff --git a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java index c39dbe52d9f..d1c5707a8d8 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java @@ -104,14 +104,10 @@ public class ClassWriter extends BasicWriter { Signature_attribute sigAttr = getSignature(cf.attributes); if (sigAttr == null) { // use info from class file header - if (classFile.isClass()) { - if (classFile.super_class != 0 ) { - String sn = getJavaSuperclassName(cf); - if (!sn.equals("java.lang.Object") || options.compat) { // BUG XXXXXXXX - print(" extends "); - print(sn); - } - } + if (classFile.isClass() && classFile.super_class != 0 ) { + String sn = getJavaSuperclassName(cf); + print(" extends "); + print(sn); } for (int i = 0; i < classFile.interfaces.length; i++) { print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ","); @@ -124,7 +120,7 @@ public class ClassWriter extends BasicWriter { // FieldType and a ClassSignatureType that only contains a superclass type. if (t instanceof Type.ClassSigType) print(t); - else if (!t.isObject()) { + else { print(" extends "); print(t); } diff --git a/langtools/test/tools/javap/4870651/T4870651.java b/langtools/test/tools/javap/4870651/T4870651.java index a2ab5605304..874d1382bda 100644 --- a/langtools/test/tools/javap/4870651/T4870651.java +++ b/langtools/test/tools/javap/4870651/T4870651.java @@ -23,8 +23,9 @@ /* * @test - * @bug 4870651 - * @summary javap should recognize generics, varargs, enum + * @bug 4870651 6715757 + * @summary javap should recognize generics, varargs, enum; + * javap prints "extends java.lang.Object" * @build T4870651 Test * @run main T4870651 */ @@ -38,7 +39,9 @@ public class T4870651 { public void run() throws IOException { verify("Test", - "class Test, U extends java.lang.Comparable>", + "class Test, " + + "U extends java.lang.Comparable>", "v1(java.lang.String...)"); verify("Test$Enum", diff --git a/langtools/test/tools/javap/T4880663.java b/langtools/test/tools/javap/T4880663.java index 1f76c4212fc..f828274732a 100644 --- a/langtools/test/tools/javap/T4880663.java +++ b/langtools/test/tools/javap/T4880663.java @@ -23,8 +23,9 @@ /* * @test - * @bug 4880663 + * @bug 4880663 6715757 * @summary javap could output whitespace between class name and opening brace + * javap prints "extends java.lang.Object" */ @@ -38,7 +39,7 @@ public class T4880663 { public void run() throws IOException { File javaFile = writeTestFile(); File classFile = compileTestFile(javaFile); - verify(classFile, "class Test {"); + verify(classFile, "class Test extends java.lang.Object {"); if (errors > 0) throw new Error(errors + " found."); From a2ef1138ade2fa5369afd701d18698393669c143 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 8 Jul 2008 17:25:50 -0700 Subject: [PATCH 03/22] 6715753: unknown option error can be a little more helpful Reviewed-by: ksrini --- .../com/sun/tools/javap/JavapTask.java | 5 +- .../tools/javap/resources/javap.properties | 4 ++ langtools/test/tools/javap/T6715753.java | 50 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javap/T6715753.java diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index 4da923e8846..a040701bcb3 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -298,7 +298,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { return new DiagnosticListener () { public void report(Diagnostic diagnostic) { if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { - pw.print(getMessage("err.prefix")); + pw.print(getMessage("err.prefix")); pw.print(" "); } pw.println(diagnostic.getMessage(null)); @@ -331,6 +331,9 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { return ok ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { diagnosticListener.report(createDiagnostic(e.key, e.args)); + if (e.showUsage) { + log.println(getMessage("main.usage.summary", progname)); + } return EXIT_CMDERR; } catch (InternalError e) { Object[] e_args; diff --git a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties index b8d8adbae12..1243af32cbd 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties @@ -16,6 +16,10 @@ err.unknown.option=unknown option: {0} err.verify.not.supported=-verify not supported err.Xold.not.supported.here=-Xold must be given as the first option +main.usage.summary=\ +Usage: {0} \n\ +use -help for a list of possible options + main.usage=\ Usage: {0} \n\ where possible options include: diff --git a/langtools/test/tools/javap/T6715753.java b/langtools/test/tools/javap/T6715753.java new file mode 100644 index 00000000000..b331b5f98e1 --- /dev/null +++ b/langtools/test/tools/javap/T6715753.java @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; + +/* + * @test + * @bug 6715753 + * @summary Use javap to inquire about a specific inner class + */ + +public class T6715753 { + public static void main(String... args) throws Exception { + new T6715753().run(); + } + + void run() throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = { "-notAnOption" }; + int rc = com.sun.tools.javap.Main.run(args, pw); + String log = sw.toString(); + if (rc == 0 + || log.indexOf("-notAnOption") == -1 + || log.indexOf("javap") == -1) { // locale-independent indication of usage message + System.err.println("rc: " + rc + ", log=\n" + log); + throw new Exception("test failed"); + } + } +} \ No newline at end of file From d1e933393158c87cf5aceea09f7bd7971d8d1b3f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 8 Jul 2008 17:53:03 -0700 Subject: [PATCH 04/22] 6716452: (classfile) need a method to get the index of an attribute Reviewed-by: ksrini --- .../com/sun/tools/classfile/Attributes.java | 13 ++ langtools/test/tools/javap/T6716452.java | 113 ++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 langtools/test/tools/javap/T6716452.java diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Attributes.java b/langtools/src/share/classes/com/sun/tools/classfile/Attributes.java index 7891aec9cdc..d3ea27f7337 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Attributes.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Attributes.java @@ -78,6 +78,19 @@ public class Attributes implements Iterable { return map.get(name); } + public int getIndex(ConstantPool constant_pool, String name) { + for (int i = 0; i < attrs.length; i++) { + Attribute attr = attrs[i]; + try { + if (attr != null && attr.getName(constant_pool).equals(name)) + return i; + } catch (ConstantPoolException e) { + // ignore invalid entries + } + } + return -1; + } + public int size() { return attrs.length; } diff --git a/langtools/test/tools/javap/T6716452.java b/langtools/test/tools/javap/T6716452.java new file mode 100644 index 00000000000..32a2620b8f3 --- /dev/null +++ b/langtools/test/tools/javap/T6716452.java @@ -0,0 +1,113 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test 6716452 + * @summary need a method to get an index of an attribute + */ + +import java.io.*; +import com.sun.tools.classfile.*; + +public class T6716452 { + public static void main(String[] args) throws Exception { + new T6716452().run(); + } + + public void run() throws Exception { + File javaFile = writeTestFile(); + File classFile = compileTestFile(javaFile); + + ClassFile cf = ClassFile.read(classFile); + for (Method m: cf.methods) { + test(cf, m); + } + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + void test(ClassFile cf, Method m) { + test(cf, m, Attribute.Code, Code_attribute.class); + test(cf, m, Attribute.Exceptions, Exceptions_attribute.class); + } + + // test the result of Attributes.getIndex according to expectations + // encoded in the method's name + void test(ClassFile cf, Method m, String name, Class c) { + int index = m.attributes.getIndex(cf.constant_pool, name); + try { + String m_name = m.getName(cf.constant_pool); + System.err.println("Method " + m_name + " name:" + name + " index:" + index + " class: " + c); + boolean expect = (m_name.equals("") && name.equals("Code")) + || (m_name.indexOf(name) != -1); + boolean found = (index != -1); + if (expect) { + if (found) { + Attribute attr = m.attributes.get(index); + if (!c.isAssignableFrom(attr.getClass())) { + error(m + ": unexpected attribute found," + + " expected " + c.getName() + + " found " + attr.getClass().getName()); + } + } else { + error(m + ": expected attribute " + name + " not found"); + } + } else { + if (found) { + error(m + ": unexpected attribute " + name); + } + } + } catch (ConstantPoolException e) { + error(m + ": " + e); + } + } + + File writeTestFile() throws IOException { + File f = new File("Test.java"); + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); + out.println("abstract class Test { "); + out.println(" abstract void m();"); + out.println(" void m_Code() { }"); + out.println(" abstract void m_Exceptions() throws Exception;"); + out.println(" void m_Code_Exceptions() throws Exception { }"); + out.println("}"); + out.close(); + return f; + } + + File compileTestFile(File f) { + int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() }); + if (rc != 0) + throw new Error("compilation failed. rc=" + rc); + String path = f.getPath(); + return new File(path.substring(0, path.length() - 5) + ".class"); + } + + void error(String msg) { + System.err.println("error: " + msg); + errors++; + } + + int errors; +} From 02ef4bbc8c8000ce4e212f7d739baeff7beec5d6 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 8 Jul 2008 18:06:19 -0700 Subject: [PATCH 05/22] 4501661: disallow mixing -public, -private, and -protected options at the same time Reviewed-by: ksrini --- .../com/sun/tools/javap/JavapTask.java | 17 +++ .../classes/com/sun/tools/javap/Options.java | 3 + .../tools/javap/resources/javap.properties | 1 + langtools/test/tools/javap/T4501661.java | 126 ++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 langtools/test/tools/javap/T4501661.java diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index a040701bcb3..1fc2886385c 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -140,24 +140,31 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { new Option(false, "-public") { void process(JavapTask task, String opt, String arg) { + task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PUBLIC; } }, new Option(false, "-protected") { void process(JavapTask task, String opt, String arg) { + task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PROTECTED; } }, new Option(false, "-package") { void process(JavapTask task, String opt, String arg) { + task.options.accessOptions.add(opt); task.options.showAccess = 0; } }, new Option(false, "-p", "-private") { void process(JavapTask task, String opt, String arg) { + if (!task.options.accessOptions.contains("-p") && + !task.options.accessOptions.contains("-private")) { + task.options.accessOptions.add(opt); + } task.options.showAccess = AccessFlags.ACC_PRIVATE; } }, @@ -386,6 +393,16 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask { throw new BadArgs("err.unknown.option", arg).showUsage(true); } + if (!options.compat && options.accessOptions.size() > 1) { + StringBuilder sb = new StringBuilder(); + for (String opt: options.accessOptions) { + if (sb.length() > 0) + sb.append(" "); + sb.append(opt); + } + throw new BadArgs("err.incompatible.options", sb); + } + if (options.ignoreSymbolFile && fileManager instanceof JavapFileManager) ((JavapFileManager) fileManager).setIgnoreSymbolFile(true); diff --git a/langtools/src/share/classes/com/sun/tools/javap/Options.java b/langtools/src/share/classes/com/sun/tools/javap/Options.java index 33be38c2db1..fcbfc0211d8 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/Options.java +++ b/langtools/src/share/classes/com/sun/tools/javap/Options.java @@ -25,6 +25,8 @@ package com.sun.tools.javap; +import java.util.HashSet; +import java.util.Set; import com.sun.tools.classfile.AccessFlags; /* @@ -74,6 +76,7 @@ public class Options { public boolean showFlags; public boolean showLineAndLocalVariableTables; public int showAccess; + public Set accessOptions = new HashSet(); public boolean showDisassembled; public boolean showInternalSignatures; public boolean showAllAttrs; diff --git a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties index 1243af32cbd..8f50abb94bd 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties @@ -7,6 +7,7 @@ err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, err.end.of.file=unexpected end of file while reading {0} err.file.not.found=file not found: {0} err.h.not.supported=-h is no longer available - use the 'javah' program +err.incompatible.options=bad combination of options: {0} err.internal.error=internal error: {0} {1} {2} err.ioerror=IO error reading {0}: {1} err.missing.arg=no value given for {0} diff --git a/langtools/test/tools/javap/T4501661.java b/langtools/test/tools/javap/T4501661.java new file mode 100644 index 00000000000..3659db1ddeb --- /dev/null +++ b/langtools/test/tools/javap/T4501661.java @@ -0,0 +1,126 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; +import java.util.*; + +/* + * @test + * @bug 4501661 + * @summary disallow mixing -public, -private, and -protected + */ +public class T4501661 { + public static void main(String... args) throws Exception { + new T4501661().run(); + } + + void run() throws Exception { + File javaFile = writeTestFile(); + File classFile = compileTestFile(javaFile); + boolean[] values = { false, true }; + for (boolean priv: values) { + for (boolean prot: values) { + for (boolean publ: values) { + test(priv, prot, publ, classFile); + } + } + } + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + void test(boolean priv, boolean prot, boolean publ, File classFile) { + List args = new ArrayList(); + if (priv) + args.add("-private"); + if (prot) + args.add("-protected"); + if (publ) + args.add("-public"); + boolean expectOK = (args.size() <= 1); + args.add(classFile.getPath()); + String out = javap(args, expectOK); + if (out == null) + return; + if (!priv && !prot && !publ) + checkNone(out, "private"); + if (prot) + checkNone(out, "private", "package"); + if (publ) + checkNone(out, "private", "package", "protected"); + } + + File writeTestFile() throws IOException { + File f = new File("Test.java"); + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f))); + out.println("abstract class Test { "); + out.println(" public void public_m() { }"); + out.println(" protected void protected_m() { }"); + out.println(" private void private_m() { }"); + out.println(" void package_m() { }"); + out.println("}"); + out.close(); + return f; + } + + File compileTestFile(File f) { + int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() }); + if (rc != 0) + throw new Error("compilation failed. rc=" + rc); + String path = f.getPath(); + return new File(path.substring(0, path.length() - 5) + ".class"); + } + + String javap(List args, boolean expectOK) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw); + System.err.println(args); + System.err.println(sw); + if (expectOK) { + if (rc == 0) + return sw.toString(); + else + error("javap failed unexpectedly; rc=" + rc + "\n" + sw); + } else { + if (rc == 0) + error("javap succeeded unexpectedly"); + } + return null; + } + + void checkNone(String log, String... words) { + for (String word: words) { + if (log.indexOf(word) != -1) + error("\"" + word + "\" unexpectedly found in output"); + } + } + + void error(String msg) { + System.err.println("error: " + msg); + errors++; + } + + int errors; +} From 634c79b98d2ed96cae1fe6892d160360f3b93f65 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Wed, 9 Jul 2008 15:42:00 -0700 Subject: [PATCH 06/22] 6704966: OpenJDK README needs additional info on how to build freetype 6704968: OpenJDK Build README is missing ant requirement 6704973: OpenJDK Build readme needs cygwin package list improvements 6590549: Cygwin build of OpenJDK has problems and not very well documented 6462815: cygwin's gnumake 3.81-1 does not support MS-DOS path names 6597857: JDK build instructions need to be updated (BUILD_JDK_IMPORT_PATH, BUILD_BINARY_PLUGS_PATH) Reviewed-by: jjg, igor --- README-builds.html | 454 ++++++++++++++++++++++++++------------------- 1 file changed, 258 insertions(+), 196 deletions(-) diff --git a/README-builds.html b/README-builds.html index a2cf768e122..37998f9c1f6 100644 --- a/README-builds.html +++ b/README-builds.html @@ -5,15 +5,12 @@ - + +
@@ -54,6 +51,7 @@
  • Bootstrap JDK
  • Binary Plugs
  • Optional Import JDK
  • +
  • Ant
  • Certificate Authority File (cacert)
  • Compilers
      @@ -424,24 +422,37 @@ you should use gmake which will be located in either the /opt/sfw/bin or /usr/sfw/bin directory. + In more recent versions of Solaris GNU make can be found + at /usr/bin/gmake.
    • Windows: Make sure you start your build inside a bash/sh/ksh shell.
      WARNING: Watch out for make version 3.81, it may - not work due to a lack of support for drive letter paths - like C:/. See - section on gmake. + not work due to a lack of support for MS-DOS drive letter paths + like C:/ or C:\. Use a 3.80 version, or find a newer - version that has this problem fixed. + version that has this problem fixed, like 3.82. The older 3.80 version of make.exe can be downloaded with this link. + Use of this older 3.80 make.exe may require that you install the + libintl2.dll library or libintl2 cygwin package which is + no longer installed by default by the cygwin installer. +
      Also see the mozilla developer center on this topic. +
      + It's hoped that when make 3.82 starts shipping in a future cygwin + release that this MS-DOS path issue will be fixed. + In addition to the above 3.80 make.exe you can download + this + + www.cmake.org make.exe which will not have a libintl2.dll + dependency.

    @@ -507,6 +518,11 @@ Install or upgrade the FreeType development package.

  • +
  • + Install + Ant, set + ANT_HOME. +
  • @@ -567,6 +583,11 @@ CUPS Include files, set ALT_CUPS_HEADERS_PATH. +
  • + Install + Ant, set + ANT_HOME. +
  • @@ -654,6 +675,11 @@ Install Microsoft DirectX SDK. +
  • + Install + Ant, set + ANT_HOME. +
  • @@ -736,6 +762,22 @@ and the build will copy the needed files from this import area. +

    Ant

    +
    + All OpenJDK builds require access to least Ant 1.6.5. + The Ant tool is available from the + + Ant download site. + You should always set + ANT_HOME + to point to the location of + the Ant installation, this is the directory pathname + that contains a bin and lib. + It's also a good idea to also place its bin directory + in the PATH environment variable, although it's + not absolutely required. +
    +

    Certificate Authority File (cacert)

    See @@ -915,6 +957,21 @@ and ALT_FREETYPE_HEADERS_PATH to refer to place where library and header files are installed. +

    + Building the freetype 2 libraries from scratch is also possible, + however on Windows refer to the + + Windows FreeType DLL build instructions. +

    + Note that by default FreeType is built with byte code hinting + support disabled due to licensing restrictions. + In this case, text appearance and metrics are expected to + differ from Sun's official JDK build. + See + + the SourceForge FreeType2 Home Page + + for more information.

    Advanced Linux Sound Architecture (ALSA) (Linux only)

    @@ -1036,7 +1093,8 @@ - + @@ -1050,7 +1108,7 @@ - + @@ -1061,17 +1119,17 @@ - + - + - + @@ -1224,46 +1282,6 @@ document) that can impact the build are:
    -
    PATH
    -
    Typically you want to set the PATH to include: -
      -
    • The location of the GNU make binary
    • -
    • The location of the Bootstrap JDK java - (see Bootstrap JDK)
    • -
    • The location of the C/C++ compilers - (see compilers)
    • -
    • The location or locations for the Unix command utilities - (e.g. /usr/bin)
    • -
    -
    -
    MILESTONE
    -
    - The milestone name for the build (e.g."beta"). - The default value is "internal". -
    -
    BUILD_NUMBER
    -
    - The build number for the build (e.g. "b27"). - The default value is "b00". -
    -
    ARCH_DATA_MODEL
    -
    The ARCH_DATA_MODEL variable - is used to specify whether the build is to generate 32-bit or 64-bit - binaries. - The Solaris build supports either 32-bit or 64-bit builds, but - Windows and Linux will support only one, depending on the specific - OS being used. - Normally, setting this variable is only necessary on Solaris. - Set ARCH_DATA_MODEL to 32 for generating 32-bit binaries, - or to 64 for generating 64-bit binaries. -
    -
    ALT_BOOTDIR
    -
    - The location of the bootstrap JDK installation. - See Bootstrap JDK for more information. - You should always install your own local Bootstrap JDK and - always set ALT_BOOTDIR explicitly. -
    ALT_BINARY_PLUGS_PATH
    The location of the binary plugs installation. @@ -1272,118 +1290,12 @@ recent Binary Plugs install image and set this variable to that location.
    -
    ALT_JDK_IMPORT_PATH
    +
    ALT_BOOTDIR
    - The location of a previously built JDK installation. - See Optional Import JDK for more information. -
    -
    ALT_OUTPUTDIR
    -
    - An override for specifying the (absolute) path of where the - build output is to go. - The default output directory will be build/platform. -
    -
    ALT_COMPILER_PATH
    -
    - The location of the C/C++ compiler. - The default varies depending on the platform. -
    -
    ALT_CACERTS_FILE
    -
    - The location of the cacerts file. - The default will refer to - jdk/src/share/lib/security/cacerts. -
    -
    ALT_CUPS_HEADERS_PATH
    -
    - The location of the CUPS header files. - See CUPS information for more information. - If this path does not exist the fallback path is - /usr/include. -
    -
    ALT_FREETYPE_LIB_PATH
    -
    - The location of the FreeType shared library. - See FreeType information for details. -
    -
    ALT_FREETYPE_HEADERS_PATH
    -
    - The location of the FreeType header files. - See FreeType information for details. -
    -
    ALT_JDK_DEVTOOLS_PATH
    -
    - The default root location of the devtools. - The default value is - $(ALT_SLASH_JAVA)/devtools. -
    -
    ALT_DEVTOOLS_PATH
    -
    - The location of tools like the - zip and unzip - binaries, but might also contain the GNU make utility - (gmake). - So this area is a bit of a grab bag, especially on Windows. - The default value depends on the platform and - Unix Commands being used. - On Linux the default will be - $(ALT_JDK_DEVTOOLS_PATH)/linux/bin, - on Solaris - $(ALT_JDK_DEVTOOLS_PATH)/{sparc,i386}/bin, - on Windows with MKS - %SYSTEMDRIVE%/UTILS, - and on Windows with CYGWIN - /usr/bin. -
    -
    ALT_UNIXCOMMAND_PATH
    -
    - An override for specifying where the - Unix command set are located. - The default location varies depending on the platform, - "%SYSTEMDRIVE%/MKSNT" or - $(ROOTDIR) on Windows with MKS, otherwise it's - "/bin" or /usr/bin. -
    -
    ALT_UNIXCCS_PATH
    -
    - Solaris only: - An override for specifying where the Unix CCS - command set are located. - The default location is /usr/ccs/bin -
    -
    ALT_USRBIN_PATH
    -
    - An override for specifying where the - Unix /usr/bin commands are located. You usually do not need - to set this variable: the default location is /usr/bin) -
    -
    ALT_SLASHJAVA
    -
    - The default root location for many of the ALT path locations - of the following ALT variables. - The default value is - "/java" on Solaris and Linux, - "J:" on Windows. -
    -
    ALT_BUILD_JDK_IMPORT_PATH
    -
    - These are useful in managing builds on multiple platforms. - The default network location for all of the import JDK images - for all platforms. - If ALT_JDK_IMPORT_PATH - is not set, this directory will be used and should contain - the following directories: - solaris-sparc, - solaris-i586, - solaris-sparcv9, - solaris-amd64, - linux-i586, - linux-amd64, - windows-i586, - and - windows-amd64. - Where each of these directories contain the import JDK image - for that platform. + The location of the bootstrap JDK installation. + See Bootstrap JDK for more information. + You should always install your own local Bootstrap JDK and + always set ALT_BOOTDIR explicitly.
    ALT_BUILD_BINARY_PLUGS_PATH
    @@ -1405,36 +1317,186 @@ Where each of these directories contain the binary plugs image for that platform.
    -
    Windows specific:
    +
    ALT_BUILD_JDK_IMPORT_PATH
    -
    -
    ALT_MSDEVTOOLS_PATH
    -
    - The location of the Microsoft Visual Studio .NET 2003 - tools 'bin' directory. - The default is usually derived from - ALT_COMPILER_PATH. -
    -
    ALT_DXSDK_PATH
    -
    - The location of the - Microsoft DirectX 9 SDK. - The default will be to try and use the DirectX environment - variable DXSDK_DIR, - failing that, look in C:/DXSDK. -
    -
    ALT_MSVCRT_DLL_PATH
    -
    - The location of the - MSVCRT.DLL. -
    -
    ALT_MSVCR71_DLL_PATH
    -
    - i586 only: - The location of the - MSVCR71.DLL. -
    -
    + These are useful in managing builds on multiple platforms. + The default network location for all of the import JDK images + for all platforms. + If ALT_JDK_IMPORT_PATH + is not set, this directory will be used and should contain + the following directories: + solaris-sparc, + solaris-i586, + solaris-sparcv9, + solaris-amd64, + linux-i586, + linux-amd64, + windows-i586, + and + windows-amd64. + Where each of these directories contain the import JDK image + for that platform. +
    +
    ALT_CACERTS_FILE
    +
    + The location of the cacerts file. + The default will refer to + jdk/src/share/lib/security/cacerts. +
    +
    ALT_COMPILER_PATH
    +
    + The location of the C/C++ compiler. + The default varies depending on the platform. +
    +
    ALT_CUPS_HEADERS_PATH
    +
    + The location of the CUPS header files. + See CUPS information for more information. + If this path does not exist the fallback path is + /usr/include. +
    +
    ALT_DEVTOOLS_PATH
    +
    + The location of tools like the + zip and unzip + binaries, but might also contain the GNU make utility + (gmake). + So this area is a bit of a grab bag, especially on Windows. + The default value depends on the platform and + Unix Commands being used. + On Linux the default will be + $(ALT_JDK_DEVTOOLS_PATH)/linux/bin, + on Solaris + $(ALT_JDK_DEVTOOLS_PATH)/{sparc,i386}/bin, + on Windows with MKS + %SYSTEMDRIVE%/UTILS, + and on Windows with CYGWIN + /usr/bin. +
    +
    ALT_DXSDK_PATH
    +
    + Windows Only: + The location of the + Microsoft DirectX 9 SDK. + The default will be to try and use the DirectX environment + variable DXSDK_DIR, + failing that, look in C:/DXSDK. +
    +
    ALT_FREETYPE_HEADERS_PATH
    +
    + The location of the FreeType header files. + See FreeType information for details. +
    +
    ALT_FREETYPE_LIB_PATH
    +
    + The location of the FreeType shared library. + See FreeType information for details. +
    +
    ALT_JDK_DEVTOOLS_PATH
    +
    + The default root location of the devtools. + The default value is + $(ALT_SLASH_JAVA)/devtools. +
    +
    ALT_JDK_IMPORT_PATH
    +
    + The location of a previously built JDK installation. + See Optional Import JDK for more information. +
    +
    ALT_MSDEVTOOLS_PATH
    +
    + Windows Only: + The location of the Microsoft Visual Studio .NET 2003 + tools 'bin' directory. + The default is usually derived from + ALT_COMPILER_PATH. +
    +
    ALT_MSVCR71_DLL_PATH
    +
    + Windows i586 only: + The location of the + MSVCR71.DLL. +
    +
    ALT_MSVCRT_DLL_PATH
    +
    + Windows Only: + The location of the + MSVCRT.DLL. +
    +
    ALT_OUTPUTDIR
    +
    + An override for specifying the (absolute) path of where the + build output is to go. + The default output directory will be build/platform. +
    +
    ALT_SLASHJAVA
    +
    + The default root location for many of the ALT path locations + of the following ALT variables. + The default value is + "/java" on Solaris and Linux, + "J:" on Windows. +
    +
    ALT_UNIXCCS_PATH
    +
    + Solaris only: + An override for specifying where the Unix CCS + command set are located. + The default location is /usr/ccs/bin +
    +
    ALT_UNIXCOMMAND_PATH
    +
    + An override for specifying where the + Unix command set are located. + The default location varies depending on the platform, + "%SYSTEMDRIVE%/MKSNT" or + $(ROOTDIR) on Windows with MKS, otherwise it's + "/bin" or /usr/bin. +
    +
    ALT_USRBIN_PATH
    +
    + An override for specifying where the + Unix /usr/bin commands are located. You usually do not need + to set this variable: the default location is /usr/bin) +
    +
    ANT_HOME
    +
    + The location of the Ant installation. + See Ant for more information. + You should always set ANT_HOME explicitly. +
    +
    ARCH_DATA_MODEL
    +
    The ARCH_DATA_MODEL variable + is used to specify whether the build is to generate 32-bit or 64-bit + binaries. + The Solaris build supports either 32-bit or 64-bit builds, but + Windows and Linux will support only one, depending on the specific + OS being used. + Normally, setting this variable is only necessary on Solaris. + Set ARCH_DATA_MODEL to 32 for generating 32-bit binaries, + or to 64 for generating 64-bit binaries. +
    +
    BUILD_NUMBER
    +
    + The build number for the build (e.g. "b27"). + The default value is "b00". +
    +
    MILESTONE
    +
    + The milestone name for the build (e.g."beta"). + The default value is "internal". +
    +
    PATH
    +
    Typically you want to set the PATH to include: +
      +
    • The location of the GNU make binary
    • +
    • The location of the Bootstrap JDK java + (see Bootstrap JDK)
    • +
    • The location of the C/C++ compilers + (see compilers)
    • +
    • The location or locations for the Unix command utilities + (e.g. /usr/bin)
    • +
    From aa985271fdb0992062788fc35d40b98ab0bdf379 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 10 Jul 2008 11:25:23 -0700 Subject: [PATCH 07/22] 6724327: eliminate use of shell tests for simple golden file tests Reviewed-by: darcy --- .../test/tools/javac/CyclicInheritance.java | 2 +- .../test/tools/javac/CyclicInheritance.out | 32 +-- .../test/tools/javac/CyclicInheritance.sh | 86 -------- .../javac/ExtendsAccess/ExtendsAccess.java | 2 +- .../javac/ExtendsAccess/ExtendsAccess.out | 196 ++++-------------- .../javac/ExtendsAccess/ExtendsAccess.sh | 83 -------- .../BadConstructorModifiers.java | 2 +- .../BadConstructorModifiers.out | 4 +- .../BadConstructorModifiers.sh | 82 -------- .../tools/javac/InnerNamedConstant_2.java | 2 +- .../test/tools/javac/InnerNamedConstant_2.out | 16 +- .../test/tools/javac/InnerNamedConstant_2.sh | 82 -------- .../test/tools/javac/LocalClasses_2.java | 2 +- langtools/test/tools/javac/LocalClasses_2.out | 4 +- langtools/test/tools/javac/LocalClasses_2.sh | 82 -------- langtools/test/tools/javac/NameCollision.java | 2 +- langtools/test/tools/javac/NameCollision.out | 4 +- langtools/test/tools/javac/NameCollision.sh | 83 -------- .../tools/javac/NestedInnerClassNames.java | 2 +- .../tools/javac/NestedInnerClassNames.out | 68 ++---- .../test/tools/javac/NestedInnerClassNames.sh | 82 -------- .../test/tools/javac/NonStaticFieldExpr1.java | 2 +- .../test/tools/javac/NonStaticFieldExpr1.out | 4 +- .../test/tools/javac/NonStaticFieldExpr1.sh | 85 -------- .../test/tools/javac/NonStaticFieldExpr2.java | 2 +- .../test/tools/javac/NonStaticFieldExpr2.out | 4 +- .../test/tools/javac/NonStaticFieldExpr2.sh | 82 -------- .../test/tools/javac/NonStaticFieldExpr3.java | 2 +- .../test/tools/javac/NonStaticFieldExpr3.out | 4 +- .../test/tools/javac/NonStaticFieldExpr3.sh | 82 -------- .../QualifiedAccess/QualifiedAccess_1.java | 4 +- .../QualifiedAccess/QualifiedAccess_1.out | 72 ++----- .../QualifiedAccess/QualifiedAccess_1.sh | 85 -------- .../QualifiedAccess/QualifiedAccess_2.java | 4 +- .../QualifiedAccess/QualifiedAccess_2.out | 24 +-- .../QualifiedAccess/QualifiedAccess_2.sh | 85 -------- .../QualifiedAccess/QualifiedAccess_3.java | 2 +- .../QualifiedAccess/QualifiedAccess_3.out | 16 +- .../QualifiedAccess/QualifiedAccess_3.sh | 83 -------- .../test/tools/javac/SynchronizedClass.java | 2 +- .../test/tools/javac/SynchronizedClass.out | 4 +- .../test/tools/javac/SynchronizedClass.sh | 82 -------- .../depDocComment/DeprecatedDocComment.java | 3 +- .../depDocComment/DeprecatedDocComment.out | 12 +- .../depDocComment/DeprecatedDocComment.sh | 84 -------- 45 files changed, 133 insertions(+), 1614 deletions(-) delete mode 100644 langtools/test/tools/javac/CyclicInheritance.sh delete mode 100644 langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.sh delete mode 100644 langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.sh delete mode 100644 langtools/test/tools/javac/InnerNamedConstant_2.sh delete mode 100644 langtools/test/tools/javac/LocalClasses_2.sh delete mode 100644 langtools/test/tools/javac/NameCollision.sh delete mode 100644 langtools/test/tools/javac/NestedInnerClassNames.sh delete mode 100644 langtools/test/tools/javac/NonStaticFieldExpr1.sh delete mode 100644 langtools/test/tools/javac/NonStaticFieldExpr2.sh delete mode 100644 langtools/test/tools/javac/NonStaticFieldExpr3.sh delete mode 100644 langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.sh delete mode 100644 langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.sh delete mode 100644 langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.sh delete mode 100644 langtools/test/tools/javac/SynchronizedClass.sh delete mode 100644 langtools/test/tools/javac/depDocComment/DeprecatedDocComment.sh diff --git a/langtools/test/tools/javac/CyclicInheritance.java b/langtools/test/tools/javac/CyclicInheritance.java index e1eaeb2b279..6c09543249f 100644 --- a/langtools/test/tools/javac/CyclicInheritance.java +++ b/langtools/test/tools/javac/CyclicInheritance.java @@ -4,7 +4,7 @@ * @summary Test that recursive 'extends' and 'implements' clauses are detected * and disallowed. * - * @run shell CyclicInheritance.sh + * @compile/fail/ref=CyclicInheritance.out -XDrawDiagnostics -XDstdout CyclicInheritance.java */ diff --git a/langtools/test/tools/javac/CyclicInheritance.out b/langtools/test/tools/javac/CyclicInheritance.out index 01dc515687c..2923e4f1306 100644 --- a/langtools/test/tools/javac/CyclicInheritance.out +++ b/langtools/test/tools/javac/CyclicInheritance.out @@ -1,25 +1,9 @@ -CyclicInheritance.java:15: cyclic inheritance involving C1 -class C1 extends C1 {} // ERROR - Cyclic inheritance -^ -CyclicInheritance.java:17: cyclic inheritance involving C11 -class C11 extends C12 {} // ERROR - Cyclic inheritance -^ -CyclicInheritance.java:20: cyclic inheritance involving I1 -interface I1 extends I1 {} // ERROR - Cyclic inheritance -^ -CyclicInheritance.java:22: cyclic inheritance involving I11 -interface I11 extends I12 {} // ERROR - Cyclic inheritance -^ -CyclicInheritance.java:27: cyclic inheritance involving C211 -class C211 implements C211.I { // ERROR - may change pending resoluation of 4087020 -^ -CyclicInheritance.java:31: cyclic inheritance involving C212 -class C212 extends C212.C { // ERROR - Cyclic inheritance, subclass cannot enclose superclass -^ -CyclicInheritance.java:36: C221.I has private access in C221 -class C221 implements C221.I { // ERROR - Cannot access C21 (private) - ^ -CyclicInheritance.java:40: C222.C has private access in C222 -class C222 extends C222.C { // ERROR - Cannot access C22 (private) - ^ +CyclicInheritance.java:15:1: compiler.err.cyclic.inheritance: C1 +CyclicInheritance.java:17:1: compiler.err.cyclic.inheritance: C11 +CyclicInheritance.java:20:1: compiler.err.cyclic.inheritance: I1 +CyclicInheritance.java:22:1: compiler.err.cyclic.inheritance: I11 +CyclicInheritance.java:27:1: compiler.err.cyclic.inheritance: C211 +CyclicInheritance.java:31:1: compiler.err.cyclic.inheritance: C212 +CyclicInheritance.java:36:27: compiler.err.report.access: C221.I, private, C221 +CyclicInheritance.java:40:24: compiler.err.report.access: C222.C, private, C222 8 errors diff --git a/langtools/test/tools/javac/CyclicInheritance.sh b/langtools/test/tools/javac/CyclicInheritance.sh deleted file mode 100644 index b37cde27858..00000000000 --- a/langtools/test/tools/javac/CyclicInheritance.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -rm -rf C1.class C11.class C12.class -rm -rf I1.class I11.class I12.class -rm -rf C211.class C2.class - -cp "${TESTSRC}${FS}CyclicInheritance.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} CyclicInheritance.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}CyclicInheritance.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.java b/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.java index c32f33c1a1e..b3865d04c7d 100644 --- a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.java +++ b/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.java @@ -3,7 +3,7 @@ * @bug 4087314 4087314 4785453 * @summary Test access checking within 'extends' and 'implements' clause. * @author William Maddox (maddox) - * @run shell ExtendsAccess.sh + * @compile/fail/ref=ExtendsAccess.out -XDrawDiagnostics -XDstdout ExtendsAccess.java */ /* diff --git a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.out b/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.out index b38ca6f1376..f1848bc8ec0 100644 --- a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.out +++ b/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.out @@ -1,151 +1,47 @@ -ExtendsAccess.java:31: cannot find symbol -symbol: class publicClass -class ExtendsAccess111 extends publicClass { } // ERROR - 'publicClass' not in scope - ^ -ExtendsAccess.java:32: cannot find symbol -symbol: class defaultClass -class ExtendsAccess112 extends defaultClass { } // ERROR - 'defaultClass' not in scope - ^ -ExtendsAccess.java:33: cannot find symbol -symbol: class protectedClass -class ExtendsAccess113 extends protectedClass { } // ERROR - 'protectedClass' not in scope - ^ -ExtendsAccess.java:34: cannot find symbol -symbol: class privateClass -class ExtendsAccess114 extends privateClass { } // ERROR - 'privateClass' not in scope - ^ -ExtendsAccess.java:39: ExtendsAccess.privateClass has private access in ExtendsAccess -class ExtendsAccess1241 extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:42: p.ExtendsAccess.defaultClass is not public in p.ExtendsAccess; cannot be accessed from outside package -class ExtendsAccess1222 extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass' - ^ -ExtendsAccess.java:43: p.ExtendsAccess.protectedClass has protected access in p.ExtendsAccess -class ExtendsAccess1232 extends p.ExtendsAccess.protectedClass { } // ERROR - cannot access 'protectedClass' - ^ -ExtendsAccess.java:44: p.ExtendsAccess.privateClass has private access in p.ExtendsAccess -class ExtendsAccess1242 extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:56: ExtendsAccess.privateClass has private access in ExtendsAccess - class N extends privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:63: p.ExtendsAccess.defaultClass is not public in p.ExtendsAccess; cannot be accessed from outside package - class N extends defaultClass { } // ERROR - cannot access 'defaultClass' - ^ -ExtendsAccess.java:69: p.ExtendsAccess.privateClass has private access in p.ExtendsAccess - class N extends privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:85: ExtendsAccess.privateClass has private access in ExtendsAccess - class N extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:92: p.ExtendsAccess.defaultClass is not public in p.ExtendsAccess; cannot be accessed from outside package - class N extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass' - ^ -ExtendsAccess.java:101: p.ExtendsAccess.privateClass has private access in p.ExtendsAccess - class N extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass' - ^ -ExtendsAccess.java:104: cannot find symbol -symbol: class publicStaticClass -class ExtendsAccess211 extends publicStaticClass { } // ERROR - 'publicStaticClass' not in scope - ^ -ExtendsAccess.java:105: cannot find symbol -symbol: class defaultStaticClass -class ExtendsAccess212 extends defaultStaticClass { } // ERROR - 'defaultStaticClass' not in scope - ^ -ExtendsAccess.java:106: cannot find symbol -symbol: class protectedStaticClass -class ExtendsAccess213 extends protectedStaticClass { } // ERROR - 'protectedStaticClass' not in scope - ^ -ExtendsAccess.java:107: cannot find symbol -symbol: class privateStaticClass -class ExtendsAccess214 extends privateStaticClass { } // ERROR - 'privateStaticClass' not in scope - ^ -ExtendsAccess.java:112: ExtendsAccess.privateStaticClass has private access in ExtendsAccess -class ExtendsAccess2241 extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:115: p.ExtendsAccess.defaultStaticClass is not public in p.ExtendsAccess; cannot be accessed from outside package -class ExtendsAccess2222 extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass' - ^ -ExtendsAccess.java:116: p.ExtendsAccess.protectedStaticClass has protected access in p.ExtendsAccess -class ExtendsAccess2232 extends p.ExtendsAccess.protectedStaticClass { }// ERROR - cannot access 'protectedStaticClass' - ^ -ExtendsAccess.java:117: p.ExtendsAccess.privateStaticClass has private access in p.ExtendsAccess -class ExtendsAccess2242 extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:129: ExtendsAccess.privateStaticClass has private access in ExtendsAccess - class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:136: p.ExtendsAccess.defaultStaticClass is not public in p.ExtendsAccess; cannot be accessed from outside package - class N extends defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass' - ^ -ExtendsAccess.java:142: p.ExtendsAccess.privateStaticClass has private access in p.ExtendsAccess - class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:158: ExtendsAccess.privateStaticClass has private access in ExtendsAccess - class N extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:165: p.ExtendsAccess.defaultStaticClass is not public in p.ExtendsAccess; cannot be accessed from outside package - class N extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass' - ^ -ExtendsAccess.java:174: p.ExtendsAccess.privateStaticClass has private access in p.ExtendsAccess - class N extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass' - ^ -ExtendsAccess.java:177: cannot find symbol -symbol: class publicInterface -class ExtendsAccess311 extends ExtendsAccess implements publicInterface { } // ERROR - 'publicInterface' not in scope - ^ -ExtendsAccess.java:178: cannot find symbol -symbol: class defaultInterface -class ExtendsAccess312 extends ExtendsAccess implements defaultInterface { } // ERROR - 'defaultInterface' not in scope - ^ -ExtendsAccess.java:179: cannot find symbol -symbol: class protectedInterface -class ExtendsAccess313 extends ExtendsAccess implements protectedInterface { } // ERROR - 'protectedInterface' not in scope - ^ -ExtendsAccess.java:180: cannot find symbol -symbol: class privateInterface -class ExtendsAccess314 extends ExtendsAccess implements privateInterface { } // ERROR - 'privateInterface' not in scope - ^ -ExtendsAccess.java:186: ExtendsAccess.privateInterface has private access in ExtendsAccess - implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:191: p.ExtendsAccess.defaultInterface is not public in p.ExtendsAccess; cannot be accessed from outside package - implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultStaticClass' - ^ -ExtendsAccess.java:193: p.ExtendsAccess.protectedInterface has protected access in p.ExtendsAccess - implements p.ExtendsAccess.protectedInterface { } // ERROR - cannot access 'protectedStaticClass' - ^ -ExtendsAccess.java:195: p.ExtendsAccess.privateInterface has private access in p.ExtendsAccess - implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:207: ExtendsAccess.privateInterface has private access in ExtendsAccess - class N implements privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:214: p.ExtendsAccess.defaultInterface is not public in p.ExtendsAccess; cannot be accessed from outside package - class N implements defaultInterface { } // ERROR - cannot access 'defaultStaticClass' - ^ -ExtendsAccess.java:220: p.ExtendsAccess.privateInterface has private access in p.ExtendsAccess - class N implements privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:236: ExtendsAccess.privateInterface has private access in ExtendsAccess - class N implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:243: p.ExtendsAccess.defaultInterface is not public in p.ExtendsAccess; cannot be accessed from outside package - class N implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultClass' - ^ -ExtendsAccess.java:252: p.ExtendsAccess.privateInterface has private access in p.ExtendsAccess - class N implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface' - ^ -ExtendsAccess.java:36: an enclosing instance that contains ExtendsAccess.publicClass is required -class ExtendsAccess1211 extends ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance) -^ -ExtendsAccess.java:37: an enclosing instance that contains ExtendsAccess.defaultClass is required -class ExtendsAccess1221 extends ExtendsAccess.defaultClass { } // OK - can extend inner classes (was ERROR - no enclosing instance) -^ -ExtendsAccess.java:38: an enclosing instance that contains ExtendsAccess.protectedClass is required -class ExtendsAccess1231 extends ExtendsAccess.protectedClass { } // OK - can extend inner classes (was ERROR - no enclosing instance) -^ -ExtendsAccess.java:41: an enclosing instance that contains p.ExtendsAccess.publicClass is required -class ExtendsAccess1212 extends p.ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance) -^ +ExtendsAccess.java:31:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), publicClass, , +ExtendsAccess.java:32:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), defaultClass, , +ExtendsAccess.java:33:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), protectedClass, , +ExtendsAccess.java:34:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), privateClass, , +ExtendsAccess.java:39:46: compiler.err.report.access: ExtendsAccess.privateClass, private, ExtendsAccess +ExtendsAccess.java:42:48: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultClass, p.ExtendsAccess +ExtendsAccess.java:43:48: compiler.err.report.access: p.ExtendsAccess.protectedClass, protected, p.ExtendsAccess +ExtendsAccess.java:44:48: compiler.err.report.access: p.ExtendsAccess.privateClass, private, p.ExtendsAccess +ExtendsAccess.java:56:21: compiler.err.report.access: ExtendsAccess.privateClass, private, ExtendsAccess +ExtendsAccess.java:63:21: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultClass, p.ExtendsAccess +ExtendsAccess.java:69:21: compiler.err.report.access: p.ExtendsAccess.privateClass, private, p.ExtendsAccess +ExtendsAccess.java:85:34: compiler.err.report.access: ExtendsAccess.privateClass, private, ExtendsAccess +ExtendsAccess.java:92:36: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultClass, p.ExtendsAccess +ExtendsAccess.java:101:36: compiler.err.report.access: p.ExtendsAccess.privateClass, private, p.ExtendsAccess +ExtendsAccess.java:104:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), publicStaticClass, , +ExtendsAccess.java:105:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), defaultStaticClass, , +ExtendsAccess.java:106:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), protectedStaticClass, , +ExtendsAccess.java:107:32: compiler.err.cant.resolve: (- compiler.misc.kindname.class), privateStaticClass, , +ExtendsAccess.java:112:46: compiler.err.report.access: ExtendsAccess.privateStaticClass, private, ExtendsAccess +ExtendsAccess.java:115:48: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultStaticClass, p.ExtendsAccess +ExtendsAccess.java:116:48: compiler.err.report.access: p.ExtendsAccess.protectedStaticClass, protected, p.ExtendsAccess +ExtendsAccess.java:117:48: compiler.err.report.access: p.ExtendsAccess.privateStaticClass, private, p.ExtendsAccess +ExtendsAccess.java:129:21: compiler.err.report.access: ExtendsAccess.privateStaticClass, private, ExtendsAccess +ExtendsAccess.java:136:21: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultStaticClass, p.ExtendsAccess +ExtendsAccess.java:142:21: compiler.err.report.access: p.ExtendsAccess.privateStaticClass, private, p.ExtendsAccess +ExtendsAccess.java:158:34: compiler.err.report.access: ExtendsAccess.privateStaticClass, private, ExtendsAccess +ExtendsAccess.java:165:36: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultStaticClass, p.ExtendsAccess +ExtendsAccess.java:174:36: compiler.err.report.access: p.ExtendsAccess.privateStaticClass, private, p.ExtendsAccess +ExtendsAccess.java:177:57: compiler.err.cant.resolve: (- compiler.misc.kindname.class), publicInterface, , +ExtendsAccess.java:178:57: compiler.err.cant.resolve: (- compiler.misc.kindname.class), defaultInterface, , +ExtendsAccess.java:179:57: compiler.err.cant.resolve: (- compiler.misc.kindname.class), protectedInterface, , +ExtendsAccess.java:180:57: compiler.err.cant.resolve: (- compiler.misc.kindname.class), privateInterface, , +ExtendsAccess.java:186:33: compiler.err.report.access: ExtendsAccess.privateInterface, private, ExtendsAccess +ExtendsAccess.java:191:35: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultInterface, p.ExtendsAccess +ExtendsAccess.java:193:35: compiler.err.report.access: p.ExtendsAccess.protectedInterface, protected, p.ExtendsAccess +ExtendsAccess.java:195:35: compiler.err.report.access: p.ExtendsAccess.privateInterface, private, p.ExtendsAccess +ExtendsAccess.java:207:24: compiler.err.report.access: ExtendsAccess.privateInterface, private, ExtendsAccess +ExtendsAccess.java:214:24: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultInterface, p.ExtendsAccess +ExtendsAccess.java:220:24: compiler.err.report.access: p.ExtendsAccess.privateInterface, private, p.ExtendsAccess +ExtendsAccess.java:236:37: compiler.err.report.access: ExtendsAccess.privateInterface, private, ExtendsAccess +ExtendsAccess.java:243:39: compiler.err.not.def.public.cant.access: p.ExtendsAccess.defaultInterface, p.ExtendsAccess +ExtendsAccess.java:252:39: compiler.err.report.access: p.ExtendsAccess.privateInterface, private, p.ExtendsAccess +ExtendsAccess.java:36:1: compiler.err.encl.class.required: ExtendsAccess.publicClass +ExtendsAccess.java:37:1: compiler.err.encl.class.required: ExtendsAccess.defaultClass +ExtendsAccess.java:38:1: compiler.err.encl.class.required: ExtendsAccess.protectedClass +ExtendsAccess.java:41:1: compiler.err.encl.class.required: p.ExtendsAccess.publicClass 46 errors diff --git a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.sh b/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.sh deleted file mode 100644 index 3d244cf9598..00000000000 --- a/langtools/test/tools/javac/ExtendsAccess/ExtendsAccess.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}ExtendsAccess.java" . -cp -r "${TESTSRC}${FS}p" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} ExtendsAccess.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}ExtendsAccess.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.java b/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.java index b6080336373..321a7c0dc6b 100644 --- a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.java +++ b/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.java @@ -4,7 +4,7 @@ * @summary strictfp may not be used with constructors * @author David Stoutamire (dps) * - * @run shell BadConstructorModifiers.sh + * @compile/fail/ref=BadConstructorModifiers.out -XDrawDiagnostics -XDstdout BadConstructorModifiers.java */ public class BadConstructorModifiers { diff --git a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.out b/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.out index 25b9ed0def1..92b2470286e 100644 --- a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.out +++ b/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.out @@ -1,4 +1,2 @@ -BadConstructorModifiers.java:12: modifier strictfp not allowed here - strictfp BadConstructorModifiers (double abra) { } - ^ +BadConstructorModifiers.java:12:14: compiler.err.mod.not.allowed.here: strictfp 1 error diff --git a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.sh b/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.sh deleted file mode 100644 index 88ce7290254..00000000000 --- a/langtools/test/tools/javac/FloatingPointChanges/BadConstructorModifiers.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}BadConstructorModifiers.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} BadConstructorModifiers.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}BadConstructorModifiers.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/InnerNamedConstant_2.java b/langtools/test/tools/javac/InnerNamedConstant_2.java index ad1e6d9b5a7..0c7ff16faae 100644 --- a/langtools/test/tools/javac/InnerNamedConstant_2.java +++ b/langtools/test/tools/javac/InnerNamedConstant_2.java @@ -4,7 +4,7 @@ * @summary Verify rejection of illegal static variables in inner classes. * @author William Maddox (maddox) * - * @run shell InnerNamedConstant_2.sh + * @compile/fail/ref=InnerNamedConstant_2.out -XDrawDiagnostics -XDstdout InnerNamedConstant_2.java */ public class InnerNamedConstant_2 { diff --git a/langtools/test/tools/javac/InnerNamedConstant_2.out b/langtools/test/tools/javac/InnerNamedConstant_2.out index a08a4e57281..659006c8380 100644 --- a/langtools/test/tools/javac/InnerNamedConstant_2.out +++ b/langtools/test/tools/javac/InnerNamedConstant_2.out @@ -1,13 +1,5 @@ -InnerNamedConstant_2.java:22: inner classes cannot have static declarations - static int x = 1; // ERROR - static not final - ^ -InnerNamedConstant_2.java:23: inner classes cannot have static declarations - static final String z; // ERROR - static blank final - ^ -InnerNamedConstant_2.java:25: cannot assign a value to final variable z - z = "foobar"; // Error may be reported here. See 4278961. - ^ -InnerNamedConstant_2.java:34: inner classes cannot have static declarations - static final int y = Inner1.x * 5; // ERROR - initializer not constant - ^ +InnerNamedConstant_2.java:22:20: compiler.err.icls.cant.have.static.decl +InnerNamedConstant_2.java:23:29: compiler.err.icls.cant.have.static.decl +InnerNamedConstant_2.java:25:13: compiler.err.cant.assign.val.to.final.var: z +InnerNamedConstant_2.java:34:26: compiler.err.icls.cant.have.static.decl 4 errors diff --git a/langtools/test/tools/javac/InnerNamedConstant_2.sh b/langtools/test/tools/javac/InnerNamedConstant_2.sh deleted file mode 100644 index 9d6337aab39..00000000000 --- a/langtools/test/tools/javac/InnerNamedConstant_2.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}InnerNamedConstant_2.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} InnerNamedConstant_2.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}InnerNamedConstant_2.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/LocalClasses_2.java b/langtools/test/tools/javac/LocalClasses_2.java index e6024c17554..fe916cb57e7 100644 --- a/langtools/test/tools/javac/LocalClasses_2.java +++ b/langtools/test/tools/javac/LocalClasses_2.java @@ -4,7 +4,7 @@ * @summary Verify that a local class cannot be redefined within its scope. * @author William Maddox (maddox) * - * @run shell LocalClasses_2.sh + * @compile/fail/ref=LocalClasses_2.out -XDrawDiagnostics -XDstdout LocalClasses_2.java */ class LocalClasses_2 { diff --git a/langtools/test/tools/javac/LocalClasses_2.out b/langtools/test/tools/javac/LocalClasses_2.out index a812fafe884..5391308409d 100644 --- a/langtools/test/tools/javac/LocalClasses_2.out +++ b/langtools/test/tools/javac/LocalClasses_2.out @@ -1,4 +1,2 @@ -LocalClasses_2.java:15: Local is already defined in foo() - class Local { } // ERROR - ^ +LocalClasses_2.java:15:13: compiler.err.already.defined: Local, foo() 1 error diff --git a/langtools/test/tools/javac/LocalClasses_2.sh b/langtools/test/tools/javac/LocalClasses_2.sh deleted file mode 100644 index bd3b1ce74b1..00000000000 --- a/langtools/test/tools/javac/LocalClasses_2.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}LocalClasses_2.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} LocalClasses_2.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}LocalClasses_2.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/NameCollision.java b/langtools/test/tools/javac/NameCollision.java index 512ade8ebb9..1b187c10708 100644 --- a/langtools/test/tools/javac/NameCollision.java +++ b/langtools/test/tools/javac/NameCollision.java @@ -4,7 +4,7 @@ * @summary Interface names for classes in the same scope should not * cause the compiler to crash. * - * @run shell NameCollision.sh + * @compile/fail/ref=NameCollision.out -XDrawDiagnostics -XDstdout NameCollision.java */ // The test fails if the compiler crashes. diff --git a/langtools/test/tools/javac/NameCollision.out b/langtools/test/tools/javac/NameCollision.out index b6b923ff1c0..17b39218513 100644 --- a/langtools/test/tools/javac/NameCollision.out +++ b/langtools/test/tools/javac/NameCollision.out @@ -1,4 +1,2 @@ -NameCollision.java:13: interface expected here - class Runnable implements Runnable { } // ERROR - ^ +NameCollision.java:13:31: compiler.err.intf.expected.here 1 error diff --git a/langtools/test/tools/javac/NameCollision.sh b/langtools/test/tools/javac/NameCollision.sh deleted file mode 100644 index 989c2a374e8..00000000000 --- a/langtools/test/tools/javac/NameCollision.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - - -cp "${TESTSRC}${FS}NameCollision.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NameCollision.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}NameCollision.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/NestedInnerClassNames.java b/langtools/test/tools/javac/NestedInnerClassNames.java index 6dbd26f6762..17426f9dc41 100644 --- a/langtools/test/tools/javac/NestedInnerClassNames.java +++ b/langtools/test/tools/javac/NestedInnerClassNames.java @@ -4,7 +4,7 @@ * @summary Verify that an inner class cannot have the same simple name as an enclosing one. * @author William Maddox (maddox) * - * @run shell NestedInnerClassNames.sh + * @compile/fail/ref=NestedInnerClassNames.out -XDrawDiagnostics -XDstdout NestedInnerClassNames.java */ /* diff --git a/langtools/test/tools/javac/NestedInnerClassNames.out b/langtools/test/tools/javac/NestedInnerClassNames.out index 90107ba4096..bee489e56ce 100644 --- a/langtools/test/tools/javac/NestedInnerClassNames.out +++ b/langtools/test/tools/javac/NestedInnerClassNames.out @@ -1,52 +1,18 @@ -NestedInnerClassNames.java:16: NestedInnerClassNames is already defined in unnamed package - class NestedInnerClassNames {} // ERROR - ^ -NestedInnerClassNames.java:23: NestedInnerClassNames.foo is already defined in NestedInnerClassNames - class foo { } // ERROR - ^ -NestedInnerClassNames.java:34: NestedInnerClassNames is already defined in unnamed package - class NestedInnerClassNames {} // ERROR - ^ -NestedInnerClassNames.java:45: NestedInnerClassNames.baz is already defined in NestedInnerClassNames - class baz { // ERROR - ^ -NestedInnerClassNames.java:46: NestedInnerClassNames.baz.baz is already defined in NestedInnerClassNames.baz - class baz { } // ERROR - ^ -NestedInnerClassNames.java:59: NestedInnerClassNames.foo$bar is already defined in NestedInnerClassNames - class foo$bar { // ERROR - ^ -NestedInnerClassNames.java:76: NestedInnerClassNames.$bar is already defined in NestedInnerClassNames - class $bar { } // ERROR - ^ -NestedInnerClassNames.java:90: NestedInnerClassNames.bar$bar.bar is already defined in NestedInnerClassNames.bar$bar - class bar{ } // ERROR - ^ -NestedInnerClassNames.java:109: duplicate class: NestedInnerClassNames.foo.foo - class foo$foo { } // ERROR - ^ -NestedInnerClassNames.java:19: NestedInnerClassNames is already defined in unnamed package - class NestedInnerClassNames {} // ERROR - ^ -NestedInnerClassNames.java:28: foo is already defined in m2() - class foo { } // ERROR - ^ -NestedInnerClassNames.java:40: NestedInnerClassNames is already defined in unnamed package - class NestedInnerClassNames {} // ERROR - ^ -NestedInnerClassNames.java:52: baz is already defined in m4() - class baz { // ERROR - ^ -NestedInnerClassNames.java:53: baz.baz is already defined in baz - class baz { } // ERROR - ^ -NestedInnerClassNames.java:67: foo$bar is already defined in m5() - class foo$bar { // ERROR - ^ -NestedInnerClassNames.java:83: $bar is already defined in m6() - class $bar { } // ERROR - ^ -NestedInnerClassNames.java:97: bar$bar.bar is already defined in bar$bar - class bar{ } // ERROR - ^ +NestedInnerClassNames.java:16:5: compiler.err.already.defined: NestedInnerClassNames, unnamed package +NestedInnerClassNames.java:23:9: compiler.err.already.defined: NestedInnerClassNames.foo, NestedInnerClassNames +NestedInnerClassNames.java:34:9: compiler.err.already.defined: NestedInnerClassNames, unnamed package +NestedInnerClassNames.java:45:9: compiler.err.already.defined: NestedInnerClassNames.baz, NestedInnerClassNames +NestedInnerClassNames.java:46:13: compiler.err.already.defined: NestedInnerClassNames.baz.baz, NestedInnerClassNames.baz +NestedInnerClassNames.java:59:9: compiler.err.already.defined: NestedInnerClassNames.foo$bar, NestedInnerClassNames +NestedInnerClassNames.java:76:13: compiler.err.already.defined: NestedInnerClassNames.$bar, NestedInnerClassNames +NestedInnerClassNames.java:90:13: compiler.err.already.defined: NestedInnerClassNames.bar$bar.bar, NestedInnerClassNames.bar$bar +NestedInnerClassNames.java:109:5: compiler.err.duplicate.class: NestedInnerClassNames.foo.foo +NestedInnerClassNames.java:19:9: compiler.err.already.defined: NestedInnerClassNames, unnamed package +NestedInnerClassNames.java:28:13: compiler.err.already.defined: foo, m2() +NestedInnerClassNames.java:40:13: compiler.err.already.defined: NestedInnerClassNames, unnamed package +NestedInnerClassNames.java:52:13: compiler.err.already.defined: baz, m4() +NestedInnerClassNames.java:53:17: compiler.err.already.defined: baz.baz, baz +NestedInnerClassNames.java:67:13: compiler.err.already.defined: foo$bar, m5() +NestedInnerClassNames.java:83:17: compiler.err.already.defined: $bar, m6() +NestedInnerClassNames.java:97:17: compiler.err.already.defined: bar$bar.bar, bar$bar 17 errors diff --git a/langtools/test/tools/javac/NestedInnerClassNames.sh b/langtools/test/tools/javac/NestedInnerClassNames.sh deleted file mode 100644 index a78c4c72182..00000000000 --- a/langtools/test/tools/javac/NestedInnerClassNames.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}NestedInnerClassNames.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NestedInnerClassNames.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}NestedInnerClassNames.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/NonStaticFieldExpr1.java b/langtools/test/tools/javac/NonStaticFieldExpr1.java index 59e14329c50..173e7fdda4c 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr1.java +++ b/langtools/test/tools/javac/NonStaticFieldExpr1.java @@ -3,7 +3,7 @@ @author dps @summary field: instance access through types is not allowed - @run shell NonStaticFieldExpr1.sh + @compile/fail/ref=NonStaticFieldExpr1.out -XDrawDiagnostics -XDstdout NonStaticFieldExpr1.java */ class NonStaticFieldExpr1 { public int x; diff --git a/langtools/test/tools/javac/NonStaticFieldExpr1.out b/langtools/test/tools/javac/NonStaticFieldExpr1.out index b8a092b4344..0cc8c9c97ec 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr1.out +++ b/langtools/test/tools/javac/NonStaticFieldExpr1.out @@ -1,4 +1,2 @@ -NonStaticFieldExpr1.java:10: non-static variable x cannot be referenced from a static context - int y = NonStaticFieldExpr1.x; // SHOULD BE ERROR - ^ +NonStaticFieldExpr1.java:10:30: compiler.err.non-static.cant.be.ref: (- compiler.misc.kindname.variable), x 1 error diff --git a/langtools/test/tools/javac/NonStaticFieldExpr1.sh b/langtools/test/tools/javac/NonStaticFieldExpr1.sh deleted file mode 100644 index 3b0d2ce0579..00000000000 --- a/langtools/test/tools/javac/NonStaticFieldExpr1.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}NonStaticFieldExpr1.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NonStaticFieldExpr1.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}NonStaticFieldExpr1.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result - - - diff --git a/langtools/test/tools/javac/NonStaticFieldExpr2.java b/langtools/test/tools/javac/NonStaticFieldExpr2.java index fdb290aac6e..b258ac6c90e 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr2.java +++ b/langtools/test/tools/javac/NonStaticFieldExpr2.java @@ -3,7 +3,7 @@ @author dps @summary method: instance access through types is not allowed - @run shell NonStaticFieldExpr2.sh + @compile/fail/ref=NonStaticFieldExpr2.out -XDrawDiagnostics -XDstdout NonStaticFieldExpr2.java */ class NonStaticFieldExpr2 { diff --git a/langtools/test/tools/javac/NonStaticFieldExpr2.out b/langtools/test/tools/javac/NonStaticFieldExpr2.out index cc060182735..0f4c863b126 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr2.out +++ b/langtools/test/tools/javac/NonStaticFieldExpr2.out @@ -1,4 +1,2 @@ -NonStaticFieldExpr2.java:14: non-static variable x cannot be referenced from a static context - int z = NonStaticFieldExpr2.x; // SHOULD BE ERROR - ^ +NonStaticFieldExpr2.java:14:33: compiler.err.non-static.cant.be.ref: (- compiler.misc.kindname.variable), x 1 error diff --git a/langtools/test/tools/javac/NonStaticFieldExpr2.sh b/langtools/test/tools/javac/NonStaticFieldExpr2.sh deleted file mode 100644 index 647621d1ed6..00000000000 --- a/langtools/test/tools/javac/NonStaticFieldExpr2.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}NonStaticFieldExpr2.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NonStaticFieldExpr2.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}NonStaticFieldExpr2.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/NonStaticFieldExpr3.java b/langtools/test/tools/javac/NonStaticFieldExpr3.java index 87024f000c5..d0485e0d404 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr3.java +++ b/langtools/test/tools/javac/NonStaticFieldExpr3.java @@ -3,7 +3,7 @@ @author dps @summary class: instance access through types is not allowed - @run shell NonStaticFieldExpr3.sh + @compile/fail/ref=NonStaticFieldExpr3.out -XDrawDiagnostics -XDstdout NonStaticFieldExpr3.java */ class NonStaticFieldExpr3 { diff --git a/langtools/test/tools/javac/NonStaticFieldExpr3.out b/langtools/test/tools/javac/NonStaticFieldExpr3.out index e2250401be0..c2395b6594b 100644 --- a/langtools/test/tools/javac/NonStaticFieldExpr3.out +++ b/langtools/test/tools/javac/NonStaticFieldExpr3.out @@ -1,4 +1,2 @@ -NonStaticFieldExpr3.java:14: non-static variable x cannot be referenced from a static context - int a = NonStaticFieldExpr3.x; // SHOULD BE ERROR - ^ +NonStaticFieldExpr3.java:14:30: compiler.err.non-static.cant.be.ref: (- compiler.misc.kindname.variable), x 1 error diff --git a/langtools/test/tools/javac/NonStaticFieldExpr3.sh b/langtools/test/tools/javac/NonStaticFieldExpr3.sh deleted file mode 100644 index c21d843bd91..00000000000 --- a/langtools/test/tools/javac/NonStaticFieldExpr3.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}NonStaticFieldExpr3.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NonStaticFieldExpr3.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}NonStaticFieldExpr3.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.java b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.java index fd8f607fe3e..18261e1d730 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.java +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.java @@ -5,7 +5,9 @@ * the type to which a component member belongs be accessible in qualified * names. * - * @run shell QualifiedAccess_1.sh + * @compile pack1/P1.java + * @compile pack1/P2.java + * @compile/fail/ref=QualifiedAccess_1.out -XDrawDiagnostics -XDstdout QualifiedAccess_1.java */ import pack1.P1; diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.out b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.out index a718768a6a9..4b0aabf1190 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.out +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.out @@ -1,55 +1,19 @@ -QualifiedAccess_1.java:22: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3 bar; // ERROR - ^ -QualifiedAccess_1.java:23: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4 baz; // ERROR - ^ -QualifiedAccess_1.java:24: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4.P5 quux; // ERROR - ^ -QualifiedAccess_1.java:27: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3 m12() {return null;} // ERROR - ^ -QualifiedAccess_1.java:28: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4 m13() {return null;} // ERROR - ^ -QualifiedAccess_1.java:29: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4.P5 m14() {return null;} // ERROR - ^ -QualifiedAccess_1.java:32: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - void m22(P1.P3 x) {} // ERROR - ^ -QualifiedAccess_1.java:33: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - void m23(P1.P3.P4 x) {} // ERROR - ^ -QualifiedAccess_1.java:34: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - void m24(P1.P3.P4.P5 x) {} // ERROR - ^ -QualifiedAccess_1.java:44: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3 bar = null; // ERROR - ^ -QualifiedAccess_1.java:45: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4 baz = null; // ERROR - ^ -QualifiedAccess_1.java:46: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - P1.P3.P4.P5 quux = null; // ERROR - ^ -QualifiedAccess_1.java:57: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - Object bar = (P1.P3)null; // ERROR - ^ -QualifiedAccess_1.java:58: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - Object baz = (P1.P3.P4)null; // ERROR - ^ -QualifiedAccess_1.java:59: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - Object quux = (P1.P3.P4.P5)null; // ERROR - ^ -QualifiedAccess_1.java:70: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - boolean bar = null instanceof P1.P3; // ERROR - ^ -QualifiedAccess_1.java:71: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - boolean baz = null instanceof P1.P3.P4; // ERROR - ^ -QualifiedAccess_1.java:72: pack1.P1.P3 is not public in pack1.P1; cannot be accessed from outside package - boolean quux = null instanceof P1.P3.P4.P5; // ERROR - ^ +QualifiedAccess_1.java:24:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:25:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:26:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:29:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:30:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:31:7: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:34:16: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:35:16: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:36:16: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:46:11: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:47:11: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:48:11: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:59:25: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:60:25: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:61:26: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:72:41: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:73:41: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 +QualifiedAccess_1.java:74:42: compiler.err.not.def.public.cant.access: pack1.P1.P3, pack1.P1 18 errors diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.sh b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.sh deleted file mode 100644 index 1ea65aeefe9..00000000000 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_1.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}QualifiedAccess_1.java" . -cp -r "${TESTSRC}${FS}pack1" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} pack1${FS}P1.java -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} pack1${FS}P2.java -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} QualifiedAccess_1.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}QualifiedAccess_1.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.java b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.java index 5cc373787af..eaa21b81273 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.java +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.java @@ -5,7 +5,9 @@ * the type to which a component member belongs be accessible in qualified * names. * - * @run shell QualifiedAccess_2.sh + * @compile pack1/P1.java + * @compile pack1/P2.java + * @compile/fail/ref=QualifiedAccess_2.out -XDrawDiagnostics -XDstdout QualifiedAccess_2.java */ import pack1.P1; diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.out b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.out index e495fb7a9c7..d5c64e56b25 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.out +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.out @@ -1,19 +1,7 @@ -QualifiedAccess_2.java:38: A.B has private access in A - class C extends A.B {} // ERROR - B is inaccessible - ^ -QualifiedAccess_2.java:39: A.B has private access in A - class D extends A.B.Inner {} // ERROR - B is inaccessible - ^ -QualifiedAccess_2.java:43: pack1.P1.Foo is not public in pack1.P1; cannot be accessed from outside package - P1.Foo.Bar x; // ERROR - Foo is inaccessible - ^ -QualifiedAccess_2.java:50: Y.Quux.Quem has private access in Y.Quux - void foo() throws Y.Quux.Quem.MyError { - ^ -QualifiedAccess_2.java:28: pack1.P1.R.S has private access in pack1.P1.R - Object z = new R.S.T(); // ERROR - S is inaccessible - ^ -QualifiedAccess_2.java:52: Y.Quux.Quem has private access in Y.Quux - throw new Y.Quux.Quem.MyError(); - ^ +QualifiedAccess_2.java:40:22: compiler.err.report.access: A.B, private, A +QualifiedAccess_2.java:41:22: compiler.err.report.access: A.B, private, A +QualifiedAccess_2.java:45:15: compiler.err.not.def.public.cant.access: pack1.P1.Foo, pack1.P1 +QualifiedAccess_2.java:52:29: compiler.err.report.access: Y.Quux.Quem, private, Y.Quux +QualifiedAccess_2.java:30:25: compiler.err.report.access: pack1.P1.R.S, private, pack1.P1.R +QualifiedAccess_2.java:54:25: compiler.err.report.access: Y.Quux.Quem, private, Y.Quux 6 errors diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.sh b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.sh deleted file mode 100644 index 1f1b58e30b9..00000000000 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_2.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}QualifiedAccess_2.java" . -cp -r "${TESTSRC}${FS}pack1" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} pack1${FS}P1.java -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} pack1${FS}P2.java -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} QualifiedAccess_2.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}QualifiedAccess_2.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.java b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.java index a932e79489a..2f7fc78fe28 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.java +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.java @@ -5,7 +5,7 @@ * the type to which a component member belongs be accessible in qualified * names. * - * @run shell QualifiedAccess_3.sh + * @compile/fail/ref=QualifiedAccess_3.out -XDrawDiagnostics -XDstdout QualifiedAccess_3.java */ import pack1.P1; diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.out b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.out index a2590ca9ac3..9cf7a4d2b96 100644 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.out +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.out @@ -1,13 +1,5 @@ -QualifiedAccess_3.java:39: pack1.P1.Foo is not public in pack1.P1; cannot be accessed from outside package - P1.Foo.Bar x = null; // ERROR - 'P1.Foo' not accessible - ^ -QualifiedAccess_3.java:40: length in Array is defined in an inaccessible class or interface - int i = p1.a.length; // ERROR - Type of 'a' not accessible - ^ -QualifiedAccess_3.java:43: privatei in pack1.P2 is defined in an inaccessible class or interface - p1.p2.privatei = 3; // ERROR - Type of 'p1.p2' not accessible. - ^ -QualifiedAccess_3.java:44: privatei in pack1.P2 is defined in an inaccessible class or interface - System.out.println (p1.p2.privatei); // ERROR - Type of 'p1.p2' not accessible. - ^ +QualifiedAccess_3.java:39:11: compiler.err.not.def.public.cant.access: pack1.P1.Foo, pack1.P1 +QualifiedAccess_3.java:40:21: compiler.err.not.def.access.class.intf.cant.access: length, Array +QualifiedAccess_3.java:43:14: compiler.err.not.def.access.class.intf.cant.access: privatei, pack1.P2 +QualifiedAccess_3.java:44:34: compiler.err.not.def.access.class.intf.cant.access: privatei, pack1.P2 4 errors diff --git a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.sh b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.sh deleted file mode 100644 index 0fd842d6008..00000000000 --- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_3.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}QualifiedAccess_3.java" . -cp -r "${TESTSRC}${FS}pack1" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} QualifiedAccess_3.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}QualifiedAccess_3.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/SynchronizedClass.java b/langtools/test/tools/javac/SynchronizedClass.java index 66794c7e4a5..74cf9c60b14 100644 --- a/langtools/test/tools/javac/SynchronizedClass.java +++ b/langtools/test/tools/javac/SynchronizedClass.java @@ -3,7 +3,7 @@ @summary Verify that ClassModifier "synchronized" is not allowed. @author dps - @run shell SynchronizedClass.sh + @compile/fail/ref=SynchronizedClass.out -XDrawDiagnostics -XDstdout SynchronizedClass.java */ public synchronized class SynchronizedClass { } // ERROR diff --git a/langtools/test/tools/javac/SynchronizedClass.out b/langtools/test/tools/javac/SynchronizedClass.out index d291e6d5ad8..f36dcadf748 100644 --- a/langtools/test/tools/javac/SynchronizedClass.out +++ b/langtools/test/tools/javac/SynchronizedClass.out @@ -1,4 +1,2 @@ -SynchronizedClass.java:9: modifier synchronized not allowed here -public synchronized class SynchronizedClass { } // ERROR - ^ +SynchronizedClass.java:9:21: compiler.err.mod.not.allowed.here: synchronized 1 error diff --git a/langtools/test/tools/javac/SynchronizedClass.sh b/langtools/test/tools/javac/SynchronizedClass.sh deleted file mode 100644 index e36d4cd1a65..00000000000 --- a/langtools/test/tools/javac/SynchronizedClass.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}SynchronizedClass.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} SynchronizedClass.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}SynchronizedClass.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result diff --git a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.java b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.java index 9596516a1e7..2d4447bc9e8 100644 --- a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.java +++ b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.java @@ -5,7 +5,8 @@ * docComment only * @author Jing Qian * - * @run shell DeprecatedDocComment.sh + * @compile DeprecatedDocComment2.java + * @compile/fail/ref=DeprecatedDocComment.out -XDrawDiagnostics -XDstdout -Werror -deprecation DeprecatedDocComment.java */ // WARNING: This file needs to be compiled with the -deprecation flag on. diff --git a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.out b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.out index d0676b17c07..e3cb33f72f8 100644 --- a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.out +++ b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.out @@ -1,10 +1,4 @@ -DeprecatedDocComment.java:26: warning: [deprecation] deprecatedTest1() in DeprecatedDocComment2 has been deprecated - DeprecatedDocComment2.deprecatedTest1(); - ^ -DeprecatedDocComment.java:30: warning: [deprecation] deprecatedTest5() in DeprecatedDocComment2 has been deprecated - DeprecatedDocComment2.deprecatedTest5(); - ^ -DeprecatedDocComment.java:31: warning: [deprecation] deprecatedTest6() in DeprecatedDocComment2 has been deprecated - DeprecatedDocComment2.deprecatedTest6(); - ^ +DeprecatedDocComment.java:27:28: compiler.warn.has.been.deprecated: deprecatedTest1(), DeprecatedDocComment2 +DeprecatedDocComment.java:31:28: compiler.warn.has.been.deprecated: deprecatedTest5(), DeprecatedDocComment2 +DeprecatedDocComment.java:32:28: compiler.warn.has.been.deprecated: deprecatedTest6(), DeprecatedDocComment2 3 warnings diff --git a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.sh b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.sh deleted file mode 100644 index 49de1de4b28..00000000000 --- a/langtools/test/tools/javac/depDocComment/DeprecatedDocComment.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh - -# -# Copyright 1999-2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTSRC=${TESTSRC}" -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTJAVA=${TESTJAVA}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi -echo "TESTCLASSES=${TESTCLASSES}" -echo "CLASSPATH=${CLASSPATH}" - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows* ) - NULL=NUL - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -TMP1=OUTPUT.txt - -cp "${TESTSRC}${FS}DeprecatedDocComment.java" . -cp "${TESTSRC}${FS}DeprecatedDocComment2.java" . -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} DeprecatedDocComment2.java -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -deprecation DeprecatedDocComment.java 2> ${TMP1} -cat ${TMP1} - -diff -c "${TESTSRC}${FS}DeprecatedDocComment.out" ${TMP1} -result=$? -rm ${TMP1} - -if [ $result -eq 0 ] -then - echo "Passed" -else - echo "Failed" -fi -exit $result From efd2515395f51710e5e00ffdc2452637eb738edc Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 10 Jul 2008 16:50:38 -0700 Subject: [PATCH 08/22] 6724551: Use Queues instead of Lists to link compiler phases Reviewed-by: darcy --- .../sun/tools/javac/api/JavacTaskImpl.java | 10 +-- .../com/sun/tools/javac/comp/Enter.java | 7 +- .../sun/tools/javac/main/JavaCompiler.java | 79 ++++++++----------- .../com/sun/tools/javac/util/ListBuffer.java | 55 +++++++++---- 4 files changed, 86 insertions(+), 65 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java index 508e9ceedb4..bf7019719b2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java @@ -381,8 +381,8 @@ public class JavacTaskImpl extends JavacTask { return results; } // where - private void handleFlowResults(List> list, ListBuffer elems) { - for (Env env: list) { + private void handleFlowResults(Queue> queue, ListBuffer elems) { + for (Env env: queue) { switch (env.tree.getTag()) { case JCTree.CLASSDEF: JCClassDecl cdef = (JCClassDecl) env.tree; @@ -396,7 +396,7 @@ public class JavacTaskImpl extends JavacTask { break; } } - genList.appendList(list); + genList.addAll(queue); } @@ -424,13 +424,13 @@ public class JavacTaskImpl extends JavacTask { analyze(null); // ensure all classes have been parsed, entered, and analyzed if (classes == null) { - compiler.generate(compiler.desugar(genList.toList()), results); + compiler.generate(compiler.desugar(genList), results); genList.clear(); } else { Filter f = new Filter() { public void process(Env env) { - compiler.generate(compiler.desugar(List.of(env)), results); + compiler.generate(compiler.desugar(ListBuffer.of(env)), results); } }; f.run(genList, classes); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java index 4d3774cac74..8741a817095 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java @@ -260,8 +260,11 @@ public class Enter extends JCTree.Visitor { */ List classEnter(List trees, Env env) { ListBuffer ts = new ListBuffer(); - for (List l = trees; l.nonEmpty(); l = l.tail) - ts.append(classEnter(l.head, env)); + for (List l = trees; l.nonEmpty(); l = l.tail) { + Type t = classEnter(l.head, env); + if (t != null) + ts.append(t); + } return ts.toList(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index fbb21d7f107..402c2998275 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -63,6 +63,7 @@ import static com.sun.tools.javac.util.ListBuffer.lb; // TEMP, until we have a more efficient way to save doc comment info import com.sun.tools.javac.parser.DocCommentScanner; +import java.util.Queue; import javax.lang.model.SourceVersion; /** This class could be the main entry point for GJC when GJC is used as a @@ -460,11 +461,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter { return log.nerrors; } - protected final List stopIfError(ListBuffer listBuffer) { + protected final Queue stopIfError(Queue queue) { if (errorCount() == 0) - return listBuffer.toList(); + return queue; else - return List.nil(); + return ListBuffer.lb(); } protected final List stopIfError(List list) { @@ -776,8 +777,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter { break; case BY_FILE: - for (List> list : groupByFile(flow(attribute(todo))).values()) - generate(desugar(list)); + for (Queue> queue : groupByFile(flow(attribute(todo))).values()) + generate(desugar(queue)); break; case BY_TODO: @@ -794,7 +795,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { } if (verbose) { - elapsed_msec = elapsed(start_msec);; + elapsed_msec = elapsed(start_msec); printVerbose("total", Long.toString(elapsed_msec)); } @@ -1026,11 +1027,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter { * Attribution of the entries in the list does not stop if any errors occur. * @returns a list of environments for attributd classes. */ - public List> attribute(ListBuffer> envs) { + public Queue> attribute(Queue> envs) { ListBuffer> results = lb(); - while (envs.nonEmpty()) - results.append(attribute(envs.next())); - return results.toList(); + while (!envs.isEmpty()) + results.append(attribute(envs.remove())); + return results; } /** @@ -1068,10 +1069,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter { * If any errors occur, an empty list will be returned. * @returns the list of attributed parse trees */ - public List> flow(List> envs) { + public Queue> flow(Queue> envs) { ListBuffer> results = lb(); - for (List> l = envs; l.nonEmpty(); l = l.tail) { - flow(l.head, results); + for (Env env: envs) { + flow(env, results); } return stopIfError(results); } @@ -1079,7 +1080,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { /** * Perform dataflow checks on an attributed parse tree. */ - public List> flow(Env env) { + public Queue> flow(Env env) { ListBuffer> results = lb(); flow(env, results); return stopIfError(results); @@ -1132,10 +1133,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter { * If any errors occur, an empty list will be returned. * @returns a list containing the classes to be generated */ - public List, JCClassDecl>> desugar(List> envs) { + public Queue, JCClassDecl>> desugar(Queue> envs) { ListBuffer, JCClassDecl>> results = lb(); - for (List> l = envs; l.nonEmpty(); l = l.tail) - desugar(l.head, results); + for (Env env: envs) + desugar(env, results); return stopIfError(results); } @@ -1145,7 +1146,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { * the current implicitSourcePolicy is taken into account. * The preparation stops as soon as an error is found. */ - protected void desugar(Env env, ListBuffer, JCClassDecl>> results) { + protected void desugar(Env env, Queue, JCClassDecl>> results) { if (errorCount() > 0) return; @@ -1180,7 +1181,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { List pdef = lower.translateTopLevelClass(env, env.tree, localMake); if (pdef.head != null) { assert pdef.tail.isEmpty(); - results.append(new Pair, JCClassDecl>(env, (JCClassDecl)pdef.head)); + results.add(new Pair, JCClassDecl>(env, (JCClassDecl)pdef.head)); } } return; @@ -1194,7 +1195,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { rootClasses.contains((JCClassDecl)untranslated) && ((cdef.mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 || cdef.sym.packge().getQualifiedName() == names.java_lang)) { - results.append(new Pair, JCClassDecl>(env, removeMethodBodies(cdef))); + results.add(new Pair, JCClassDecl>(env, removeMethodBodies(cdef))); } return; } @@ -1210,7 +1211,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { JCClassDecl cdef = (JCClassDecl)env.tree; if (untranslated instanceof JCClassDecl && rootClasses.contains((JCClassDecl)untranslated)) { - results.append(new Pair, JCClassDecl>(env, cdef)); + results.add(new Pair, JCClassDecl>(env, cdef)); } return; } @@ -1224,7 +1225,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter { //generate code for each class for (List l = cdefs; l.nonEmpty(); l = l.tail) { JCClassDecl cdef = (JCClassDecl)l.head; - results.append(new Pair, JCClassDecl>(env, cdef)); + results.add(new Pair, JCClassDecl>(env, cdef)); } } finally { @@ -1275,15 +1276,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter { * based upon the compiler's options. * Generation stops if an error occurs while writing files. */ - public void generate(List, JCClassDecl>> list) { - generate(list, null); + public void generate(Queue, JCClassDecl>> queue) { + generate(queue, null); } - public void generate(List, JCClassDecl>> list, ListBuffer results) { + public void generate(Queue, JCClassDecl>> queue, ListBuffer results) { boolean usePrintSource = (stubOutput || sourceOutput || printFlat); - for (List, JCClassDecl>> l = list; l.nonEmpty(); l = l.tail) { - Pair, JCClassDecl> x = l.head; + for (Pair, JCClassDecl> x: queue) { Env env = x.fst; JCClassDecl cdef = x.snd; @@ -1325,26 +1325,17 @@ public class JavaCompiler implements ClassReader.SourceCompleter { } // where - Map>> groupByFile(List> list) { + Map>> groupByFile(Queue> envs) { // use a LinkedHashMap to preserve the order of the original list as much as possible - Map>> map = new LinkedHashMap>>(); - Set fixupSet = new HashSet(); - for (List> l = list; l.nonEmpty(); l = l.tail) { - Env env = l.head; - List> sublist = map.get(env.toplevel); - if (sublist == null) - sublist = List.of(env); - else { - // this builds the list for the file in reverse order, so make a note - // to reverse the list before returning. - sublist = sublist.prepend(env); - fixupSet.add(env.toplevel); + Map>> map = new LinkedHashMap>>(); + for (Env env: envs) { + Queue> sublist = map.get(env.toplevel); + if (sublist == null) { + sublist = new ListBuffer>(); + map.put(env.toplevel, sublist); } - map.put(env.toplevel, sublist); + sublist.add(env); } - // fixup any lists that need reversing back to the correct order - for (JCTree.JCCompilationUnit tree: fixupSet) - map.put(tree, map.get(tree).reverse()); return map; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/ListBuffer.java b/langtools/src/share/classes/com/sun/tools/javac/util/ListBuffer.java index 33204ce0e8a..9c26185c5ac 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/ListBuffer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/ListBuffer.java @@ -25,6 +25,7 @@ package com.sun.tools.javac.util; +import java.util.AbstractQueue; import java.util.Collection; import java.util.Iterator; import java.util.NoSuchElementException; @@ -37,12 +38,18 @@ import java.util.NoSuchElementException; * This code and its internal interfaces are subject to change or * deletion without notice. */ -public class ListBuffer implements Collection { +public class ListBuffer extends AbstractQueue { public static ListBuffer lb() { return new ListBuffer(); } + public static ListBuffer of(T x) { + ListBuffer lb = new ListBuffer(); + lb.add(x); + return lb; + } + /** The list of elements of this buffer. */ public List elems; @@ -119,6 +126,7 @@ public class ListBuffer implements Collection { /** Append an element to buffer. */ public ListBuffer append(A x) { + x.getClass(); // null check if (shared) copy(); last.head = x; last.setTail(new List(null,null)); @@ -180,20 +188,14 @@ public class ListBuffer implements Collection { return elems.head; } - /** Remove the first element in this buffer. - */ - public void remove() { - if (elems != last) { - elems = elems.tail; - count--; - } - } - /** Return first element in this buffer and remove */ public A next() { A x = elems.head; - remove(); + if (elems != last) { + elems = elems.tail; + count--; + } return x; } @@ -219,21 +221,46 @@ public class ListBuffer implements Collection { } public boolean add(A a) { - throw new UnsupportedOperationException(); + append(a); + return true; } + public boolean remove(Object o) { throw new UnsupportedOperationException(); } + public boolean containsAll(Collection c) { - throw new UnsupportedOperationException(); + for (Object x: c) { + if (!contains(x)) + return false; + } + return true; } + public boolean addAll(Collection c) { - throw new UnsupportedOperationException(); + for (A a: c) + append(a); + return true; } + public boolean removeAll(Collection c) { throw new UnsupportedOperationException(); } + public boolean retainAll(Collection c) { throw new UnsupportedOperationException(); } + + public boolean offer(A a) { + append(a); + return true; + } + + public A poll() { + return next(); + } + + public A peek() { + return first(); + } } From 72e64424e06f8492901a0fc752c3860dcd8abcb0 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 11 Jul 2008 14:59:48 -0700 Subject: [PATCH 09/22] 6725036: javac returns incorrect value for lastModifiedTime() when source is a zip file archive Reviewed-by: darcy --- .../sun/tools/javac/file/ZipFileIndex.java | 18 +++- langtools/test/tools/javac/T6725036.java | 94 +++++++++++++++++++ 2 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/T6725036.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java index d677e2b603b..2130370a180 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java @@ -32,6 +32,7 @@ import java.io.RandomAccessFile; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -1307,11 +1308,18 @@ public class ZipFileIndex { return javatime; } - // From java.util.zip - private static long dosToJavaTime(int nativetime) { - // Bootstrap build problems prevent me from using the code directly - // Convert the raw/native time to a long for now - return (long)nativetime; + // based on dosToJavaTime in java.util.Zip, but avoiding the + // use of deprecated Date constructor + private static long dosToJavaTime(int dtime) { + Calendar c = Calendar.getInstance(); + c.set(Calendar.YEAR, ((dtime >> 25) & 0x7f) + 1980); + c.set(Calendar.MONTH, ((dtime >> 21) & 0x0f) - 1); + c.set(Calendar.DATE, ((dtime >> 16) & 0x1f)); + c.set(Calendar.HOUR_OF_DAY, ((dtime >> 11) & 0x1f)); + c.set(Calendar.MINUTE, ((dtime >> 5) & 0x3f)); + c.set(Calendar.SECOND, ((dtime << 1) & 0x3e)); + c.set(Calendar.MILLISECOND, 0); + return c.getTimeInMillis(); } void setNativeTime(int natTime) { diff --git a/langtools/test/tools/javac/T6725036.java b/langtools/test/tools/javac/T6725036.java new file mode 100644 index 00000000000..85330468039 --- /dev/null +++ b/langtools/test/tools/javac/T6725036.java @@ -0,0 +1,94 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6725036 + * @summary javac returns incorrect value for lastModifiedTime() when + * source is a zip file archive + */ + +import java.io.File; +import java.util.Date; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import javax.tools.JavaFileObject; + +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.file.ZipFileIndex; +import com.sun.tools.javac.file.ZipFileIndexArchive; +import com.sun.tools.javac.util.Context; + +public class T6725036 { + public static void main(String... args) throws Exception { + new T6725036().run(); + } + + void run() throws Exception { + String TEST_ENTRY_NAME = "java/lang/String.class"; + + File f = new File(System.getProperty("java.home")); + if (!f.getName().equals("jre")) + f = new File(f, "jre"); + File rt_jar = new File(new File(f, "lib"), "rt.jar"); + + JarFile j = new JarFile(rt_jar); + JarEntry je = j.getJarEntry(TEST_ENTRY_NAME); + long jarEntryTime = je.getTime(); + + ZipFileIndex zfi = + ZipFileIndex.getZipFileIndex(rt_jar, null, false, null, false); + long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME); + + check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME, zfiTime); + + Context context = new Context(); + JavacFileManager fm = new JavacFileManager(context, false, null); + ZipFileIndexArchive zfia = new ZipFileIndexArchive(fm, zfi); + int sep = TEST_ENTRY_NAME.lastIndexOf("/"); + JavaFileObject jfo = + zfia.getFileObject(TEST_ENTRY_NAME.substring(0, sep + 1), + TEST_ENTRY_NAME.substring(sep + 1)); + long jfoTime = jfo.getLastModified(); + + check(je, jarEntryTime, jfo, jfoTime); + + if (errors > 0) + throw new Exception(errors + " occurred"); + } + + void check(Object ref, long refTime, Object test, long testTime) { + if (refTime == testTime) + return; + System.err.println("Error: "); + System.err.println("Expected: " + getText(ref, refTime)); + System.err.println(" Found: " + getText(test, testTime)); + errors++; + } + + String getText(Object x, long t) { + return String.format("%14d", t) + " (" + new Date(t) + ") from " + x; + } + + int errors; +} From 43dbd05ddec142efe2b14d2fe37c6382b6bfcdc8 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 15 Jul 2008 09:50:36 -0700 Subject: [PATCH 10/22] 6724071: refactor Log into a front end and back end Reviewed-by: darcy --- .../com/sun/tools/javac/util/AbstractLog.java | 197 ++++++++++ .../tools/javac/util/DiagnosticFormatter.java | 1 - .../tools/javac/util/DiagnosticSource.java | 214 +++++++++++ .../sun/tools/javac/util/JCDiagnostic.java | 12 - .../classes/com/sun/tools/javac/util/Log.java | 338 ++---------------- 5 files changed, 433 insertions(+), 329 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java create mode 100644 langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java new file mode 100644 index 00000000000..1de1e825d6b --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java @@ -0,0 +1,197 @@ +/* + * Copyright 1999-2008 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package com.sun.tools.javac.util; + +import java.util.HashMap; +import java.util.Map; +import javax.tools.JavaFileObject; + +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; + + +/** + * A base class for error logs. Reports errors and warnings, and + * keeps track of error numbers and positions. + * + *

    This is NOT part of any API supported by Sun Microsystems. 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 abstract class AbstractLog { + AbstractLog(JCDiagnostic.Factory diags) { + this.diags = diags; + sourceMap = new HashMap(); + } + + /** Re-assign source, returning previous setting. + */ + public JavaFileObject useSource(JavaFileObject file) { + JavaFileObject prev = (source == null ? null : source.getFile()); + source = getSource(file); + return prev; + } + + protected DiagnosticSource getSource(JavaFileObject file) { + if (file == null) + return null; + DiagnosticSource s = sourceMap.get(file); + if (s == null) { + s = new DiagnosticSource(file, this); + sourceMap.put(file, s); + } + return s; + } + + /** Report an error, unless another error was already reported at same + * source position. + * @param key The key for the localized error message. + * @param args Fields of the error message. + */ + public void error(String key, Object ... args) { + report(diags.error(source, null, key, args)); + } + + /** Report an error, unless another error was already reported at same + * source position. + * @param pos The source position at which to report the error. + * @param key The key for the localized error message. + * @param args Fields of the error message. + */ + public void error(DiagnosticPosition pos, String key, Object ... args) { + report(diags.error(source, pos, key, args)); + } + + /** Report an error, unless another error was already reported at same + * source position. + * @param pos The source position at which to report the error. + * @param key The key for the localized error message. + * @param args Fields of the error message. + */ + public void error(int pos, String key, Object ... args) { + report(diags.error(source, wrap(pos), key, args)); + } + + /** Report a warning, unless suppressed by the -nowarn option or the + * maximum number of warnings has been reached. + * @param pos The source position at which to report the warning. + * @param key The key for the localized warning message. + * @param args Fields of the warning message. + */ + public void warning(String key, Object ... args) { + report(diags.warning(source, null, key, args)); + } + + /** Report a warning, unless suppressed by the -nowarn option or the + * maximum number of warnings has been reached. + * @param pos The source position at which to report the warning. + * @param key The key for the localized warning message. + * @param args Fields of the warning message. + */ + public void warning(DiagnosticPosition pos, String key, Object ... args) { + report(diags.warning(source, pos, key, args)); + } + + /** Report a warning, unless suppressed by the -nowarn option or the + * maximum number of warnings has been reached. + * @param pos The source position at which to report the warning. + * @param key The key for the localized warning message. + * @param args Fields of the warning message. + */ + public void warning(int pos, String key, Object ... args) { + report(diags.warning(source, wrap(pos), key, args)); + } + + /** Report a warning. + * @param pos The source position at which to report the warning. + * @param key The key for the localized warning message. + * @param args Fields of the warning message. + */ + public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) { + report(diags.mandatoryWarning(source, pos, key, args)); + } + + /** Provide a non-fatal notification, unless suppressed by the -nowarn option. + * @param key The key for the localized notification message. + * @param args Fields of the notint an error or warning message: + */ + public void note(String key, Object ... args) { + report(diags.note(source, null, key, args)); + } + + /** Provide a non-fatal notification, unless suppressed by the -nowarn option. + * @param key The key for the localized notification message. + * @param args Fields of the notification message. + */ + public void note(DiagnosticPosition pos, String key, Object ... args) { + report(diags.note(source, pos, key, args)); + } + + /** Provide a non-fatal notification, unless suppressed by the -nowarn option. + * @param key The key for the localized notification message. + * @param args Fields of the notification message. + */ + public void note(int pos, String key, Object ... args) { + report(diags.note(source, wrap(pos), key, args)); + } + + /** Provide a non-fatal notification, unless suppressed by the -nowarn option. + * @param key The key for the localized notification message. + * @param args Fields of the notification message. + */ + public void note(JavaFileObject file, String key, Object ... args) { + report(diags.note(getSource(file), null, key, args)); + } + + /** Provide a non-fatal notification, unless suppressed by the -nowarn option. + * @param key The key for the localized notification message. + * @param args Fields of the notification message. + */ + public void mandatoryNote(final JavaFileObject file, String key, Object ... args) { + report(diags.mandatoryNote(getSource(file), key, args)); + } + + protected abstract void report(JCDiagnostic diagnostic); + + protected abstract void directError(String key, Object... args); + + private DiagnosticPosition wrap(int pos) { + return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos)); + } + + /** Factory for diagnostics + */ + protected JCDiagnostic.Factory diags; + + /** The file that's currently being translated. + */ + protected DiagnosticSource source; + + /** A cache of lightweight DiagnosticSource objects. + */ + protected Map sourceMap; +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticFormatter.java index 2c549105256..511ee28fe9f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticFormatter.java @@ -28,7 +28,6 @@ package com.sun.tools.javac.util; import javax.tools.JavaFileObject; import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java b/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java new file mode 100644 index 00000000000..c30d0a5cb2e --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java @@ -0,0 +1,214 @@ +/* + * Copyright 1999-2008 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package com.sun.tools.javac.util; + +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.nio.CharBuffer; +import java.util.Map; +import javax.tools.JavaFileObject; + +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.tree.JCTree; + +import static com.sun.tools.javac.util.LayoutCharacters.*; + +/** + * A simple abstraction of a source file, as needed for use in a diagnostic message. + * Provides access to the line and position in a line for any given character offset. + * + *

    This is NOT part of any API supported by Sun Microsystems. 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 DiagnosticSource { + public DiagnosticSource(JavaFileObject fo, AbstractLog log) { + this.fileObject = fo; + this.log = log; + } + + /** Return the underlying file object handled by this + * DiagnosticSource object. + */ + public JavaFileObject getFile() { + return fileObject; + } + + public CharSequence getName() { + return JavacFileManager.getJavacBaseFileName(fileObject); + } + + /** Return the one-based line number associated with a given pos + * for the current source file. Zero is returned if no line exists + * for the given position. + */ + public int getLineNumber(int pos) { + try { + if (findLine(pos)) { + return line; + } + return 0; + } finally { + buf = null; + } + } + + /** Return the one-based column number associated with a given pos + * for the current source file. Zero is returned if no column exists + * for the given position. + */ + public int getColumnNumber(int pos) { + try { + if (findLine(pos)) { + int column = 0; + for (int bp = lineStart; bp < pos; bp++) { + if (bp >= bufLen) { + return 0; + } + if (buf[bp] == '\t') { + column = (column / TabInc * TabInc) + TabInc; + } else { + column++; + } + } + return column + 1; // positions are one-based + } + return 0; + } finally { + buf = null; + } + } + + /** Return the content of the line containing a given pos. + */ + public String getLine(int pos) { + try { + if (!findLine(pos)) + return null; + + int lineEnd = lineStart; + while (lineEnd < bufLen && buf[lineEnd] != CR && buf[lineEnd] != LF) + lineEnd++; + if (lineEnd - lineStart == 0) + return null; + return new String(buf, lineStart, lineEnd - lineStart); + } finally { + buf = null; + } + } + + public Map getEndPosTable() { + return endPosTable; + } + + public void setEndPosTable(Map t) { + if (endPosTable != null && endPosTable != t) + throw new IllegalStateException("endPosTable already set"); + endPosTable = t; + } + + /** Find the line in the buffer that contains the current position + * @param pos Character offset into the buffer + */ + private boolean findLine(int pos) { + if (pos == Position.NOPOS) + return false; + + try { + // try and recover buffer from soft reference cache + if (buf == null && refBuf != null) + buf = refBuf.get(); + + if (buf == null) { + buf = initBuf(fileObject); + lineStart = 0; + line = 1; + } else if (lineStart > pos) { // messages don't come in order + lineStart = 0; + line = 1; + } + + int bp = lineStart; + while (bp < bufLen && bp < pos) { + switch (buf[bp++]) { + case CR: + if (bp < bufLen && buf[bp] == LF) bp++; + line++; + lineStart = bp; + break; + case LF: + line++; + lineStart = bp; + break; + } + } + return bp <= bufLen; + } catch (IOException e) { + log.directError("source.unavailable"); + buf = new char[0]; + return false; + } + } + + protected char[] initBuf(JavaFileObject fileObject) throws IOException { + char[] buf; + CharSequence cs = fileObject.getCharContent(true); + if (cs instanceof CharBuffer) { + CharBuffer cb = (CharBuffer) cs; + buf = JavacFileManager.toArray(cb); + bufLen = cb.limit(); + } else { + buf = cs.toString().toCharArray(); + bufLen = buf.length; + } + refBuf = new SoftReference(buf); + return buf; + } + + /** The underlying file object. */ + protected JavaFileObject fileObject; + + protected Map endPosTable; + + /** A soft reference to the content of the file object. */ + protected SoftReference refBuf; + + /** A temporary hard reference to the content of the file object. */ + protected char[] buf; + + /** The length of the content. */ + protected int bufLen; + + /** The start of a line found by findLine. */ + protected int lineStart; + + /** The line number of a line found by findLine. */ + protected int line; + + /** A log for reporting errors, such as errors accessing the content. */ + protected AbstractLog log; +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java index 75f7c0758c0..a7d862203db 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java @@ -174,18 +174,6 @@ public class JCDiagnostic implements Diagnostic { args); } - /** - * A simple abstraction of a source file, as needed for use in a diagnostic message. - */ - // Note: This class may be superceded by a more general abstraction - public interface DiagnosticSource { - JavaFileObject getFile(); - CharSequence getName(); - int getLineNumber(int pos); - int getColumnNumber(int pos); - Map getEndPosTable(); - }; - /** * A DiagnosticType defines the type of the diagnostic. **/ diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java index 93bdd542a05..5cd08aed172 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java @@ -26,8 +26,6 @@ package com.sun.tools.javac.util; import java.io.*; -import java.nio.CharBuffer; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -38,9 +36,6 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; -import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; - -import static com.sun.tools.javac.util.LayoutCharacters.*; /** A class for error logs. Reports errors and warnings, and * keeps track of error numbers and positions. @@ -50,7 +45,7 @@ import static com.sun.tools.javac.util.LayoutCharacters.*; * This code and its internal interfaces are subject to change or * deletion without notice. */ -public class Log { +public class Log extends AbstractLog { /** The context key for the log. */ public static final Context.Key logKey = new Context.Key(); @@ -98,28 +93,22 @@ public class Log { * interface to javac (JSR 199). */ protected DiagnosticListener diagListener; + /** * Formatter for diagnostics */ private DiagnosticFormatter diagFormatter; - /** - * Factory for diagnostics - */ - private JCDiagnostic.Factory diags; - - /** Construct a log with given I/O redirections. */ @Deprecated protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) { + super(JCDiagnostic.Factory.instance(context)); context.put(logKey, this); this.errWriter = errWriter; this.warnWriter = warnWriter; this.noticeWriter = noticeWriter; - this.diags = JCDiagnostic.Factory.instance(context); - Options options = Options.instance(context); this.dumpOnError = options.get("-doe") != null; this.promptOnError = options.get("-prompt") != null; @@ -174,10 +163,6 @@ public class Log { return instance; } - /** The file that's currently translated. - */ - protected JCDiagnostic.DiagnosticSource source; - /** The number of errors encountered so far. */ public int nerrors = 0; @@ -192,77 +177,13 @@ public class Log { */ private Set> recorded = new HashSet>(); - private Map> endPosTables; - - /** The buffer containing the file that's currently translated. - */ - private char[] buf = null; - - /** The length of useful data in buf - */ - private int bufLen = 0; - - /** The position in the buffer at which last error was reported - */ - private int bp; - - /** number of the current source line; first line is 1 - */ - private int line; - - /** buffer index of the first character of the current source line - */ - private int lineStart; - public boolean hasDiagnosticListener() { return diagListener != null; } public void setEndPosTable(JavaFileObject name, Map table) { - if (endPosTables == null) - endPosTables = new HashMap>(); - endPosTables.put(name, table); - } - - /** Re-assign source, returning previous setting. - */ - public JavaFileObject useSource(final JavaFileObject name) { - JavaFileObject prev = currentSource(); - if (name != prev) { - source = new JCDiagnostic.DiagnosticSource() { - public JavaFileObject getFile() { - return name; - } - public CharSequence getName() { - return JavacFileManager.getJavacBaseFileName(getFile()); - } - public int getLineNumber(int pos) { - return Log.this.getLineNumber(pos); - } - public int getColumnNumber(int pos) { - return Log.this.getColumnNumber(pos); - } - public Map getEndPosTable() { - return (endPosTables == null ? null : endPosTables.get(name)); - } - }; - buf = null; - } - return prev; - } - - /** Re-assign source buffer for existing source name. - */ - protected void setBuf(char[] newBuf) { - buf = newBuf; - bufLen = buf.length; - bp = 0; - lineStart = 0; - line = 1; - } - - protected char[] getBuf() { - return buf; + name.getClass(); // null check + getSource(name).setEndPosTable(table); } /** Return current source name. @@ -320,74 +241,19 @@ public class Log { * @param pos Buffer index of the error position, must be on current line */ private void printErrLine(int pos, PrintWriter writer) { - if (!findLine(pos)) + String line = (source == null ? null : source.getLine(pos)); + if (line == null) return; + int col = source.getColumnNumber(pos); - int lineEnd = lineStart; - while (lineEnd < bufLen && buf[lineEnd] != CR && buf[lineEnd] != LF) - lineEnd++; - if (lineEnd - lineStart == 0) - return; - printLines(writer, new String(buf, lineStart, lineEnd - lineStart)); - for (bp = lineStart; bp < pos; bp++) { - writer.print((buf[bp] == '\t') ? "\t" : " "); + printLines(writer, line); + for (int i = 0; i < col - 1; i++) { + writer.print((line.charAt(i) == '\t') ? "\t" : " "); } writer.println("^"); writer.flush(); } - protected void initBuf(JavaFileObject fileObject) throws IOException { - CharSequence cs = fileObject.getCharContent(true); - if (cs instanceof CharBuffer) { - CharBuffer cb = (CharBuffer) cs; - buf = JavacFileManager.toArray(cb); - bufLen = cb.limit(); - } else { - buf = cs.toString().toCharArray(); - bufLen = buf.length; - } - } - - /** Find the line in the buffer that contains the current position - * @param pos Character offset into the buffer - */ - private boolean findLine(int pos) { - if (pos == Position.NOPOS || currentSource() == null) - return false; - try { - if (buf == null) { - initBuf(currentSource()); - lineStart = 0; - line = 1; - } else if (lineStart > pos) { // messages don't come in order - lineStart = 0; - line = 1; - } - bp = lineStart; - while (bp < bufLen && bp < pos) { - switch (buf[bp++]) { - case CR: - if (bp < bufLen && buf[bp] == LF) bp++; - line++; - lineStart = bp; - break; - case LF: - line++; - lineStart = bp; - break; - } - } - return bp <= bufLen; - } catch (IOException e) { - //e.printStackTrace(); - // FIXME: include e.getLocalizedMessage() in error message - printLines(errWriter, getLocalizedString("source.unavailable")); - errWriter.flush(); - buf = new char[0]; - } - return false; - } - /** Print the text of a message, translating newlines appropriately * for the platform. */ @@ -400,72 +266,9 @@ public class Log { if (msg.length() != 0) writer.println(msg); } - /** Report an error, unless another error was already reported at same - * source position. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void error(String key, Object ... args) { - report(diags.error(source, null, key, args)); - } - - /** Report an error, unless another error was already reported at same - * source position. - * @param pos The source position at which to report the error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void error(DiagnosticPosition pos, String key, Object ... args) { - report(diags.error(source, pos, key, args)); - } - - /** Report an error, unless another error was already reported at same - * source position. - * @param pos The source position at which to report the error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void error(int pos, String key, Object ... args) { - report(diags.error(source, wrap(pos), key, args)); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void warning(String key, Object ... args) { - report(diags.warning(source, null, key, args)); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void warning(DiagnosticPosition pos, String key, Object ... args) { - report(diags.warning(source, pos, key, args)); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void warning(int pos, String key, Object ... args) { - report(diags.warning(source, wrap(pos), key, args)); - } - - /** Report a warning. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) { - report(diags.mandatoryWarning(source, pos, key, args)); + protected void directError(String key, Object... args) { + printLines(errWriter, getLocalizedString(key, args)); + errWriter.flush(); } /** Report a warning that cannot be suppressed. @@ -478,74 +281,6 @@ public class Log { nwarnings++; } - /** Provide a non-fatal notification, unless suppressed by the -nowarn option. - * @param key The key for the localized notification message. - * @param args Fields of the notification message. - */ - public void note(String key, Object ... args) { - report(diags.note(source, null, key, args)); - } - - /** Provide a non-fatal notification, unless suppressed by the -nowarn option. - * @param key The key for the localized notification message. - * @param args Fields of the notification message. - */ - public void note(DiagnosticPosition pos, String key, Object ... args) { - report(diags.note(source, pos, key, args)); - } - - /** Provide a non-fatal notification, unless suppressed by the -nowarn option. - * @param key The key for the localized notification message. - * @param args Fields of the notification message. - */ - public void note(int pos, String key, Object ... args) { - report(diags.note(source, wrap(pos), key, args)); - } - - /** Provide a non-fatal notification, unless suppressed by the -nowarn option. - * @param file The file to which the note applies. - * @param key The key for the localized notification message. - * @param args Fields of the notification message. - */ - public void note(JavaFileObject file, String key, Object ... args) { - report(diags.note(wrap(file), null, key, args)); - } - - /** Provide a non-fatal notification, unless suppressed by the -nowarn option. - * @param key The key for the localized notification message. - * @param args Fields of the notification message. - */ - public void mandatoryNote(final JavaFileObject file, String key, Object ... args) { - report(diags.mandatoryNote(wrap(file), key, args)); - } - - private JCDiagnostic.DiagnosticSource wrap(final JavaFileObject file) { - if (file == null) { - return null; - } - return new JCDiagnostic.DiagnosticSource() { - public JavaFileObject getFile() { - return file; - } - public CharSequence getName() { - return JavacFileManager.getJavacBaseFileName(getFile()); - } - public int getLineNumber(int pos) { - return Log.this.getLineNumber(pos); - } - public int getColumnNumber(int pos) { - return Log.this.getColumnNumber(pos); - } - public Map getEndPosTable() { - return (endPosTables == null ? null : endPosTables.get(file)); - } - }; - } - - private DiagnosticPosition wrap(int pos) { - return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos)); - } - /** * Common diagnostic handling. * The diagnostic is counted, and depending on the options and how many diagnostics have been @@ -657,12 +392,13 @@ public class Log { * and quick prototyping ***************************************************************************/ -/** print an error or warning message: - */ + /** print an error or warning message: + */ private void printRawError(int pos, String msg) { - if (!findLine(pos)) { + if (source == null || pos == Position.NOPOS) { printLines(errWriter, "error: " + msg); } else { + int line = source.getLineNumber(pos); JavaFileObject file = currentSource(); if (file != null) printLines(errWriter, @@ -673,8 +409,8 @@ public class Log { errWriter.flush(); } -/** report an error: - */ + /** report an error: + */ public void rawError(int pos, String msg) { if (nerrors < MaxErrors && shouldReport(currentSource(), pos)) { printRawError(pos, msg); @@ -684,8 +420,8 @@ public class Log { errWriter.flush(); } -/** report a warning: - */ + /** report a warning: + */ public void rawWarning(int pos, String msg) { if (nwarnings < MaxWarnings && emitWarnings) { printRawError(pos, "warning: " + msg); @@ -695,36 +431,6 @@ public class Log { errWriter.flush(); } - /** Return the one-based line number associated with a given pos - * for the current source file. Zero is returned if no line exists - * for the given position. - */ - protected int getLineNumber(int pos) { - if (findLine(pos)) - return line; - return 0; - } - - /** Return the one-based column number associated with a given pos - * for the current source file. Zero is returned if no column exists - * for the given position. - */ - protected int getColumnNumber(int pos) { - if (findLine(pos)) { - int column = 0; - for (bp = lineStart; bp < pos; bp++) { - if (bp >= bufLen) - return 0; - if (buf[bp] == '\t') - column = (column / TabInc * TabInc) + TabInc; - else - column++; - } - return column + 1; // positions are one-based - } - return 0; - } - public static String format(String fmt, Object... args) { return String.format((java.util.Locale)null, fmt, args); } From a6f6acaf2713f08abda380141c8650454cb41e0b Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 15 Jul 2008 19:22:51 -0700 Subject: [PATCH 11/22] 6657907: javadoc has unchecked warnings Reviewed-by: bpatel --- .../formats/html/AbstractMemberWriter.java | 8 +- .../doclets/formats/html/ClassUseWriter.java | 62 +++---- .../formats/html/ConfigurationImpl.java | 4 +- .../html/ConstantsSummaryWriterImpl.java | 2 +- .../formats/html/ConstructorWriterImpl.java | 6 +- .../formats/html/HtmlDocletWriter.java | 8 +- .../formats/html/HtmlSerialMethodWriter.java | 2 +- .../formats/html/PackageFrameWriter.java | 2 +- .../formats/html/PackageIndexWriter.java | 7 +- .../formats/html/PackageUseWriter.java | 8 +- .../internal/toolkit/Configuration.java | 20 +-- .../toolkit/ConstantsSummaryWriter.java | 2 +- .../toolkit/builders/AbstractBuilder.java | 2 +- .../builders/AnnotationTypeBuilder.java | 2 +- .../AnnotationTypeOptionalMemberBuilder.java | 2 +- .../AnnotationTypeRequiredMemberBuilder.java | 4 +- .../toolkit/builders/ClassBuilder.java | 2 +- .../builders/ConstantsSummaryBuilder.java | 22 +-- .../toolkit/builders/ConstructorBuilder.java | 10 +- .../toolkit/builders/EnumConstantBuilder.java | 4 +- .../toolkit/builders/FieldBuilder.java | 6 +- .../toolkit/builders/LayoutParser.java | 12 +- .../builders/MemberSummaryBuilder.java | 8 +- .../toolkit/builders/MethodBuilder.java | 4 +- .../internal/toolkit/taglets/CodeTaglet.java | 3 +- .../toolkit/taglets/LiteralTaglet.java | 2 +- .../internal/toolkit/taglets/ParamTaglet.java | 10 +- .../toolkit/taglets/TagletManager.java | 85 +++++----- .../toolkit/taglets/ThrowsTaglet.java | 12 +- .../toolkit/util/ClassDocCatalog.java | 46 ++--- .../internal/toolkit/util/ClassTree.java | 60 +++---- .../internal/toolkit/util/ClassUseMapper.java | 158 ++++++++++-------- .../util/DeprecatedAPIListBuilder.java | 14 +- .../internal/toolkit/util/DocFinder.java | 2 +- .../doclets/internal/toolkit/util/Extern.java | 6 +- .../doclets/internal/toolkit/util/Group.java | 30 ++-- .../toolkit/util/ImplementedMethods.java | 12 +- .../internal/toolkit/util/IndexBuilder.java | 22 +-- .../internal/toolkit/util/MetaKeywords.java | 12 +- .../toolkit/util/SourceToHTMLConverter.java | 4 +- .../doclets/internal/toolkit/util/Util.java | 34 ++-- .../toolkit/util/VisibleMemberMap.java | 64 ++++--- .../toolkit/util/links/LinkFactory.java | 6 +- .../com/sun/tools/javadoc/DocletInvoker.java | 2 +- .../javadoc/ExecutableMemberDocImpl.java | 2 +- .../com/sun/tools/javadoc/JavadocEnter.java | 2 +- .../sun/tools/javadoc/JavadocMemberEnter.java | 4 +- .../com/sun/tools/javadoc/SeeTagImpl.java | 2 +- .../com/sun/tools/javadoc/SerializedForm.java | 2 +- .../classes/com/sun/tools/javah/Gen.java | 2 +- 50 files changed, 411 insertions(+), 396 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java index 0bbb6e4b392..943a7af66ee 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java @@ -345,18 +345,18 @@ public abstract class AbstractMemberWriter { /** * Print use info. */ - protected void printUseInfo(Object mems, String heading) { + protected void printUseInfo(List mems, String heading) { if (mems == null) { return; } - List members = (List)mems; + List members = mems; if (members.size() > 0) { writer.tableIndexSummary(); writer.tableUseInfoHeaderStart("#CCCCFF"); writer.print(heading); writer.tableHeaderEnd(); - for (Iterator it = members.iterator(); it.hasNext(); ) { - ProgramElementDoc pgmdoc = (ProgramElementDoc)it.next(); + for (Iterator it = members.iterator(); it.hasNext(); ) { + ProgramElementDoc pgmdoc = it.next(); ClassDoc cd = pgmdoc.containingClass(); writer.printSummaryLinkType(this, pgmdoc); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java index 713dce1e88f..ca1f32543d3 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java @@ -39,28 +39,28 @@ public class ClassUseWriter extends SubWriterHolderWriter { final ClassDoc classdoc; Set pkgToPackageAnnotations = null; - final Map pkgToClassTypeParameter; - final Map pkgToClassAnnotations; - final Map pkgToMethodTypeParameter; - final Map pkgToMethodArgTypeParameter; - final Map pkgToMethodReturnTypeParameter; - final Map pkgToMethodAnnotations; - final Map pkgToMethodParameterAnnotations; - final Map pkgToFieldTypeParameter; - final Map pkgToFieldAnnotations; - final Map pkgToSubclass; - final Map pkgToSubinterface; - final Map pkgToImplementingClass; - final Map pkgToField; - final Map pkgToMethodReturn; - final Map pkgToMethodArgs; - final Map pkgToMethodThrows; - final Map pkgToConstructorAnnotations; - final Map pkgToConstructorParameterAnnotations; - final Map pkgToConstructorArgs; - final Map pkgToConstructorArgTypeParameter; - final Map pkgToConstructorThrows; - final SortedSet pkgSet; + final Map> pkgToClassTypeParameter; + final Map> pkgToClassAnnotations; + final Map> pkgToMethodTypeParameter; + final Map> pkgToMethodArgTypeParameter; + final Map> pkgToMethodReturnTypeParameter; + final Map> pkgToMethodAnnotations; + final Map> pkgToMethodParameterAnnotations; + final Map> pkgToFieldTypeParameter; + final Map> pkgToFieldAnnotations; + final Map> pkgToSubclass; + final Map> pkgToSubinterface; + final Map> pkgToImplementingClass; + final Map> pkgToField; + final Map> pkgToMethodReturn; + final Map> pkgToMethodArgs; + final Map> pkgToMethodThrows; + final Map> pkgToConstructorAnnotations; + final Map> pkgToConstructorParameterAnnotations; + final Map> pkgToConstructorArgs; + final Map> pkgToConstructorArgTypeParameter; + final Map> pkgToConstructorThrows; + final SortedSet pkgSet; final MethodWriterImpl methodSubWriter; final ConstructorWriterImpl constrSubWriter; final FieldWriterImpl fieldSubWriter; @@ -81,9 +81,9 @@ public class ClassUseWriter extends SubWriterHolderWriter { super(configuration, path, filename, relpath); this.classdoc = classdoc; if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName())) - pkgToPackageAnnotations = new HashSet((List) mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); + pkgToPackageAnnotations = new HashSet(mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); configuration.currentcd = classdoc; - this.pkgSet = new TreeSet(); + this.pkgSet = new TreeSet(); this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations); this.pkgToMethodTypeParameter = pkgDivide(mapper.classToExecMemberDocTypeParam); @@ -135,19 +135,19 @@ public class ClassUseWriter extends SubWriterHolderWriter { } } - private Map pkgDivide(Map classMap) { - Map map = new HashMap(); - List list= (List)classMap.get(classdoc.qualifiedName()); + private Map> pkgDivide(Map> classMap) { + Map> map = new HashMap>(); + List list= classMap.get(classdoc.qualifiedName()); if (list != null) { Collections.sort(list); - Iterator it = list.iterator(); + Iterator it = list.iterator(); while (it.hasNext()) { - ProgramElementDoc doc = (ProgramElementDoc)it.next(); + ProgramElementDoc doc = it.next(); PackageDoc pkg = doc.containingPackage(); pkgSet.add(pkg); - List inPkg = (List)map.get(pkg.name()); + List inPkg = map.get(pkg.name()); if (inPkg == null) { - inPkg = new ArrayList(); + inPkg = new ArrayList(); map.put(pkg.name(), inPkg); } inPkg.add(doc); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java index 4ea6d38c13f..98c27bfb4eb 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java @@ -253,7 +253,7 @@ public class ConfigurationImpl extends Configuration { } } if (root.specifiedClasses().length > 0) { - Map map = new HashMap(); + Map map = new HashMap(); PackageDoc pd; ClassDoc[] classes = root.classes(); for (int i = 0; i < classes.length; i++) { @@ -481,7 +481,7 @@ public class ConfigurationImpl extends Configuration { /** * {@inheritDoc} */ - public Comparator getMemberComparator() { + public Comparator getMemberComparator() { return null; } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java index 24cefb2e896..7237638920e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -107,7 +107,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ - public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set printedPackageHeaders) { + public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set printedPackageHeaders) { String packageName = pkg.name(); //add link to summary li(); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java index 979553e77cf..b219876b6cd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java @@ -55,10 +55,10 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter super(writer, classDoc); VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated); - List constructors = new ArrayList(visibleMemberMap.getMembersFor(classDoc)); + List constructors = new ArrayList(visibleMemberMap.getMembersFor(classDoc)); for (int i = 0; i < constructors.size(); i++) { - if (((ProgramElementDoc)(constructors.get(i))).isProtected() || - ((ProgramElementDoc)(constructors.get(i))).isPrivate()) { + if ((constructors.get(i)).isProtected() || + (constructors.get(i)).isPrivate()) { setFoundNonPubConstructor(true); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index 8a08253c6f2..67ce9bb4665 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -1463,7 +1463,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { int originalLength = result.length(); TagletOutput output = TagletWriter.getInlineTagOuput( configuration.tagletManager, holderTag, - (Tag) tagelem, getTagletWriterInstance(isFirstSentence)); + tagelem, getTagletWriterInstance(isFirstSentence)); result.append(output == null ? "" : output.toString()); if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) { break; @@ -1750,8 +1750,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @return an array of strings representing the annotations being * documented. */ - private List getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) { - List results = new ArrayList(); + private List getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) { + List results = new ArrayList(); StringBuffer annotation; for (int i = 0; i < descList.length; i++) { AnnotationTypeDoc annotationDoc = descList[i].annotationType(); @@ -1781,7 +1781,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { pairs[j].element(), pairs[j].element().name(), false)); annotation.append('='); AnnotationValue annotationValue = pairs[j].value(); - List annotationTypeValues = new ArrayList(); + List annotationTypeValues = new ArrayList(); if (annotationValue.value() instanceof AnnotationValue[]) { AnnotationValue[] annotationArray = (AnnotationValue[]) annotationValue.value(); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java index 3f8eb66d804..b14a8855e9d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java @@ -90,7 +90,7 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements tagletManager.getSerializedFormTags(), writer.getTagletWriterInstance(false), output); print(output.toString()); - MethodDoc method = (MethodDoc)member; + MethodDoc method = member; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { serialWarning(member.position(), "doclet.MissingSerialDataTag", diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java index 2a5da68ca2b..0f78a41408b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java @@ -73,7 +73,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc)); this.packageDoc = packageDoc; if (configuration.root.specifiedPackages().length == 0) { - documentedClasses = new HashSet(Arrays.asList(configuration.root.classes())); + documentedClasses = new HashSet(Arrays.asList(configuration.root.classes())); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java index b794d3e72c9..ea100178570 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java @@ -49,7 +49,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @see Group */ - private Map groupPackageMap; + private Map> groupPackageMap; /** * List to store the order groups as specified on the command line. @@ -120,10 +120,9 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { protected void generateIndex() { for (int i = 0; i < groupList.size(); i++) { String groupname = (String)groupList.get(i); - List list = (List)groupPackageMap.get(groupname); + List list = groupPackageMap.get(groupname); if (list != null && list.size() > 0) { - printIndexContents((PackageDoc[])list. - toArray(new PackageDoc[list.size()]), + printIndexContents(list.toArray(new PackageDoc[list.size()]), groupname); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java index c16ce6d7483..ccece091ecf 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java @@ -38,7 +38,7 @@ import java.util.*; public class PackageUseWriter extends SubWriterHolderWriter { final PackageDoc pkgdoc; - final SortedMap usingPackageToUsedClasses = new TreeMap(); + final SortedMap> usingPackageToUsedClasses = new TreeMap>(); /** * Constructor. @@ -61,15 +61,15 @@ public class PackageUseWriter extends SubWriterHolderWriter { ClassDoc[] content = pkgdoc.allClasses(); for (int i = 0; i < content.length; ++i) { ClassDoc usedClass = content[i]; - Set usingClasses = (Set)mapper.classToClass.get(usedClass.qualifiedName()); + Set usingClasses = mapper.classToClass.get(usedClass.qualifiedName()); if (usingClasses != null) { for (Iterator it = usingClasses.iterator(); it.hasNext(); ) { ClassDoc usingClass = (ClassDoc)it.next(); PackageDoc usingPackage = usingClass.containingPackage(); - Set usedClasses = (Set)usingPackageToUsedClasses + Set usedClasses = usingPackageToUsedClasses .get(usingPackage.name()); if (usedClasses == null) { - usedClasses = new TreeSet(); + usedClasses = new TreeSet(); usingPackageToUsedClasses.put(Util.getPackageName(usingPackage), usedClasses); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index 794c5c6d044..fdefbc4d43d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -120,12 +120,12 @@ public abstract class Configuration { /** * The list of doc-file subdirectories to exclude */ - protected Set excludedDocFileDirs; + protected Set excludedDocFileDirs; /** * The list of qualifiers to exclude */ - protected Set excludedQualifiers; + protected Set excludedQualifiers; /** * The Root of the generated Program Structure from the Doclet API. @@ -255,8 +255,8 @@ public abstract class Configuration { message = new MessageRetriever(this, "com.sun.tools.doclets.internal.toolkit.resources.doclets"); - excludedDocFileDirs = new HashSet(); - excludedQualifiers = new HashSet(); + excludedDocFileDirs = new HashSet(); + excludedQualifiers = new HashSet(); } /** @@ -329,14 +329,14 @@ public abstract class Configuration { DocErrorReporter reporter); private void initPackageArray() { - Set set = new HashSet(Arrays.asList(root.specifiedPackages())); + Set set = new HashSet(Arrays.asList(root.specifiedPackages())); ClassDoc[] classes = root.specifiedClasses(); for (int i = 0; i < classes.length; i++) { set.add(classes[i].containingPackage()); } - ArrayList results = new ArrayList(set); + ArrayList results = new ArrayList(set); Collections.sort(results); - packages = (PackageDoc[]) results.toArray(new PackageDoc[] {}); + packages = results.toArray(new PackageDoc[] {}); } /** @@ -345,7 +345,7 @@ public abstract class Configuration { * @param options the two dimensional array of options. */ public void setOptions(String[][] options) { - LinkedHashSet customTagStrs = new LinkedHashSet(); + LinkedHashSet customTagStrs = new LinkedHashSet(); for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; String opt = os[0].toLowerCase(); @@ -476,7 +476,7 @@ public abstract class Configuration { } } - private void addToSet(Set s, String str){ + private void addToSet(Set s, String str){ StringTokenizer st = new StringTokenizer(str, ":"); String current; while(st.hasMoreTokens()){ @@ -712,5 +712,5 @@ public abstract class Configuration { * * @return the {@link java.util.Comparator} used to sort members. */ - public abstract Comparator getMemberComparator(); + public abstract Comparator getMemberComparator(); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java index c7c944e369f..2168ec1b1ab 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java @@ -79,7 +79,7 @@ public interface ConstantsSummaryWriter { * something more than once. */ public abstract void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, - Set WriteedPackageHeaders); + Set WriteedPackageHeaders); /** * Write the given package name. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java index 0776f408946..a27bf737d85 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java @@ -61,7 +61,7 @@ public abstract class AbstractBuilder { * efficiency purposes. We don't want to copy the * doc files multiple times for a single package. */ - protected static Set containingPackagesSeen; + protected static Set containingPackagesSeen; /** * True if we want to print debug output. diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java index 959428b938f..67a6096190b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java @@ -84,7 +84,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder { builder.annotationTypeDoc = annotationTypeDoc; builder.writer = writer; if(containingPackagesSeen == null) { - containingPackagesSeen = new HashSet(); + containingPackagesSeen = new HashSet(); } return builder; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java index 747190897e6..511b457d2be 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java @@ -73,7 +73,7 @@ public class AnnotationTypeOptionalMemberBuilder extends builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated); - builder.members = new ArrayList( + builder.members = new ArrayList( builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort(builder.members, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index b92b8b42c5e..98b5278f551 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -62,7 +62,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { /** * The list of members being documented. */ - protected List members; + protected List members; /** * The index of the current member that is being documented at this point @@ -97,7 +97,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated); - builder.members = new ArrayList( + builder.members = new ArrayList( builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort(builder.members, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java index e37f6426005..3c287a3473d 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java @@ -100,7 +100,7 @@ public class ClassBuilder extends AbstractBuilder { Util.setEnumDocumentation(configuration, classDoc); } if(containingPackagesSeen == null) { - containingPackagesSeen = new HashSet(); + containingPackagesSeen = new HashSet(); } return builder; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java index 746c44013d4..eaf3f11464f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java @@ -63,12 +63,12 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * The set of ClassDocs that have constant fields. */ - protected Set classDocsWithConstFields; + protected Set classDocsWithConstFields; /** * The set of printed package headers. */ - protected Set printedPackageHeaders; + protected Set printedPackageHeaders; /** * The current package being documented. @@ -102,7 +102,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder( configuration); builder.writer = writer; - builder.classDocsWithConstFields = new HashSet(); + builder.classDocsWithConstFields = new HashSet(); return builder; } @@ -169,7 +169,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { public void buildContents() { writer.writeContentsHeader(); PackageDoc[] packages = configuration.packages; - printedPackageHeaders = new HashSet(); + printedPackageHeaders = new HashSet(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { writer.writeLinkToPackageContent(packages[i], @@ -188,7 +188,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { */ public void buildConstantSummaries(List elements) { PackageDoc[] packages = configuration.packages; - printedPackageHeaders = new HashSet(); + printedPackageHeaders = new HashSet(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i])) { currentPackage = packages[i]; @@ -315,7 +315,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param pkgname the name of the package to check. */ private boolean hasPrintedPackageIndex(String pkgname) { - String[] list = (String[])printedPackageHeaders.toArray(new String[] {}); + String[] list = printedPackageHeaders.toArray(new String[] {}); for (int i = 0; i < list.length; i++) { if (pkgname.startsWith(list[i])) { return true; @@ -363,7 +363,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * Builds the table of constants for a given class. */ protected void buildMembersSummary() { - List members = new ArrayList(members()); + List members = new ArrayList(members()); if (members.size() > 0) { Collections.sort(members); writer.writeConstantMembers(classdoc, members); @@ -375,17 +375,17 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param cd the classdoc to examine. * @return the list of visible constant fields for the given classdoc. */ - protected List members() { - List l = visibleMemberMapFields.getLeafClassMembers(configuration); + protected List members() { + List l = visibleMemberMapFields.getLeafClassMembers(configuration); l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration)); - Iterator iter; + Iterator iter; if(l != null){ iter = l.iterator(); } else { return null; } - List inclList = new LinkedList(); + List inclList = new LinkedList(); FieldDoc member; while(iter.hasNext()){ member = (FieldDoc)iter.next(); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java index 8e4dc812e7c..d7e2a8c46ac 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java @@ -72,7 +72,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * The constructors being documented. */ - private List constructors; + private List constructors; /** * Construct a new ConstructorBuilder. @@ -104,12 +104,10 @@ public class ConstructorBuilder extends AbstractMemberBuilder { VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated); builder.constructors = - new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); + new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); for (int i = 0; i < builder.constructors.size(); i++) { - if (((ProgramElementDoc) (builder.constructors.get(i))) - .isProtected() - || ((ProgramElementDoc) (builder.constructors.get(i))) - .isPrivate()) { + if (builder.constructors.get(i).isProtected() + || builder.constructors.get(i).isPrivate()) { writer.setFoundNonPubConstructor(true); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java index bfba89bed92..f9bb17f84ae 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java @@ -61,7 +61,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * The list of enum constants being documented. */ - private List enumConstants; + private List enumConstants; /** * The index of the current enum constant that is being documented at this point @@ -99,7 +99,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated); builder.enumConstants = - new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); + new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort( builder.enumConstants, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java index 87b4a02d7ff..cfa53f0f7bf 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java @@ -61,7 +61,7 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * The list of fields being documented. */ - private List fields; + private List fields; /** * The index of the current field that is being documented at this point @@ -99,8 +99,8 @@ public class FieldBuilder extends AbstractMemberBuilder { VisibleMemberMap.FIELDS, configuration.nodeprecated); builder.fields = - new ArrayList(builder.visibleMemberMap.getLeafClassMembers( - configuration)); + new ArrayList(builder.visibleMemberMap.getLeafClassMembers( + configuration)); if (configuration.getMemberComparator() != null) { Collections.sort( builder.fields, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java index 43f208302f6..8cca83d98d2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java @@ -45,7 +45,7 @@ public class LayoutParser extends DefaultHandler { /** * The map of XML elements that have been parsed. */ - private Map xmlElementsMap; + private Map> xmlElementsMap; private Configuration configuration; private static LayoutParser instance; @@ -56,7 +56,7 @@ public class LayoutParser extends DefaultHandler { * This class is a singleton. */ private LayoutParser(Configuration configuration) { - xmlElementsMap = new HashMap(); + xmlElementsMap = new HashMap>(); this.configuration = configuration; } @@ -83,7 +83,7 @@ public class LayoutParser extends DefaultHandler { return (List) xmlElementsMap.get(root); } try { - List xmlElements = new ArrayList(); + List xmlElements = new ArrayList(); xmlElementsMap.put(root, xmlElements); currentRoot = root; isParsing = false; @@ -106,7 +106,7 @@ public class LayoutParser extends DefaultHandler { throws SAXException { if (isParsing || qName.equals(currentRoot)) { isParsing = true; - List xmlElements = (List) xmlElementsMap.get(currentRoot); + List xmlElements = xmlElementsMap.get(currentRoot); xmlElements.add(qName); } } @@ -120,11 +120,11 @@ public class LayoutParser extends DefaultHandler { isParsing = false; return; } - List xmlElements = (List) xmlElementsMap.get(currentRoot); + List xmlElements = xmlElementsMap.get(currentRoot); if (xmlElements.get(xmlElements.size()-1).equals(qName)) { return; } else { - List subElements = new ArrayList(); + List subElements = new ArrayList(); int targetIndex = xmlElements.indexOf(qName); int size = xmlElements.size(); for (int i = targetIndex; i < size; i++) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java index 86c8d9a5d9b..c375772b648 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java @@ -306,13 +306,13 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { */ private void buildSummary(MemberSummaryWriter writer, VisibleMemberMap visibleMemberMap) { - List members = new ArrayList(visibleMemberMap.getLeafClassMembers( + List members = new ArrayList(visibleMemberMap.getLeafClassMembers( configuration)); if (members.size() > 0) { Collections.sort(members); writer.writeMemberSummaryHeader(classDoc); for (int i = 0; i < members.size(); i++) { - ProgramElementDoc member = (ProgramElementDoc) members.get(i); + ProgramElementDoc member = members.get(i); Tag[] firstSentenceTags = member.firstSentenceTags(); if (member instanceof MethodDoc && firstSentenceTags.length == 0) { //Inherit comments from overriden or implemented method if @@ -349,7 +349,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { if (inhclass == classDoc) { continue; } - List inhmembers = visibleMemberMap.getMembersFor(inhclass); + List inhmembers = visibleMemberMap.getMembersFor(inhclass); if (inhmembers.size() > 0) { Collections.sort(inhmembers); writer.writeInheritedMemberSummaryHeader(inhclass); @@ -358,7 +358,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { inhclass.isPackagePrivate() && ! Util.isLinkable(inhclass, configuration) ? classDoc : inhclass, - (ProgramElementDoc) inhmembers.get(j), + inhmembers.get(j), j == 0, j == inhmembers.size() - 1); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java index 1f00adc275f..41531a0a4dd 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java @@ -66,7 +66,7 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * The methods being documented. */ - private List methods; + private List methods; private MethodBuilder(Configuration configuration) { super(configuration); @@ -94,7 +94,7 @@ public class MethodBuilder extends AbstractMemberBuilder { VisibleMemberMap.METHODS, configuration.nodeprecated); builder.methods = - new ArrayList(builder.visibleMemberMap.getLeafClassMembers( + new ArrayList(builder.visibleMemberMap.getLeafClassMembers( configuration)); if (configuration.getMemberComparator() != null) { Collections.sort( diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java index 63e10aa0daf..e1db9dc7966 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java @@ -26,6 +26,7 @@ package com.sun.tools.doclets.internal.toolkit.taglets; import java.util.Map; import com.sun.javadoc.Tag; +import com.sun.tools.doclets.Taglet; /** * An inline Taglet used to denote literal code fragments. @@ -47,7 +48,7 @@ public class CodeTaglet extends LiteralTaglet { private static final String NAME = "code"; - public static void register(Map map) { + public static void register(Map map) { map.remove(NAME); map.put(NAME, new CodeTaglet()); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java index 9a5341fd492..db7cbe788fe 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java @@ -46,7 +46,7 @@ public class LiteralTaglet implements Taglet { private static final String NAME = "literal"; - public static void register(Map map) { + public static void register(Map map) { map.remove(NAME); map.put(NAME, new LiteralTaglet()); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java index 2159f3c7ab9..a53112f7817 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java @@ -56,11 +56,11 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { * check. * @return a name-rank number map. */ - private static Map getRankMap(Object[] params){ + private static Map getRankMap(Object[] params){ if (params == null) { return null; } - HashMap result = new HashMap(); + HashMap result = new HashMap(); for (int i = 0; i < params.length; i++) { String name = params[i] instanceof Parameter ? ((Parameter) params[i]).name() : @@ -192,7 +192,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { private TagletOutput getTagletOutput(boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) { TagletOutput result = writer.getOutputInstance(); - Set alreadyDocumented = new HashSet(); + Set alreadyDocumented = new HashSet(); if (paramTags.length > 0) { result.appendOutput( processParamTags(isNonTypeParams, paramTags, @@ -214,7 +214,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { */ private TagletOutput getInheritedTagletOutput(boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, - Set alreadyDocumented) { + Set alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if ((! alreadyDocumented.contains(null)) && holder instanceof MethodDoc) { @@ -263,7 +263,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { */ private TagletOutput processParamTags(boolean isNonTypeParams, ParamTag[] paramTags, Map rankMap, TagletWriter writer, - Set alreadyDocumented) { + Set alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if (paramTags.length > 0) { for (int i = 0; i < paramTags.length; ++i) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java index 33d7c98a828..d04045704ab 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java @@ -61,7 +61,7 @@ public class TagletManager { /** * The map of custom tags. */ - private LinkedHashMap customTags; + private LinkedHashMap customTags; /** * The array of custom tags that can appear in packages. @@ -111,31 +111,31 @@ public class TagletManager { /** * Keep track of standard tags. */ - private Set standardTags; + private Set standardTags; /** * Keep track of standard tags in lowercase to compare for better * error messages when a tag like @docRoot is mistakenly spelled * lowercase @docroot. */ - private Set standardTagsLowercase; + private Set standardTagsLowercase; /** * Keep track of overriden standard tags. */ - private Set overridenStandardTags; + private Set overridenStandardTags; /** * Keep track of the tags that may conflict * with standard tags in the future (any custom tag without * a period in its name). */ - private Set potentiallyConflictingTags; + private Set potentiallyConflictingTags; /** * The set of unseen custom tags. */ - private Set unseenCustomTags; + private Set unseenCustomTags; /** * True if we do not want to use @since tags. @@ -161,12 +161,12 @@ public class TagletManager { */ public TagletManager(boolean nosince, boolean showversion, boolean showauthor, MessageRetriever message){ - overridenStandardTags = new HashSet(); - potentiallyConflictingTags = new HashSet(); - standardTags = new HashSet(); - standardTagsLowercase = new HashSet(); - unseenCustomTags = new HashSet(); - customTags = new LinkedHashMap(); + overridenStandardTags = new HashSet(); + potentiallyConflictingTags = new HashSet(); + standardTags = new HashSet(); + standardTagsLowercase = new HashSet(); + unseenCustomTags = new HashSet(); + customTags = new LinkedHashMap(); this.nosince = nosince; this.showversion = showversion; this.showauthor = showauthor; @@ -201,7 +201,7 @@ public class TagletManager { */ public void addCustomTag(String classname, String tagletPath) { try { - Class customTagClass = null; + Class customTagClass = null; // construct class loader String cpString = null; // make sure env.class.path defaults to dot @@ -219,7 +219,7 @@ public class TagletManager { meth.invoke(null, new Object[] {customTags}); list = customTags.values().toArray(); Object newLastTag = (list != null&& list.length > 0) - ? (Object) list[list.length-1] : null; + ? list[list.length-1] : null; if (lastTag != newLastTag) { //New taglets must always be added to the end of the LinkedHashMap. //If the current and previous last taglet are not equal, that @@ -315,7 +315,7 @@ public class TagletManager { if (tagName == null || locations == null) { return; } - Taglet tag = (Taglet) customTags.get(tagName); + Taglet tag = customTags.get(tagName); locations = locations.toLowerCase(); if (tag == null || header != null) { customTags.remove(tagName); @@ -396,7 +396,7 @@ public class TagletManager { } } //Check if this tag is being used in the wrong location. - if((taglet = (Taglet) customTags.get(name)) != null) { + if ((taglet = customTags.get(name)) != null) { if (areInlineTags && ! taglet.isInlineTag()) { printTagMisuseWarn(taglet, tags[i], "inline"); } @@ -425,7 +425,7 @@ public class TagletManager { * @param holderType the type of documentation that the misused tag was found in. */ private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) { - Set locationsSet = new LinkedHashSet(); + Set locationsSet = new LinkedHashSet(); if (taglet.inOverview()) { locationsSet.add("overview"); } @@ -447,7 +447,7 @@ public class TagletManager { if (taglet.isInlineTag()) { locationsSet.add("inline text"); } - String[] locations = (String[]) locationsSet.toArray(new String[]{}); + String[] locations = locationsSet.toArray(new String[]{}); if (locations == null || locations.length == 0) { //This known tag is excluded. return; @@ -592,17 +592,17 @@ public class TagletManager { * Initialize the custom tag arrays. */ private void initCustomTagArrays() { - Iterator it = customTags.values().iterator(); - ArrayList pTags = new ArrayList(customTags.size()); - ArrayList tTags = new ArrayList(customTags.size()); - ArrayList fTags = new ArrayList(customTags.size()); - ArrayList cTags = new ArrayList(customTags.size()); - ArrayList mTags = new ArrayList(customTags.size()); - ArrayList iTags = new ArrayList(customTags.size()); - ArrayList oTags = new ArrayList(customTags.size()); + Iterator it = customTags.values().iterator(); + ArrayList pTags = new ArrayList(customTags.size()); + ArrayList tTags = new ArrayList(customTags.size()); + ArrayList fTags = new ArrayList(customTags.size()); + ArrayList cTags = new ArrayList(customTags.size()); + ArrayList mTags = new ArrayList(customTags.size()); + ArrayList iTags = new ArrayList(customTags.size()); + ArrayList oTags = new ArrayList(customTags.size()); Taglet current; while (it.hasNext()) { - current = (Taglet) it.next(); + current = it.next(); if (current.inPackage() && !current.isInlineTag()) { pTags.add(current); } @@ -625,20 +625,20 @@ public class TagletManager { oTags.add(current); } } - packageTags = (Taglet[]) pTags.toArray(new Taglet[] {}); - typeTags = (Taglet[]) tTags.toArray(new Taglet[] {}); - fieldTags = (Taglet[]) fTags.toArray(new Taglet[] {}); - constructorTags = (Taglet[]) cTags.toArray(new Taglet[] {}); - methodTags = (Taglet[]) mTags.toArray(new Taglet[] {}); - overviewTags = (Taglet[]) oTags.toArray(new Taglet[] {}); - inlineTags = (Taglet[]) iTags.toArray(new Taglet[] {}); + packageTags = pTags.toArray(new Taglet[] {}); + typeTags = tTags.toArray(new Taglet[] {}); + fieldTags = fTags.toArray(new Taglet[] {}); + constructorTags = cTags.toArray(new Taglet[] {}); + methodTags = mTags.toArray(new Taglet[] {}); + overviewTags = oTags.toArray(new Taglet[] {}); + inlineTags = iTags.toArray(new Taglet[] {}); //Init the serialized form tags serializedFormTags = new Taglet[4]; - serializedFormTags[0] = (Taglet) customTags.get("serialData"); - serializedFormTags[1] = (Taglet) customTags.get("throws"); - serializedFormTags[2] = (Taglet) customTags.get("since"); - serializedFormTags[3] = (Taglet) customTags.get("see"); + serializedFormTags[0] = customTags.get("serialData"); + serializedFormTags[1] = customTags.get("throws"); + serializedFormTags[2] = customTags.get("since"); + serializedFormTags[3] = customTags.get("see"); } /** @@ -726,10 +726,9 @@ public class TagletManager { printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags); } - private void printReportHelper(String noticeKey, Set names) { + private void printReportHelper(String noticeKey, Set names) { if (names.size() > 0) { - String[] namesArray = - (String[]) names.toArray(new String[] {}); + String[] namesArray = names.toArray(new String[] {}); String result = " "; for (int i = 0; i < namesArray.length; i++) { result += "@" + namesArray[i]; @@ -751,9 +750,9 @@ public class TagletManager { */ public Taglet getTaglet(String name) { if (name.indexOf("@") == 0) { - return (Taglet) customTags.get(name.substring(1)); + return customTags.get(name.substring(1)); } else { - return (Taglet) customTags.get(name); + return customTags.get(name); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java index 15e7e7924b9..5077c60315e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java @@ -82,7 +82,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet * Add links for exceptions that are declared but not documented. */ private TagletOutput linkToUndocumentedDeclaredExceptions( - Type[] declaredExceptionTypes, Set alreadyDocumented, + Type[] declaredExceptionTypes, Set alreadyDocumented, TagletWriter writer) { TagletOutput result = writer.getOutputInstance(); //Add links to the exceptions declared but not documented. @@ -107,11 +107,11 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet * documented. */ private TagletOutput inheritThrowsDocumentation(Doc holder, - Type[] declaredExceptionTypes, Set alreadyDocumented, + Type[] declaredExceptionTypes, Set alreadyDocumented, TagletWriter writer) { TagletOutput result = writer.getOutputInstance(); if (holder instanceof MethodDoc) { - Set declaredExceptionTags = new LinkedHashSet(); + Set declaredExceptionTags = new LinkedHashSet(); for (int j = 0; j < declaredExceptionTypes.length; j++) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, @@ -124,7 +124,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet declaredExceptionTags.addAll(inheritedDoc.tagList); } result.appendOutput(throwsTagsOutput( - (ThrowsTag[]) declaredExceptionTags.toArray(new ThrowsTag[] {}), + declaredExceptionTags.toArray(new ThrowsTag[] {}), writer, alreadyDocumented, false)); } return result; @@ -137,7 +137,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder; ThrowsTag[] tags = execHolder.throwsTags(); TagletOutput result = writer.getOutputInstance(); - HashSet alreadyDocumented = new HashSet(); + HashSet alreadyDocumented = new HashSet(); if (tags.length > 0) { result.appendOutput(throwsTagsOutput( execHolder.throwsTags(), writer, alreadyDocumented, true)); @@ -161,7 +161,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet * @return the TagletOutput representation of this Tag. */ protected TagletOutput throwsTagsOutput(ThrowsTag[] throwTags, - TagletWriter writer, Set alreadyDocumented, boolean allowDups) { + TagletWriter writer, Set alreadyDocumented, boolean allowDups) { TagletOutput result = writer.getOutputInstance(); if (throwTags.length > 0) { for (int i = 0; i < throwTags.length; ++i) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java index 5169e169909..31c8d3f21b3 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java @@ -49,44 +49,44 @@ import java.util.*; * Stores the set of packages that the classes specified on the command line * belong to. Note that the default package is "". */ - private Set packageSet; + private Set packageSet; /** * Stores all classes for each package */ - private Map allClasses; + private Map> allClasses; /** * Stores ordinary classes (excluding Exceptions and Errors) for each * package */ - private Map ordinaryClasses; + private Map> ordinaryClasses; /** * Stores exceptions for each package */ - private Map exceptions; + private Map> exceptions; /** * Stores enums for each package. */ - private Map enums; + private Map> enums; /** * Stores annotation types for each package. */ - private Map annotationTypes; + private Map> annotationTypes; /** * Stores errors for each package */ - private Map errors; + private Map> errors; /** * Stores interfaces for each package */ - private Map interfaces; + private Map> interfaces; /** * Construct a new ClassDocCatalog. @@ -109,14 +109,14 @@ import java.util.*; } private void init() { - allClasses = new HashMap(); - ordinaryClasses = new HashMap(); - exceptions = new HashMap(); - enums = new HashMap(); - annotationTypes = new HashMap(); - errors = new HashMap(); - interfaces = new HashMap(); - packageSet = new HashSet(); + allClasses = new HashMap>(); + ordinaryClasses = new HashMap>(); + exceptions = new HashMap>(); + enums = new HashMap>(); + annotationTypes = new HashMap>(); + errors = new HashMap>(); + interfaces = new HashMap>(); + packageSet = new HashSet(); } /** @@ -148,7 +148,7 @@ import java.util.*; * @param classdoc the ClassDoc to add to the catelog. * @param map the Map to add the ClassDoc to. */ - private void addClass(ClassDoc classdoc, Map map) { + private void addClass(ClassDoc classdoc, Map> map) { PackageDoc pkg = classdoc.containingPackage(); if (pkg.isIncluded()) { @@ -157,22 +157,22 @@ import java.util.*; return; } String key = Util.getPackageName(pkg); - Set s = (Set) map.get(key); + Set s = map.get(key); if (s == null) { packageSet.add(key); - s = new HashSet(); + s = new HashSet(); } s.add(classdoc); map.put(key, s); } - private ClassDoc[] getArray(Map m, String key) { - Set s = (Set) m.get(key); + private ClassDoc[] getArray(Map> m, String key) { + Set s = m.get(key); if (s == null) { return new ClassDoc[] {}; } else { - return (ClassDoc[]) s.toArray(new ClassDoc[] {}); + return s.toArray(new ClassDoc[] {}); } } @@ -202,7 +202,7 @@ import java.util.*; * ClassDocs for. */ public String[] packageNames() { - return (String[]) packageSet.toArray(new String[] {}); + return packageSet.toArray(new String[] {}); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java index 20e0e0a7c43..8e1ba208f82 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java @@ -49,35 +49,35 @@ public class ClassTree { * List of baseclasses. Contains only java.lang.Object. Can be used to get * the mapped listing of sub-classes. */ - private List baseclasses = new ArrayList(); + private List baseclasses = new ArrayList(); /** * Mapping for each Class with their SubClasses */ - private Map subclasses = new HashMap(); + private Map> subclasses = new HashMap>(); /** * List of base-interfaces. Contains list of all the interfaces who do not * have super-interfaces. Can be used to get the mapped listing of * sub-interfaces. */ - private List baseinterfaces = new ArrayList(); + private List baseinterfaces = new ArrayList(); /** * Mapping for each Interface with their SubInterfaces */ - private Map subinterfaces = new HashMap(); + private Map> subinterfaces = new HashMap>(); - private List baseEnums = new ArrayList(); - private Map subEnums = new HashMap(); + private List baseEnums = new ArrayList(); + private Map> subEnums = new HashMap>(); - private List baseAnnotationTypes = new ArrayList(); - private Map subAnnotationTypes = new HashMap(); + private List baseAnnotationTypes = new ArrayList(); + private Map> subAnnotationTypes = new HashMap>(); /** * Mapping for each Interface with classes who implement it. */ - private Map implementingclasses = new HashMap(); + private Map> implementingclasses = new HashMap>(); /** * Constructor. Build the Tree using the Root of this Javadoc run. @@ -132,7 +132,7 @@ public class ClassTree { processType(classes[i], configuration, baseclasses, subclasses); } else if (classes[i].isInterface()) { processInterface(classes[i]); - List list = (List)implementingclasses.get(classes[i]); + List list = implementingclasses.get(classes[i]); if (list != null) { Collections.sort(list); } @@ -143,11 +143,11 @@ public class ClassTree { } Collections.sort(baseinterfaces); - for (Iterator it = subinterfaces.values().iterator(); it.hasNext(); ) { - Collections.sort((List)it.next()); + for (Iterator> it = subinterfaces.values().iterator(); it.hasNext(); ) { + Collections.sort(it.next()); } - for (Iterator it = subclasses.values().iterator(); it.hasNext(); ) { - Collections.sort((List)it.next()); + for (Iterator> it = subclasses.values().iterator(); it.hasNext(); ) { + Collections.sort(it.next()); } } @@ -164,7 +164,7 @@ public class ClassTree { * @param configuration the current configurtation of the doclet. */ private void processType(ClassDoc cd, Configuration configuration, - List bases, Map subs) { + List bases, Map> subs) { ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration); if (superclass != null) { if (!add(subs, superclass, cd)) { @@ -219,10 +219,10 @@ public class ClassTree { * @param cd sub-interface to be mapped. * @returns boolean true if class added, false if class already processed. */ - private boolean add(Map map, ClassDoc superclass, ClassDoc cd) { - List list = (List)map.get(superclass); + private boolean add(Map> map, ClassDoc superclass, ClassDoc cd) { + List list = map.get(superclass); if (list == null) { - list = new ArrayList(); + list = new ArrayList(); map.put(superclass, list); } if (list.contains(cd)) { @@ -241,10 +241,10 @@ public class ClassTree { * @param cd class for which the sub-class list is requested. * @returns List Sub-Class list for the class passed. */ - private List get(Map map, ClassDoc cd) { - List list = (List)map.get(cd); + private List get(Map> map, ClassDoc cd) { + List list = map.get(cd); if (list == null) { - return new ArrayList(); + return new ArrayList(); } return list; } @@ -254,7 +254,7 @@ public class ClassTree { * * @param cd class whose sub-class list is required. */ - public List subclasses(ClassDoc cd) { + public List subclasses(ClassDoc cd) { return get(subclasses, cd); } @@ -263,7 +263,7 @@ public class ClassTree { * * @param cd interface whose sub-interface list is required. */ - public List subinterfaces(ClassDoc cd) { + public List subinterfaces(ClassDoc cd) { return get(subinterfaces, cd); } @@ -272,9 +272,9 @@ public class ClassTree { * * @param cd interface whose implementing-classes list is required. */ - public List implementingclasses(ClassDoc cd) { - List result = get(implementingclasses, cd); - List subinterfaces = allSubs(cd, false); + public List implementingclasses(ClassDoc cd) { + List result = get(implementingclasses, cd); + List subinterfaces = allSubs(cd, false); //If class x implements a subinterface of cd, then it follows //that class x implements cd. @@ -301,7 +301,7 @@ public class ClassTree { * @param isEnum true if the subclasses should be forced to come from the * enum tree. */ - public List subs(ClassDoc cd, boolean isEnum) { + public List subs(ClassDoc cd, boolean isEnum) { if (isEnum) { return get(subEnums, cd); } else if (cd.isAnnotationType()) { @@ -324,10 +324,10 @@ public class ClassTree { * @param isEnum true if the subclasses should be forced to come from the * enum tree. */ - public List allSubs(ClassDoc cd, boolean isEnum) { - List list = subs(cd, isEnum); + public List allSubs(ClassDoc cd, boolean isEnum) { + List list = subs(cd, isEnum); for (int i = 0; i < list.size(); i++) { - cd = (ClassDoc)list.get(i); + cd = list.get(i); List tlist = subs(cd, isEnum); for (int j = 0; j < tlist.size(); j++) { ClassDoc tcd = (ClassDoc)tlist.get(j); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java index 7edc0ee22b8..b9af61778eb 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java @@ -46,138 +46,138 @@ public class ClassUseMapper { * Mapping of ClassDocs to set of PackageDoc used by that class. * Entries may be null. */ - public Map classToPackage = new HashMap(); + public Map> classToPackage = new HashMap>(); /** * Mapping of Annotations to set of PackageDoc that use the annotation. */ - public Map classToPackageAnnotations = new HashMap(); + public Map> classToPackageAnnotations = new HashMap>(); /** * Mapping of ClassDocs to set of ClassDoc used by that class. * Entries may be null. */ - public Map classToClass = new HashMap(); + public Map> classToClass = new HashMap>(); /** * Mapping of ClassDocs to list of ClassDoc which are direct or * indirect subclasses of that class. * Entries may be null. */ - public Map classToSubclass = new HashMap(); + public Map> classToSubclass = new HashMap>(); /** * Mapping of ClassDocs to list of ClassDoc which are direct or * indirect subinterfaces of that interface. * Entries may be null. */ - public Map classToSubinterface = new HashMap(); + public Map> classToSubinterface = new HashMap>(); /** * Mapping of ClassDocs to list of ClassDoc which implement * this interface. * Entries may be null. */ - public Map classToImplementingClass = new HashMap(); + public Map> classToImplementingClass = new HashMap>(); /** * Mapping of ClassDocs to list of FieldDoc declared as that class. * Entries may be null. */ - public Map classToField = new HashMap(); + public Map> classToField = new HashMap>(); /** * Mapping of ClassDocs to list of MethodDoc returning that class. * Entries may be null. */ - public Map classToMethodReturn = new HashMap(); + public Map> classToMethodReturn = new HashMap>(); /** * Mapping of ClassDocs to list of MethodDoc having that class * as an arg. * Entries may be null. */ - public Map classToMethodArgs = new HashMap(); + public Map> classToMethodArgs = new HashMap>(); /** * Mapping of ClassDocs to list of MethodDoc which throws that class. * Entries may be null. */ - public Map classToMethodThrows = new HashMap(); + public Map> classToMethodThrows = new HashMap>(); /** * Mapping of ClassDocs to list of ConstructorDoc having that class * as an arg. * Entries may be null. */ - public Map classToConstructorArgs = new HashMap(); + public Map> classToConstructorArgs = new HashMap>(); /** * Mapping of ClassDocs to list of ConstructorDoc which throws that class. * Entries may be null. */ - public Map classToConstructorThrows = new HashMap(); + public Map> classToConstructorThrows = new HashMap>(); /** * The mapping of AnnotationTypeDocs to constructors that use them. */ - public Map classToConstructorAnnotations = new HashMap(); + public Map> classToConstructorAnnotations = new HashMap>(); /** * The mapping of AnnotationTypeDocs to Constructor parameters that use them. */ - public Map classToConstructorParamAnnotation = new HashMap(); + public Map> classToConstructorParamAnnotation = new HashMap>(); /** * The mapping of ClassDocs to Constructor arguments that use them as type parameters. */ - public Map classToConstructorDocArgTypeParam = new HashMap(); + public Map> classToConstructorDocArgTypeParam = new HashMap>(); /** * The mapping of ClassDocs to ClassDocs that use them as type parameters. */ - public Map classToClassTypeParam = new HashMap(); + public Map> classToClassTypeParam = new HashMap>(); /** * The mapping of AnnotationTypeDocs to ClassDocs that use them. */ - public Map classToClassAnnotations = new HashMap(); + public Map> classToClassAnnotations = new HashMap>(); /** * The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters. */ - public Map classToExecMemberDocTypeParam = new HashMap(); + public Map> classToExecMemberDocTypeParam = new HashMap>(); /** * The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters. */ - public Map classToExecMemberDocArgTypeParam = new HashMap(); + public Map> classToExecMemberDocArgTypeParam = new HashMap>(); /** * The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them. */ - public Map classToExecMemberDocAnnotations = new HashMap(); + public Map> classToExecMemberDocAnnotations = new HashMap>(); /** * The mapping of ClassDocs to ExecutableMemberDocs that have return type * with type parameters of that class. */ - public Map classToExecMemberDocReturnTypeParam = new HashMap(); + public Map> classToExecMemberDocReturnTypeParam = new HashMap>(); /** * The mapping of AnnotationTypeDocs to MethodDoc parameters that use them. */ - public Map classToExecMemberDocParamAnnotation = new HashMap(); + public Map> classToExecMemberDocParamAnnotation = new HashMap>(); /** * The mapping of ClassDocs to FieldDocs that use them as type parameters. */ - public Map classToFieldDocTypeParam = new HashMap(); + public Map> classToFieldDocTypeParam = new HashMap>(); /** * The mapping of AnnotationTypeDocs to FieldDocs that use them. */ - public Map annotationToFieldDoc = new HashMap(); + public Map> annotationToFieldDoc = new HashMap>(); public ClassUseMapper(RootDoc root, ClassTree classtree) { @@ -231,15 +231,15 @@ public class ClassUseMapper { /** * Return all subclasses of a class AND fill-in classToSubclass map. */ - private Collection subclasses(ClassDoc cd) { - Collection ret = (Collection)classToSubclass.get(cd.qualifiedName()); + private Collection subclasses(ClassDoc cd) { + Collection ret = classToSubclass.get(cd.qualifiedName()); if (ret == null) { - ret = new TreeSet(); - List subs = classtree.subclasses(cd); + ret = new TreeSet(); + List subs = classtree.subclasses(cd); if (subs != null) { ret.addAll(subs); - for (Iterator it = subs.iterator(); it.hasNext();) { - ret.addAll(subclasses((ClassDoc)it.next())); + for (Iterator it = subs.iterator(); it.hasNext();) { + ret.addAll(subclasses(it.next())); } } addAll(classToSubclass, cd, ret); @@ -250,15 +250,15 @@ public class ClassUseMapper { /** * Return all subinterfaces of an interface AND fill-in classToSubinterface map. */ - private Collection subinterfaces(ClassDoc cd) { - Collection ret = (Collection)classToSubinterface.get(cd.qualifiedName()); + private Collection subinterfaces(ClassDoc cd) { + Collection ret = classToSubinterface.get(cd.qualifiedName()); if (ret == null) { - ret = new TreeSet(); - List subs = classtree.subinterfaces(cd); + ret = new TreeSet(); + List subs = classtree.subinterfaces(cd); if (subs != null) { ret.addAll(subs); - for (Iterator it = subs.iterator(); it.hasNext();) { - ret.addAll(subinterfaces((ClassDoc)it.next())); + for (Iterator it = subs.iterator(); it.hasNext();) { + ret.addAll(subinterfaces(it.next())); } } addAll(classToSubinterface, cd, ret); @@ -272,11 +272,11 @@ public class ClassUseMapper { * implementing subinterfaces) AND fill-in both classToImplementingClass * and classToSubinterface maps. */ - private Collection implementingClasses(ClassDoc cd) { - Collection ret = (List)classToImplementingClass.get(cd.qualifiedName()); + private Collection implementingClasses(ClassDoc cd) { + Collection ret = classToImplementingClass.get(cd.qualifiedName()); if (ret == null) { - ret = new TreeSet(); - List impl = classtree.implementingclasses(cd); + ret = new TreeSet(); + List impl = classtree.implementingclasses(cd); if (impl != null) { ret.addAll(impl); for (Iterator it = impl.iterator(); it.hasNext();) { @@ -298,7 +298,7 @@ public class ClassUseMapper { private void mapExecutable(ExecutableMemberDoc em) { Parameter[] params = em.parameters(); boolean isConstructor = em.isConstructor(); - List classArgs = new ArrayList(); + List classArgs = new ArrayList(); for (int k = 0; k < params.length; k++) { Type pcd = params[k].type(); // primitives don't get mapped, also avoid dups @@ -325,34 +325,38 @@ public class ClassUseMapper { } } - private List refList(Map map, ClassDoc cd) { - List list = (List)map.get(cd.qualifiedName()); + private List refList(Map> map, ClassDoc cd) { + List list = map.get(cd.qualifiedName()); if (list == null) { - list = new ArrayList(); + @SuppressWarnings("unchecked") + List l = new ArrayList(); + list = l; map.put(cd.qualifiedName(), list); } return list; } - private Set packageSet(ClassDoc cd) { - Set pkgSet = (Set)classToPackage.get(cd.qualifiedName()); + private Set packageSet(ClassDoc cd) { + Set pkgSet = classToPackage.get(cd.qualifiedName()); if (pkgSet == null) { - pkgSet = new TreeSet(); + pkgSet = new TreeSet(); classToPackage.put(cd.qualifiedName(), pkgSet); } return pkgSet; } - private Set classSet(ClassDoc cd) { - Set clsSet = (Set)classToClass.get(cd.qualifiedName()); + private Set classSet(ClassDoc cd) { + Set clsSet = classToClass.get(cd.qualifiedName()); if (clsSet == null) { - clsSet = new TreeSet(); + @SuppressWarnings("unchecked") + Set s = new TreeSet(); + clsSet = s; classToClass.put(cd.qualifiedName(), clsSet); } return clsSet; } - private void add(Map map, ClassDoc cd, ProgramElementDoc ref) { + private void add(Map> map, ClassDoc cd, T ref) { // add to specified map refList(map, cd).add(ref); @@ -361,25 +365,23 @@ public class ClassUseMapper { classSet(cd).add(ref instanceof MemberDoc? ((MemberDoc)ref).containingClass() : - ref); + (ClassDoc)ref); } - private void addAll(Map map, ClassDoc cd, Collection refs) { + private void addAll(Map> map, ClassDoc cd, Collection refs) { if (refs == null) { return; } // add to specified map refList(map, cd).addAll(refs); - Set pkgSet = packageSet(cd); - Set clsSet = classSet(cd); + Set pkgSet = packageSet(cd); + Set clsSet = classSet(cd); // add ref's package to package map and class map - for (Iterator it = refs.iterator(); it.hasNext();) { - ProgramElementDoc pedoc = (ProgramElementDoc)it.next(); - pkgSet.add(pedoc.containingPackage()); - clsSet.add(pedoc instanceof MemberDoc? - ((MemberDoc)pedoc).containingClass() : - pedoc); + for (Iterator it = refs.iterator(); it.hasNext();) { + ClassDoc cls = it.next(); + pkgSet.add(cls.containingPackage()); + clsSet.add(cls); } } @@ -392,8 +394,8 @@ public class ClassUseMapper { * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ - private void mapTypeParameters(Map map, Object doc, - ProgramElementDoc holder) { + private void mapTypeParameters(Map> map, Object doc, + T holder) { TypeVariable[] typeVariables; if (doc instanceof ClassDoc) { typeVariables = ((ClassDoc) doc).typeParameters(); @@ -438,9 +440,8 @@ public class ClassUseMapper { * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ - private void mapAnnotations(Map map, Object doc, - Object holder) { - TypeVariable[] typeVariables; + private void mapAnnotations(Map> map, Object doc, + T holder) { AnnotationDesc[] annotations; boolean isPackage = false; if (doc instanceof ProgramElementDoc) { @@ -458,12 +459,31 @@ public class ClassUseMapper { if (isPackage) refList(map, annotationDoc).add(holder); else - add(map, annotationDoc, (ProgramElementDoc) holder); + add(map, annotationDoc, holder); } } - private void addTypeParameterToMap(Map map, Type type, - ProgramElementDoc holder) { + + /** + * Map the AnnotationType to the ProgramElementDocs that use them as + * type parameters. + * + * @param map the map the insert the information into. + * @param doc the doc whose type parameters are being checked. + * @param holder the holder that owns the type parameters. + */ + private void mapAnnotations(Map> map, PackageDoc doc, + T holder) { + AnnotationDesc[] annotations; + annotations = doc.annotations(); + for (int i = 0; i < annotations.length; i++) { + AnnotationTypeDoc annotationDoc = annotations[i].annotationType(); + refList(map, annotationDoc).add(holder); + } + } + + private void addTypeParameterToMap(Map> map, Type type, + T holder) { if (type instanceof ClassDoc) { add(map, (ClassDoc) type, holder); } else if (type instanceof ParameterizedType) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java index b1a39fb4f36..271cde9d8ca 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java @@ -52,7 +52,7 @@ public class DeprecatedAPIListBuilder { /** * List of deprecated type Lists. */ - private List deprecatedLists; + private List> deprecatedLists; /** @@ -61,9 +61,9 @@ public class DeprecatedAPIListBuilder { * @param root Root of the tree. */ public DeprecatedAPIListBuilder(RootDoc root) { - deprecatedLists = new ArrayList(); + deprecatedLists = new ArrayList>(); for (int i = 0; i < NUM_TYPES; i++) { - deprecatedLists.add(i, new ArrayList()); + deprecatedLists.add(i, new ArrayList()); } buildDeprecatedAPIInfo(root); } @@ -114,7 +114,7 @@ public class DeprecatedAPIListBuilder { * @param list List of all the particular deprecated members, e.g. methods. * @param members members to be added in the list. */ - private void composeDeprecatedList(List list, MemberDoc[] members) { + private void composeDeprecatedList(List list, MemberDoc[] members) { for (int i = 0; i < members.length; i++) { if (Util.isDeprecated(members[i])) { list.add(members[i]); @@ -137,8 +137,8 @@ public class DeprecatedAPIListBuilder { * * @param the constant representing the type of list being returned. */ - public List getList(int type) { - return (List) deprecatedLists.get(type); + public List getList(int type) { + return deprecatedLists.get(type); } /** @@ -147,6 +147,6 @@ public class DeprecatedAPIListBuilder { * @param type the type of list being checked. */ public boolean hasDocumentation(int type) { - return ((List) deprecatedLists.get(type)).size() > 0; + return (deprecatedLists.get(type)).size() > 0; } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java index 38cfb310e33..7b0b11c4444 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java @@ -164,7 +164,7 @@ public class DocFinder { * subclass of IOException. This subclass of DocFinder.Output allows * multiple tag inheritence. */ - public List tagList = new ArrayList(); + public List tagList = new ArrayList(); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java index 9ea25ae7322..6608183435b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java @@ -53,7 +53,7 @@ public class Extern { * Map package names onto Extern Item objects. * Lazily initialized. */ - private Map packageToItemMap; + private Map packageToItemMap; /** * The global configuration information for this run. @@ -101,7 +101,7 @@ public class Extern { this.path = path; this.relative = relative; if (packageToItemMap == null) { - packageToItemMap = new HashMap(); + packageToItemMap = new HashMap(); } if (!packageToItemMap.containsKey(packageName)) { // save the previous packageToItemMap.put(packageName, this); // mapped location @@ -185,7 +185,7 @@ public class Extern { if (packageToItemMap == null) { return null; } - return (Item)packageToItemMap.get(pkgName); + return packageToItemMap.get(pkgName); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java index b0380d93205..4fc3af1e9de 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java @@ -61,24 +61,24 @@ public class Group { /** * Map of regular expressions with the corresponding group name. */ - private Map regExpGroupMap = new HashMap(); + private Map regExpGroupMap = new HashMap(); /** * List of regular expressions sorted according to the length. Regular * expression with longest length will be first in the sorted order. */ - private List sortedRegExpList = new ArrayList(); + private List sortedRegExpList = new ArrayList(); /** * List of group names in the same order as given on the command line. */ - private List groupList = new ArrayList(); + private List groupList = new ArrayList(); /** * Map of non-regular expressions(possible package names) with the * corresponding group name. */ - private Map pkgNameGroupMap = new HashMap(); + private Map pkgNameGroupMap = new HashMap(); /** * The global configuration information for this run. @@ -90,9 +90,9 @@ public class Group { * the compare method in the implementing class is doing the reverse * comparison. */ - private static class MapKeyComparator implements Comparator { - public int compare(Object key1, Object key2) { - return ((String)key2).length() - ((String)key1).length(); + private static class MapKeyComparator implements Comparator { + public int compare(String key1, String key2) { + return key2.length() - key1.length(); } } @@ -182,8 +182,8 @@ public class Group { * * @param packages Packages specified on the command line. */ - public Map groupPackages(PackageDoc[] packages) { - Map groupPackageMap = new HashMap(); + public Map> groupPackages(PackageDoc[] packages) { + Map> groupPackageMap = new HashMap>(); String defaultGroupName = (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())? configuration.message.getText("doclet.Packages") : @@ -195,7 +195,7 @@ public class Group { for (int i = 0; i < packages.length; i++) { PackageDoc pkg = packages[i]; String pkgName = pkg.name(); - String groupName = (String)pkgNameGroupMap.get(pkgName); + String groupName = pkgNameGroupMap.get(pkgName); // if this package is not explicitly assigned to a group, // try matching it to group specified by regular expression if (groupName == null) { @@ -220,9 +220,9 @@ public class Group { */ String regExpGroupName(String pkgName) { for (int j = 0; j < sortedRegExpList.size(); j++) { - String regexp = (String)sortedRegExpList.get(j); + String regexp = sortedRegExpList.get(j); if (pkgName.startsWith(regexp)) { - return (String)regExpGroupMap.get(regexp); + return regExpGroupMap.get(regexp); } } return null; @@ -235,10 +235,10 @@ public class Group { * @param map Map to be searched for gorup name. * @param groupname Group name to search. */ - List getPkgList(Map map, String groupname) { - List list = (List)map.get(groupname); + List getPkgList(Map> map, String groupname) { + List list = map.get(groupname); if (list == null) { - list = new ArrayList(); + list = new ArrayList(); map.put(groupname, list); } return list; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java index b12ccea55b8..8fad64d3fd6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java @@ -41,8 +41,8 @@ import java.util.*; */ public class ImplementedMethods { - private Map interfaces = new HashMap(); - private List methlist = new ArrayList(); + private Map interfaces = new HashMap(); + private List methlist = new ArrayList(); private Configuration configuration; private final ClassDoc classdoc; private final MethodDoc method; @@ -67,7 +67,7 @@ public class ImplementedMethods { */ public MethodDoc[] build(boolean sort) { buildImplementedMethodList(sort); - return (MethodDoc[])methlist.toArray(new MethodDoc[methlist.size()]); + return methlist.toArray(new MethodDoc[methlist.size()]); } public MethodDoc[] build() { @@ -75,7 +75,7 @@ public class ImplementedMethods { } public Type getMethodHolder(MethodDoc methodDoc) { - return (Type) interfaces.get(methodDoc); + return interfaces.get(methodDoc); } /** @@ -111,7 +111,7 @@ public class ImplementedMethods { ClassDoc overriddenClass = method.overriddenClass(); if (overriddenClass != null) { for (int i = 0; i < methlist.size(); i++) { - ClassDoc cd = ((MethodDoc)methlist.get(i)).containingClass(); + ClassDoc cd = methlist.get(i).containingClass(); if (cd == overriddenClass || overriddenClass.subclassOf(cd)) { methlist.remove(i); // remove overridden method return; @@ -131,7 +131,7 @@ public class ImplementedMethods { private boolean overridingMethodFound(MethodDoc method) { ClassDoc containingClass = method.containingClass(); for (int i = 0; i < methlist.size(); i++) { - MethodDoc listmethod = (MethodDoc)methlist.get(i); + MethodDoc listmethod = methlist.get(i); if (containingClass == listmethod.containingClass()) { // it's the same method. return true; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java index af3de778b6d..ef8c41dfea0 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java @@ -49,7 +49,7 @@ public class IndexBuilder { * Mapping of each Unicode Character with the member list containing * members with names starting with it. */ - private Map indexmap = new HashMap(); + private Map> indexmap = new HashMap>(); /** * Don't generate deprecated information if true. @@ -68,10 +68,10 @@ public class IndexBuilder { * A comparator used to sort classes and members. * Note: Maybe this compare code belongs in the tool? */ - private class DocComparator implements Comparator { - public int compare(Object d1, Object d2) { - String doc1 = (((Doc) d1).name()); - String doc2 = (((Doc) d2).name()); + private class DocComparator implements Comparator { + public int compare(Doc d1, Doc d2) { + String doc1 = d1.name(); + String doc2 = d2.name(); int compareResult; if ((compareResult = doc1.compareToIgnoreCase(doc2)) != 0) { return compareResult; @@ -124,8 +124,8 @@ public class IndexBuilder { * sort each element which is a list. */ protected void sortIndexMap() { - for (Iterator it = indexmap.values().iterator(); it.hasNext(); ) { - Collections.sort((List)it.next(), new DocComparator()); + for (Iterator> it = indexmap.values().iterator(); it.hasNext(); ) { + Collections.sort(it.next(), new DocComparator()); } } @@ -141,7 +141,7 @@ public class IndexBuilder { ClassDoc[] classes = root.classes(); if (!classesOnly) { if (packages.length == 0) { - Set set = new HashSet(); + Set set = new HashSet(); PackageDoc pd; for (int i = 0; i < classes.length; i++) { pd = classes[i].containingPackage(); @@ -149,7 +149,7 @@ public class IndexBuilder { set.add(pd); } } - adjustIndexMap((PackageDoc[]) set.toArray(packages)); + adjustIndexMap(set.toArray(packages)); } else { adjustIndexMap(packages); } @@ -193,9 +193,9 @@ public class IndexBuilder { '*' : Character.toUpperCase(name.charAt(0)); Character unicode = new Character(ch); - List list = (List)indexmap.get(unicode); + List list = indexmap.get(unicode); if (list == null) { - list = new ArrayList(); + list = new ArrayList(); indexmap.put(unicode, list); } list.add(elements[i]); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java index 203ed21f93c..d60da7d1688 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java @@ -82,7 +82,7 @@ public class MetaKeywords { * definitions are on separate pages. */ public String[] getMetaKeywords(ClassDoc classdoc) { - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList(); // Add field and method keywords only if -keywords option is used if( configuration.keywords ) { @@ -90,16 +90,16 @@ public class MetaKeywords { results.addAll(getMemberKeywords(classdoc.fields())); results.addAll(getMemberKeywords(classdoc.methods())); } - return (String[]) results.toArray(new String[]{}); + return results.toArray(new String[]{}); } /** * Get the current class for a meta tag keyword, as the first * and only element of an array list. */ - protected ArrayList getClassKeyword(ClassDoc classdoc) { + protected ArrayList getClassKeyword(ClassDoc classdoc) { String cltypelower = classdoc.isInterface() ? "interface" : "class"; - ArrayList metakeywords = new ArrayList(1); + ArrayList metakeywords = new ArrayList(1); metakeywords.add(classdoc.qualifiedName() + " " + cltypelower); return metakeywords; } @@ -141,8 +141,8 @@ public class MetaKeywords { * * @param memberdocs array of MemberDoc objects to be added to keywords */ - protected ArrayList getMemberKeywords(MemberDoc[] memberdocs) { - ArrayList results = new ArrayList(); + protected ArrayList getMemberKeywords(MemberDoc[] memberdocs) { + ArrayList results = new ArrayList(); String membername; for (int i=0; i < memberdocs.length; i++) { membername = memberdocs[i].name() diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java index 22f975da10b..6094dbdc096 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java @@ -260,12 +260,12 @@ public class SourceToHTMLConverter { * @param docs the array of Docs to add anchors for. * @param hash the HashMap to add to. */ - protected static void addToHash(Doc[] docs, HashMap hash) { + protected static void addToHash(Doc[] docs, HashMap hash) { if(docs == null) { return; } for(int i = 0; i < docs.length; i++) { - hash.put(new Integer(docs[i].position().line()), getAnchor(docs[i])); + hash.put(docs[i].position().line(), getAnchor(docs[i])); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index 5cf20e2a9be..0111db73041 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -73,9 +73,9 @@ public class Util { * @return List List of eligible members for whom * documentation is getting generated. */ - public static List excludeDeprecatedMembersAsList( + public static List excludeDeprecatedMembersAsList( ProgramElementDoc[] members) { - List list = new ArrayList(); + List list = new ArrayList(); for (int i = 0; i < members.length; i++) { if (members[i].tags("deprecated").length == 0) { list.add(members[i]); @@ -372,10 +372,10 @@ public class Util { * We want the list of types in alphabetical order. However, types are not * comparable. We need a comparator for now. */ - private static class TypeComparator implements Comparator { - public int compare(Object type1, Object type2) { - return ((Type) type1).qualifiedTypeName().toLowerCase().compareTo( - ((Type) type2).qualifiedTypeName().toLowerCase()); + private static class TypeComparator implements Comparator { + public int compare(Type type1, Type type2) { + return type1.qualifiedTypeName().toLowerCase().compareTo( + type2.qualifiedTypeName().toLowerCase()); } } @@ -391,9 +391,9 @@ public class Util { * @param sort if true, return list of interfaces sorted alphabetically. * @return List of all the required interfaces. */ - public static List getAllInterfaces(Type type, + public static List getAllInterfaces(Type type, Configuration configuration, boolean sort) { - Map results = sort ? new TreeMap() : new LinkedHashMap(); + Map results = sort ? new TreeMap() : new LinkedHashMap(); Type[] interfaceTypes = null; Type superType = null; if (type instanceof ParameterizedType) { @@ -423,7 +423,7 @@ public class Util { } } if (superType == null) - return new ArrayList(results.values()); + return new ArrayList(results.values()); //Try walking the tree. addAllInterfaceTypes(results, superType, @@ -431,7 +431,7 @@ public class Util { ((ClassDoc) superType).interfaceTypes() : ((ParameterizedType) superType).interfaceTypes(), false, configuration); - List resultsList = new ArrayList(results.values()); + List resultsList = new ArrayList(results.values()); if (sort) { Collections.sort(resultsList, new TypeComparator()); } @@ -442,7 +442,7 @@ public class Util { return getAllInterfaces(type, configuration, true); } - private static void findAllInterfaceTypes(Map results, ClassDoc c, boolean raw, + private static void findAllInterfaceTypes(Map results, ClassDoc c, boolean raw, Configuration configuration) { Type superType = c.superclassType(); if (superType == null) @@ -454,7 +454,7 @@ public class Util { raw, configuration); } - private static void findAllInterfaceTypes(Map results, ParameterizedType p, + private static void findAllInterfaceTypes(Map results, ParameterizedType p, Configuration configuration) { Type superType = p.superclassType(); if (superType == null) @@ -466,7 +466,7 @@ public class Util { false, configuration); } - private static void addAllInterfaceTypes(Map results, Type type, + private static void addAllInterfaceTypes(Map results, Type type, Type[] interfaceTypes, boolean raw, Configuration configuration) { for (int i = 0; i < interfaceTypes.length; i++) { @@ -495,8 +495,8 @@ public class Util { } - public static List asList(ProgramElementDoc[] members) { - List list = new ArrayList(); + public static List asList(ProgramElementDoc[] members) { + List list = new ArrayList(); for (int i = 0; i < members.length; i++) { list.add(members[i]); } @@ -639,7 +639,7 @@ public class Util { * @return an array of tokens. */ public static String[] tokenize(String s, char separator, int maxTokens) { - List tokens = new ArrayList(); + List tokens = new ArrayList(); StringBuilder token = new StringBuilder (); boolean prevIsEscapeChar = false; for (int i = 0; i < s.length(); i += Character.charCount(i)) { @@ -663,7 +663,7 @@ public class Util { if (token.length() > 0) { tokens.add(token.toString()); } - return (String[]) tokens.toArray(new String[] {}); + return tokens.toArray(new String[] {}); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java index 34b9117227f..480a2ce5b54 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java @@ -65,19 +65,19 @@ public class VisibleMemberMap { /** * List of ClassDoc objects for which ClassMembers objects are built. */ - private final List visibleClasses = new ArrayList(); + private final List visibleClasses = new ArrayList(); /** * Map for each member name on to a map which contains members with same * name-signature. The mapped map will contain mapping for each MemberDoc * onto it's respecive level string. */ - private final Map memberNameMap = new HashMap(); + private final Map> memberNameMap = new HashMap>(); /** * Map of class and it's ClassMembers object. */ - private final Map classMap = new HashMap(); + private final Map classMap = new HashMap(); /** * Type whose visible members are requested. This is the leaf of @@ -128,8 +128,8 @@ public class VisibleMemberMap { * @param configuation the current configuration of the doclet. * @return the package private members inherited by the class. */ - private List getInheritedPackagePrivateMethods(Configuration configuration) { - List results = new ArrayList(); + private List getInheritedPackagePrivateMethods(Configuration configuration) { + List results = new ArrayList(); for (Iterator iter = visibleClasses.iterator(); iter.hasNext(); ) { ClassDoc currentClass = (ClassDoc) iter.next(); if (currentClass != classdoc && @@ -150,8 +150,8 @@ public class VisibleMemberMap { * * @param configuation the current configuration of the doclet. */ - public List getLeafClassMembers(Configuration configuration) { - List result = getMembersFor(classdoc); + public List getLeafClassMembers(Configuration configuration) { + List result = getMembersFor(classdoc); result.addAll(getInheritedPackagePrivateMethods(configuration)); return result; } @@ -163,10 +163,10 @@ public class VisibleMemberMap { * * @return the list of members for the given class. */ - public List getMembersFor(ClassDoc cd) { - ClassMembers clmembers = (ClassMembers)(classMap.get(cd)); + public List getMembersFor(ClassDoc cd) { + ClassMembers clmembers = classMap.get(cd); if (clmembers == null) { - return new ArrayList(); + return new ArrayList(); } return clmembers.getMembers(); } @@ -175,11 +175,11 @@ public class VisibleMemberMap { * Sort the given mixed list of classes and interfaces to a list of * classes followed by interfaces traversed. Don't sort alphabetically. */ - private void sort(List list) { - List classes = new ArrayList(); - List interfaces = new ArrayList(); + private void sort(List list) { + List classes = new ArrayList(); + List interfaces = new ArrayList(); for (int i = 0; i < list.size(); i++) { - ClassDoc cd = (ClassDoc)list.get(i); + ClassDoc cd = list.get(i); if (cd.isClass()) { classes.add(cd); } else { @@ -191,12 +191,12 @@ public class VisibleMemberMap { list.addAll(interfaces); } - private void fillMemberLevelMap(List list, String level) { + private void fillMemberLevelMap(List list, String level) { for (int i = 0; i < list.size(); i++) { - Object key = getMemberKey((ProgramElementDoc)list.get(i)); - Map memberLevelMap = (Map) memberNameMap.get(key); + Object key = getMemberKey(list.get(i)); + Map memberLevelMap = memberNameMap.get(key); if (memberLevelMap == null) { - memberLevelMap = new HashMap(); + memberLevelMap = new HashMap(); memberNameMap.put(key, memberLevelMap); } memberLevelMap.put(list.get(i), level); @@ -218,10 +218,10 @@ public class VisibleMemberMap { * type variables in consideration when comparing. */ private class ClassMember { - private Set members; + private Set members; public ClassMember(ProgramElementDoc programElementDoc) { - members = new HashSet(); + members = new HashSet(); members.add(programElementDoc); } @@ -256,7 +256,7 @@ public class VisibleMemberMap { /** * List of inherited members from the mapping class. */ - private List members = new ArrayList(); + private List members = new ArrayList(); /** * Level/Depth of inheritance. @@ -268,7 +268,7 @@ public class VisibleMemberMap { * * @return List Inherited members. */ - public List getMembers() { + public List getMembers() { return members; } @@ -276,11 +276,11 @@ public class VisibleMemberMap { this.mappingClass = mappingClass; this.level = level; if (classMap.containsKey(mappingClass) && - level.startsWith(((ClassMembers) classMap.get(mappingClass)).level)) { + level.startsWith(classMap.get(mappingClass).level)) { //Remove lower level class so that it can be replaced with //same class found at higher level. purgeMemberLevelMap(getClassMembers(mappingClass, false), - ((ClassMembers) classMap.get(mappingClass)).level); + classMap.get(mappingClass).level); classMap.remove(mappingClass); visibleClasses.remove(mappingClass); } @@ -326,11 +326,10 @@ public class VisibleMemberMap { * Adjust member-level-map, class-map. */ private void addMembers(ClassDoc fromClass) { - List cdmembers = getClassMembers(fromClass, true); - List incllist = new ArrayList(); + List cdmembers = getClassMembers(fromClass, true); + List incllist = new ArrayList(); for (int i = 0; i < cdmembers.size(); i++) { - ProgramElementDoc pgmelem = - (ProgramElementDoc)(cdmembers.get(i)); + ProgramElementDoc pgmelem = cdmembers.get(i); if (!found(members, pgmelem) && memberIsVisible(pgmelem) && !isOverridden(pgmelem, level)) { @@ -373,7 +372,7 @@ public class VisibleMemberMap { /** * Return all available class members. */ - private List getClassMembers(ClassDoc cd, boolean filter) { + private List getClassMembers(ClassDoc cd, boolean filter) { if (cd.isEnum() && kind == CONSTRUCTORS) { //If any of these rules are hit, return empty array because //we don't document these members ever. @@ -428,16 +427,15 @@ public class VisibleMemberMap { */ private AnnotationTypeElementDoc[] filter(AnnotationTypeDoc doc, boolean required) { - AnnotationTypeElementDoc[] members = ((AnnotationTypeDoc) doc).elements(); - List targetMembers = new ArrayList(); + AnnotationTypeElementDoc[] members = doc.elements(); + List targetMembers = new ArrayList(); for (int i = 0; i < members.length; i++) { if ((required && members[i].defaultValue() == null) || ((!required) && members[i].defaultValue() != null)){ targetMembers.add(members[i]); } } - return (AnnotationTypeElementDoc[]) - targetMembers.toArray(new AnnotationTypeElementDoc[]{}); + return targetMembers.toArray(new AnnotationTypeElementDoc[]{}); } private boolean found(List list, ProgramElementDoc elem) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java index 088faa05d05..dd0b78f4c77 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java @@ -84,7 +84,7 @@ public abstract class LinkFactory { owner instanceof ClassDoc) { linkInfo.classDoc = (ClassDoc) owner; linkInfo.label = type.typeName(); - linkOutput.append(getClassLink((LinkInfo) linkInfo)); + linkOutput.append(getClassLink(linkInfo)); } else { //No need to link method type parameters. linkInfo.displayLength += type.typeName().length(); @@ -113,7 +113,7 @@ public abstract class LinkFactory { return linkOutput; } else { linkInfo.classDoc = type.asClassDoc(); - linkOutput = getClassLink((LinkInfo) linkInfo); + linkOutput = getClassLink(linkInfo); if (linkInfo.includeTypeAsSepLink) { linkOutput.append(getTypeParameterLinks(linkInfo, false)); } @@ -136,7 +136,7 @@ public abstract class LinkFactory { return linkOutput; } else if (linkInfo.classDoc != null) { //Just a class link - LinkOutput linkOutput = getClassLink((LinkInfo) linkInfo); + LinkOutput linkOutput = getClassLink(linkInfo); if (linkInfo.includeTypeAsSepLink) { linkOutput.append(getTypeParameterLinks(linkInfo, false)); } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java index 2a0c1ba9020..4379c9e5eab 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java @@ -47,7 +47,7 @@ import java.util.StringTokenizer; */ public class DocletInvoker { - private final Class docletClass; + private final Class docletClass; private final String docletClassName; diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java index 1e8e2e36a8c..5a1a2b8e027 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java @@ -231,7 +231,7 @@ public abstract class ExecutableMemberDocImpl StringBuffer result = new StringBuffer(); result.append("("); for (List types = sym.type.getParameterTypes(); types.nonEmpty(); ) { - Type t = (Type)types.head; + Type t = types.head; result.append(TypeMaker.getTypeString(env, t, full)); types = types.tail; if (types.nonEmpty()) { diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java index 5ca9cf84c7a..0137a2bf46b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java @@ -86,7 +86,7 @@ public class JavadocEnter extends Enter { if (tree.sym != null && tree.sym.kind == Kinds.TYP) { if (tree.sym == null) return; String comment = env.toplevel.docComments.get(tree); - ClassSymbol c = (ClassSymbol)tree.sym; + ClassSymbol c = tree.sym; docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java index 4b6d4d2a5d5..ce815b44284 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java @@ -63,7 +63,7 @@ class JavadocMemberEnter extends MemberEnter { public void visitMethodDef(JCMethodDecl tree) { super.visitMethodDef(tree); - MethodSymbol meth = (MethodSymbol)tree.sym; + MethodSymbol meth = tree.sym; if (meth == null || meth.kind != Kinds.MTH) return; String docComment = env.toplevel.docComments.get(tree); Position.LineMap lineMap = env.toplevel.lineMap; @@ -82,7 +82,7 @@ class JavadocMemberEnter extends MemberEnter { !isParameter(tree.sym)) { String docComment = env.toplevel.docComments.get(tree); Position.LineMap lineMap = env.toplevel.lineMap; - docenv.makeFieldDoc((VarSymbol)tree.sym, docComment, tree, lineMap); + docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java index b25f96159bc..b8feb4cc468 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java @@ -450,7 +450,7 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters { if (typeId.length() > 0) { paramList.append(typeId.toString()); } - return (String[])paramList.toArray(new String[paramList.length()]); + return paramList.toArray(new String[paramList.length()]); } void addTypeToParamList() { diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java b/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java index 044d075090d..8908fead75e 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java @@ -267,7 +267,7 @@ class SerializedForm { * @return an array of MethodDocImpl for serialization methods in this class. */ MethodDoc[] methods() { - return (MethodDoc[])methods.toArray(new MethodDoc[methods.length()]); + return methods.toArray(new MethodDoc[methods.length()]); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javah/Gen.java b/langtools/src/share/classes/com/sun/tools/javah/Gen.java index a2f03aed75e..ef7c131984a 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javah/Gen.java @@ -324,7 +324,7 @@ public abstract class Gen { FieldDoc[] getAllFields(ClassDoc subclazz) throws ClassNotFoundException { - Vector fields = new Vector(); + Vector fields = new Vector(); ClassDoc cd = null; Stack s = new Stack(); From c65bf79ac2ec24c4906f9958d6750aa74ec0e949 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Wed, 16 Jul 2008 09:51:43 -0700 Subject: [PATCH 12/22] 6548261: Use of SE in make/common/Defs-windows.gmk Reviewed-by: darcy --- jdk/make/common/Defs-windows.gmk | 29 ++++++++++++++++++----------- jdk/make/common/Defs.gmk | 2 +- jdk/make/common/shared/Defs.gmk | 14 ++++++++------ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk index 5bb50249c9d..51982dc1a1b 100644 --- a/jdk/make/common/Defs-windows.gmk +++ b/jdk/make/common/Defs-windows.gmk @@ -404,7 +404,6 @@ ifdef JDK_UPDATE_VERSION else JDK_UPDATE_VER := 0 endif -JDK_VER = $(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER) RC_FLAGS = /l 0x409 /r @@ -414,15 +413,23 @@ else RC_FLAGS += $(MS_RC_DEBUG_OPTION) endif -ifndef COPYRIGHT_YEAR - COPYRIGHT_YEAR = 2007 -endif +# Values for the RC variables defined in RC_FLAGS +JDK_RC_BUILD_ID = $(FULL_VERSION) +JDK_RC_COMPANY = $(COMPANY_NAME) +JDK_RC_COMPONENT = $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) binary +JDK_RC_VER = \ + $(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER) +JDK_RC_COPYRIGHT = Copyright \xA9 $(COPYRIGHT_YEAR) +JDK_RC_NAME = \ + $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG) +JDK_RC_FVER = \ + $(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER) # J2SE name required here -RC_FLAGS += -d "J2SE_BUILD_ID=$(FULL_VERSION)" \ - -d "J2SE_COMPANY=$(COMPANY_NAME)" \ - -d "J2SE_COMPONENT=$(PRODUCT_NAME) Platform SE binary" \ - -d "J2SE_VER=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)" \ - -d "J2SE_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \ - -d "J2SE_NAME=$(PRODUCT_NAME) Platform SE $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG)" \ - -d "J2SE_FVER=$(JDK_VER)" +RC_FLAGS += -d "J2SE_BUILD_ID=$(JDK_RC_BUILD_ID)" \ + -d "J2SE_COMPANY=$(JDK_RC_COMPANY)" \ + -d "J2SE_COMPONENT=$(JDK_RC_COMPONENT)" \ + -d "J2SE_VER=$(JDK_RC_VER)" \ + -d "J2SE_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \ + -d "J2SE_NAME=$(JDK_RC_NAME)" \ + -d "J2SE_FVER=$(JDK_RC_FVER)" diff --git a/jdk/make/common/Defs.gmk b/jdk/make/common/Defs.gmk index 1c72ff99dfe..16eb1e2258f 100644 --- a/jdk/make/common/Defs.gmk +++ b/jdk/make/common/Defs.gmk @@ -703,7 +703,7 @@ endif ifdef ALT_COPYRIGHT_YEAR COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR) else - COPYRIGHT_YEAR = $(shell $(DATE) '+%Y') + COPYRIGHT_YEAR := $(shell $(DATE) '+%Y') endif # Install of imported file (JDK_IMPORT_PATH, or some other external location) diff --git a/jdk/make/common/shared/Defs.gmk b/jdk/make/common/shared/Defs.gmk index 8fc28e239e0..af86be8085d 100644 --- a/jdk/make/common/shared/Defs.gmk +++ b/jdk/make/common/shared/Defs.gmk @@ -188,16 +188,18 @@ ifndef MILESTONE endif # Default names -LAUNCHER_NAME = java -PRODUCT_NAME = Java(TM) -PRODUCT_SUFFIX = SE Runtime Environment -COMPANY_NAME = Sun Microsystems, Inc. - ifdef OPENJDK LAUNCHER_NAME = openjdk PRODUCT_NAME = OpenJDK PRODUCT_SUFFIX = Runtime Environment - COMPANY_NAME = + JDK_RC_PLATFORM_NAME = Platform + COMPANY_NAME = N/A +else + LAUNCHER_NAME = java + PRODUCT_NAME = Java(TM) + PRODUCT_SUFFIX = SE Runtime Environment + JDK_RC_PLATFORM_NAME = Platform SE + COMPANY_NAME = Sun Microsystems, Inc. endif RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX) From 873c5789943abbb6b5825672b0dc6179fcf8cd9c Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:31 -0700 Subject: [PATCH 13/22] Added tag jdk7-b31 for changeset d9dc137c39e1 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index cec8ccbe986..ce58a609d1b 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -5,3 +5,4 @@ cbc8ad9dd0e085a607427ea35411990982f19a36 jdk7-b25 56652b46f328937f6b9b5130f1e4cd80f48868ef jdk7-b28 31e08f70e88d77c2053f91c21b49a04296bdc59a jdk7-b29 2dab2f712e1832c92acfa63ec0337048b9422c20 jdk7-b30 +3300a35a0bd56d695b92fe0b34f03ebbfc939064 jdk7-b31 From 271059534c0da72db79409800216145450f5e3d3 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:32 -0700 Subject: [PATCH 14/22] Added tag jdk7-b31 for changeset 918ff19c1a3a --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index c2bfd6ff394..6792e20a86a 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -5,3 +5,4 @@ e84e9018bebbf3e5bafc5706e7882a15cb1c7d99 jdk7-b27 27509b7d21ed783b3f6eb7b7612781c675a30c2f jdk7-b28 8b71960f79ce0a6fb8ddfeec03f03d400a361747 jdk7-b29 c0252adbb2abbfdd6c35595429ac6fbdd98e20ac jdk7-b30 +ef6af34d75a7b44e77083f1d4ee47631fa09d3b4 jdk7-b31 From c04b76a222b995a7701e9e435dbbdc36d1fd845f Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:34 -0700 Subject: [PATCH 15/22] Added tag jdk7-b31 for changeset e1baa9c8f16f --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 1c7dc2a0349..b23c6ac9012 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -5,3 +5,4 @@ e3d2692f8442e2d951166dc9bd9a330684754438 jdk7-b27 c14dab40ed9bf45ad21150bd70c9c80cdf655415 jdk7-b28 4f91c08b3e4498213a9c5a24898f7d9c38cf86fb jdk7-b29 d1605aabd0a15ecf93787c47de63073c33fba52d jdk7-b30 +9c2ecc2ffb125f14fab3857fe7689598956348a0 jdk7-b31 From 702349555710906e18d9fcb09dc2d132d0975042 Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:38 -0700 Subject: [PATCH 16/22] Added tag jdk7-b31 for changeset 2378316adee0 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index f4f91fe3c71..c749c17a66d 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -5,3 +5,4 @@ bafed478d67c3acf7744aaad88b9404261ea6739 jdk7-b27 b996318955c0ad8e9fa0ffb56c74f626786e863f jdk7-b28 617ee8607cfd5fd81f233f3c0b690f85084687a0 jdk7-b29 2d94a238a1641d074e6032dcdceed461d6f85d6a jdk7-b30 +255d64ee287e926e8629dd80bc67690e65eeba30 jdk7-b31 From 4a6a92120161a5f6bed7baf54b2324158b660c0e Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:40 -0700 Subject: [PATCH 17/22] Added tag jdk7-b31 for changeset 3e8ca32a629a --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 8bfe2a4df5c..0224fa8b6b1 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -5,3 +5,4 @@ debd37e1a422e580edb086c95d6e89199133a39c jdk7-b26 eefcd5204500a11d6aa802dca9f961cf10ab64c2 jdk7-b28 836c55713abab186e4de0c6eabd06ff008c7b8d0 jdk7-b29 7f2466f8cc7009702e548d1a763254f546024d7e jdk7-b30 +f978623825364a2ad9c6f51d02fc9424a8b0bc86 jdk7-b31 From d7394859b3fb0ee8ace236a69517d118194e88bd Mon Sep 17 00:00:00 2001 From: Xiomara Jayasena Date: Thu, 17 Jul 2008 11:28:51 -0700 Subject: [PATCH 18/22] Added tag jdk7-b31 for changeset bcb5c0d7c1ab --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 3ef9e4ac619..2454b025be9 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -5,3 +5,4 @@ a17265993253d61becd04fe7d96d1fe8b4bd6dff jdk7-b27 4ef4bd31856949554967fbf22783babb21a62a0e jdk7-b28 dec081837b01d509dcc2b9de86a4299c1ec17e04 jdk7-b29 eaf608c64fecf70f955dc9f29f94c055b183aeec jdk7-b30 +07c916ecfc71f6bf432e4ff09bfbfb6290b5703c jdk7-b31 From 20dba03e99189bf3c1d3fcdeacfe7e41a49eaeaf Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Sat, 19 Jul 2008 17:38:22 -0400 Subject: [PATCH 19/22] 6716785: implicit null checks not triggering with CompressedOops Allocate alignment-sized page(s) below java heap so that memory accesses at heap_base+1page give signal and cause an implicit null check Reviewed-by: kvn, jmasa, phh, jcoomes --- hotspot/src/os/linux/vm/os_linux.cpp | 19 +++- hotspot/src/os/solaris/vm/os_solaris.cpp | 17 +++- hotspot/src/os/windows/vm/os_windows.cpp | 29 +++++- .../linux_sparc/vm/assembler_linux_sparc.cpp | 6 -- .../linux_x86/vm/assembler_linux_x86_32.cpp | 7 -- .../linux_x86/vm/assembler_linux_x86_64.cpp | 19 ---- .../vm/assembler_solaris_sparc.cpp | 12 --- .../vm/assembler_solaris_x86_32.cpp | 6 -- .../vm/assembler_solaris_x86_64.cpp | 19 ---- .../vm/assembler_windows_x86_32.cpp | 4 - .../vm/assembler_windows_x86_64.cpp | 16 ---- hotspot/src/share/vm/asm/assembler.cpp | 18 ++++ .../parallelScavenge/parMarkBitMap.cpp | 2 + .../parallelScavenge/parallelScavengeHeap.cpp | 4 +- .../parallelScavenge/psParallelCompact.cpp | 2 + .../parallelScavenge/psVirtualspace.cpp | 9 +- .../src/share/vm/memory/genCollectedHeap.cpp | 4 +- hotspot/src/share/vm/prims/jni.cpp | 3 +- hotspot/src/share/vm/runtime/arguments.cpp | 4 +- hotspot/src/share/vm/runtime/os.cpp | 5 +- hotspot/src/share/vm/runtime/os.hpp | 6 +- hotspot/src/share/vm/runtime/virtualspace.cpp | 93 ++++++++++++++++--- hotspot/src/share/vm/runtime/virtualspace.hpp | 26 +++++- 23 files changed, 197 insertions(+), 133 deletions(-) diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 4c7ab6f6dd1..bc5d9ebc69e 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -2414,8 +2414,20 @@ static bool linux_mprotect(char* addr, size_t size, int prot) { return ::mprotect(bottom, size, prot) == 0; } -bool os::protect_memory(char* addr, size_t size) { - return linux_mprotect(addr, size, PROT_READ); +// Set protections specified +bool os::protect_memory(char* addr, size_t bytes, ProtType prot, + bool is_committed) { + unsigned int p = 0; + switch (prot) { + case MEM_PROT_NONE: p = PROT_NONE; break; + case MEM_PROT_READ: p = PROT_READ; break; + case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break; + case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break; + default: + ShouldNotReachHere(); + } + // is_committed is unused. + return linux_mprotect(addr, bytes, p); } bool os::guard_memory(char* addr, size_t size) { @@ -3704,8 +3716,9 @@ void os::make_polling_page_unreadable(void) { // Mark the polling page as readable void os::make_polling_page_readable(void) { - if( !protect_memory((char *)_polling_page, Linux::page_size()) ) + if( !linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) { fatal("Could not enable polling page"); + } }; int os::active_processor_count() { diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 952706c66b3..b6ca2a6db90 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -2965,10 +2965,21 @@ static bool solaris_mprotect(char* addr, size_t bytes, int prot) { return retVal == 0; } -// Protect memory (make it read-only. (Used to pass readonly pages through +// Protect memory (Used to pass readonly pages through // JNI GetArrayElements with empty arrays.) -bool os::protect_memory(char* addr, size_t bytes) { - return solaris_mprotect(addr, bytes, PROT_READ); +bool os::protect_memory(char* addr, size_t bytes, ProtType prot, + bool is_committed) { + unsigned int p = 0; + switch (prot) { + case MEM_PROT_NONE: p = PROT_NONE; break; + case MEM_PROT_READ: p = PROT_READ; break; + case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break; + case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break; + default: + ShouldNotReachHere(); + } + // is_committed is unused. + return solaris_mprotect(addr, bytes, p); } // guard_memory and unguard_memory only happens within stack guard pages. diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 97b2d752a28..14b3141d27e 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -2170,6 +2170,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // Windows 98 reports faulting addresses incorrectly if (!MacroAssembler::needs_explicit_null_check((intptr_t)addr) || !os::win32::is_nt()) { + return Handle_Exception(exceptionInfo, SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL)); } @@ -2563,9 +2564,33 @@ bool os::release_memory(char* addr, size_t bytes) { return VirtualFree(addr, 0, MEM_RELEASE) != 0; } -bool os::protect_memory(char* addr, size_t bytes) { +// Set protections specified +bool os::protect_memory(char* addr, size_t bytes, ProtType prot, + bool is_committed) { + unsigned int p = 0; + switch (prot) { + case MEM_PROT_NONE: p = PAGE_NOACCESS; break; + case MEM_PROT_READ: p = PAGE_READONLY; break; + case MEM_PROT_RW: p = PAGE_READWRITE; break; + case MEM_PROT_RWX: p = PAGE_EXECUTE_READWRITE; break; + default: + ShouldNotReachHere(); + } + DWORD old_status; - return VirtualProtect(addr, bytes, PAGE_READONLY, &old_status) != 0; + + // Strange enough, but on Win32 one can change protection only for committed + // memory, not a big deal anyway, as bytes less or equal than 64K + if (!is_committed && !commit_memory(addr, bytes)) { + fatal("cannot commit protection page"); + } + // One cannot use os::guard_memory() here, as on Win32 guard page + // have different (one-shot) semantics, from MSDN on PAGE_GUARD: + // + // Pages in the region become guard pages. Any attempt to access a guard page + // causes the system to raise a STATUS_GUARD_PAGE exception and turn off + // the guard page status. Guard pages thus act as a one-time access alarm. + return VirtualProtect(addr, bytes, p, &old_status) != 0; } bool os::guard_memory(char* addr, size_t bytes) { diff --git a/hotspot/src/os_cpu/linux_sparc/vm/assembler_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/assembler_linux_sparc.cpp index 95488f108cc..0fcd3b0d6d8 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/assembler_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/assembler_linux_sparc.cpp @@ -27,12 +27,6 @@ #include -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Since the linux kernel resides at the low end of - // user address space, no null pointer check is needed. - return offset < 0 || offset >= 0x100000; -} - void MacroAssembler::read_ccr_trap(Register ccr_save) { // No implementation breakpoint_trap(); diff --git a/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_32.cpp b/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_32.cpp index 6de7ee2811e..1854b007516 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_32.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_32.cpp @@ -39,10 +39,3 @@ void MacroAssembler::get_thread(Register thread) { movptr(thread, tls); } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Linux kernel guarantees that the first page is always unmapped. Don't - // assume anything more than that. - bool offset_in_first_page = 0 <= offset && offset < os::vm_page_size(); - return !offset_in_first_page; -} diff --git a/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_64.cpp b/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_64.cpp index 2a817f3adb0..24a4dce09e4 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_64.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/assembler_linux_x86_64.cpp @@ -65,22 +65,3 @@ void MacroAssembler::get_thread(Register thread) { popq(rax); } } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Exception handler checks the nmethod's implicit null checks table - // only when this method returns false. - if (UseCompressedOops) { - // The first page after heap_base is unmapped and - // the 'offset' is equal to [heap_base + offset] for - // narrow oop implicit null checks. - uintptr_t heap_base = (uintptr_t)Universe::heap_base(); - if ((uintptr_t)offset >= heap_base) { - // Normalize offset for the next check. - offset = (intptr_t)(pointer_delta((void*)offset, (void*)heap_base, 1)); - } - } - // Linux kernel guarantees that the first page is always unmapped. Don't - // assume anything more than that. - bool offset_in_first_page = 0 <= offset && offset < os::vm_page_size(); - return !offset_in_first_page; -} diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/assembler_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/assembler_solaris_sparc.cpp index 8e18dde9c31..caab18f5dcd 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/assembler_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/assembler_solaris_sparc.cpp @@ -28,18 +28,6 @@ #include // For trap numbers #include // For V8 compatibility -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // The first page of virtual addresses is unmapped on SPARC. - // Thus, any access the VM makes through a null pointer with an offset of - // less than 4K will get a recognizable SIGSEGV, which the signal handler - // will transform into a NullPointerException. - // (Actually, the first 64K or so is unmapped, but it's simpler - // to depend only on the first 4K or so.) - - bool offset_in_first_page = 0 <= offset && offset < os::vm_page_size(); - return !offset_in_first_page; -} - void MacroAssembler::read_ccr_trap(Register ccr_save) { // Execute a trap to get the PSR, mask and shift // to get the condition codes. diff --git a/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_32.cpp b/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_32.cpp index 30a66f317c0..bce611c1125 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_32.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_32.cpp @@ -79,9 +79,3 @@ void MacroAssembler::get_thread(Register thread) { if (thread != rax) popl(rax); popl(thread); } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Identical to Sparc/Solaris code - bool offset_in_first_page = 0 <= offset && offset < os::vm_page_size(); - return !offset_in_first_page; -} diff --git a/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_64.cpp b/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_64.cpp index 1e84101e200..2ccae8a683d 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_64.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/assembler_solaris_x86_64.cpp @@ -85,22 +85,3 @@ void MacroAssembler::get_thread(Register thread) { popq(rax); } } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Identical to Sparc/Solaris code - - // Exception handler checks the nmethod's implicit null checks table - // only when this method returns false. - if (UseCompressedOops) { - // The first page after heap_base is unmapped and - // the 'offset' is equal to [heap_base + offset] for - // narrow oop implicit null checks. - uintptr_t heap_base = (uintptr_t)Universe::heap_base(); - if ((uintptr_t)offset >= heap_base) { - // Normalize offset for the next check. - offset = (intptr_t)(pointer_delta((void*)offset, (void*)heap_base, 1)); - } - } - bool offset_in_first_page = 0 <= offset && offset < os::vm_page_size(); - return !offset_in_first_page; -} diff --git a/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_32.cpp b/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_32.cpp index 52f307686ae..5e91ce654f8 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_32.cpp +++ b/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_32.cpp @@ -58,7 +58,3 @@ void MacroAssembler::get_thread(Register thread) { "Thread Pointer Offset has not been initialized"); movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset())); } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - return offset < 0 || (int)os::vm_page_size() <= offset; -} diff --git a/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_64.cpp b/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_64.cpp index d0abc969080..7ff190fb21b 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_64.cpp +++ b/hotspot/src/os_cpu/windows_x86/vm/assembler_windows_x86_64.cpp @@ -65,19 +65,3 @@ void MacroAssembler::get_thread(Register thread) { popq(rax); } } - -bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { - // Exception handler checks the nmethod's implicit null checks table - // only when this method returns false. - if (UseCompressedOops) { - // The first page after heap_base is unmapped and - // the 'offset' is equal to [heap_base + offset] for - // narrow oop implicit null checks. - uintptr_t heap_base = (uintptr_t)Universe::heap_base(); - if ((uintptr_t)offset >= heap_base) { - // Normalize offset for the next check. - offset = (intptr_t)(pointer_delta((void*)offset, (void*)heap_base, 1)); - } - } - return offset < 0 || os::vm_page_size() <= offset; -} diff --git a/hotspot/src/share/vm/asm/assembler.cpp b/hotspot/src/share/vm/asm/assembler.cpp index 62c9d232f72..dcf1f0dcd94 100644 --- a/hotspot/src/share/vm/asm/assembler.cpp +++ b/hotspot/src/share/vm/asm/assembler.cpp @@ -246,6 +246,24 @@ void AbstractAssembler::block_comment(const char* comment) { } } +bool MacroAssembler::needs_explicit_null_check(intptr_t offset) { + // Exception handler checks the nmethod's implicit null checks table + // only when this method returns false. +#ifndef SPARC + // Sparc does not have based addressing + if (UseCompressedOops) { + // The first page after heap_base is unmapped and + // the 'offset' is equal to [heap_base + offset] for + // narrow oop implicit null checks. + uintptr_t heap_base = (uintptr_t)Universe::heap_base(); + if ((uintptr_t)offset >= heap_base) { + // Normalize offset for the next check. + offset = (intptr_t)(pointer_delta((void*)offset, (void*)heap_base, 1)); + } + } +#endif // SPARC + return offset < 0 || os::vm_page_size() <= offset; +} #ifndef PRODUCT void Label::print_instructions(MacroAssembler* masm) const { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp index c6723714344..204bf39171b 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp @@ -61,6 +61,8 @@ ParMarkBitMap::initialize(MemRegion covered_region) if (_virtual_space != NULL) { delete _virtual_space; _virtual_space = NULL; + // Release memory reserved in the space. + rs.release(); } return false; } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 59542f94bfe..6814abf6b44 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -108,8 +108,8 @@ jint ParallelScavengeHeap::initialize() { // size than is needed or wanted for the perm gen. Use the "compound // alignment" ReservedSpace ctor to avoid having to use the same page size for // all gens. - ReservedSpace heap_rs(pg_max_size, pg_align, og_max_size + yg_max_size, - og_align); + ReservedHeapSpace heap_rs(pg_max_size, pg_align, og_max_size + yg_max_size, + og_align); os::trace_page_sizes("ps perm", pg_min_size, pg_max_size, pg_page_sz, heap_rs.base(), pg_max_size); os::trace_page_sizes("ps main", og_min_size + yg_min_size, diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index ae516b74518..7bfbdb53978 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -422,6 +422,8 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size) return vspace; } delete vspace; + // Release memory reserved in the space. + rs.release(); } return 0; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp index 912f5414cc9..001f579e5d2 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp @@ -71,13 +71,8 @@ bool PSVirtualSpace::contains(void* p) const { void PSVirtualSpace::release() { DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this)); - if (reserved_low_addr() != NULL) { - if (special()) { - os::release_memory_special(reserved_low_addr(), reserved_size()); - } else { - (void)os::release_memory(reserved_low_addr(), reserved_size()); - } - } + // This may not release memory it didn't reserve. + // Use rs.release() to release the underlying memory instead. _reserved_low_addr = _reserved_high_addr = NULL; _committed_low_addr = _committed_high_addr = NULL; _special = false; diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index 3548137abd5..e77e86a0096 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -222,8 +222,8 @@ char* GenCollectedHeap::allocate(size_t alignment, *_total_reserved = total_reserved; *_n_covered_regions = n_covered_regions; - *heap_rs = ReservedSpace(total_reserved, alignment, - UseLargePages, heap_address); + *heap_rs = ReservedHeapSpace(total_reserved, alignment, + UseLargePages, heap_address); return heap_address; } diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 8d75b762b3e..49ace5c9823 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -2173,8 +2173,7 @@ static char* get_bad_address() { size_t size = os::vm_allocation_granularity(); bad_address = os::reserve_memory(size); if (bad_address != NULL) { - os::commit_memory(bad_address, size); - os::protect_memory(bad_address, size); + os::protect_memory(bad_address, size, os::MEM_PROT_READ); } } return bad_address; diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 421eae2cf0b..b5d35226c0d 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1176,9 +1176,7 @@ void Arguments::set_ergonomics_flags() { // by ergonomics. if (MaxHeapSize <= max_heap_for_compressed_oops()) { if (FLAG_IS_DEFAULT(UseCompressedOops)) { - // Leave compressed oops off by default. Uncomment - // the following line to return it to default status. - // FLAG_SET_ERGO(bool, UseCompressedOops, true); + FLAG_SET_ERGO(bool, UseCompressedOops, true); } } else { if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 27febbee046..f276e7e7250 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -922,8 +922,9 @@ void os::serialize_thread_states() { // time and expensive page trap spinning, 'SerializePageLock' is used to block // the mutator thread if such case is encountered. See bug 6546278 for details. Thread::muxAcquire(&SerializePageLock, "serialize_thread_states"); - os::protect_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() ); - os::unguard_memory( (char *)os::get_memory_serialize_page(), os::vm_page_size() ); + os::protect_memory((char *)os::get_memory_serialize_page(), + os::vm_page_size(), MEM_PROT_READ, /*is_committed*/true ); + os::unguard_memory((char *)os::get_memory_serialize_page(), os::vm_page_size()); Thread::muxRelease(&SerializePageLock); } diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 41b7ed80e03..0b8cea57884 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -193,7 +193,11 @@ class os: AllStatic { static bool commit_memory(char* addr, size_t size, size_t alignment_hint); static bool uncommit_memory(char* addr, size_t bytes); static bool release_memory(char* addr, size_t bytes); - static bool protect_memory(char* addr, size_t bytes); + + enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX }; + static bool protect_memory(char* addr, size_t bytes, ProtType prot, + bool is_committed = false); + static bool guard_memory(char* addr, size_t bytes); static bool unguard_memory(char* addr, size_t bytes); static char* map_memory(int fd, const char* file_name, size_t file_offset, diff --git a/hotspot/src/share/vm/runtime/virtualspace.cpp b/hotspot/src/share/vm/runtime/virtualspace.cpp index 23b75dc9dd4..44471632df6 100644 --- a/hotspot/src/share/vm/runtime/virtualspace.cpp +++ b/hotspot/src/share/vm/runtime/virtualspace.cpp @@ -28,12 +28,15 @@ // ReservedSpace ReservedSpace::ReservedSpace(size_t size) { - initialize(size, 0, false, NULL); + initialize(size, 0, false, NULL, 0); } ReservedSpace::ReservedSpace(size_t size, size_t alignment, - bool large, char* requested_address) { - initialize(size, alignment, large, requested_address); + bool large, + char* requested_address, + const size_t noaccess_prefix) { + initialize(size+noaccess_prefix, alignment, large, requested_address, + noaccess_prefix); } char * @@ -105,7 +108,8 @@ char* ReservedSpace::reserve_and_align(const size_t reserve_size, ReservedSpace::ReservedSpace(const size_t prefix_size, const size_t prefix_align, const size_t suffix_size, - const size_t suffix_align) + const size_t suffix_align, + const size_t noaccess_prefix) { assert(prefix_size != 0, "sanity"); assert(prefix_align != 0, "sanity"); @@ -118,12 +122,16 @@ ReservedSpace::ReservedSpace(const size_t prefix_size, assert((suffix_align & prefix_align - 1) == 0, "suffix_align not divisible by prefix_align"); + // Add in noaccess_prefix to prefix_size; + const size_t adjusted_prefix_size = prefix_size + noaccess_prefix; + const size_t size = adjusted_prefix_size + suffix_size; + // On systems where the entire region has to be reserved and committed up // front, the compound alignment normally done by this method is unnecessary. const bool try_reserve_special = UseLargePages && prefix_align == os::large_page_size(); if (!os::can_commit_large_page_memory() && try_reserve_special) { - initialize(prefix_size + suffix_size, prefix_align, true); + initialize(size, prefix_align, true, NULL, noaccess_prefix); return; } @@ -131,15 +139,19 @@ ReservedSpace::ReservedSpace(const size_t prefix_size, _size = 0; _alignment = 0; _special = false; + _noaccess_prefix = 0; + + // Assert that if noaccess_prefix is used, it is the same as prefix_align. + assert(noaccess_prefix == 0 || + noaccess_prefix == prefix_align, "noaccess prefix wrong"); // Optimistically try to reserve the exact size needed. - const size_t size = prefix_size + suffix_size; char* addr = os::reserve_memory(size, NULL, prefix_align); if (addr == NULL) return; // Check whether the result has the needed alignment (unlikely unless // prefix_align == suffix_align). - const size_t ofs = size_t(addr) + prefix_size & suffix_align - 1; + const size_t ofs = size_t(addr) + adjusted_prefix_size & suffix_align - 1; if (ofs != 0) { // Wrong alignment. Release, allocate more space and do manual alignment. // @@ -153,11 +165,11 @@ ReservedSpace::ReservedSpace(const size_t prefix_size, } const size_t extra = MAX2(ofs, suffix_align - ofs); - addr = reserve_and_align(size + extra, prefix_size, prefix_align, + addr = reserve_and_align(size + extra, adjusted_prefix_size, prefix_align, suffix_size, suffix_align); if (addr == NULL) { // Try an even larger region. If this fails, address space is exhausted. - addr = reserve_and_align(size + suffix_align, prefix_size, + addr = reserve_and_align(size + suffix_align, adjusted_prefix_size, prefix_align, suffix_size, suffix_align); } } @@ -165,10 +177,12 @@ ReservedSpace::ReservedSpace(const size_t prefix_size, _base = addr; _size = size; _alignment = prefix_align; + _noaccess_prefix = noaccess_prefix; } void ReservedSpace::initialize(size_t size, size_t alignment, bool large, - char* requested_address) { + char* requested_address, + const size_t noaccess_prefix) { const size_t granularity = os::vm_allocation_granularity(); assert((size & granularity - 1) == 0, "size not aligned to os::vm_allocation_granularity()"); @@ -181,6 +195,7 @@ void ReservedSpace::initialize(size_t size, size_t alignment, bool large, _size = 0; _special = false; _alignment = 0; + _noaccess_prefix = 0; if (size == 0) { return; } @@ -220,7 +235,8 @@ void ReservedSpace::initialize(size_t size, size_t alignment, bool large, // important. If available space is not detected, return NULL. if (requested_address != 0) { - base = os::attempt_reserve_memory_at(size, requested_address); + base = os::attempt_reserve_memory_at(size, + requested_address-noaccess_prefix); } else { base = os::reserve_memory(size, NULL, alignment); } @@ -259,6 +275,11 @@ void ReservedSpace::initialize(size_t size, size_t alignment, bool large, _base = base; _size = size; _alignment = MAX2(alignment, (size_t) os::vm_page_size()); + _noaccess_prefix = noaccess_prefix; + + // Assert that if noaccess_prefix is used, it is the same as alignment. + assert(noaccess_prefix == 0 || + noaccess_prefix == _alignment, "noaccess prefix wrong"); assert(markOopDesc::encode_pointer_as_mark(_base)->decode_pointer() == _base, "area must be distinguisable from marks for mark-sweep"); @@ -274,6 +295,7 @@ ReservedSpace::ReservedSpace(char* base, size_t size, size_t alignment, _base = base; _size = size; _alignment = alignment; + _noaccess_prefix = 0; _special = special; } @@ -320,17 +342,58 @@ size_t ReservedSpace::allocation_align_size_down(size_t size) { void ReservedSpace::release() { if (is_reserved()) { + char *real_base = _base - _noaccess_prefix; + const size_t real_size = _size + _noaccess_prefix; if (special()) { - os::release_memory_special(_base, _size); + os::release_memory_special(real_base, real_size); } else{ - os::release_memory(_base, _size); + os::release_memory(real_base, real_size); } _base = NULL; _size = 0; + _noaccess_prefix = 0; _special = false; } } +void ReservedSpace::protect_noaccess_prefix(const size_t size) { + // If there is noaccess prefix, return. + if (_noaccess_prefix == 0) return; + + assert(_noaccess_prefix >= (size_t)os::vm_page_size(), + "must be at least page size big"); + + // Protect memory at the base of the allocated region. + // If special, the page was committed (only matters on windows) + if (!os::protect_memory(_base, _noaccess_prefix, os::MEM_PROT_NONE, + _special)) { + fatal("cannot protect protection page"); + } + + _base += _noaccess_prefix; + _size -= _noaccess_prefix; + assert((size == _size) && ((uintptr_t)_base % _alignment == 0), + "must be exactly of required size and alignment"); +} + +ReservedHeapSpace::ReservedHeapSpace(size_t size, size_t alignment, + bool large, char* requested_address) : + ReservedSpace(size, alignment, large, + requested_address, + UseCompressedOops ? lcm(os::vm_page_size(), alignment) : 0) { + // Only reserved space for the java heap should have a noaccess_prefix + // if using compressed oops. + protect_noaccess_prefix(size); +} + +ReservedHeapSpace::ReservedHeapSpace(const size_t prefix_size, + const size_t prefix_align, + const size_t suffix_size, + const size_t suffix_align) : + ReservedSpace(prefix_size, prefix_align, suffix_size, suffix_align, + UseCompressedOops ? lcm(os::vm_page_size(), prefix_align) : 0) { + protect_noaccess_prefix(prefix_size+suffix_size); +} // VirtualSpace @@ -348,6 +411,7 @@ VirtualSpace::VirtualSpace() { _lower_alignment = 0; _middle_alignment = 0; _upper_alignment = 0; + _special = false; } @@ -402,7 +466,8 @@ VirtualSpace::~VirtualSpace() { void VirtualSpace::release() { - (void)os::release_memory(low_boundary(), reserved_size()); + // This does not release memory it never reserved. + // Caller must release via rs.release(); _low_boundary = NULL; _high_boundary = NULL; _low = NULL; diff --git a/hotspot/src/share/vm/runtime/virtualspace.hpp b/hotspot/src/share/vm/runtime/virtualspace.hpp index ad952e49a3d..556b4c92bb6 100644 --- a/hotspot/src/share/vm/runtime/virtualspace.hpp +++ b/hotspot/src/share/vm/runtime/virtualspace.hpp @@ -29,13 +29,15 @@ class ReservedSpace VALUE_OBJ_CLASS_SPEC { private: char* _base; size_t _size; + size_t _noaccess_prefix; size_t _alignment; bool _special; // ReservedSpace ReservedSpace(char* base, size_t size, size_t alignment, bool special); void initialize(size_t size, size_t alignment, bool large, - char* requested_address = NULL); + char* requested_address, + const size_t noaccess_prefix); // Release parts of an already-reserved memory region [addr, addr + len) to // get a new region that has "compound alignment." Return the start of the @@ -59,13 +61,19 @@ class ReservedSpace VALUE_OBJ_CLASS_SPEC { const size_t suffix_size, const size_t suffix_align); + protected: + // Create protection page at the beginning of the space. + void protect_noaccess_prefix(const size_t size); + public: // Constructor ReservedSpace(size_t size); ReservedSpace(size_t size, size_t alignment, bool large, - char* requested_address = NULL); + char* requested_address = NULL, + const size_t noaccess_prefix = 0); ReservedSpace(const size_t prefix_size, const size_t prefix_align, - const size_t suffix_size, const size_t suffix_align); + const size_t suffix_size, const size_t suffix_align, + const size_t noaccess_prefix); // Accessors char* base() const { return _base; } @@ -73,6 +81,8 @@ class ReservedSpace VALUE_OBJ_CLASS_SPEC { size_t alignment() const { return _alignment; } bool special() const { return _special; } + size_t noaccess_prefix() const { return _noaccess_prefix; } + bool is_reserved() const { return _base != NULL; } void release(); @@ -104,6 +114,16 @@ ReservedSpace ReservedSpace::last_part(size_t partition_size) return last_part(partition_size, alignment()); } +// Class encapsulating behavior specific of memory space reserved for Java heap +class ReservedHeapSpace : public ReservedSpace { +public: + // Constructor + ReservedHeapSpace(size_t size, size_t forced_base_alignment, + bool large, char* requested_address); + ReservedHeapSpace(const size_t prefix_size, const size_t prefix_align, + const size_t suffix_size, const size_t suffix_align); +}; + // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks. class VirtualSpace VALUE_OBJ_CLASS_SPEC { From 034e883c863a40a8cbbe1e8460beabbcb80cf502 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Sun, 27 Jul 2008 18:42:57 -0700 Subject: [PATCH 20/22] 6727683: Cleanup use of COMPILER_WARNINGS_FATAL in makefiles Reviewed-by: tbell --- jdk/make/com/sun/java/pack/Makefile | 3 - .../com/sun/security/auth/module/Makefile | 3 - jdk/make/common/Defs-linux.gmk | 5 +- jdk/make/common/Defs-solaris.gmk | 38 +++++- jdk/make/common/Defs-windows.gmk | 23 ++-- jdk/make/common/shared/Compiler-gcc.gmk | 27 ++--- jdk/make/common/shared/Defs-java.gmk | 10 +- jdk/make/common/shared/Platform.gmk | 112 ++++++++++-------- jdk/make/java/fdlibm/Makefile | 2 - jdk/make/java/hpi/windows/Makefile | 2 - jdk/make/java/java/Makefile | 2 - jdk/make/java/java_crw_demo/Makefile | 5 - jdk/make/java/java_hprof_demo/Makefile | 5 - jdk/make/java/jli/Makefile | 3 - jdk/make/java/net/Makefile | 2 - jdk/make/java/nio/Makefile | 1 - jdk/make/java/npt/Makefile | 5 - jdk/make/java/verify/Makefile | 2 - jdk/make/java/zip/Makefile | 3 - jdk/make/jpda/back/Makefile | 5 - jdk/make/jpda/transport/shmem/Makefile | 7 -- jdk/make/jpda/transport/socket/Makefile | 5 - jdk/make/sun/cmm/kcms/Makefile | 2 - jdk/make/sun/font/Makefile | 3 - jdk/make/sun/font/t2k/Makefile | 3 - jdk/make/sun/jdbc/Makefile | 5 - jdk/make/sun/jpeg/Makefile | 5 - 27 files changed, 127 insertions(+), 161 deletions(-) diff --git a/jdk/make/com/sun/java/pack/Makefile b/jdk/make/com/sun/java/pack/Makefile index 0a230f7364f..9229e3f4c99 100644 --- a/jdk/make/com/sun/java/pack/Makefile +++ b/jdk/make/com/sun/java/pack/Makefile @@ -97,9 +97,6 @@ ifeq ($(PLATFORM), windows) /D "J2SE_FTYPE=0x1L" RES = $(OBJDIR)/$(PGRM).res - - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false else LDOUTPUT = -o #Have a space LDDFLAGS += -lc diff --git a/jdk/make/com/sun/security/auth/module/Makefile b/jdk/make/com/sun/security/auth/module/Makefile index 303c8475163..d9f705d4df7 100644 --- a/jdk/make/com/sun/security/auth/module/Makefile +++ b/jdk/make/com/sun/security/auth/module/Makefile @@ -55,9 +55,6 @@ LIBRARY = jaas_nt EXTRA_LIBS += netapi32.lib user32.lib mpr.lib endif #fdlibm # code generates errors when compiled at warning level 3 and warnings are fatal - ifeq ($(ARCH_DATA_MODEL), 64) - COMPILER_WARNINGS_FATAL=false - endif # ARCH_DATA_MODEL endif # windows ifeq ($(PLATFORM), solaris) diff --git a/jdk/make/common/Defs-linux.gmk b/jdk/make/common/Defs-linux.gmk index c4f1856f5fc..65814ba472a 100644 --- a/jdk/make/common/Defs-linux.gmk +++ b/jdk/make/common/Defs-linux.gmk @@ -149,10 +149,9 @@ endif # ARCH PIC_CODE_LARGE = -fPIC PIC_CODE_SMALL = -fpic GLOBAL_KPIC = $(PIC_CODE_LARGE) +CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS) ifeq ($(ARCH), amd64) - CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS) -pipe -else - CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS) + CFLAGS_COMMON += -pipe endif # Linux 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1 diff --git a/jdk/make/common/Defs-solaris.gmk b/jdk/make/common/Defs-solaris.gmk index 01ea5bd271f..d0874e43070 100644 --- a/jdk/make/common/Defs-solaris.gmk +++ b/jdk/make/common/Defs-solaris.gmk @@ -40,6 +40,9 @@ # LDLIBS (set $(EXTRA_LIBS) instead) # LDLIBS_COMMON (set $(EXTRA_LIBS) instead) # LINTFLAGS (set $(OTHER_LINTFLAGS) instead) +# +# Note: CPPFLAGS are used in C and C++ compiles. +# # Get shared JDK settings include $(JDK_MAKE_SHARED_DIR)/Defs.gmk @@ -112,6 +115,10 @@ endif # Required with many of the source files. # -mt Assume multi-threaded (important) # +# The more unusual options to the Sun C compiler: +# +w Print more warnings +# +w2 Maximum warnings +# # # Debug flag for C and C++ compiler @@ -140,15 +147,34 @@ ifeq ($(FASTDEBUG), true) CXXFLAGS_DEBUG_OPTION = -g0 $(CC_FASTDEBUG_OPT) endif -CFLAGS_COMMON = -v -mt -L$(OBJDIR) -xc99=%none +CFLAGS_COMMON = -L$(OBJDIR) + +# Do not allow C99 language features like declarations in code etc. +CFLAGS_COMMON += -xc99=%none + +# Allow C++ comments in C code CFLAGS_COMMON += -xCC -CFLAGS_COMMON += -errshort=tags + +# Show error message tags on errors +CFLAGS_COMMON += -errshort=tags +CXXFLAGS_COMMON += -errtags=yes + +# Optimization flags CFLAGS_OPT = $(POPT) + +# Debug version flags CFLAGS_DBG = $(CFLAGS_DEBUG_OPTION) -CFLAGS_COMMON += -Xa $(CFLAGS_REQUIRED) + +# Required C compiler flags +CFLAGS_COMMON += -Xa $(CFLAGS_REQUIRED) + +# Maximum warnings all the time +CXXFLAGS_COMMON += +w +CFLAGS_COMMON += -v # Assume MT behavior all the time (important) -CXXFLAGS_COMMON = -mt +CXXFLAGS_COMMON += -mt +CFLAGS_COMMON += -mt # Assume no C++ exceptions are used CXXFLAGS_COMMON += -features=no%except -DCC_NOEX @@ -237,8 +263,8 @@ LINTFLAGS_COMMON += $(LINT_XARCH_OPTION) # OTHER_CFLAGS += -DPERTURBALOT # -CPPFLAGS_COMMON = -D$(ARCH_FAMILY) -D__solaris__ -D_REENTRANT -CPPFLAGS_OPT = +CPPFLAGS_COMMON = -D__solaris__ -D$(ARCH_FAMILY) +CPPFLAGS_OPT = -DNDEBUG CPPFLAGS_DBG = -DDEBUG ifeq ($(ARCH_FAMILY), i586) diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk index 51982dc1a1b..d7c11837e96 100644 --- a/jdk/make/common/Defs-windows.gmk +++ b/jdk/make/common/Defs-windows.gmk @@ -283,7 +283,7 @@ CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN ifeq ($(ARCH), amd64) CPPFLAGS_COMMON += -D_AMD64_ -Damd64 else - CPPFLAGS_COMMON += -DWIN32 -D_X86_ -Dx86 + CPPFLAGS_COMMON += -D_X86_ -Dx86 endif CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN @@ -292,17 +292,24 @@ CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN # CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map +# +# Use -wdNNNN to disable warning NNNN. +# C4800 is a warning about bool performance casts (can't make go away) +# +COMPILER_WARNINGS_TO_IGNORE = 4800 +CFLAGS_COMMON += $(COMPILER_WARNINGS_TO_IGNORE:%=-wd%) + # # Add warnings and extra on 64bit issues # ifeq ($(ARCH_DATA_MODEL), 64) CFLAGS_COMMON += -Wp64 endif -CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL) # # Treat compiler warnings as errors, if requested # +CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL) ifeq ($(COMPILER_WARNINGS_FATAL),true) CFLAGS_COMMON += -WX endif @@ -352,17 +359,9 @@ else # BUILD_WIN_SA=1 # on the make command. ifdef BUILD_WIN_SA - ifeq ($(ARCH), amd64) - INCLUDE_SA = true - else - INCLUDE_SA = true - endif + INCLUDE_SA = true else - ifeq ($(ARCH), amd64) - INCLUDE_SA = false - else - INCLUDE_SA = false - endif + INCLUDE_SA = false endif endif diff --git a/jdk/make/common/shared/Compiler-gcc.gmk b/jdk/make/common/shared/Compiler-gcc.gmk index 2eca25a5a98..27501956368 100644 --- a/jdk/make/common/shared/Compiler-gcc.gmk +++ b/jdk/make/common/shared/Compiler-gcc.gmk @@ -73,23 +73,18 @@ ifeq ($(PLATFORM), linux) REQUIRED_CC_VER = 4.0 REQUIRED_GCC_VER = 4.0.* else - ifeq ($(ARCH_DATA_MODEL), 32) - # i586 REQUIRED_CC_VER = 3.2 - REQUIRED_GCC_VER = 3.2.1* - REQUIRED_GCC_VER_INT = 3.2.1-7a - else - ifeq ($(ARCH), amd64) - # amd64 - REQUIRED_CC_VER = 3.2 - REQUIRED_GCC_VER = 3.2.* - endif - ifeq ($(ARCH), ia64) - # ia64 - REQUIRED_CC_VER = 3.2 - REQUIRED_GCC_VER = 2.9[56789].* - endif - endif + ifeq ($(ARCH_DATA_MODEL), 32) + REQUIRED_GCC_VER = 3.2.1* + REQUIRED_GCC_VER_INT = 3.2.1-7a + else + ifeq ($(ARCH), amd64) + REQUIRED_GCC_VER = 3.2.* + endif + ifeq ($(ARCH), ia64) + REQUIRED_GCC_VER = 2.9[56789].* + endif + endif endif # Option used to create a shared library SHARED_LIBRARY_FLAG = -shared -mimpure-text diff --git a/jdk/make/common/shared/Defs-java.gmk b/jdk/make/common/shared/Defs-java.gmk index b3e02702783..179e53a01a9 100644 --- a/jdk/make/common/shared/Defs-java.gmk +++ b/jdk/make/common/shared/Defs-java.gmk @@ -107,7 +107,10 @@ JAVACFLAGS = ifeq ($(DEBUG_CLASSFILES),true) JAVACFLAGS += -g endif -ifeq ($(COMPILER_WARNINGS_FATAL), true) +ifeq ($(JAVAC_MAX_WARNINGS), true) + JAVACFLAGS += -Xlint:all +endif +ifeq ($(JAVAC_WARNINGS_FATAL), true) JAVACFLAGS += -Werror endif @@ -180,7 +183,10 @@ endif # The javac options supplied to the boot javac is limited. This compiler # should only be used to build the 'make/tools' sources, which are not # class files that end up in the classes directory. -ifeq ($(COMPILER_WARNINGS_FATAL), true) +ifeq ($(JAVAC_MAX_WARNINGS), true) + BOOT_JAVACFLAGS += -Xlint:all +endif +ifeq ($(JAVAC_WARNINGS_FATAL), true) BOOT_JAVACFLAGS += -Werror endif BOOT_JAVACFLAGS += -encoding ascii diff --git a/jdk/make/common/shared/Platform.gmk b/jdk/make/common/shared/Platform.gmk index abf93964332..e9859dd4bad 100644 --- a/jdk/make/common/shared/Platform.gmk +++ b/jdk/make/common/shared/Platform.gmk @@ -373,34 +373,40 @@ ifeq ($(PLATFORM), windows) REQUIRED_DXSDK_VER = 0x0700 OS_VENDOR = Microsoft # How much RAM does this machine have: - ifeq ($(USING_CYGWIN),true) - # CYGWIN has the 'free' utility - _MB_OF_MEMORY := \ - $(shell free -m | grep Mem: | awk '{print $$2;}' ) - else - # Windows 2000 has the mem utility, but two memory areas - # extended memory is what is beyond 1024M - _B_OF_EXT_MEMORY := \ - $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}') - ifeq ($(_B_OF_EXT_MEMORY),) - _B_OF_MEMORY := \ - $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}') - else - _B_OF_MEMORY := \ - $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) - endif - ifeq ($(_B_OF_MEMORY),) - # Windows 2003 has the systeminfo utility use it if mem doesn't work + ifeq ($(JDK_HAS_MEM_INFO),) + ifeq ($(USING_CYGWIN),true) + # CYGWIN has the 'free' utility _MB_OF_MEMORY := \ - $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@') + $(shell free -m | grep Mem: | awk '{print $$2;}' ) else - _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) + # Windows 2000 has the mem utility, but two memory areas + # extended memory is what is beyond 1024M + _B_OF_EXT_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | \ + grep 'total contiguous extended memory' | awk '{print $$1;}') + ifeq ($(_B_OF_EXT_MEMORY),) + _B_OF_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | \ + grep 'total conventional memory' | awk '{print $$1;}') + else + _B_OF_MEMORY := \ + $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) + endif + ifeq ($(_B_OF_MEMORY),) + # Windows 2003 has the systeminfo utility use it if mem doesn't work + _MB_OF_MEMORY := \ + $(shell systeminfo 2> $(DEV_NULL) | \ + grep 'Total Physical Memory:' | \ + awk '{print $$4;}' | sed -e 's@,@@') + else + _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) + endif + endif + ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) + MB_OF_MEMORY := $(_MB_OF_MEMORY) + else + MB_OF_MEMORY := 512 endif - endif - ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) - MB_OF_MEMORY := $(_MB_OF_MEMORY) - else - MB_OF_MEMORY := 512 endif endif @@ -446,30 +452,38 @@ endif # system swapping during the build. # If we don't know, assume 512. Subtract 128 from MB for VM MAX. # Don't set VM max over 1024-128=896. -ifneq ($(MB_OF_MEMORY),) - LOW_MEMORY_MACHINE := $(shell \ - if [ $(MB_OF_MEMORY) -le 512 ] ; then \ - echo "true"; \ - else \ - echo "false"; \ - fi) - MAX_VM_MEMORY := $(shell \ - if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ - expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \ - else \ - echo "896"; \ - fi) - MIN_VM_MEMORY := $(shell \ - if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ - expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \ - else \ - echo "128"; \ - fi) -else - MB_OF_MEMORY := unknown - LOW_MEMORY_MACHINE := true - MAX_VM_MEMORY := 384 - MIN_VM_MEMORY := 128 +ifeq ($(JDK_HAS_MEM_INFO),) + JDK_HAS_MEM_INFO=true + export JDK_HAS_MEM_INFO + ifneq ($(MB_OF_MEMORY),) + LOW_MEMORY_MACHINE := $(shell \ + if [ $(MB_OF_MEMORY) -le 512 ] ; then \ + echo "true"; \ + else \ + echo "false"; \ + fi) + MAX_VM_MEMORY := $(shell \ + if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ + expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \ + else \ + echo "896"; \ + fi) + MIN_VM_MEMORY := $(shell \ + if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ + expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \ + else \ + echo "128"; \ + fi) + else + MB_OF_MEMORY := unknown + LOW_MEMORY_MACHINE := true + MAX_VM_MEMORY := 384 + MIN_VM_MEMORY := 128 + endif + export MB_OF_MEMORY + export LOW_MEMORY_MACHINE + export MAX_VM_MEMORY + export MIN_VM_MEMORY endif # If blanks in the username, use the first 4 words and pack them together diff --git a/jdk/make/java/fdlibm/Makefile b/jdk/make/java/fdlibm/Makefile index fd2442b0321..ab7a411579c 100644 --- a/jdk/make/java/fdlibm/Makefile +++ b/jdk/make/java/fdlibm/Makefile @@ -46,8 +46,6 @@ ifeq ($(PLATFORM),windows) _OPT = $(CC_NO_OPT) OTHER_CFLAGS = CPPFLAGS_DBG += -DLOGGING - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif # diff --git a/jdk/make/java/hpi/windows/Makefile b/jdk/make/java/hpi/windows/Makefile index da163368e21..fa04ec6a362 100644 --- a/jdk/make/java/hpi/windows/Makefile +++ b/jdk/make/java/hpi/windows/Makefile @@ -37,8 +37,6 @@ include $(BUILDDIR)/common/Defs.gmk # windows compiler flags ifeq ($(PLATFORM),windows) CPPFLAGS_DBG += -DLOGGING - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif FILES_c = \ diff --git a/jdk/make/java/java/Makefile b/jdk/make/java/java/Makefile index 671bff3cf1a..8755a4c3a6e 100644 --- a/jdk/make/java/java/Makefile +++ b/jdk/make/java/java/Makefile @@ -37,8 +37,6 @@ include $(BUILDDIR)/common/Defs.gmk # windows compiler flags ifeq ($(PLATFORM),windows) OTHER_CFLAGS = - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false # build directly into BINDIR... LIB_LOCATION = $(BINDIR) # Exported functions diff --git a/jdk/make/java/java_crw_demo/Makefile b/jdk/make/java/java_crw_demo/Makefile index 2157e2f892c..c65a84df1e8 100644 --- a/jdk/make/java/java_crw_demo/Makefile +++ b/jdk/make/java/java_crw_demo/Makefile @@ -47,11 +47,6 @@ FILES_c = java_crw_demo.c OTHER_INCLUDES = -I$(SRCDIR) -# -# This removes all asserts in the optimized version -# -CPPFLAGS_OPT += -DNDEBUG - # # Library to compile. # diff --git a/jdk/make/java/java_hprof_demo/Makefile b/jdk/make/java/java_hprof_demo/Makefile index 71529433b14..9c97a6a24e5 100644 --- a/jdk/make/java/java_hprof_demo/Makefile +++ b/jdk/make/java/java_hprof_demo/Makefile @@ -91,11 +91,6 @@ endif # INIT += $(LIBDIR)/jvm.hprof.txt -# -# This removes all asserts in the optimized version -# -CPPFLAGS_OPT += -DNDEBUG - # # This puts logging code in # diff --git a/jdk/make/java/jli/Makefile b/jdk/make/java/jli/Makefile index 65adb05e248..5a1c312d7ab 100644 --- a/jdk/make/java/jli/Makefile +++ b/jdk/make/java/jli/Makefile @@ -115,9 +115,6 @@ ifeq ($(PLATFORM), windows) -export:JLI_ManifestIterate \ -export:JLI_SetTraceLauncher - # Files from zlib built here do not compile with warning level 3 - # if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC) diff --git a/jdk/make/java/net/Makefile b/jdk/make/java/net/Makefile index 6218c63776e..4141294c02c 100644 --- a/jdk/make/java/net/Makefile +++ b/jdk/make/java/net/Makefile @@ -94,8 +94,6 @@ include $(BUILDDIR)/common/Library.gmk ifeq ($(PLATFORM), windows) OTHER_LDLIBS = ws2_32.lib $(JVMLIB) - # Will not compile at warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false else OTHER_LDLIBS = $(LIBSOCKET) -lnsl -ldl $(JVMLIB) endif diff --git a/jdk/make/java/nio/Makefile b/jdk/make/java/nio/Makefile index 9d083dab535..267a5745435 100644 --- a/jdk/make/java/nio/Makefile +++ b/jdk/make/java/nio/Makefile @@ -134,7 +134,6 @@ ifeq ($(PLATFORM),windows) $(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/FileDescriptor_md.obj endif ifeq ($(PLATFORM), linux) -COMPILER_WARNINGS_FATAL=true OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl endif ifeq ($(PLATFORM), solaris) diff --git a/jdk/make/java/npt/Makefile b/jdk/make/java/npt/Makefile index 48cab86ae07..fe9eb0ad4e3 100644 --- a/jdk/make/java/npt/Makefile +++ b/jdk/make/java/npt/Makefile @@ -52,11 +52,6 @@ FILES_c = \ OTHER_INCLUDES = -I$(SRCDIR) -I$(PSRCDIR) -# -# This removes all asserts in the optimized version -# -CPPFLAGS_OPT += -DNDEBUG - # # Library to compile. # diff --git a/jdk/make/java/verify/Makefile b/jdk/make/java/verify/Makefile index a90862d516a..c647d508569 100644 --- a/jdk/make/java/verify/Makefile +++ b/jdk/make/java/verify/Makefile @@ -43,8 +43,6 @@ ifeq ($(PLATFORM), windows) # JAVALIB = EXTRA_LIBS = - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif # diff --git a/jdk/make/java/zip/Makefile b/jdk/make/java/zip/Makefile index e25e46f1e4a..00b381d5085 100644 --- a/jdk/make/java/zip/Makefile +++ b/jdk/make/java/zip/Makefile @@ -49,9 +49,6 @@ FILES_export = \ ifneq ($(PLATFORM), windows) OTHER_CFLAGS += -DUSE_MMAP -else - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif # diff --git a/jdk/make/jpda/back/Makefile b/jdk/make/jpda/back/Makefile index a974bff608b..bd9818365e3 100644 --- a/jdk/make/jpda/back/Makefile +++ b/jdk/make/jpda/back/Makefile @@ -52,11 +52,6 @@ ifneq ($(PLATFORM), windows) OTHER_LDLIBS += -ldl endif # PLATFORM -# -# This turns off all assert() checking in the optimized library -# -CPPFLAGS_OPT += -DNDEBUG - # # This controls the ability to do logging in the library. # diff --git a/jdk/make/jpda/transport/shmem/Makefile b/jdk/make/jpda/transport/shmem/Makefile index ad5ff4b3729..a1e2382500a 100644 --- a/jdk/make/jpda/transport/shmem/Makefile +++ b/jdk/make/jpda/transport/shmem/Makefile @@ -36,13 +36,6 @@ FILES_m = mapfile-vers include $(BUILDDIR)/common/Defs.gmk -# 64-bit windows does not build at -W3 if warnings are fatal -ifeq ($(PLATFORM), windows) - ifeq ($(ARCH_DATA_MODEL), 64) - COMPILER_WARNINGS_FATAL=false - endif -endif - FILES_c = \ SharedMemoryTransport.c \ SharedMemoryConnection.c \ diff --git a/jdk/make/jpda/transport/socket/Makefile b/jdk/make/jpda/transport/socket/Makefile index 07c5642a2d3..828613d49ed 100644 --- a/jdk/make/jpda/transport/socket/Makefile +++ b/jdk/make/jpda/transport/socket/Makefile @@ -36,11 +36,6 @@ FILES_m = mapfile-vers include $(BUILDDIR)/common/Defs.gmk -ifeq ($(PLATFORM), windows) - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false -endif - ifeq ($(PLATFORM), linux) OTHER_LDLIBS += -lnsl $(LIBSOCKET) -lpthread endif diff --git a/jdk/make/sun/cmm/kcms/Makefile b/jdk/make/sun/cmm/kcms/Makefile index b430a140716..000f2527e5b 100644 --- a/jdk/make/sun/cmm/kcms/Makefile +++ b/jdk/make/sun/cmm/kcms/Makefile @@ -47,8 +47,6 @@ FILES_export = \ ifeq ($(PLATFORM), windows) # Override the default version info with our own resource file (see 5043594) VERSIONINFO_RESOURCE = $(CLOSED_SRC)/share/native/sun/java2d/cmm/kcms/cmm.rc - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false endif # Rules diff --git a/jdk/make/sun/font/Makefile b/jdk/make/sun/font/Makefile index def2eba8057..a247bb21eb5 100644 --- a/jdk/make/sun/font/Makefile +++ b/jdk/make/sun/font/Makefile @@ -77,9 +77,6 @@ FILES_export = \ ifeq ($(PLATFORM), windows) - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false - LDLIBS += user32.lib gdi32.lib $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_CFLAGS += -DCC_NOEX diff --git a/jdk/make/sun/font/t2k/Makefile b/jdk/make/sun/font/t2k/Makefile index 93d2e59d29b..65f7f99a4dd 100644 --- a/jdk/make/sun/font/t2k/Makefile +++ b/jdk/make/sun/font/t2k/Makefile @@ -64,9 +64,6 @@ FILES_export = \ ifeq ($(PLATFORM), windows) - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false - # t2k imports several shared methods from fontmanager.dll LDLIBS += user32.lib $(OBJDIR)/../../../sun.font/fontmanager/$(OBJDIRNAME)/fontmanager.lib diff --git a/jdk/make/sun/jdbc/Makefile b/jdk/make/sun/jdbc/Makefile index d520b22cf85..818a89d0e8b 100644 --- a/jdk/make/sun/jdbc/Makefile +++ b/jdk/make/sun/jdbc/Makefile @@ -69,11 +69,6 @@ ifneq ($(PLATFORM), windows) INIT += $(ODBC_FAKE_LIBRARIES) endif -ifeq ($(PLATFORM),windows) - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false -endif - # # Rules # diff --git a/jdk/make/sun/jpeg/Makefile b/jdk/make/sun/jpeg/Makefile index 45bc70855dd..e3513763316 100644 --- a/jdk/make/sun/jpeg/Makefile +++ b/jdk/make/sun/jpeg/Makefile @@ -73,10 +73,5 @@ include $(BUILDDIR)/common/Library.gmk # vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -ifeq ($(PLATFORM), windows) - # Files built here do not compile with warning level 3 if warnings are fatal - COMPILER_WARNINGS_FATAL=false -endif # PLATFORM - CLASSES.export += java.io.InputStream From 632c83fb46317a48bfb608e6c7ca415d5f38187d Mon Sep 17 00:00:00 2001 From: Erik Trimble Date: Fri, 1 Aug 2008 18:51:27 -0700 Subject: [PATCH 21/22] 6732819: Turn off compressed oops by default for now Workaround for CompOops bug Reviewed-by: coleenp --- hotspot/src/share/vm/runtime/arguments.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index b5d35226c0d..882e92b337d 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1176,7 +1176,8 @@ void Arguments::set_ergonomics_flags() { // by ergonomics. if (MaxHeapSize <= max_heap_for_compressed_oops()) { if (FLAG_IS_DEFAULT(UseCompressedOops)) { - FLAG_SET_ERGO(bool, UseCompressedOops, true); + // Turn off until bug is fixed. + // FLAG_SET_ERGO(bool, UseCompressedOops, true); } } else { if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { From c3f114974aa01d46fa49e4fad332aad812db4827 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 16:39:00 +0200 Subject: [PATCH 22/22] Added tag jdk7-b31 for changeset cd8b8f500fac --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 391c13e90e5..f0dd95d1127 100644 --- a/.hgtags +++ b/.hgtags @@ -5,3 +5,4 @@ bf2517e15f0c0f950e5b3143c4ca11e2df73dcc1 jdk7-b25 18dc4ba4739a537fd146f77da51db16efce28da2 jdk7-b28 bfe4572fd301a6fcd120373cdb2eff5d2da0c72c jdk7-b29 bee4731164a06ddece1297ae58db24aca6a1c626 jdk7-b30 +cd8b8f500face60d1566d850857a7fccadbd383a jdk7-b31

    - - OpenJDK - + OpenJDK
    make.exe Develmake: The GNU version of the 'make' utilitymake: The GNU version of the 'make' utility
    + NOTE: See the GNU make section
    m4.execpio: A program to manage archives of files
    awk.exegawk.exe Utils awk: Pattern-directed scanning and processing language
    zip.exeUtilsArchive zip: Package and compress (archive) files
    unzip.exeUtilsArchive unzip: Extract compressed files in a ZIP archive
    free.exeUtilsProcps free: Display amount of free and used memory in the system