Error message bug: name of initializer is 'null'

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 8
    • Affects Version/s: 7
    • Component/s: 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.

              Assignee:
              Maurizio Cimadamore
              Reporter:
              Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: