test/runtime/jni/CallWithJNIWeak/CallWithJNIWeak.java

Fri, 10 May 2019 18:50:40 +0000

author
phh
date
Fri, 10 May 2019 18:50:40 +0000
changeset 9671
e86bc9786d83
permissions
-rw-r--r--

8223664: Add jtreg tests for 8223528, backport to jdk8u of 8176100
Summary: Add hotspot/test/runtime/jni directory with two tests for 8176100
Reviewed-by: kbarrett, coleenp, tschatzl

     1 /*
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 public class CallWithJNIWeak {
    25     static {
    26         System.loadLibrary("CallWithJNIWeak");
    27     }
    29     private static native void testJNIFieldAccessors(CallWithJNIWeak o);
    31     // The field initializations must be kept in sync with the JNI code
    32     // which reads verifies the values of these fields.
    33     private int i = 1;
    34     private long j = 2;
    35     private boolean z = true;
    36     private char c = 'a';
    37     private short s = 3;
    38     private float f = 1.0f;
    39     private double d = 2.0;
    40     private Object l;
    42     private CallWithJNIWeak() {
    43         this.l = this;
    44     }
    46     private native void weakReceiverTest0();
    47     private void weakReceiverTest() {
    48         weakReceiverTest0();
    49     }
    51     private synchronized void synchonizedWeakReceiverTest() {
    52         this.notifyAll();
    53     }
    55     private static native void runTests(CallWithJNIWeak o);
    57     public static void main(String[] args) {
    58         CallWithJNIWeak w = new CallWithJNIWeak();
    59         for (int i = 0; i < 20000; i++) {
    60             runTests(w);
    61         }
    62     }
    63 }

mercurial