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

javadoc does not parse valid assert statements that javac accepts

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • tools
    • beta3
    • generic, sparc
    • generic, solaris_7
    • Verified

      JSR 41 has added a simple assertion facility to Java. In the proposed final draft, assert statements have one of two forms:

      assert Expr_1;
      assert Expr_1:Expr_2;

      Both of these forms, with and without parentheses around Expr_1 and Expr_2, are recognized by javac when the "-source 1.4" flag is used. However, javadoc (Standard Doclet version 1.4 beta (04 Aug 2001)) only recognizes

      assert(Expr)
      and
      assert (Expr)

      independent of whether or not the "-source 1.4" flag is used. In particular, the program

      /**
       * JavaDoc for AssertTest2
       */

      public class AssertTest2 {

          public static void main(String argv[]) {
      assert true;
      assert true:true;
      assert(true):true;
      assert (true):true;
      assert true:(true);
      assert(true):(true);
      assert (true):(true);
          }
      }

      compiles with javac -source 1.4 but javadoc generates an error for each line of input. By commenting out all preceeding assert lines, I verified each line is rejected by itself; i.e. the 2nd and subsequent assert statements are *not* rejected because of poor "error" recovery in javadoc for the first "mistaken" line, "assert true".

      Moreover, javadoc accepts the previous two-arg assert construction

      assert(Expr_1, Expr_2); // no longer valid

      Concretely,

      /**
       * JavaDoc for AssertTest3
       */

      public class AssertTest3 {

          public static void main(String argv[]) {
      assert(true, true);
      assert (true, true);
          }

      }

      Is parsed by javadoc but rejected by javac. This should be fixed.

            gafter Neal Gafter (Inactive)
            darcy Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: