hotspot/test/compiler/jsr292/ConcurrentClassLoadingTest.java
author redestad
Mon, 18 Apr 2016 16:48:12 +0200
changeset 37370 4dcebdd2bbc0
parent 36851 03e2f4d0a421
child 40059 c2304140ed64
permissions -rw-r--r--
8154454: Fix compilation issue in PlainSocketImpl Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27453
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     4
 *
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     8
 *
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    14
 *
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    18
 *
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    21
 * questions.
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    22
 */
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    23
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    24
/**
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    25
 * @test
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    26
 * @bug 8022595
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    27
 * @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    28
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27453
diff changeset
    30
 *          java.management
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    31
 * @run main/othervm ConcurrentClassLoadingTest
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    32
 */
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    33
import jdk.test.lib.Utils;
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    34
import java.util.ArrayList;
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    35
import java.util.Arrays;
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    36
import java.util.List;
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    37
import java.util.Random;
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    38
import java.util.concurrent.BrokenBarrierException;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    39
import java.util.concurrent.CyclicBarrier;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    40
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    41
public class ConcurrentClassLoadingTest {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    42
    int numThreads = 0;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    43
    CyclicBarrier l;
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    44
    private static final Random rand = Utils.getRandomInstance();
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    45
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    46
    public static void main(String[] args) throws Throwable {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    47
        ConcurrentClassLoadingTest test = new ConcurrentClassLoadingTest();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    48
        test.parseArgs(args);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    49
        test.run();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    50
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    51
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    52
    void parseArgs(String[] args) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    53
        int i = 0;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    54
        while (i < args.length) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    55
            String flag = args[i];
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    56
            switch(flag) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    57
                case "-numThreads":
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    58
                    numThreads = Integer.parseInt(args[++i]);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    59
                    break;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    60
                default:
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    61
                    throw new Error("Unknown flag: " + flag);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    62
            }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    63
            ++i;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    64
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    65
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    66
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    67
    void init() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    68
        if (numThreads == 0) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    69
            numThreads = Runtime.getRuntime().availableProcessors();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    70
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    71
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    72
        l = new CyclicBarrier(numThreads + 1);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    73
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    74
        System.out.printf("Threads: %d\n", numThreads);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    75
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    76
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    77
    final List<Loader> loaders = new ArrayList<>();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    78
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    79
    void prepare() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    80
        List<String> c = new ArrayList<>(Arrays.asList(classNames));
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    81
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    82
        // Split classes between loading threads
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    83
        int count = (classNames.length / numThreads) + 1;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    84
        for (int t = 0; t < numThreads; t++) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    85
            List<String> sel = new ArrayList<>();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    86
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    87
            System.out.printf("Thread #%d:\n", t);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    88
            for (int i = 0; i < count; i++) {
27453
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    89
                if (c.isEmpty()) {
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    90
                    break;
9aeb9b97bef6 8044186: Introduce a reproducible random generator
iignatyev
parents: 22229
diff changeset
    91
                }
19713
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    92
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    93
                int k = rand.nextInt(c.size());
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    94
                String elem = c.remove(k);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    95
                sel.add(elem);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    96
                System.out.printf("\t%s\n", elem);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    97
            }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    98
            loaders.add(new Loader(sel));
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    99
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   100
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   101
        // Print diagnostic info when the test hangs
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   102
        Runtime.getRuntime().addShutdownHook(new Thread() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   103
            public void run() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   104
                boolean alive = false;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   105
                for (Loader l : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   106
                    if (!l.isAlive())  continue;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   107
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   108
                    if (!alive) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   109
                        System.out.println("Some threads are still alive:");
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   110
                        alive = true;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   111
                    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   112
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   113
                    System.out.println(l.getName());
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   114
                    for (StackTraceElement elem : l.getStackTrace()) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   115
                        System.out.println("\t"+elem.toString());
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   116
                    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   117
                }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   118
            }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   119
        });
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   120
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   121
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   122
    public void run() throws Throwable {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   123
        init();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   124
        prepare();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   125
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   126
        for (Loader loader : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   127
            loader.start();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   128
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   129
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   130
        l.await();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   131
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   132
        for (Loader loader : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   133
            loader.join();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   134
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   135
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   136
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   137
    class Loader extends Thread {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   138
        List<String> classes;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   139
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   140
        public Loader(List<String> classes) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   141
            this.classes = classes;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   142
            setDaemon(true);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   143
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   144
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   145
        @Override
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   146
        public void run() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   147
            try {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   148
                l.await();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   149
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   150
                for (String name : classes) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   151
                    Class.forName(name).getName();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   152
                }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   153
            } catch (ClassNotFoundException | BrokenBarrierException | InterruptedException e) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   154
                throw new Error(e);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   155
            }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   156
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   157
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   158
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   159
    final static String[] classNames = {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   160
            "java.lang.invoke.CallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   161
            "java.lang.invoke.ConstantCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   162
            "java.lang.invoke.LambdaConversionException",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   163
            "java.lang.invoke.LambdaMetafactory",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   164
            "java.lang.invoke.MethodHandle",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   165
            "java.lang.invoke.MethodHandleInfo",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   166
            "java.lang.invoke.MethodHandleProxies",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   167
            "java.lang.invoke.MethodHandles",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   168
            "java.lang.invoke.MethodType",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   169
            "java.lang.invoke.MutableCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   170
            "java.lang.invoke.SerializedLambda",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   171
            "java.lang.invoke.SwitchPoint",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   172
            "java.lang.invoke.VolatileCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   173
            "java.lang.invoke.WrongMethodTypeException"
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   174
    };
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   175
}