--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/codegen/BadLogicCode.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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 4157675
+ * @summary Solaris JIT generates bad code for logic expression
+ * @author Tom Rodriguez
+ * @run main compiler.codegen.BadLogicCode
+ */
+
+package compiler.codegen;
+
+public class BadLogicCode {
+ static int values[] = {Integer.MIN_VALUE, -1, 0, 1, 4, 16, 31,
+ 32, 33, Integer.MAX_VALUE};
+ static char b[][] = {null, new char[32]};
+ static boolean nullPtr = false, indexOutBnd = false;
+ static boolean indexOutBnd2 = false;
+
+ public static void main(String args[]) throws Exception{
+ int i = 1, j = 4, k = 9;
+
+ nullPtr = (b[i] == null);
+
+ int bufLen = nullPtr ? 0 : b[i].length;
+ indexOutBnd = (values[j] < 0)
+ || (values[j] > bufLen)
+ || (values[k] < 0)
+ || ((values[j] + values[k]) > bufLen)
+ ||((values[j] + values[k]) < 0);
+
+ indexOutBnd2 = (values[j] < 0);
+ indexOutBnd2 = indexOutBnd2 || (values[j] > bufLen);
+ indexOutBnd2 = indexOutBnd2 || (values[k] < 0);
+ indexOutBnd2 = indexOutBnd2 || ((values[j] + values[k]) > bufLen);
+ indexOutBnd2 = indexOutBnd2 ||((values[j] + values[k]) < 0);
+ if (indexOutBnd != indexOutBnd2)
+ throw new Error("logic expression generate different results");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/codegen/ShiftTest.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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 4093292
+ * @summary Test for correct code generation by the JIT
+ * @run main compiler.codegen.ShiftTest
+ */
+
+package compiler.codegen;
+
+public class ShiftTest {
+ static final int w = 32;
+
+ private static void doTest(long ct) throws Exception {
+ int S22 = 0xc46cf7c2;
+ int S23 = 0xcfda9162;
+ int S24 = 0xd029aa4c;
+ int S25 = 0x17cf1801;
+ int A = (int)(ct & 0xffffffffL);
+ int B = (int)(ct >>> 32);
+ int x, y;
+ x = B - S25;
+ y = A & (w-1);
+ B = ((x >>> y) | (x << (w-y))) ^ A;
+ x = A - S24;
+ y = B & (w-1);
+ A = ((x >>> y) | (x << (w-y))) ^ B;
+ x = B - S23;
+ y = A & (w-1);
+ B = ((x >>> y) | (x << (w-y))) ^ A;
+ x = A - S22;
+ y = B & (w-1);
+ A = ((x >>> y) | (x << (w-y))) ^ B;
+ String astr = Integer.toHexString(A);
+ String bstr = Integer.toHexString(B);
+ System.err.println("A = " + astr + " B = " + bstr);
+ if ((!astr.equals("dcb38144")) ||
+ (!bstr.equals("1916de73"))) {
+ throw new RuntimeException("Unexpected shift results!");
+ }
+ System.err.println("Test passed");
+ }
+
+ public static void main(String[] args) throws Exception {
+ doTest(0x496def29b74be041L);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/exceptions/ExceptionInInit.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,96 @@
+/*
+ * 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 4165973
+ * @summary Attempt to read inaccessible property can produce
+ * exception of the wrong type.
+ * @author Tom Rodriguez
+ *
+ * @modules java.rmi
+ * @run main compiler.exceptions.ExceptionInInit
+ */
+
+package compiler.exceptions;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class ExceptionInInit {
+
+ public static void main(String[] args) {
+
+ Test test = null;
+
+ try {
+ System.setSecurityManager(new java.rmi.RMISecurityManager());
+ Test.showTest();
+ } catch (ExceptionInInitializerError e) {
+ }
+ }
+
+ public static class FooBar {
+ static String test = "test";
+ FooBar(String test) {
+ this.test = test;
+ }
+ }
+
+ public static class Test extends FooBar {
+
+ /*
+ * An AccessControlException is thrown in the static initializer of the
+ * class FooBar. This exception should produce an ExceptionInInitializer
+ * error. Instead it causes a more cryptic ClassNotFound error.
+ *
+ * The following is an excerpt from the output from java.security.debug=all
+ *
+ * access: access denied (java.util.PropertyPermission test.src read)
+ * java.lang.Exception: Stack trace
+ * at java.lang.Thread.dumpStack(Thread.java:938)
+ * at java.security.AccessControlContext.checkPermission(AccessControlContext.java:184)
+ * at java.security.AccessController.checkPermission(AccessController.java:402)
+ * at java.lang.SecurityManager.checkPermission(SecurityManager.java:516)
+ * at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1035)
+ * at java.lang.System.getProperty(System.java:441)
+ * at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:73)
+ * at java.security.AccessController.doPrivileged(Native Method)
+ * at ExceptionInInit$Test.<clinit>(ExceptionInInit.java:33)
+ * at ExceptionInInit.main(ExceptionInInit.java:18)
+ * access: domain that failed ProtectionDomain (file:/tmp/exceptionInInit/<no certificates>)
+ *
+ * The following exception is occurring when this test program tries
+ * to access the test.src property.
+ */
+ private static String test =
+ AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty("test.src", "."));
+
+ Test(String test) {
+ super(test);
+ }
+ public static void showTest() {
+ System.err.println(test);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/runtime/JITClassInit.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 4154887
+ * @summary self-parser test causes JDK 1.2 Beta4K segmentation fault
+ * @author Tom Rodriguez
+ * @run main/othervm compiler.runtime.JITClassInit
+ */
+
+package compiler.runtime;
+
+public class JITClassInit {
+ public static void main(String[] args) {
+ Token t = new Token();
+ new TokenTable();
+ }
+
+}
+
+class TokenTable {
+ public TokenTable() {
+ new TokenTypeIterator(this);
+ }
+
+ public void for_token_type(Token t) {
+ t.keyword_character_class();
+ }
+}
+
+class Token {
+ public Object keyword_character_class() {
+ return new Object();
+ }
+}
+
+class NameOrKeywordToken extends Token {
+ static TokenTable kt = new TokenTable();
+ public Object keyword_character_class() {
+ return new Object();
+ }
+}
+
+class CapKeywordToken extends NameOrKeywordToken {
+ public Object keyword_character_class() {
+ return new Object();
+ }
+};
+
+
+class TokenTypeIterator {
+ public TokenTypeIterator(TokenTable c) {
+ c.for_token_type(new CapKeywordToken());
+ c.for_token_type(new NameOrKeywordToken());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/ArraySize.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 4063078
+ * @summary Allocating a ridiculously large array should not crash the VM
+ * @run main/othervm -Xmx32m -Xms32m gc.ArraySize
+ */
+
+package gc;
+
+public class ArraySize {
+
+ public static void main(String[] args) throws Exception {
+ boolean thrown = false;
+ try {
+ byte[] buf = new byte[Integer.MAX_VALUE - 1];
+ System.out.print(buf[0]);
+ } catch (OutOfMemoryError x) {
+ thrown = true;
+ }
+ if (! thrown) {
+ throw new Exception("Didn't throw expected OutOfMemoryError");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/InfiniteList.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,52 @@
+/*
+ * 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 4098578
+ * @summary Check if the VM properly throws OutOfMemoryError
+ * @author Sheng Liang
+ * @run main/othervm -Xmx25M gc.InfiniteList
+ */
+
+package gc;
+
+public class InfiniteList {
+ InfiniteList next;
+ long data[] = new long[50000];
+ public static void main(String[] args) throws Exception {
+ InfiniteList p, q;
+ p = new InfiniteList ();
+ p.data[p.data.length -1 ] = 999;
+ try {
+ while (p != null) {
+ q = new InfiniteList ();
+ q.next = p;
+ p = q;
+ }
+ throw new Exception ("OutOfMemoryError not thrown as expected.");
+ } catch (OutOfMemoryError e) {
+ return;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ExplicitArithmeticCheck.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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!");
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Thread/MonitorCacheMaybeExpand_DeadLock.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,186 @@
+/*
+ * 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"
+ };
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/interpreter/WideStrictInline.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,127 @@
+/*
+ * 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();
+ }
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/reflect/ReflectStackOverflow.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,67 @@
+/*
+ * 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 4185411
+ * @summary This program crashes in 1.1, but runs okay in 1.2.
+ * @run main/othervm -Xss512k ReflectStackOverflow
+ */
+import java.lang.reflect.*;
+
+public class ReflectStackOverflow {
+ private static final int COUNT = 11000;
+
+ public static void main(String[] cmdline) throws Throwable {
+ for (int i = 0; i < COUNT+1; i++) {
+ stuff(i);
+ }
+ }
+
+ private static void stuff(int count) throws Throwable {
+ if (count < COUNT)
+ return; // don't do anything the first COUNT times.
+
+ try {
+ final Method method =
+ Method.class.getMethod
+ ("invoke", new Class[] { Object.class, Object[].class });
+
+ final Object[] args = new Object[] { method, null };
+ args[1] = args;
+
+ method.invoke(method, args); // "recursive reflection"
+ // exception should have been thrown by now...
+ System.out.println("how did I get here?");
+ } catch(Throwable t) {
+ int layers;
+ for(layers = 0; t instanceof InvocationTargetException; layers++)
+ t = ((InvocationTargetException)t).getTargetException();
+
+ System.err.println("Found " + layers + " layers of wrappers.");
+ if (!(t instanceof StackOverflowError)) {
+ throw t;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/verifier/TestStaticIF.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013, 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 8007736
+ * @summary Test static interface method.
+ * @run main/othervm -Xverify:all TestStaticIF
+ */
+
+public class TestStaticIF implements StaticMethodInInterface {
+
+ public static void main(String[] args) {
+ System.out.printf("main: %s%n", StaticMethodInInterface.get());
+ }
+}
+
+interface StaticMethodInInterface {
+
+ public static String get() {
+ return "Hello from StaticMethodInInterface.get()";
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/verifier/VerifyProtectedConstructor.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2007, 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 6490436
+ * @summary Verify that protected constructor calls are not allowed for any classfile versions in either verifier.
+ * @author Keith McGuigan
+ */
+
+public class VerifyProtectedConstructor extends ClassLoader {
+ public static void main(String argv[]) throws Exception {
+ VerifyProtectedConstructor t = new VerifyProtectedConstructor();
+
+ t.loadSuperClass();
+
+ try {
+ t.checkClassVersion(49); // should not throw VerifyError
+ throw new Exception("FAIL: should be a VerifyError for CF version 49");
+ }
+ catch(VerifyError e) {
+ System.out.println("PASS for CF version 49");
+ }
+
+ try {
+ t.checkClassVersion(50); // should throw VerifyError
+ throw new Exception("FAIL: should be a VerifyError for CF version 50");
+ }
+ catch(VerifyError e) {
+ System.out.println("PASS");
+ }
+ }
+
+ private void loadSuperClass() {
+ /* -- code for super class A.A --
+ package A;
+ public class A {
+ protected A() {}
+ }
+ */
+ long[] cls_data = {
+ 0xcafebabe00000032L, 0x000a0a0003000707L,
+ 0x0008070009010006L, 0x3c696e69743e0100L,
+ 0x0328295601000443L, 0x6f64650c00040005L,
+ 0x010003412f410100L, 0x106a6176612f6c61L,
+ 0x6e672f4f626a6563L, 0x7400210002000300L,
+ 0x0000000001000400L, 0x0400050001000600L,
+ 0x0000110001000100L, 0x0000052ab70001b1L,
+ 0x0000000000000000L // 2 bytes extra
+ };
+ final int EXTRA = 2;
+ byte cf_bytes[] = toByteArray(cls_data);
+ defineClass("A.A", cf_bytes, 0, cf_bytes.length - EXTRA);
+ }
+
+ private int num_calls;
+ private static String classNames[] = { "B.B", "C.C" };
+
+ private void checkClassVersion(int version) throws VerifyError {
+ // This class is in violation of the spec since it accesses
+ // a protected constructor of a superclass while not being in the
+ // same package.
+ /* -- code for test class --
+ package B;
+ public class B extends A.A {
+ public static void f() { new A.A(); }
+ }
+ */
+ long[] cls_data = {
+ 0xcafebabe00000032L, 0x000b0a0002000807L,
+ 0x000907000a010006L, 0x3c696e69743e0100L,
+ 0x0328295601000443L, 0x6f6465010001660cL,
+ 0x0004000501000341L, 0x2f41010003422f42L,
+ 0x0021000300020000L, 0x0000000200010004L,
+ 0x0005000100060000L, 0x0011000100010000L,
+ 0x00052ab70001b100L, 0x0000000009000700L,
+ 0x0500010006000000L, 0x1500020000000000L,
+ 0x09bb000259b70001L, 0x57b1000000000000L // no extra bytes
+ };
+ final int EXTRA = 0;
+
+ byte cf_bytes[] = toByteArray(cls_data);
+
+ // set version
+ cf_bytes[7] = (byte)version;
+
+ // Change B.B to C.C, D.D, ... for subsequent calls so we can call this
+ // multiple times and define different classes.
+ cf_bytes[61] += num_calls;
+ cf_bytes[63] += num_calls;
+ String name = classNames[num_calls];
+ num_calls++;
+
+ Class c = defineClass(name, cf_bytes, 0, cf_bytes.length - EXTRA);
+
+ try { c.newInstance(); } // to force linking, thus verification
+ catch(InstantiationException e) {}
+ catch(IllegalAccessException e) {}
+ }
+
+ static private byte[] toByteArray(long arr[]) {
+ // convert long array to byte array
+ java.nio.ByteBuffer bbuf = java.nio.ByteBuffer.allocate(arr.length * 8);
+ bbuf.asLongBuffer().put(java.nio.LongBuffer.wrap(arr));
+ return bbuf.array();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/verifier/VerifyStackForExceptionHandlers.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2007, 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 6547378
+ * @summary Verify that methods with max_stack==0 don't have exception handlers
+ * @author Keith McGuigan
+ */
+
+public class VerifyStackForExceptionHandlers extends ClassLoader {
+ public static void main(String argv[]) throws Exception {
+ VerifyStackForExceptionHandlers t =
+ new VerifyStackForExceptionHandlers();
+
+ try {
+ t.loadGoodClass();
+ } catch(VerifyError e) {
+ throw new Exception("FAIL: should be no VerifyError for class A");
+ }
+
+ try {
+ t.loadBadClass();
+ throw new Exception("FAIL: should be a VerifyError for class B");
+ } catch(VerifyError e) {
+ System.out.println("PASS");
+ }
+ }
+
+ private void loadGoodClass() {
+ /* -- code for class A --
+ public class A {
+ public static void f() {}
+ }
+ */
+ long[] cls_data = {
+ 0xcafebabe00000031L, 0x000e0a0003000b07L,
+ 0x000c07000d010006L, 0x3c696e69743e0100L,
+ 0x0328295601000443L, 0x6f646501000f4c69L,
+ 0x6e654e756d626572L, 0x5461626c65010001L,
+ 0x6601000a536f7572L, 0x636546696c650100L,
+ 0x06412e6a6176610cL, 0x0004000501000141L,
+ 0x0100106a6176612fL, 0x6c616e672f4f626aL,
+ 0x6563740021000200L, 0x0300000000000200L,
+ 0x0100040005000100L, 0x060000001d000100L,
+ 0x01000000052ab700L, 0x01b1000000010007L,
+ 0x0000000600010000L, 0x0001000900080005L,
+ 0x0001000600000019L, 0x0000000000000001L,
+ 0xb100000001000700L, 0x0000060001000000L,
+ 0x0200010009000000L, 0x02000a0000000000L
+ };
+ final int EXTRA = 5;
+
+ byte cf_bytes[] = toByteArray(cls_data);
+ Class c = defineClass("A", cf_bytes, 0, cf_bytes.length - EXTRA);
+
+ try { c.newInstance(); } // to force linking, thus verification
+ catch(InstantiationException e) {}
+ catch(IllegalAccessException e) {}
+ }
+
+ private void loadBadClass() throws VerifyError {
+ /* -- code for class B --
+ public class B {
+ public static void g() {}
+ public static void f() {
+ // bytecode modified to have a max_stack value of 0
+ try { g(); }
+ catch (NullPointerException e) {}
+ }
+ }
+ */
+ long[] cls_data = {
+ 0xcafebabe00000031L, 0x00120a000400060aL,
+ 0x000d00030c000f00L, 0x0a0700050100106aL,
+ 0x6176612f6c616e67L, 0x2f4f626a6563740cL,
+ 0x0011000a01000a53L, 0x6f7572636546696cL,
+ 0x6507000901001e6aL, 0x6176612f6c616e67L,
+ 0x2f4e756c6c506f69L, 0x6e74657245786365L,
+ 0x7074696f6e010003L, 0x282956010006422eL,
+ 0x6a61736d01000443L, 0x6f646507000e0100L,
+ 0x0142010001670100L, 0x01660100063c696eL,
+ 0x69743e0021000d00L, 0x0400000000000300L,
+ 0x010011000a000100L, 0x0c00000011000100L,
+ 0x01000000052ab700L, 0x01b1000000000009L,
+ 0x000f000a0001000cL, 0x0000000d00000000L,
+ 0x00000001b1000000L, 0x0000090010000a00L,
+ 0x01000c0000001c00L, 0x00000100000008b8L,
+ 0x0002a700044bb100L, 0x0100000003000600L,
+ 0x0800000001000700L, 0x000002000b000000L // 3 bytes extra
+
+ };
+ final int EXTRA = 3;
+
+ byte cf_bytes[] = toByteArray(cls_data);
+ Class c = defineClass("B", cf_bytes, 0, cf_bytes.length - EXTRA);
+
+ try { c.newInstance(); } // to force linking, thus verification
+ catch(InstantiationException e) {}
+ catch(IllegalAccessException e) {}
+ }
+
+ static private byte[] toByteArray(long arr[]) {
+ // convert long array to byte array
+ java.nio.ByteBuffer bbuf = java.nio.ByteBuffer.allocate(arr.length * 8);
+ bbuf.asLongBuffer().put(java.nio.LongBuffer.wrap(arr));
+ return bbuf.array();
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/verifier/defaultMethods/DefaultMethodRegressionTests.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2012, 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 8003639
+ * @summary defaultMethod resolution and verification
+ * @run main DefaultMethodRegressionTests
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This set of classes/interfaces (K/I/C) is specially designed to expose a
+ * bug in the JVM where it did not find some overloaded methods in some
+ * specific situations. (fixed by hotspot changeset ffb9316fd9ed).
+ */
+interface K {
+ int bbb(Long l);
+}
+
+interface I extends K {
+ default void aaa() {}
+ default void aab() {}
+ default void aac() {}
+
+ default int bbb(Integer i) { return 22; }
+ default int bbb(Float f) { return 33; }
+ default int bbb(Long l) { return 44; }
+ default int bbb(Double d) { return 55; }
+ default int bbb(String s) { return 66; }
+
+ default void caa() {}
+ default void cab() {}
+ default void cac() {}
+}
+
+class C implements I {}
+
+public class DefaultMethodRegressionTests {
+ public static void main(String... args) {
+ new DefaultMethodRegressionTests().run(args);
+ }
+ void run(String... args) {
+ testLostOverloadedMethod();
+ System.out.println("testLostOverloadedMethod: OK");
+ testInferenceVerifier();
+ System.out.println("testInferenceVerifier: OK");
+ }
+ void testLostOverloadedMethod() {
+ C c = new C();
+ assertEquals(c.bbb(new Integer(1)), 22);
+ assertEquals(c.bbb(new Float(1.1)), 33);
+ assertEquals(c.bbb(new Long(1L)), 44);
+ assertEquals(c.bbb(new Double(0.01)), 55);
+ assertEquals(c.bbb(new String("")), 66);
+ }
+ // Test to ensure that the inference verifier accepts older classfiles
+ // with classes that implement interfaces with defaults.
+ void testInferenceVerifier() {
+ // interface I { int m() default { return 99; } }
+ byte I_bytes[] = {
+ (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x34,
+ 0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00,
+ 0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43,
+ 0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01,
+ 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+ 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01,
+ 0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05,
+ 0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ // public class C implements I {} /* -target 1.5 */
+ byte C_bytes[] = {
+ (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31,
+ 0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07,
+ 0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b,
+ 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74,
+ 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01,
+ 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00,
+ 0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01,
+ 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+ 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21,
+ 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05,
+ 0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00,
+ 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ ClassLoader cl = new ClassLoader() {
+ protected Class<?> findClass(String name) {
+ if (name.equals("I")) {
+ return defineClass("I", I_bytes, 0, I_bytes.length);
+ } else if (name.equals("C")) {
+ return defineClass("C", C_bytes, 0, C_bytes.length);
+ } else {
+ return null;
+ }
+ }
+ };
+ try {
+ Class.forName("C", true, cl);
+ } catch (Exception e) {
+ // unmodified verifier will throw VerifyError
+ throw new RuntimeException(e);
+ }
+ }
+ void assertEquals(Object o1, Object o2) {
+ System.out.print("Expected: " + o1);
+ System.out.println(", Obtained: " + o2);
+ if (!o1.equals(o2)) {
+ throw new RuntimeException("got unexpected values");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, 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 8003639
+ * @summary defaultMethod resolution and verification using an URLClassLoader
+ * @modules jdk.compiler
+ * jdk.zipfs
+ * @compile -XDignore.symbol.file=true DefaultMethodRegressionTestsRun.java
+ * @run main DefaultMethodRegressionTestsRun
+ */
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+/**
+ * This test is a variant of DefaultMethodRegressionTests, this one creates
+ * an URLClassLoader to load the support classes.
+ *
+ */
+public class DefaultMethodRegressionTestsRun {
+ public static void main(String... args) throws Exception {
+ File scratchDir = new File(".");
+ File testDir = new File(scratchDir, "testdir");
+ testDir.mkdirs();
+ File srcFile = new File(new File(System.getProperty("test.src")),
+ "DefaultMethodRegressionTests.java");
+ String[] javacargs = {
+ srcFile.getAbsolutePath(),
+ "-d",
+ testDir.getAbsolutePath()
+ };
+ com.sun.tools.javac.Main.compile(javacargs);
+ runClass(testDir, "DefaultMethodRegressionTests");
+ }
+ static void runClass(
+ File classPath,
+ String classname) throws Exception {
+ URL[] urls = {classPath.toURI().toURL()};
+ ClassLoader loader = new URLClassLoader(urls);
+ Class<?> c = loader.loadClass(classname);
+
+ Class<?>[] argTypes = new Class<?>[]{String[].class};
+ Object[] methodArgs = new Object[]{null};
+
+ Method method = c.getMethod("main", argTypes);
+ method.invoke(c, methodArgs);
+ }
+}
--- a/test/jdk/TEST.groups Thu Mar 14 16:28:31 2019 -0700
+++ b/test/jdk/TEST.groups Thu Mar 14 19:37:17 2019 -0700
@@ -103,8 +103,7 @@
jdk/internal/ref \
jdk/internal/jimage \
jdk/internal/math \
- jdk/modules \
- vm
+ jdk/modules
# All of the java.util package
jdk_util = \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/JniInvocationTest.java Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, 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 8213362
+ * @comment Test uses custom launcher that starts VM using JNI via libjli, only for MacOS
+ * @requires os.family == "mac"
+ * @library /test/lib
+ * @run main/native JniInvocationTest
+ */
+
+import java.util.Map;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class JniInvocationTest {
+ public static void main(String[] args) throws IOException {
+ Path launcher = Paths.get(System.getProperty("test.nativepath"), "JniInvocationTest");
+ System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)"));
+ ProcessBuilder pb = new ProcessBuilder(launcher.toString());
+ Map<String, String> env = pb.environment();
+ String libdir = Paths.get(Utils.TEST_JDK).resolve("lib").toAbsolutePath().toString();
+ env.compute(Platform.sharedLibraryPathVariableName(), (k, v) -> (k == null) ? libdir : v + ":" + libdir);
+ OutputAnalyzer outputf = new OutputAnalyzer(pb.start());
+ outputf.shouldHaveExitValue(0);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/exeJniInvocationTest.c Thu Mar 14 19:37:17 2019 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ */
+
+#include "jni.h"
+#include "stdio.h"
+#include "stdlib.h"
+
+int main(int argc, char** args) {
+ JavaVMInitArgs vm_args;
+ JNIEnv *env;
+ JavaVM *vm;
+ int i =0;
+ jint result;
+
+ vm_args.version = JNI_VERSION_1_2;
+ vm_args.ignoreUnrecognized = JNI_FALSE;
+
+ JavaVMOption option1[2];
+ option1[0].optionString="-XX:+PrintCommandLineFlags";
+ option1[1].optionString="-Xrs";
+
+ vm_args.options=option1;
+ vm_args.nOptions=2;
+
+ // Print the VM options in use
+ printf("initVM: numOptions = %d\n", vm_args.nOptions);
+ for (i = 0; i < vm_args.nOptions; i++)
+ {
+ printf("\tvm_args.options[%d].optionString = %s\n", i, vm_args.options[i].optionString);
+ }
+
+ // Initialize VM with given options
+ result = JNI_CreateJavaVM( &vm, (void **) &env, &vm_args );
+ if (result != 0) {
+ printf("ERROR: cannot create JAVA VM.\n");
+ exit(-1);
+ }
+
+ (*vm)->DestroyJavaVM(vm);
+}
+
--- a/test/jdk/vm/JniInvocationTest.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2016, 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 8213362
- * @comment Test uses custom launcher that starts VM using JNI via libjli, only for MacOS
- * @requires os.family == "mac"
- * @library /test/lib
- * @run main/native JniInvocationTest
- */
-
-import java.util.Map;
-import jdk.test.lib.Platform;
-import jdk.test.lib.Utils;
-import jdk.test.lib.process.OutputAnalyzer;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public class JniInvocationTest {
- public static void main(String[] args) throws IOException {
- Path launcher = Paths.get(System.getProperty("test.nativepath"), "JniInvocationTest");
- System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)"));
- ProcessBuilder pb = new ProcessBuilder(launcher.toString());
- Map<String, String> env = pb.environment();
- String libdir = Paths.get(Utils.TEST_JDK).resolve("lib").toAbsolutePath().toString();
- env.compute(Platform.sharedLibraryPathVariableName(), (k, v) -> (k == null) ? libdir : v + ":" + libdir);
- OutputAnalyzer outputf = new OutputAnalyzer(pb.start());
- outputf.shouldHaveExitValue(0);
- }
-}
-
--- a/test/jdk/vm/exeJniInvocationTest.c Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2018, 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.
- *
- */
-
-#include "jni.h"
-#include "stdio.h"
-#include "stdlib.h"
-
-int main(int argc, char** args) {
- JavaVMInitArgs vm_args;
- JNIEnv *env;
- JavaVM *vm;
- int i =0;
- jint result;
-
- vm_args.version = JNI_VERSION_1_2;
- vm_args.ignoreUnrecognized = JNI_FALSE;
-
- JavaVMOption option1[2];
- option1[0].optionString="-XX:+PrintCommandLineFlags";
- option1[1].optionString="-Xrs";
-
- vm_args.options=option1;
- vm_args.nOptions=2;
-
- // Print the VM options in use
- printf("initVM: numOptions = %d\n", vm_args.nOptions);
- for (i = 0; i < vm_args.nOptions; i++)
- {
- printf("\tvm_args.options[%d].optionString = %s\n", i, vm_args.options[i].optionString);
- }
-
- // Initialize VM with given options
- result = JNI_CreateJavaVM( &vm, (void **) &env, &vm_args );
- if (result != 0) {
- printf("ERROR: cannot create JAVA VM.\n");
- exit(-1);
- }
-
- (*vm)->DestroyJavaVM(vm);
-}
-
--- a/test/jdk/vm/gc/ArraySize.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4063078
- * @summary Allocating a ridiculously large array should not crash the VM
- * @run main/othervm -Xmx32m -Xms32m ArraySize
- */
-
-public class ArraySize {
-
- public static void main(String[] args) throws Exception {
- boolean thrown = false;
- try {
- byte[] buf = new byte[Integer.MAX_VALUE - 1];
- System.out.print(buf[0]);
- } catch (OutOfMemoryError x) {
- thrown = true;
- }
- if (! thrown) {
- throw new Exception("Didn't throw expected OutOfMemoryError");
- }
- }
-
-}
--- a/test/jdk/vm/gc/InfiniteList.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4098578
- * @summary Check if the VM properly throws OutOfMemoryError
- * @author Sheng Liang
- * @run main/othervm -Xmx25M InfiniteList
- */
-public class InfiniteList {
- InfiniteList next;
- long data[] = new long[50000];
- public static void main(String[] args) throws Exception {
- InfiniteList p, q;
- p = new InfiniteList ();
- p.data[p.data.length -1 ] = 999;
- try {
- while (p != null) {
- q = new InfiniteList ();
- q.next = p;
- p = q;
- }
- throw new Exception ("OutOfMemoryError not thrown as expected.");
- } catch (OutOfMemoryError e) {
- return;
- }
- }
-}
--- a/test/jdk/vm/jit/BadLogicCode.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4157675
- * @summary Solaris JIT generates bad code for logic expression
- * @author Tom Rodriguez
- */
-
-public class BadLogicCode {
- static int values[] = {Integer.MIN_VALUE, -1, 0, 1, 4, 16, 31,
- 32, 33, Integer.MAX_VALUE};
- static char b[][] = {null, new char[32]};
- static boolean nullPtr = false, indexOutBnd = false;
- static boolean indexOutBnd2 = false;
-
- public static void main(String args[]) throws Exception{
- int i = 1, j = 4, k = 9;
-
- nullPtr = (b[i] == null);
-
- int bufLen = nullPtr ? 0 : b[i].length;
- indexOutBnd = (values[j] < 0)
- || (values[j] > bufLen)
- || (values[k] < 0)
- || ((values[j] + values[k]) > bufLen)
- ||((values[j] + values[k]) < 0);
-
- indexOutBnd2 = (values[j] < 0);
- indexOutBnd2 = indexOutBnd2 || (values[j] > bufLen);
- indexOutBnd2 = indexOutBnd2 || (values[k] < 0);
- indexOutBnd2 = indexOutBnd2 || ((values[j] + values[k]) > bufLen);
- indexOutBnd2 = indexOutBnd2 ||((values[j] + values[k]) < 0);
- if (indexOutBnd != indexOutBnd2)
- throw new Error("logic expression generate different results");
- }
-}
--- a/test/jdk/vm/jit/ExceptionInInit.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4165973
- * @summary Attempt to read inaccessible property can produce
- * exception of the wrong type.
- * @author Tom Rodriguez
- *
- * @modules java.rmi
- */
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-public class ExceptionInInit {
-
- public static void main(String[] args) {
-
- Test test = null;
-
- try {
- System.setSecurityManager(new java.rmi.RMISecurityManager());
- Test.showTest();
- } catch (ExceptionInInitializerError e) {
- }
- }
-
- public static class FooBar {
- static String test = "test";
- FooBar(String test) {
- this.test = test;
- }
- }
-
- public static class Test extends FooBar {
-
- /*
- * An AccessControlException is thrown in the static initializer of the
- * class FooBar. This exception should produce an ExceptionInInitializer
- * error. Instead it causes a more cryptic ClassNotFound error.
- *
- * The following is an excerpt from the output from java.security.debug=all
- *
- * access: access denied (java.util.PropertyPermission test.src read)
- * java.lang.Exception: Stack trace
- * at java.lang.Thread.dumpStack(Thread.java:938)
- * at java.security.AccessControlContext.checkPermission(AccessControlContext.java:184)
- * at java.security.AccessController.checkPermission(AccessController.java:402)
- * at java.lang.SecurityManager.checkPermission(SecurityManager.java:516)
- * at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1035)
- * at java.lang.System.getProperty(System.java:441)
- * at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:73)
- * at java.security.AccessController.doPrivileged(Native Method)
- * at ExceptionInInit$Test.<clinit>(ExceptionInInit.java:33)
- * at ExceptionInInit.main(ExceptionInInit.java:18)
- * access: domain that failed ProtectionDomain (file:/tmp/exceptionInInit/<no certificates>)
- *
- * The following exception is occurring when this test program tries
- * to access the test.src property.
- */
- private static String test =
- AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty("test.src", "."));
-
- Test(String test) {
- super(test);
- }
- public static void showTest() {
- System.err.println(test);
- }
- }
-}
--- a/test/jdk/vm/jit/JITClassInit.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4154887
- * @summary self-parser test causes JDK 1.2 Beta4K segmentation fault
- * @run main/othervm JITClassInit
- * @author Tom Rodriguez
- */
-
-public class JITClassInit {
- public static void main(String[] args) {
- Token t = new Token();
- new TokenTable();
- }
-
-}
-
-class TokenTable {
- public TokenTable() {
- new TokenTypeIterator(this);
- }
-
- public void for_token_type(Token t) {
- t.keyword_character_class();
- }
-}
-
-class Token {
- public Object keyword_character_class() {
- return new Object();
- }
-}
-
-class NameOrKeywordToken extends Token {
- static TokenTable kt = new TokenTable();
- public Object keyword_character_class() {
- return new Object();
- }
-}
-
-class CapKeywordToken extends NameOrKeywordToken {
- public Object keyword_character_class() {
- return new Object();
- }
-};
-
-
-class TokenTypeIterator {
- public TokenTypeIterator(TokenTable c) {
- c.for_token_type(new CapKeywordToken());
- c.for_token_type(new NameOrKeywordToken());
- }
-}
--- a/test/jdk/vm/runtime/ExplicitArithmeticCheck.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2018, 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!");
- }
- }
- }
-}
--- a/test/jdk/vm/runtime/MonitorCacheMaybeExpand_DeadLock.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2018, 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"
- };
-
-}
--- a/test/jdk/vm/runtime/ReflectStackOverflow.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4185411
- * @summary This program crashes in 1.1, but runs okay in 1.2.
- * @run main/othervm -Xss512k ReflectStackOverflow
- */
-import java.lang.reflect.*;
-
-public class ReflectStackOverflow {
- private static final int COUNT = 11000;
-
- public static void main(String[] cmdline) throws Throwable {
- for (int i = 0; i < COUNT+1; i++) {
- stuff(i);
- }
- }
-
- private static void stuff(int count) throws Throwable {
- if (count < COUNT)
- return; // don't do anything the first COUNT times.
-
- try {
- final Method method =
- Method.class.getMethod
- ("invoke", new Class[] { Object.class, Object[].class });
-
- final Object[] args = new Object[] { method, null };
- args[1] = args;
-
- method.invoke(method, args); // "recursive reflection"
- // exception should have been thrown by now...
- System.out.println("how did I get here?");
- } catch(Throwable t) {
- int layers;
- for(layers = 0; t instanceof InvocationTargetException; layers++)
- t = ((InvocationTargetException)t).getTargetException();
-
- System.err.println("Found " + layers + " layers of wrappers.");
- if (!(t instanceof StackOverflowError)) {
- throw t;
- }
- }
- }
-}
--- a/test/jdk/vm/runtime/ShiftTest.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2018, 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 4093292
- * @summary Test for correct code generation by the JIT
- */
-public class ShiftTest {
- static final int w = 32;
-
- private static void doTest(long ct) throws Exception {
- int S22 = 0xc46cf7c2;
- int S23 = 0xcfda9162;
- int S24 = 0xd029aa4c;
- int S25 = 0x17cf1801;
- int A = (int)(ct & 0xffffffffL);
- int B = (int)(ct >>> 32);
- int x, y;
- x = B - S25;
- y = A & (w-1);
- B = ((x >>> y) | (x << (w-y))) ^ A;
- x = A - S24;
- y = B & (w-1);
- A = ((x >>> y) | (x << (w-y))) ^ B;
- x = B - S23;
- y = A & (w-1);
- B = ((x >>> y) | (x << (w-y))) ^ A;
- x = A - S22;
- y = B & (w-1);
- A = ((x >>> y) | (x << (w-y))) ^ B;
- String astr = Integer.toHexString(A);
- String bstr = Integer.toHexString(B);
- System.err.println("A = " + astr + " B = " + bstr);
- if ((!astr.equals("dcb38144")) ||
- (!bstr.equals("1916de73"))) {
- throw new RuntimeException("Unexpected shift results!");
- }
- System.err.println("Test passed");
- }
-
- public static void main(String[] args) throws Exception {
- doTest(0x496def29b74be041L);
- }
-}
--- a/test/jdk/vm/runtime/WideStrictInline.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2018, 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();
- }
- }
- }
-
-}
--- a/test/jdk/vm/verifier/TestStaticIF.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2013, 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 8007736
- * @summary Test static interface method.
- * @run main/othervm -Xverify:all TestStaticIF
- */
-
-public class TestStaticIF implements StaticMethodInInterface {
-
- public static void main(String[] args) {
- System.out.printf("main: %s%n", StaticMethodInInterface.get());
- }
-}
-
-interface StaticMethodInInterface {
-
- public static String get() {
- return "Hello from StaticMethodInInterface.get()";
- }
-}
--- a/test/jdk/vm/verifier/VerifyProtectedConstructor.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2007, 2015, 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 6490436
- * @summary Verify that protected constructor calls are not allowed for any classfile versions in either verifier.
- * @author Keith McGuigan
- */
-
-public class VerifyProtectedConstructor extends ClassLoader {
- public static void main(String argv[]) throws Exception {
- VerifyProtectedConstructor t = new VerifyProtectedConstructor();
-
- t.loadSuperClass();
-
- try {
- t.checkClassVersion(49); // should not throw VerifyError
- throw new Exception("FAIL: should be a VerifyError for CF version 49");
- }
- catch(VerifyError e) {
- System.out.println("PASS for CF version 49");
- }
-
- try {
- t.checkClassVersion(50); // should throw VerifyError
- throw new Exception("FAIL: should be a VerifyError for CF version 50");
- }
- catch(VerifyError e) {
- System.out.println("PASS");
- }
- }
-
- private void loadSuperClass() {
- /* -- code for super class A.A --
- package A;
- public class A {
- protected A() {}
- }
- */
- long[] cls_data = {
- 0xcafebabe00000032L, 0x000a0a0003000707L,
- 0x0008070009010006L, 0x3c696e69743e0100L,
- 0x0328295601000443L, 0x6f64650c00040005L,
- 0x010003412f410100L, 0x106a6176612f6c61L,
- 0x6e672f4f626a6563L, 0x7400210002000300L,
- 0x0000000001000400L, 0x0400050001000600L,
- 0x0000110001000100L, 0x0000052ab70001b1L,
- 0x0000000000000000L // 2 bytes extra
- };
- final int EXTRA = 2;
- byte cf_bytes[] = toByteArray(cls_data);
- defineClass("A.A", cf_bytes, 0, cf_bytes.length - EXTRA);
- }
-
- private int num_calls;
- private static String classNames[] = { "B.B", "C.C" };
-
- private void checkClassVersion(int version) throws VerifyError {
- // This class is in violation of the spec since it accesses
- // a protected constructor of a superclass while not being in the
- // same package.
- /* -- code for test class --
- package B;
- public class B extends A.A {
- public static void f() { new A.A(); }
- }
- */
- long[] cls_data = {
- 0xcafebabe00000032L, 0x000b0a0002000807L,
- 0x000907000a010006L, 0x3c696e69743e0100L,
- 0x0328295601000443L, 0x6f6465010001660cL,
- 0x0004000501000341L, 0x2f41010003422f42L,
- 0x0021000300020000L, 0x0000000200010004L,
- 0x0005000100060000L, 0x0011000100010000L,
- 0x00052ab70001b100L, 0x0000000009000700L,
- 0x0500010006000000L, 0x1500020000000000L,
- 0x09bb000259b70001L, 0x57b1000000000000L // no extra bytes
- };
- final int EXTRA = 0;
-
- byte cf_bytes[] = toByteArray(cls_data);
-
- // set version
- cf_bytes[7] = (byte)version;
-
- // Change B.B to C.C, D.D, ... for subsequent calls so we can call this
- // multiple times and define different classes.
- cf_bytes[61] += num_calls;
- cf_bytes[63] += num_calls;
- String name = classNames[num_calls];
- num_calls++;
-
- Class c = defineClass(name, cf_bytes, 0, cf_bytes.length - EXTRA);
-
- try { c.newInstance(); } // to force linking, thus verification
- catch(InstantiationException e) {}
- catch(IllegalAccessException e) {}
- }
-
- static private byte[] toByteArray(long arr[]) {
- // convert long array to byte array
- java.nio.ByteBuffer bbuf = java.nio.ByteBuffer.allocate(arr.length * 8);
- bbuf.asLongBuffer().put(java.nio.LongBuffer.wrap(arr));
- return bbuf.array();
- }
-}
--- a/test/jdk/vm/verifier/VerifyStackForExceptionHandlers.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2007, 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 6547378
- * @summary Verify that methods with max_stack==0 don't have exception handlers
- * @author Keith McGuigan
- */
-
-public class VerifyStackForExceptionHandlers extends ClassLoader {
- public static void main(String argv[]) throws Exception {
- VerifyStackForExceptionHandlers t =
- new VerifyStackForExceptionHandlers();
-
- try {
- t.loadGoodClass();
- } catch(VerifyError e) {
- throw new Exception("FAIL: should be no VerifyError for class A");
- }
-
- try {
- t.loadBadClass();
- throw new Exception("FAIL: should be a VerifyError for class B");
- } catch(VerifyError e) {
- System.out.println("PASS");
- }
- }
-
- private void loadGoodClass() {
- /* -- code for class A --
- public class A {
- public static void f() {}
- }
- */
- long[] cls_data = {
- 0xcafebabe00000031L, 0x000e0a0003000b07L,
- 0x000c07000d010006L, 0x3c696e69743e0100L,
- 0x0328295601000443L, 0x6f646501000f4c69L,
- 0x6e654e756d626572L, 0x5461626c65010001L,
- 0x6601000a536f7572L, 0x636546696c650100L,
- 0x06412e6a6176610cL, 0x0004000501000141L,
- 0x0100106a6176612fL, 0x6c616e672f4f626aL,
- 0x6563740021000200L, 0x0300000000000200L,
- 0x0100040005000100L, 0x060000001d000100L,
- 0x01000000052ab700L, 0x01b1000000010007L,
- 0x0000000600010000L, 0x0001000900080005L,
- 0x0001000600000019L, 0x0000000000000001L,
- 0xb100000001000700L, 0x0000060001000000L,
- 0x0200010009000000L, 0x02000a0000000000L
- };
- final int EXTRA = 5;
-
- byte cf_bytes[] = toByteArray(cls_data);
- Class c = defineClass("A", cf_bytes, 0, cf_bytes.length - EXTRA);
-
- try { c.newInstance(); } // to force linking, thus verification
- catch(InstantiationException e) {}
- catch(IllegalAccessException e) {}
- }
-
- private void loadBadClass() throws VerifyError {
- /* -- code for class B --
- public class B {
- public static void g() {}
- public static void f() {
- // bytecode modified to have a max_stack value of 0
- try { g(); }
- catch (NullPointerException e) {}
- }
- }
- */
- long[] cls_data = {
- 0xcafebabe00000031L, 0x00120a000400060aL,
- 0x000d00030c000f00L, 0x0a0700050100106aL,
- 0x6176612f6c616e67L, 0x2f4f626a6563740cL,
- 0x0011000a01000a53L, 0x6f7572636546696cL,
- 0x6507000901001e6aL, 0x6176612f6c616e67L,
- 0x2f4e756c6c506f69L, 0x6e74657245786365L,
- 0x7074696f6e010003L, 0x282956010006422eL,
- 0x6a61736d01000443L, 0x6f646507000e0100L,
- 0x0142010001670100L, 0x01660100063c696eL,
- 0x69743e0021000d00L, 0x0400000000000300L,
- 0x010011000a000100L, 0x0c00000011000100L,
- 0x01000000052ab700L, 0x01b1000000000009L,
- 0x000f000a0001000cL, 0x0000000d00000000L,
- 0x00000001b1000000L, 0x0000090010000a00L,
- 0x01000c0000001c00L, 0x00000100000008b8L,
- 0x0002a700044bb100L, 0x0100000003000600L,
- 0x0800000001000700L, 0x000002000b000000L // 3 bytes extra
-
- };
- final int EXTRA = 3;
-
- byte cf_bytes[] = toByteArray(cls_data);
- Class c = defineClass("B", cf_bytes, 0, cf_bytes.length - EXTRA);
-
- try { c.newInstance(); } // to force linking, thus verification
- catch(InstantiationException e) {}
- catch(IllegalAccessException e) {}
- }
-
- static private byte[] toByteArray(long arr[]) {
- // convert long array to byte array
- java.nio.ByteBuffer bbuf = java.nio.ByteBuffer.allocate(arr.length * 8);
- bbuf.asLongBuffer().put(java.nio.LongBuffer.wrap(arr));
- return bbuf.array();
- }
- }
--- a/test/jdk/vm/verifier/defaultMethods/DefaultMethodRegressionTests.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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 8003639
- * @summary defaultMethod resolution and verification
- * @run main DefaultMethodRegressionTests
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * This set of classes/interfaces (K/I/C) is specially designed to expose a
- * bug in the JVM where it did not find some overloaded methods in some
- * specific situations. (fixed by hotspot changeset ffb9316fd9ed).
- */
-interface K {
- int bbb(Long l);
-}
-
-interface I extends K {
- default void aaa() {}
- default void aab() {}
- default void aac() {}
-
- default int bbb(Integer i) { return 22; }
- default int bbb(Float f) { return 33; }
- default int bbb(Long l) { return 44; }
- default int bbb(Double d) { return 55; }
- default int bbb(String s) { return 66; }
-
- default void caa() {}
- default void cab() {}
- default void cac() {}
-}
-
-class C implements I {}
-
-public class DefaultMethodRegressionTests {
- public static void main(String... args) {
- new DefaultMethodRegressionTests().run(args);
- }
- void run(String... args) {
- testLostOverloadedMethod();
- System.out.println("testLostOverloadedMethod: OK");
- testInferenceVerifier();
- System.out.println("testInferenceVerifier: OK");
- }
- void testLostOverloadedMethod() {
- C c = new C();
- assertEquals(c.bbb(new Integer(1)), 22);
- assertEquals(c.bbb(new Float(1.1)), 33);
- assertEquals(c.bbb(new Long(1L)), 44);
- assertEquals(c.bbb(new Double(0.01)), 55);
- assertEquals(c.bbb(new String("")), 66);
- }
- // Test to ensure that the inference verifier accepts older classfiles
- // with classes that implement interfaces with defaults.
- void testInferenceVerifier() {
- // interface I { int m() default { return 99; } }
- byte I_bytes[] = {
- (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x34,
- 0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00,
- 0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43,
- 0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01,
- 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
- 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
- 0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01,
- 0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05,
- 0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00
- };
- // public class C implements I {} /* -target 1.5 */
- byte C_bytes[] = {
- (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31,
- 0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07,
- 0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b,
- 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74,
- 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01,
- 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00,
- 0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01,
- 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
- 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
- 0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21,
- 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05,
- 0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00,
- 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
- ClassLoader cl = new ClassLoader() {
- protected Class<?> findClass(String name) {
- if (name.equals("I")) {
- return defineClass("I", I_bytes, 0, I_bytes.length);
- } else if (name.equals("C")) {
- return defineClass("C", C_bytes, 0, C_bytes.length);
- } else {
- return null;
- }
- }
- };
- try {
- Class.forName("C", true, cl);
- } catch (Exception e) {
- // unmodified verifier will throw VerifyError
- throw new RuntimeException(e);
- }
- }
- void assertEquals(Object o1, Object o2) {
- System.out.print("Expected: " + o1);
- System.out.println(", Obtained: " + o2);
- if (!o1.equals(o2)) {
- throw new RuntimeException("got unexpected values");
- }
- }
-}
--- a/test/jdk/vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java Thu Mar 14 16:28:31 2019 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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 8003639
- * @summary defaultMethod resolution and verification using an URLClassLoader
- * @modules jdk.compiler
- * jdk.zipfs
- * @compile -XDignore.symbol.file=true DefaultMethodRegressionTestsRun.java
- * @run main DefaultMethodRegressionTestsRun
- */
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-/**
- * This test is a variant of DefaultMethodRegressionTests, this one creates
- * an URLClassLoader to load the support classes.
- *
- */
-public class DefaultMethodRegressionTestsRun {
- public static void main(String... args) throws Exception {
- File scratchDir = new File(".");
- File testDir = new File(scratchDir, "testdir");
- testDir.mkdirs();
- File srcFile = new File(new File(System.getProperty("test.src")),
- "DefaultMethodRegressionTests.java");
- String[] javacargs = {
- srcFile.getAbsolutePath(),
- "-d",
- testDir.getAbsolutePath()
- };
- com.sun.tools.javac.Main.compile(javacargs);
- runClass(testDir, "DefaultMethodRegressionTests");
- }
- static void runClass(
- File classPath,
- String classname) throws Exception {
- URL[] urls = {classPath.toURI().toURL()};
- ClassLoader loader = new URLClassLoader(urls);
- Class<?> c = loader.loadClass(classname);
-
- Class<?>[] argTypes = new Class<?>[]{String[].class};
- Object[] methodArgs = new Object[]{null};
-
- Method method = c.getMethod("main", argTypes);
- method.invoke(c, methodArgs);
- }
-}