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

AssertException has wrong source line number

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • tools
    • x86
    • windows_2000



      Name: bsC130419 Date: 06/18/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      I've written a trivial test program to try out the new Assertion facility in JDK
      1.4, and I notice that the AssertException that is thrown in my simple test
      program contains the wrong line number as the origin of the exception. Instead
      of showing line 8 as the line where the exception occurred, it shows line 1.
      Here's the test program:

      cindercone% cat AssertTest.java
      class AssertTest {
         public static void main(String[] args) {
            System.out.println("Start of 1st assert test");
            assert 1==1;
            System.out.println("End of 1st assert test");

            System.out.println("Start of 2nd assert test");
            assert 1==5;
            System.out.println("End of 2nd assert test");
         }
      }
      % javac -source 1.4 AssertTest.java
      % java -ea AssertTest
      Start of 1st assert test
      End of 1st assert test
      Start of 2nd assert test
      Exception in thread "main" java.lang.AssertionError
              at AssertTest.main(AssertTest.java:1)
      %

      ------------------------------------------------

      (Review ID: 126752)
      ======================================================================

            gafter Neal Gafter (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: