|
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 */ |
|
23 |
|
24 public class CallWithJNIWeak { |
|
25 static { |
|
26 System.loadLibrary("CallWithJNIWeak"); |
|
27 } |
|
28 |
|
29 private static native void testJNIFieldAccessors(CallWithJNIWeak o); |
|
30 |
|
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; |
|
41 |
|
42 private CallWithJNIWeak() { |
|
43 this.l = this; |
|
44 } |
|
45 |
|
46 private native void weakReceiverTest0(); |
|
47 private void weakReceiverTest() { |
|
48 weakReceiverTest0(); |
|
49 } |
|
50 |
|
51 private synchronized void synchonizedWeakReceiverTest() { |
|
52 this.notifyAll(); |
|
53 } |
|
54 |
|
55 private static native void runTests(CallWithJNIWeak o); |
|
56 |
|
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 } |