changeset 300:20f954ba3059

merge openjdk b41 changes
author Mahmood Ali <mali@csail.mit.edu>
date Sun, 07 Dec 2008 15:58:16 -0500
parents fec632145153 4674298aaf3b
children 54af869a8e10
files
diffstat 12 files changed, 183 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sun Dec 07 14:50:38 2008 -0500
+++ b/.hgtags	Sun Dec 07 15:58:16 2008 -0500
@@ -14,3 +14,5 @@
 24a47c3062fe8869fcfb533ce0ff770c8ceb550d jdk7-b37
 3fd42dfa6f27f2767a241fb82bc01a613f0c2096 jdk7-b38
 3fb51e47622bb771571680bc6a7b64c6172b482d jdk7-b39
+32e30988324601d08b87989f0821d99aa8534511 jdk7-b40
+ded6b40f558e8d19b3c17715b3d67ee001606645 jdk7-b41
--- a/make/Makefile	Sun Dec 07 14:50:38 2008 -0500
+++ b/make/Makefile	Sun Dec 07 15:58:16 2008 -0500
@@ -82,7 +82,11 @@
 endif 
 
 ifdef MILESTONE
+ifneq ($(MILESTONE),fcs)
   ANT_OPTIONS += -Dmilestone=$(MILESTONE)
+else
+  ANT_OPTIONS += -Drelease=$(JDK_VERSION)
+endif
 endif
 
 ifdef BUILD_NUMBER
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sun Dec 07 15:58:16 2008 -0500
@@ -559,6 +559,7 @@
                       boolean useVarargs,
                       boolean operator) {
         if (sym.kind == ERR) return bestSoFar;
+        if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
         assert sym.kind < AMBIGUOUS;
         try {
             if (rawInstantiate(env, site, sym, argtypes, typeargtypes,
--- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Sun Dec 07 15:58:16 2008 -0500
@@ -27,13 +27,13 @@
 import java.util.Collection;
 import java.util.Locale;
 import javax.tools.JavaFileObject;
-import java.util.ResourceBundle;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.api.Formattable;
 import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind;
 import com.sun.tools.javac.file.JavacFileManager;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
+import static com.sun.tools.javac.util.LayoutCharacters.*;
 
 /**
  * This abstract class provides a basic implementation of the functionalities that should be provided
@@ -72,8 +72,13 @@
 
     public String formatMessage(JCDiagnostic d, Locale l) {
         //this code should rely on the locale settings but it's not! See RFE 6443132
+        StringBuilder buf = new StringBuilder();
         Collection<String> args = formatArguments(d, l);
-        return localize(l, d.getCode(), args.toArray());
+        buf.append(localize(l, d.getCode(), args.toArray()));
+        if (d.isMultiline()) {
+            buf.append(formatSubdiagnostics(d, l));
+        }
+        return buf.toString();
     }
 
     public String formatKind(JCDiagnostic d, Locale l) {
@@ -165,6 +170,23 @@
         return sbuf.toString();
     }
 
+    /**
+     * Format all the subdiagnostics attached to a given diagnostic
+     *
+     * @param d diagnostic whose subdiagnostics are to be formatted
+     * @param l locale object to be used for i18n
+     * @return string representation of the subdiagnostics
+     */
+    protected String formatSubdiagnostics(JCDiagnostic d, Locale l) {
+        StringBuilder buf = new StringBuilder();
+        for (JCDiagnostic d2 : d.getSubdiagnostics()) {
+            buf.append('\n');
+            String subdiagMsg = format(d2, l);
+            buf.append(indent(subdiagMsg, DiagInc));
+        }
+        return buf.toString();
+    }
+
     /** Format the faulty source code line and point to the error.
      *  @param d The diagnostic for which the error line should be printed
      */
@@ -201,4 +223,44 @@
     public boolean displaySource(JCDiagnostic d) {
         return showSource && d.getType() != FRAGMENT;
     }
+
+    /**
+     * Creates a string with a given amount of empty spaces. Useful for
+     * indenting the text of a diagnostic message.
+     *
+     * @param nSpaces the amount of spaces to be added to the result string
+     * @return the indentation string
+     */
+    protected String indentString(int nSpaces) {
+        String spaces = "                        ";
+        if (nSpaces <= spaces.length())
+            return spaces.substring(0, nSpaces);
+        else {
+            StringBuilder buf = new StringBuilder();
+            for (int i = 0 ; i < nSpaces ; i++)
+                buf.append(" ");
+            return buf.toString();
+        }
+    }
+
+    /**
+     * Indent a string by prepending a given amount of empty spaces to each line
+     * of the string
+     *
+     * @param s the string to be indented
+     * @param nSpaces the amount of spaces that should be prepended to each line
+     * of the string
+     * @return an indented string
+     */
+    protected String indent(String s, int nSpaces) {
+        String indent = indentString(nSpaces);
+        StringBuilder buf = new StringBuilder();
+        String nl = "";
+        for (String line : s.split("\n")) {
+            buf.append(nl);
+            buf.append(indent + line);
+            nl = "\n";
+        }
+        return buf.toString();
+    }
 }
--- a/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Sun Dec 07 15:58:16 2008 -0500
@@ -67,6 +67,12 @@
         return s;
     }
 
+    /** Return the underlying diagnostic source
+     */
+    public DiagnosticSource currentSource() {
+        return source;
+    }
+
     /** Report an error, unless another error was already reported at same
      *  source position.
      *  @param key    The key for the localized error message.
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Sun Dec 07 15:58:16 2008 -0500
@@ -289,7 +289,7 @@
         this.source = source;
         this.position = pos;
         this.key = key;
-        this.args = args;
+            this.args = args;
 
         int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
         if (n == Position.NOPOS || source == null)
@@ -309,6 +309,18 @@
     }
 
     /**
+     * Get the subdiagnostic list
+     * @return subdiagnostic list
+     */
+    public List<JCDiagnostic> getSubdiagnostics() {
+        return List.nil();
+    }
+
+    public boolean isMultiline() {
+        return false;
+    }
+
+    /**
      * Check whether or not this diagnostic is required to be shown.
      * @return true if this diagnostic is required to be shown.
      */
@@ -440,7 +452,32 @@
     }
 
     public String getMessage(Locale locale) {
-        // RFE 6406133: JCDiagnostic.getMessage ignores locale argument
         return defaultFormatter.formatMessage(this, locale);
     }
+
+    public static class MultilineDiagnostic extends JCDiagnostic {
+
+        private final List<JCDiagnostic> subdiagnostics;
+
+        public MultilineDiagnostic(JCDiagnostic other, List<JCDiagnostic> subdiagnostics) {
+            super(other.defaultFormatter,
+                  other.getType(),
+                  other.isMandatory(),
+                  other.getDiagnosticSource(),
+                  other.position,
+                  other.getCode(),
+                  other.getArgs());
+            this.subdiagnostics = subdiagnostics;
+        }
+
+        @Override
+        public List<JCDiagnostic> getSubdiagnostics() {
+            return subdiagnostics;
+        }
+
+        @Override
+        public boolean isMultiline() {
+            return true;
+        }
+    }
 }
--- a/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java	Sun Dec 07 15:58:16 2008 -0500
@@ -39,6 +39,10 @@
      */
     final static int TabInc = 8;
 
+    /** Diagnostic standard indentation
+     */
+    final static int DiagInc = 2;
+
     /** Tabulator character.
      */
     final static byte TAB   = 0x8;
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Sun Dec 07 15:58:16 2008 -0500
@@ -190,9 +190,9 @@
         getSource(name).setEndPosTable(table);
     }
 
-    /** Return current source name.
+    /** Return current sourcefile.
      */
-    public JavaFileObject currentSource() {
+    public JavaFileObject currentSourceFile() {
         return source == null ? null : source.getFile();
     }
 
@@ -395,7 +395,7 @@
             printLines(errWriter, "error: " + msg);
         } else {
             int line = source.getLineNumber(pos);
-            JavaFileObject file = currentSource();
+            JavaFileObject file = source.getFile();
             if (file != null)
                 printLines(errWriter,
                            JavacFileManager.getJavacFileName(file) + ":" +
@@ -408,7 +408,7 @@
     /** report an error:
      */
     public void rawError(int pos, String msg) {
-        if (nerrors < MaxErrors && shouldReport(currentSource(), pos)) {
+        if (nerrors < MaxErrors && shouldReport(currentSourceFile(), pos)) {
             printRawError(pos, msg);
             prompt();
             nerrors++;
--- a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Sun Dec 07 15:58:16 2008 -0500
@@ -118,7 +118,7 @@
      * Report a mandatory warning.
      */
     public void report(DiagnosticPosition pos, String msg, Object... args) {
-        JavaFileObject currentSource = log.currentSource();
+        JavaFileObject currentSource = log.currentSourceFile();
 
         if (verbose) {
             if (sourcesWithReportedWarnings == null)
--- a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Sun Dec 07 14:50:38 2008 -0500
+++ b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Sun Dec 07 15:58:16 2008 -0500
@@ -85,6 +85,20 @@
     }
 
     @Override
+    protected String formatSubdiagnostics(JCDiagnostic d, Locale l) {
+        StringBuilder buf = new StringBuilder();
+        String sep = "";
+        buf.append(",{");
+        for (JCDiagnostic d2 : d.getSubdiagnostics()) {
+            buf.append(sep);
+            buf.append("(" + format(d2, l) + ")");
+            sep = ",";
+        }
+        buf.append('}');
+        return buf.toString();
+    }
+
+    @Override
     protected String localize(Locale l, String s, Object... args) {
         StringBuffer buf = new StringBuffer();
         buf.append(s);
--- a/test/tools/javac/generics/6711619/T6711619a.out	Sun Dec 07 14:50:38 2008 -0500
+++ b/test/tools/javac/generics/6711619/T6711619a.out	Sun Dec 07 15:58:16 2008 -0500
@@ -1,5 +1,5 @@
-T6711619a.java:63:14: compiler.err.report.access: a(), private, T6711619a.A
-T6711619a.java:64:14: compiler.err.report.access: b(), private, T6711619a.B
+T6711619a.java:63:14: compiler.err.cant.resolve.args: kindname.method, a, , 
+T6711619a.java:64:14: compiler.err.cant.resolve.args: kindname.method, b, , 
 T6711619a.java:69:19: compiler.err.report.access: a, private, T6711619a.A
 T6711619a.java:70:19: compiler.err.report.access: b, private, T6711619a.B
 T6711619a.java:71:19: compiler.err.report.access: a, private, T6711619a.A
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/overload/T6776289.java	Sun Dec 07 15:58:16 2008 -0500
@@ -0,0 +1,42 @@
+/*
+ * 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 6776289
+ * @summary Regression: javac7 doesnt resolve method calls properly
+ * @compile T6776289.java
+ */
+
+class A {
+    private void m(int a, int b) { }
+}
+
+class T6776289 {
+    static void m(int a, String s) { }
+    class B extends A {
+        public void test() {
+            m(1, "");
+        }
+    }
+}