10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test LFMultiThreadCachingTest
26 * @bug 8046703
27 * @key randomness
28 * @summary Test verifies that lambda forms are cached when run with multiple threads
29 * @author kshefov
30 * @library /java/lang/invoke/common /lib/testlibrary
31 * @modules java.base/java.lang.invoke:open
32 * java.base/java.lang.ref:open
33 * java.management
34 * @build TestMethods
35 * @build LambdaFormTestCase
36 * @build LFCachingTestCase
37 * @build LFMultiThreadCachingTest
38 * @run main/othervm LFMultiThreadCachingTest
39 */
40
41 import java.lang.invoke.MethodHandle;
42 import java.util.Collections;
43 import java.util.EnumSet;
44 import java.util.HashMap;
45 import java.util.Map;
46 import java.util.concurrent.ConcurrentLinkedQueue;
47 import java.util.concurrent.CountDownLatch;
48 import java.util.concurrent.CyclicBarrier;
49 import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
50
51 /**
52 * Multiple threaded lambda forms caching test class.
53 */
54 public final class LFMultiThreadCachingTest extends LFCachingTestCase {
55
56 private static final TestMethods.Kind[] KINDS;
57
58 static {
59 EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
60 KINDS = set.toArray(new TestMethods.Kind[set.size()]);
61 if (KINDS.length < 2) {
62 throw new Error("TESTBUG: KINDS.length[" + KINDS.length + "] should be at least 2");
63 }
64 }
65 private static final int CORES = Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
66
67 /**
68 * Constructor a for multiple threaded lambda forms caching test case.
69 *
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test LFMultiThreadCachingTest
26 * @bug 8046703
27 * @key randomness
28 * @summary Test verifies that lambda forms are cached when run with multiple threads
29 * @author kshefov
30 * @library /lib/testlibrary /java/lang/invoke/common
31 * @modules java.base/java.lang.invoke:open
32 * java.base/java.lang.ref:open
33 * java.management
34 * @build TestMethods
35 * @build LambdaFormTestCase
36 * @build LFCachingTestCase
37 * @build LFMultiThreadCachingTest
38 * @run main/othervm LFMultiThreadCachingTest
39 */
40
41 import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
42
43 import java.lang.invoke.MethodHandle;
44 import java.util.Collections;
45 import java.util.EnumSet;
46 import java.util.HashMap;
47 import java.util.Map;
48 import java.util.concurrent.ConcurrentLinkedQueue;
49 import java.util.concurrent.CountDownLatch;
50 import java.util.concurrent.CyclicBarrier;
51
52 /**
53 * Multiple threaded lambda forms caching test class.
54 */
55 public final class LFMultiThreadCachingTest extends LFCachingTestCase {
56
57 private static final TestMethods.Kind[] KINDS;
58
59 static {
60 EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
61 KINDS = set.toArray(new TestMethods.Kind[set.size()]);
62 if (KINDS.length < 2) {
63 throw new Error("TESTBUG: KINDS.length[" + KINDS.length + "] should be at least 2");
64 }
65 }
66 private static final int CORES = Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
67
68 /**
69 * Constructor a for multiple threaded lambda forms caching test case.
70 *
|