hotspot/test/runtime/Final/TestPutMain.java
author rriggs
Wed, 12 Apr 2017 11:43:49 -0400
changeset 44633 d2f5e8921045
parent 41705 332239c052cc
permissions -rw-r--r--
8178347: Process and ProcessHandle getPid method name inconsistency Reviewed-by: hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39699
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     1
/*
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     4
 *
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     8
 *
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    13
 * accompanied this code).
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    14
 *
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    18
 *
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    21
 * questions.
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    22
 */
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    23
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    24
/*
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    25
 * @test
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    26
 * @bug 8160527
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    27
 * @summary The VM does not always perform checks added by 8157181 when updating final instance fields
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39699
diff changeset
    28
 * @library /test/lib
39699
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    29
 * @compile TestPutField.jasm
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    30
 * @compile TestPutStatic.jasm
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    31
 * @compile TestPutMain.java
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    32
 * @run main/othervm TestPutMain
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    33
 */
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    34
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    35
import jdk.test.lib.Asserts;
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    36
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    37
public class TestPutMain {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    38
    public static void main(String[] args) {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    39
        boolean exception = false;
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    40
        try {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    41
            TestPutField.test();
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    42
        } catch (java.lang.IllegalAccessError e) {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    43
            exception = true;
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    44
        }
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    45
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    46
        Asserts.assertTrue(exception, "FAILED: Expected IllegalAccessError for illegal update to final instance field was not thrown.");
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    47
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    48
        exception = false;
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    49
        try {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    50
            TestPutStatic.test();
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    51
        } catch (java.lang.IllegalAccessError e) {
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    52
            exception = true;
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    53
        }
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    54
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    55
        Asserts.assertTrue(exception, "FAILED: Expected IllegalAccessError for illegal update to final static field was not thrown.");
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    56
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    57
        System.out.println("PASSED: Expected IllegalAccessError was thrown.");
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    58
    }
7a2a49fd5ee0 8160527: Check for final instance field updates can be omitted
zmajo
parents:
diff changeset
    59
}