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

-nowarn option supresses error message

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Description



      Name: laC46010 Date: 07/22/97



      As a rule javac report an error in case when several public classes
      are defined in the single compilation, unit.

      > javac -J-version t.java
      java version "1.1.3"
      > javac t.java
      t.java:1: Public class a must be defined in a file called "a.java".
      public class a {}
                   ^
      t.java:2: Public class b must be defined in a file called "b.java".
      public class b {}
                   ^
      2 errors

      However under -nowarn option javac doesn't report that error
      and generates class files:

      > javac -nowarn t.java
      > ls -l
      total 3
      -rw-rw-r-- 1 leo java 229 Jul 22 17:14 a.class
      -rw-rw-r-- 1 leo java 229 Jul 22 17:14 b.class
      -rw-rw-r-- 1 leo java 37 Jul 22 10:47 t.java

      "-nowarn" option may supress only warnings not errors.

      As result of this bug several JCK tests are failed
      (because JavaTest harness runs javac with "-nowarn" option):

      lang/CLSS/clss014/clss01401/clss01401.html
      lang/CLSS/clss014/clss01402/clss01402.html
      lang/CLSS/clss014/clss01405/clss01405.html

      --------------------t.java----------------------
      public class a {}
      public class b {}
      ------------------------------------------------

      This message was treated as warning in jdk1.0.2.
      In jdk1.1 it was changed to be an error but it seems like
      dependency from -nowarn was not removed properly from source:

      SourceClass.java:

      if (env.warnings() && !src.equals(fname)) {
      if (isPublic()) {
      env.error(where, "public.class.file", this, fname);
      } else {
      env.error(where, "warn."+"package.class.file", this, src, fname);
      }
      }

      It could be rewritten more correctly as

      if (!src.equals(fname)) {
      if (isPublic()) {
      env.error(where, "public.class.file", this, fname);
      } else if (env.warnings()) {
      env.error(where, "warn."+"package.class.file", this, src, fname);
      }
      }


      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            dstoutamsunw David Stoutamire (Inactive)
            Reporter:
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: