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

Error message bug: name of initializer is 'null'

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 8
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b08
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: