Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7086595

Error message bug: name of initializer is 'null'

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 7
    • tools
    • b08
    • generic
    • generic
    • Verified

        An error message that is supposed to print a method name instead prints 'null' when the error occurs inside of an initializer block.

        public class InitializerError {

          int foo() {
            String s = "x";
            String s = "y";
          }

          static int bar() {
            String s = "x";
            String s = "y";
          }

          {
            String s = "x";
            String s = "y";
          }

          static {
            String s = "x";
            String s = "y";
          }

        }

        Output:

        InitializerError.java:5: error: s is already defined in foo()
            String s = "y";
                   ^
        InitializerError.java:10: error: s is already defined in bar()
            String s = "y";
                   ^
        InitializerError.java:15: error: s is already defined in null
            String s = "y";
                   ^
        InitializerError.java:20: error: s is already defined in null
            String s = "y";
                   ^
        4 errors

        In javac 6, the error message was different, but also bad -- it used an empty string as the method name.

              mcimadamore Maurizio Cimadamore
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: