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

Line number information for asserts is misleading

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • tools
    • None
    • beta2
    • generic, x86
    • generic, windows_2000
    • Verified

      javac could do a better job with line number reporting.
      All the assertion compiler messages, and AssertionErrors generated at
      runtime, refer to line 1 of the file, when it would be better to refer to
      the line where the assert statement actually occurs; in this example, the
      stack trace should refer to Foo.main(Foo.java:5).

      $ cat Foo.java
      class Foo { // 1
        public static // 2
        void main // 3
        (String[] a) { // 4
          assert false; // 5
        } // 6
      } // 7
      $ javac -source 1.4 Foo.java
      $ java -ea Foo
      Exception in thread "main" java.lang.AssertionError
              at Foo.main(Foo.java:1)

            gafter Neal Gafter (Inactive)
            jjb Josh Bloch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: