JDK-6707032 : Division by zero warning not suppressed properly in some cases
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2008-05-26
  • Updated: 2014-07-10
  • Resolved: 2014-06-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b22Fixed
Related Reports
Relates :  
Description
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 ----------