test/hotspot/jtreg/compiler/c2/TestNPEHeapBased.java
author shade
Fri, 08 Jun 2018 11:41:43 +0200
changeset 50463 929cd9246fc9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8204479: Bitwise AND on byte value sometimes produces wrong result Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44403
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     1
/*
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     3
 * Copyright (c) 2017 SAP SE. All rights reserved.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     5
 *
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     8
 * published by the Free Software Foundation.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
     9
 *
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    14
 * accompanied this code).
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    15
 *
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    19
 *
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    22
 * questions.
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    23
 */
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    24
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    25
/**
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    26
 * @test
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    27
 * @bug 8176518
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    28
 * @summary Invalid ImplicitNullChecks when heap base not protected
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    29
 *
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    30
 * @run main/othervm -XX:ObjectAlignmentInBytes=16 -XX:HeapBaseMinAddress=64g
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    31
 *      -XX:-TieredCompilation -Xbatch
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    32
 *      compiler.c2.TestNPEHeapBased
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    33
 * @requires vm.bits == "64"
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    34
 */
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    35
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    36
package compiler.c2;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    37
public class TestNPEHeapBased {
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    38
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    39
    TestNPEHeapBased instance = null;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    40
    int i = 0;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    41
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    42
    public void set_i(int value) {
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    43
        instance.i = value;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    44
    }
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    45
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    46
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    47
    static final int loop_cnt = 200000;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    48
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    49
    public static void main(String args[]){
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    50
        TestNPEHeapBased xyz = new TestNPEHeapBased();
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    51
        xyz.instance = xyz;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    52
        for (int x = 0; x < loop_cnt; x++) xyz.set_i(x);
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    53
        xyz.instance = null;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    54
        try {
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    55
            xyz.set_i(0);
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    56
        } catch (NullPointerException npe) {
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    57
            System.out.println("Got expected NullPointerException:");
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    58
            npe.printStackTrace();
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    59
            return;
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    60
        }
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    61
        throw new InternalError("NullPointerException is missing!");
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    62
    }
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    63
1b4e73257070 8176518: C2: Invalid ImplicitNullChecks with non-protected heap base
mdoerr
parents:
diff changeset
    64
}