langtools/test/tools/javac/warnings/DivZero.java
author jjg
Mon, 26 Jul 2010 14:18:45 -0700
changeset 6150 d055fa8ced62
parent 10 06bc494ca11e
permissions -rw-r--r--
6971882: Remove -XDstdout from javac test Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * @test  /nodynamiccopyright/
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 4759494 4986256
6150
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 10
diff changeset
     4
 * @compile/ref=DivZero.noLint.out                   -XDrawDiagnostics DivZero.java
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 10
diff changeset
     5
 * @compile/ref=DivZero.lint.out    -Xlint:divzero   -XDrawDiagnostics DivZero.java
d055fa8ced62 6971882: Remove -XDstdout from javac test
jjg
parents: 10
diff changeset
     6
 * @compile/ref=DivZero.lint.out    -Xlint:all,-path -XDrawDiagnostics DivZero.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
class DivZero
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
    public static final int ONE = 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
    public int i1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
    public static final int i2 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
    public int i3 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
    public static final int i4 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
    public static final int i5 = 1 / (1 - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
    public static final int i6 = 1 / (ONE - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
    public static final int i7 = 1 / (ONE - ONE);
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
    public  static final int i8 = 1 % (1 - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
    public  static final int i9 = 1 % (ONE - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
    public  static final int i10 = 1 % (ONE - ONE);
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
    public static final long ONEL = 1L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
    public long l1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
    public static final long l2 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
    public long l3 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
    public static final long l4 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
    public static final long l5 = 1L / (1L - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
    public static final long l6 = 1L / (ONEL - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
    public static final long l7 = 1L / (ONEL - ONEL);
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    public  static final long l8 = 1L % (1L - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
    public  static final long l9 = 1L % (ONEL - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
    public  static final long l10 = 1L % (ONEL - ONEL);
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    static void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        int mi1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        int mi2 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        mi1 /= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        mi1 %= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        long ml1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        long ml2 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        ml1 /= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        ml1 %= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
@SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
class DivZero2
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    public static final int ONE = 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    public int i1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public static final int i2 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public int i3 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public static final int i4 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    public static final int i5 = 1 / (1 - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    public static final int i6 = 1 / (ONE - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public static final int i7 = 1 / (ONE - ONE);
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public  static final int i8 = 1 % (1 - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    public  static final int i9 = 1 % (ONE - 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    public  static final int i10 = 1 % (ONE - ONE);
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    public static final long ONEL = 1L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    public long l1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public static final long l2 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public long l3 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public static final long l4 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public static final long l5 = 1L / (1L - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public static final long l6 = 1L / (ONEL - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public static final long l7 = 1L / (ONEL - ONEL);
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    public  static final long l8 = 1L % (1L - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    public  static final long l9 = 1L % (ONEL - 1L);
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    public  static final long l10 = 1L % (ONEL - ONEL);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    static void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        int mi1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        int mi2 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        mi1 /= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        mi1 %= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        long ml1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        long ml2 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        ml1 /= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        ml1 %= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
}
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
class DivZero3
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
{
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public int i1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    public static final int i2 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    public int i3 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    public static final int i4 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    public long l1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    public static final long l2 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    public long l3 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    public static final long l4 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    @SuppressWarnings("divzero")
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    static void m() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        int mi1 = 1 / 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        int mi2 = 1 % 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        mi1 /= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        mi1 %= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        long ml1 = 1L / 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        long ml2 = 1L % 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        ml1 /= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        ml1 %= 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
}