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

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

mercurial