author | jcbeyler |
Wed, 21 Nov 2018 09:38:27 -0800 | |
changeset 52640 | 3a7d49718852 |
parent 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
1 |
/* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
4 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
8 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
13 |
* accompanied this code). |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
14 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
18 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
21 |
* questions. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
22 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
23 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
24 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
25 |
/* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
26 |
* @test |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
27 |
* @key stress |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
28 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
29 |
* @summary converted from VM testbase nsk/stress/except/except004. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
30 |
* VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick] |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
31 |
* VM testbase readme: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
32 |
* DESCRIPTION |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
33 |
* This checks if various exceptions are thrown (and caught) correctly |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
34 |
* when there apparently are no free space in the heap to allocate new |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
35 |
* Throwable instance. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
36 |
* The test tries to occupy all of memory available in the heap by allocating |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
37 |
* lots of new Object() instances. Instances of the type Object are the smallest |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
38 |
* objects, so they apparently should occupy most fine-grained fragments in the |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
39 |
* heap and leave no free space for new Throwable instance. After that, the test |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
40 |
* provokes various exceptions (e.g.: by executing integer division by 0 and so |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
41 |
* on), and checks if appropriate exceptions are thrown. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
42 |
* COMMENTS |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
43 |
* The test needs a lot of memory to start up, so it should not run under older |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
44 |
* JDK 1.1.x release due to its poorer heap utilization. Also, some checks are |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
45 |
* skipped when testing classic VM, because OutOfMemoryError is correctly thrown |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
46 |
* instead of target exception. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
47 |
* When the test is being self-initiating (i.e.: eating heap), memory occupation |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
48 |
* is terminated if memory allocation slows down crucially. This is a workaround |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
49 |
* intended to avoid the HotSpot bug: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
50 |
* #4248801 (P1/S5) slow memory allocation when heap is almost exhausted |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
51 |
* There is also a workaround involved to avoid the following bugs known |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
52 |
* for HotSpot and for classic VM: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
53 |
* #4239841 (P1/S5) 1.1: poor garbage collector performance (HotSpot bug) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
54 |
* #4245060 (P4/S5) poor garbage collector performance (Classic VM bug) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
55 |
* However, printing of the test's error messages, warnings, and of execution |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
56 |
* trace fails under JDK 1.2 for Win32 even so. If the test fails due to this |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
57 |
* problem, exit status 96 is returned instead of 97. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
58 |
* JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
59 |
* #4245057 (P2/S3) VM crashes when heap is exhausted |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
60 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
61 |
* @run main/othervm -Xms50M -Xmx200M -XX:-UseGCOverheadLimit nsk.stress.except.except004 |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
62 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
63 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
64 |
package nsk.stress.except; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
65 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
66 |
import java.io.PrintStream; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
67 |
import java.lang.reflect.Field; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
68 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
69 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
70 |
* This checks if various exceptions are thrown (and caught) correctly |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
71 |
* when there apparently are no free space in the heap to allocate new |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
72 |
* <code>Throwable</code> instance. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
73 |
* <p> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
74 |
* <p>The test tries to occupy all of memory available in the heap by |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
75 |
* allocating lots of new <code>Object()</code> instances. Instances of the |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
76 |
* type <code>Object</code> are the smallest objects, so they apparently should |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
77 |
* occupy most fine-grained fragments in the heap and leave no free space for |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
78 |
* new <code>Throwable</code> instance. After that, the test provokes various |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
79 |
* exceptions (e.g.: by executing integer division by 0 and so on), and checks |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
80 |
* if appropriate exceptions are thrown. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
81 |
* <p> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
82 |
* <p>Note, that memory occupation is terminated if memory allocation slows |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
83 |
* down crucially. This is a workaround intended to avoid the HotSpot bug: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
84 |
* <br> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
85 |
* #4248801 (P1/S5) slow memory allocation when heap is almost exhausted |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
86 |
* <p> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
87 |
* <p>There is also a workaround involved to avoid the following bugs known |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
88 |
* for HotSpot and for classic VM: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
89 |
* <br> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
90 |
* #4239841 (P1/S5) 1.1: poor garbage collector performance |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
91 |
* <br> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
92 |
* #4245060 (P4/S5) poor garbage collector performance |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
93 |
* <br>However, printing of the test's error messages, warnings, and of |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
94 |
* execution trace may fail even so. If the test fails due to poor GC |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
95 |
* performance, exit status 96 is returned instead of 97. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
96 |
* <p> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
97 |
* <p>Also note, that the test needs a lot of memory to start up, so it should |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
98 |
* not run under older JDK 1.1.x release due to its poor heap utilization. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
99 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
100 |
public class except004 { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
101 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
102 |
* Either allow or supress printing of execution trace. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
103 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
104 |
private static boolean TRACE_ON = false; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
105 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
106 |
* Either allow or supress printing of warning messages. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
107 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
108 |
private static final boolean WARN_ON = true; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
109 |
/* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
110 |
* Storage for a lot of tiny objects |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
111 |
* "static volatile" keywords are for preventing heap optimization |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
112 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
113 |
private static volatile Object pool[] = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
114 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
115 |
* Temporary <code>log</code> for error messages, warnings and/or execution trace. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
116 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
117 |
* @see #messages |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
118 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
119 |
private static String log[] = new String[1000]; // up to 1000 messages |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
120 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
121 |
* How many <code>messages</code> were submitted to the <code>log</code>. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
122 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
123 |
* @see #log |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
124 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
125 |
private static int messages = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
126 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
127 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
128 |
* Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>), |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
129 |
* and print the test summary - either test passed of failed. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
130 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
131 |
public static int run(String args[], PrintStream out) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
132 |
if (args.length > 0) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
133 |
if (args[0].toLowerCase().startsWith("-v")) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
134 |
TRACE_ON = true; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
135 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
136 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
137 |
int exitCode; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
138 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
139 |
exitCode = run(out); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
140 |
} finally { // ensure we have free memory for exception processing |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
141 |
pool = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
142 |
System.gc(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
143 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
144 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
145 |
out.println("Test completed."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
146 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
147 |
// Print the log[] and the test summary: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
148 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
149 |
for (int i = 0; i < messages; i++) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
150 |
out.println(log[i]); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
151 |
if (exitCode == 0) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
152 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
153 |
out.println("Test passed."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
154 |
} else |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
155 |
out.println("Test failed."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
156 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
157 |
// Poor performance of garbage collector: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
158 |
exitCode = 1; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
159 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
160 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
161 |
return exitCode; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
162 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
163 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
164 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
165 |
* Allocate as much <code>Object</code> instances as possible to bring JVM |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
166 |
* into stress, and then check if exceptions are correctly thrown accordingly |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
167 |
* to various situations like integer division by 0, etc. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
168 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
169 |
private static int run(PrintStream out) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
170 |
out.println("# While printing this message, JVM seems to initiate the output"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
171 |
out.println("# stream, so that it will not need more memory to print later,"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
172 |
out.println("# when the heap would fail to provide more memory."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
173 |
out.println("# "); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
174 |
out.println("# Note, that the test maintains especial static log[] field in"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
175 |
out.println("# order to avoid printing when the heap seems exhausted."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
176 |
out.println("# Nevertheless, printing could cause OutOfMemoryError even"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
177 |
out.println("# after all the memory allocated by the test is released."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
178 |
out.println("# "); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
179 |
out.println("# That problem is caused by the known JDK/HotSpot bugs:"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
180 |
out.println("# 4239841 (P1/S5) 1.1: poor garbage collector performance"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
181 |
out.println("# 4245060 (P4/S5) poor garbage collector performance"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
182 |
out.println("# "); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
183 |
out.println("# This message is just intended to work-around that problem."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
184 |
out.println("# If printing should fail even so, the test will return the"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
185 |
out.println("# exit status 96 instead of 97 to indicate the problem."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
186 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
187 |
// run all tests normally to ensure all needed classes are loaded and |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
188 |
// initialized before the heap is exhausted - else we may trigger OOME |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
189 |
// in unexpected places. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
190 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
191 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
192 |
out.println("Running without heap exhaustion"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
193 |
runTests(out, false); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
194 |
} catch (Throwable unexpected) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
195 |
out.println("Test pre-initialisation failed: " + unexpected); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
196 |
return 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
197 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
198 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
199 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
200 |
out.println("Running with heap exhaustion"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
201 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
202 |
return runTests(out, true); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
203 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
204 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
205 |
private static int runTests(PrintStream out, boolean exhaustHeap) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
206 |
// reset message index |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
207 |
messages = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
208 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
209 |
// Prepare some items, which will be used by the test: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
210 |
Object stringArray[] = new String[1]; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
211 |
Object integerValue = new Integer(0); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
212 |
Object doubleValue = new Double(0); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
213 |
Object trash = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
214 |
Field abraIntegerField; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
215 |
Field abraBooleanField; |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
216 |
Field extPrivateField; |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
217 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
218 |
abraIntegerField = Abra.class.getDeclaredField("MAIN_CYR_NUMBER"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
219 |
abraBooleanField = Abra.class.getDeclaredField("NOT_AN_INTEGER"); |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
220 |
extPrivateField = Ext.class.getDeclaredField("DONT_TOUCH_ME"); |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
221 |
} catch (NoSuchFieldException nsfe) { |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
222 |
out.println("Test initialisation failed: field not found: " + nsfe.getMessage()); |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
223 |
return 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
224 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
225 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
226 |
Abra abra = new Abra("via public constructor"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
227 |
Abra.Cadabra cadabra = new Abra.Cadabra(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
228 |
// Sum up exit code: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
229 |
int exitCode = 0; // apparently PASSED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
230 |
int skipped = 0; // some checks may correctly suffer OutOfMemoryError |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
231 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
232 |
int poolSize = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
233 |
int index = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
234 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
235 |
if (exhaustHeap) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
236 |
pool = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
237 |
// Allocate repository for lots of tiny objects: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
238 |
for (int size = 1 << 30; size > 0 && pool == null; size >>= 1) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
239 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
240 |
pool = new Object[size]; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
241 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
242 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
243 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
244 |
if (pool == null) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
245 |
throw new Error("HS bug: cannot allocate new Object[1]"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
246 |
poolSize = pool.length; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
247 |
index = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
248 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
249 |
// Sum up time spent, when it was hard for JVM to allocate next object |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
250 |
// (i.e.: when JVM has spent more than 1 second to allocate new object): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
251 |
double totalDelay = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
252 |
long timeMark = System.currentTimeMillis(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
253 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
254 |
for (; index < poolSize; index++) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
255 |
//------------------------- |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
256 |
pool[index] = new Object(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
257 |
long nextTimeMark = System.currentTimeMillis(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
258 |
long elapsed = nextTimeMark - timeMark; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
259 |
timeMark = nextTimeMark; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
260 |
//---------------------- |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
261 |
if (elapsed > 1000) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
262 |
double seconds = elapsed / 1000.0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
263 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
264 |
out.println( |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
265 |
"pool[" + index + "]=new Object(); // elapsed " + seconds + "s"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
266 |
totalDelay += seconds; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
267 |
if (totalDelay > 60) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
268 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
269 |
out.println( |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
270 |
"Memory allocation became slow; so, heap seems exhausted."); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
271 |
break; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
272 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
273 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
274 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
275 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
276 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
277 |
log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown."; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
278 |
// Do not release any byte once allocated: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
279 |
pool[index++] = oome; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
280 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
281 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
282 |
if (index > poolSize - 1000) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
283 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
284 |
log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard..."; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
285 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
286 |
} else { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
287 |
// pool gets used for array index tests |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
288 |
pool = new Object[3]; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
289 |
poolSize = pool.length; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
290 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
291 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
292 |
// Check ArithmeticException: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
293 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
294 |
int x, y, z; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
295 |
x = y = 0; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
296 |
z = x / y; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
297 |
log[messages++] = "Failure: ArithmeticException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
298 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
299 |
} catch (ArithmeticException ae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
300 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
301 |
log[messages++] = "Success: ArithmeticException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
302 |
if (exhaustHeap) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
303 |
pool[index++] = ae; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
304 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
305 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
306 |
log[messages++] = "Skipped: ArithmeticException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
307 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
308 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
309 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
310 |
// Check ArrayIndexOutOfBoundsException: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
311 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
312 |
pool[poolSize] = pool[0]; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
313 |
log[messages++] = "Failure: ArrayIndexOutOfBoundsException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
314 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
315 |
} catch (ArrayIndexOutOfBoundsException aioobe) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
316 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
317 |
log[messages++] = "Success: ArrayIndexOutOfBoundsException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
318 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
319 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
320 |
log[messages++] = "Skipped: ArrayIndexOutOfBoundsException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
321 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
322 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
323 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
324 |
// Check ArrayStoreException: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
325 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
326 |
stringArray[0] = integerValue; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
327 |
log[messages++] = "Failure: ArrayStoreException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
328 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
329 |
} catch (ArrayStoreException ase) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
330 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
331 |
log[messages++] = "Success: ArrayStoreException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
332 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
333 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
334 |
log[messages++] = "Skipped: ArrayStoreException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
335 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
336 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
337 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
338 |
// Check ClassCastException: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
339 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
340 |
trash = (Double) integerValue; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
341 |
log[messages++] = "Failure: ClassCastException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
342 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
343 |
} catch (ClassCastException cce) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
344 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
345 |
log[messages++] = "Success: ClassCastException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
346 |
if (exhaustHeap) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
347 |
pool[index++] = cce; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
348 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
349 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
350 |
log[messages++] = "Skipped: ClassCastException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
351 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
352 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
353 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
354 |
// Check CloneNotSupportedException: |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
355 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
356 |
trash = abra.clone(); // illegal - should fail |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
357 |
// trash = cadabra.clone(); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
358 |
log[messages++] = "Failure: CloneNotSupportedException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
359 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
360 |
} catch (CloneNotSupportedException cnse) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
361 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
362 |
log[messages++] = "Success: CloneNotSupportedException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
363 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
364 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
365 |
log[messages++] = "Skipped: CloneNotSupportedException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
366 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
367 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
368 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
369 |
// Check IllegalAccessException (positive): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
370 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
371 |
int junkIt = abraIntegerField.getInt(null); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
372 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
373 |
log[messages++] = "Success: IllegalAccessException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
374 |
} catch (IllegalAccessException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
375 |
log[messages++] = "Failure: IllegalAccessException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
376 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
377 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
378 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
379 |
log[messages++] = "Skipped: IllegalAccessException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
380 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
381 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
382 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
383 |
// Check IllegalAccessException (negative): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
384 |
try { |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
385 |
int junkIt = extPrivateField.getInt(null); // illegal - should fail |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
386 |
log[messages++] = "Failure: IllegalAccessException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
387 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
388 |
} catch (IllegalAccessException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
389 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
390 |
log[messages++] = "Success: IllegalAccessException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
391 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
392 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
393 |
log[messages++] = "Skipped: IllegalAccessException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
394 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
395 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
396 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
397 |
// Check IllegalArgumentException (positive): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
398 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
399 |
int junkIt = abraIntegerField.getInt(null); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
400 |
// int junkIt = abraBooleanField.getInt(null); // illegal - should fail |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
401 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
402 |
log[messages++] = "Success: IllegalArgumentException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
403 |
} catch (IllegalAccessException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
404 |
log[messages++] = |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
405 |
"Failure: IllegalArgumentException (positive) incorrectly thrown IllegalAccessException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
406 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
407 |
} catch (IllegalArgumentException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
408 |
log[messages++] = "Failure: IllegalArgumentException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
409 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
410 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
411 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
412 |
log[messages++] = "Skipped: IllegalArgumentException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
413 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
414 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
415 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
416 |
// Check IllegalArgumentException (negative): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
417 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
418 |
// int junkIt = abraIntegerField.getInt(null); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
419 |
int junkIt = abraBooleanField.getInt(null); // illegal - should fail |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
420 |
log[messages++] = "Failure: IllegalArgumentException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
421 |
exitCode = 2; // FAILED |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
422 |
} catch (IllegalAccessException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
423 |
log[messages++] = |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
424 |
"Failure: IllegalArgumentException (negative) incorrectly thrown IllegalAccessException"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
425 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
426 |
} catch (IllegalArgumentException iae) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
427 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
428 |
log[messages++] = "Success: IllegalArgumentException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
429 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
430 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
431 |
log[messages++] = "Skipped: IllegalArgumentException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
432 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
433 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
434 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
435 |
// Check IllegalMonitorStateException (positive): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
436 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
437 |
synchronized (cadabra) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
438 |
cadabra.notifyAll(); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
439 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
440 |
// cadabra.notifyAll(); // illegal - should fail |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
441 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
442 |
log[messages++] = "Success: IllegalMonitorStateException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
443 |
} catch (IllegalMonitorStateException imse) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
444 |
log[messages++] = "Failure: IllegalMonitorStateException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
445 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
446 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
447 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
448 |
log[messages++] = "Skipped: IllegalMonitorStateException (positive)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
449 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
450 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
451 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
452 |
// Check IllegalMonitorStateException (negative): |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
453 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
454 |
// synchronized (cadabra) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
455 |
// cadabra.notifyAll(); // legal - should pass |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
456 |
// } |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
457 |
cadabra.notifyAll(); // illegal - should fail |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
458 |
log[messages++] = "Failure: IllegalMonitorStateException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
459 |
exitCode = 2; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
460 |
} catch (IllegalMonitorStateException imse) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
461 |
if (TRACE_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
462 |
log[messages++] = "Success: IllegalMonitorStateException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
463 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
464 |
if (WARN_ON) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
465 |
log[messages++] = "Skipped: IllegalMonitorStateException (negative)"; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
466 |
skipped++; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
467 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
468 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
469 |
return exitCode; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
470 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
471 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
472 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
473 |
* Re-call to <code>run(args,out)</code>, and return JCK-like exit status. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
474 |
* (The stream <code>out</code> is assigned to <code>System.out</code> here.) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
475 |
* |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
476 |
* @see #run(String[], PrintStream) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
477 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
478 |
public static void main(String args[]) { |
52640
3a7d49718852
8213721: [Graal] Tests vmTestbase/nsk/stress/except/except* may be encountering SEGV during out-of-memory conditions
jcbeyler
parents:
50735
diff
changeset
|
479 |
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
480 |
// Last try. If there is some exception outside the code, test should end correctly |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
481 |
@Override |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
482 |
public void uncaughtException(Thread t, Throwable e) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
483 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
484 |
pool = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
485 |
log = null; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
486 |
System.gc(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
487 |
if (e instanceof OutOfMemoryError) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
488 |
try { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
489 |
System.out.println("OOME : Test Skipped"); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
490 |
System.exit(0); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
491 |
} catch (Throwable ignore) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
492 |
} // No code in the handler can provoke correct exceptions. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
493 |
} else { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
494 |
e.printStackTrace(); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
495 |
if (e instanceof RuntimeException) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
496 |
throw (RuntimeException) e; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
497 |
else if (e instanceof Error) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
498 |
throw (Error) e; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
499 |
else |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
500 |
throw new Error("Unexpected checked exception", e); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
501 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
502 |
} catch (OutOfMemoryError oome) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
503 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
504 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
505 |
}); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
506 |
int exitCode = run(args, System.out); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
507 |
System.exit(exitCode + 95); |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
508 |
// JCK-like exit status. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
509 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
510 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
511 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
512 |
* This class should be used to check <code>CloneNotSupportedException</code>, |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
513 |
* and <code>IllegalArgumentException</code>. |
50169
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
514 |
* The class extends <code>except004</code> in order that its (protected) |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
515 |
* method <code>clone()</code> be available from <code>except004</code>. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
516 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
517 |
private static class Abra extends except004 { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
518 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
519 |
* Will try to incorrectly find this class as <code>Cadabra</code> |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
520 |
* instead of <code>Abra$Cadabra</code>. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
521 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
522 |
public static class Cadabra implements Cloneable { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
523 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
524 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
525 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
526 |
* Will try to incorrectly access to this field from outside this class. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
527 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
528 |
public static final int MAIN_CYR_NUMBER = 47; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
529 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
530 |
* Will try to get this field like <code>int<code> zero. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
531 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
532 |
public static final boolean NOT_AN_INTEGER = false; |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
533 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
534 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
535 |
* Will try to correctly instantiate <code>Abra.Cadabra</code>, |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
536 |
* not <code>Abra</code>. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
537 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
538 |
private Abra() { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
539 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
540 |
|
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
541 |
/** |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
542 |
* Yet another constructor, which is <code>public</code>. |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
543 |
*/ |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
544 |
public Abra(String nothingSpecial) { |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
545 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
546 |
} |
dd501973095c
8199271: [TESTBUG] open source VM testbase stress tests
lmesnik
parents:
diff
changeset
|
547 |
} |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
548 |
|
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
549 |
/* Package accessible class that has non-accessible private member */ |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
550 |
class Ext { |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
551 |
/** |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
552 |
* Will try to incorrectly access to this field from outside this class. |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
553 |
*/ |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
554 |
private static final int DONT_TOUCH_ME = 666; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
50169
diff
changeset
|
555 |
} |