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

Division by zero warning not suppressed properly in some cases

XMLWordPrintable

    • b22
    • x86
    • linux
    • Verified

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux vmware-ubuntu 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Scoping of @SuppressWarnings is not correct in the presence of final variables. This demonstrates that the compiler sometimes fails to suppress diagnostics.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the sources enclosed with

      javac -Xlint:divzero -Werror SuppressScope.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation succeeds with no diagnostics
      ACTUAL -
      Compilation fails with incorrect diagnostic and exit status nonzero.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      warning: [divzero] division by zero


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // This work is Copyright(c) 2008 Neal M Gafter. All rights reserved.
      /*
       * @test
       * @summary Test proper scoping of @SuppressWarnings in the presence of constant variables
       * @author gafter
       *
       * @clean SuppressScope
       * @compile -Xlint:divzero -Werror SuppressScope2.java
       */

      class SuppressScope2 {
          static class Y {
              final static int i = X.K + 2;
          }

          static class X {
              @SuppressWarnings("divzero")
              final static int K = 1 / 0; // warning: [divzero] division by zero
          }
      }

      ---------- END SOURCE ----------

            jlahoda Jan Lahoda
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: