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

assert facility doc should mention required "javac" option "-source 1.4"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • docs
    • beta2
    • x86
    • linux

      prev. synopsis:
      "assert boolean_expr;" does not compile (in the first public 1.4 beta, build 65)

      27 May 2001, eval1127@eng -- this was originally filed as a compiler bug.
      However, the compiler group notes that "-source 1.4" must be passed to javac
      in order for the assert capability to work. Unfortunately, the assert facility
      doc at:

          http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html

      refers to "java" runtime options that must/can be used, but does not mention
      "javac" options or requirements. The "-source 1.4" option should be mentioned
      on that page, so users can quickly discover it's a requirement for successful
      compilation.


      Name: krC82822 Date: 05/27/2001


      27 May 2001, eval1127@eng -- bug # 4446137 indicates that this has been
      fixed as of merlin-beta2. However, as of today, the problem is still
      reproducible with the latest beta-refresh build (see Comments).
      Thus, I am filing a new bug, if only to clarify the build(s) in which
      this bug's fix will appear.
      -----------
      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)

      assert does not work as described:
      CODE:
      public class AssertTest{

              public void f(int i){
                      assert (i == 42); // also does not work WITHOUT parentheses
              }

              public static void main(String[] args){
                      AssertTest a = new AssertTest();
                      a.f(42);
              }
      }

      TRY TO COMPILE IT:
      /home/jd> javac AssertTest.java
      AssertTest.java:4: warning: as of release 1.4, assert is a keyword, and may not
      be used as an identifier
                      assert (i == 42);
                      ^
      AssertTest.java:4: cannot resolve symbol
      symbol : method assert (boolean)
      location: class AssertTest
                      assert (i == 42);
                      ^
      1 error
      1 warning
      (Review ID: 125190)
      ======================================================================

            asommere Alan Sommerer (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: