8220743: [TESTBUG] Review Runtime tests recently migrated from JDK subdirs
Removed tests that will not find bugs in current code base. Reviewed-by: lfoltan, hseigel
This commit is contained in:
parent
2b048e0808
commit
f5cb284275
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4221448
|
||||
* @summary Use explicit check for integer arithmetic exception on win32.
|
||||
*/
|
||||
|
||||
public class ExplicitArithmeticCheck {
|
||||
public static void main(String argv[]) throws Exception {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
boolean result = false;
|
||||
int n;
|
||||
try {
|
||||
n = 0 / 0;
|
||||
} catch (ArithmeticException e) {
|
||||
result = true;
|
||||
}
|
||||
if (result == false) {
|
||||
throw new Error("Failed to throw correct exception!");
|
||||
}
|
||||
result = false;
|
||||
try {
|
||||
n = 0 % 0;
|
||||
} catch (ArithmeticException e) {
|
||||
result = true;
|
||||
}
|
||||
if (result == false) {
|
||||
throw new Error("Failed to throw correct exception!");
|
||||
}
|
||||
try {
|
||||
n = 0x80000000 / -1;
|
||||
} catch (Throwable t) {
|
||||
throw new Error("Failed to throw correct exception!");
|
||||
}
|
||||
if (n != 0x80000000) {
|
||||
throw new Error("Incorrect integer arithmetic ! ");
|
||||
}
|
||||
try {
|
||||
n = 0x80000000 % -1;
|
||||
} catch (Throwable t) {
|
||||
throw new Error("Failed to throw correct exception!");
|
||||
}
|
||||
if (n != 0) {
|
||||
throw new Error("Incorrect integer arithmetic!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4087516
|
||||
* @summary Incorrect locking leads to deadlock in monitorCacheMaybeExpand.
|
||||
* @author Anand Palaniswamy
|
||||
* @build MonitorCacheMaybeExpand_DeadLock
|
||||
* @run main/othervm MonitorCacheMaybeExpand_DeadLock
|
||||
*/
|
||||
|
||||
/**
|
||||
* Background on the bug:
|
||||
*
|
||||
* The thread local monitor cache had a locking bug (till
|
||||
* 1.2beta1) where two threads trying to expand the monitor cache
|
||||
* at the same time would cause deadlock. The code paths that the
|
||||
* two threads must be executing for this to happen is described
|
||||
* in the bug report.
|
||||
*
|
||||
* Caveat and red-flag:
|
||||
*
|
||||
* Since deadlocks are very timing dependent, there is a good
|
||||
* chance this test case will not catch the bug most of the time
|
||||
* -- on your machine and setting, it is _possible_ that the two
|
||||
* threads might not try a monitorCacheExpand at the same
|
||||
* time. But in practice, on Solaris native threads, this program
|
||||
* deadlocks the VM in about 2 seconds pretty consistently,
|
||||
* whether MP or not.
|
||||
*
|
||||
* The rationale for running this test despite this rather large
|
||||
* caveat is that at worst, it can do no harm.
|
||||
*
|
||||
* The idea:
|
||||
*
|
||||
* Is to create two monitor hungry threads.
|
||||
*
|
||||
* Originally Tom Rodriguez and I suspected that this weird state
|
||||
* of two threads trying to expand monitor cache can happen only
|
||||
* if:
|
||||
*
|
||||
* Thread 1: Is in the middle of a monitorCacheMaybeExpand.
|
||||
* Thread 2: Runs GC and tries to freeClasses(). This causes
|
||||
* sysFree() to be invoked, which in turn needs a
|
||||
* mutex_lock -- and oops, we end up deadlocking
|
||||
* with 1 on green_threads.
|
||||
*
|
||||
* Which is why this test tries to cause class GC at regular
|
||||
* intervals.
|
||||
*
|
||||
* Turns out that the GC is not required. Two instances of the
|
||||
* monitor hungry threads deadlock the VM pretty quick. :-) Infact
|
||||
* the static initializer in the forName'd classes running
|
||||
* alongside one of the hungry threads is sufficient to
|
||||
* deadlock. Still keep the GC stuff just-in-case (and also
|
||||
* because I wrote it :-).
|
||||
*
|
||||
*/
|
||||
public class MonitorCacheMaybeExpand_DeadLock {
|
||||
|
||||
/**
|
||||
* A monitor-hungry thread.
|
||||
*/
|
||||
static class LotsaMonitors extends Thread {
|
||||
|
||||
/** How many recursions? Could cause Java stack overflow. */
|
||||
static final int MAX_DEPTH = 800;
|
||||
|
||||
/** What is our depth? */
|
||||
int depth = 0;
|
||||
|
||||
/** Thread ID */
|
||||
int tid;
|
||||
|
||||
/** So output will have thread number. */
|
||||
public LotsaMonitors(int tid, int depth) {
|
||||
super("LotsaMonitors #" + new Integer(tid).toString());
|
||||
this.tid = tid;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
/** Start a recursion that grabs monitors. */
|
||||
public void run() {
|
||||
System.out.println(">>>Starting " + this.toString() + " ...");
|
||||
Thread.currentThread().yield();
|
||||
this.recurse();
|
||||
System.out.println("<<<Finished " + this.toString());
|
||||
}
|
||||
|
||||
/** Every call to this method grabs an extra monitor. */
|
||||
synchronized void recurse() {
|
||||
if (this.depth > 0) {
|
||||
new LotsaMonitors(tid, depth-1).recurse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The test.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
/* Start the two of these crazy threads. */
|
||||
new LotsaMonitors(1, LotsaMonitors.MAX_DEPTH).start();
|
||||
new LotsaMonitors(2, LotsaMonitors.MAX_DEPTH).start();
|
||||
|
||||
/* And sit there and GC for good measure. */
|
||||
for (int i = 0; i < MAX_GC_ITERATIONS; i++) {
|
||||
new LotsaMonitors(i+3, LotsaMonitors.MAX_DEPTH).start();
|
||||
System.out.println(">>>Loading 10 classes and gc'ing ...");
|
||||
Class[] classes = new Class[10];
|
||||
fillClasses(classes);
|
||||
classes = null;
|
||||
System.gc();
|
||||
Thread.currentThread().yield();
|
||||
System.out.println("<<<Finished loading 10 classes and gc'ing");
|
||||
}
|
||||
}
|
||||
|
||||
/** How many times to GC? */
|
||||
static final int MAX_GC_ITERATIONS = 10;
|
||||
|
||||
/** Load some classes into the array. */
|
||||
static void fillClasses(Class[] classes) {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
try {
|
||||
classes[i] = Class.forName(classnames[i]);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
cnfe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Some random classes to load. */
|
||||
private static String[] classnames = {
|
||||
"java.text.DecimalFormat",
|
||||
"java.text.MessageFormat",
|
||||
"java.util.GregorianCalendar",
|
||||
"java.util.ResourceBundle",
|
||||
"java.text.Collator",
|
||||
"java.util.Date",
|
||||
"java.io.Reader",
|
||||
"java.io.Writer",
|
||||
"java.lang.IllegalAccessException",
|
||||
"java.lang.InstantiationException",
|
||||
"java.lang.ClassNotFoundException",
|
||||
"java.lang.CloneNotSupportedException",
|
||||
"java.lang.InterruptedException",
|
||||
"java.lang.NoSuchFieldException",
|
||||
"java.lang.NoSuchMethodException",
|
||||
"java.lang.RuntimeException",
|
||||
"java.lang.ArithmeticException",
|
||||
"java.lang.ArrayStoreException",
|
||||
"java.lang.ClassCastException",
|
||||
"java.lang.StringIndexOutOfBoundsException",
|
||||
"java.lang.NegativeArraySizeException",
|
||||
"java.lang.IllegalStateException",
|
||||
"java.lang.IllegalArgumentException",
|
||||
"java.lang.NumberFormatException",
|
||||
"java.lang.IllegalThreadStateException",
|
||||
"java.lang.IllegalMonitorStateException",
|
||||
"java.lang.SecurityException",
|
||||
"java.lang.ExceptionInInitializerError"
|
||||
};
|
||||
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4169183
|
||||
* @summary Check for correct inlining by the interpreter (widefp and strictfp).
|
||||
* The default is widefp. A strictfp method was getting inlined
|
||||
* into a widefp method.
|
||||
*/
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class WideStrictInline {
|
||||
static PrintStream out;
|
||||
static float halfUlp;
|
||||
|
||||
static {
|
||||
halfUlp = 1;
|
||||
for ( int i = 127 - 24; i > 0; i-- )
|
||||
halfUlp *= 2;
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Exception {
|
||||
out = System.err;
|
||||
pr(-1,"halfUlp",halfUlp);
|
||||
WideStrictInline obj = new WideStrictInline();
|
||||
for( int i=0; i<48; i++ )
|
||||
obj.instanceMethod( i );
|
||||
}
|
||||
|
||||
private static void pr(int i, String desc, float r) {
|
||||
out.print(" i=("+i+") "+desc+" ; == "+r);
|
||||
out.println(" , 0x"+Integer.toHexString(Float.floatToIntBits(r)));
|
||||
}
|
||||
|
||||
private static strictfp float WideStrictInline(float par) {
|
||||
return par;
|
||||
}
|
||||
|
||||
public static strictfp float strictValue(int i) {
|
||||
float r;
|
||||
switch (i%4) {
|
||||
case 0: r = -Float.MAX_VALUE; break;
|
||||
case 1: r = Float.MAX_VALUE; break;
|
||||
case 2: r = Float.MIN_VALUE; break;
|
||||
default : r = 1L << 24;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void instanceMethod (int i) throws Exception {
|
||||
float r;
|
||||
switch (i%4) {
|
||||
case 0:
|
||||
if (!Float.isInfinite( WideStrictInline(strictValue(i)*2) +
|
||||
Float.MAX_VALUE ))
|
||||
{
|
||||
pr(i,
|
||||
"WideStrictInline(-Float.MAX_VALUE * 2) " +
|
||||
"!= Float.NEGATIVE_INFINITY"
|
||||
,WideStrictInline(strictValue(i)*2) + Float.MAX_VALUE);
|
||||
}
|
||||
r = WideStrictInline(strictValue(i)*2) + Float.MAX_VALUE;
|
||||
if ( !Float.isInfinite( r ) ) {
|
||||
pr(i,"r != Float.NEGATIVE_INFINITY",r);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (!Float.isInfinite(WideStrictInline(strictValue(i)+halfUlp) -
|
||||
Float.MAX_VALUE )) {
|
||||
pr(i,"WideStrictInline(Float.MAX_VALUE+halfUlp) " +
|
||||
"!= Float.POSITIVE_INFINITY"
|
||||
,WideStrictInline(strictValue(i)+halfUlp) - Float.MAX_VALUE);
|
||||
}
|
||||
r = WideStrictInline(strictValue(i)+halfUlp) - Float.MAX_VALUE;
|
||||
if ( !Float.isInfinite( r ) ) {
|
||||
pr(i,"r != Float.POSITIVE_INFINITY",r);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (WideStrictInline(strictValue(i)/2) != 0) {
|
||||
pr(i,"WideStrictInline(Float.MIN_VALUE/2) != 0",
|
||||
WideStrictInline(strictValue(i)/2));
|
||||
}
|
||||
r = WideStrictInline(strictValue(i)/2);
|
||||
if ( r != 0 ) {
|
||||
pr(i,"r != 0",r);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (WideStrictInline(strictValue(i)-0.5f) - strictValue(i) != 0) {
|
||||
pr(i,"WideStrictInline(2^24-0.5) != 2^24",
|
||||
WideStrictInline(strictValue(i)-0.5f));
|
||||
}
|
||||
r = WideStrictInline(strictValue(i)-0.5f);
|
||||
if ( r - strictValue(i) != 0 ) {
|
||||
pr(i,"r != 2^24",r);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user