hotspot/test/compiler/jsr292/ConcurrentClassLoadingTest.java
author ccheung
Fri, 04 Oct 2013 21:00:43 -0700
changeset 20384 49bfb2ec8f8f
parent 19713 8ef23b417f55
child 21729 6fe1dafeb82e
permissions -rw-r--r--
Merge
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
/*
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    28
 *
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    29
 * @run main/othervm ConcurrentClassLoadingTest
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    30
 */
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    31
import java.util.*;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    32
import java.util.concurrent.BrokenBarrierException;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    33
import java.util.concurrent.CyclicBarrier;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    34
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    35
public class ConcurrentClassLoadingTest {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    36
    int numThreads = 0;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    37
    long seed = 0;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    38
    CyclicBarrier l;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    39
    Random rand;
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 static void main(String[] args) throws Throwable {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    42
        ConcurrentClassLoadingTest test = new ConcurrentClassLoadingTest();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    43
        test.parseArgs(args);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    44
        test.run();
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
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    47
    void parseArgs(String[] args) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    48
        int i = 0;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    49
        while (i < args.length) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    50
            String flag = args[i];
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    51
            switch(flag) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    52
                case "-seed":
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    53
                    seed = Long.parseLong(args[++i]);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    54
                    break;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    55
                case "-numThreads":
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    56
                    numThreads = Integer.parseInt(args[++i]);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    57
                    break;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    58
                default:
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    59
                    throw new Error("Unknown flag: " + flag);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    60
            }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    61
            ++i;
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
    }
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
    void init() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    66
        if (numThreads == 0) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    67
            numThreads = Runtime.getRuntime().availableProcessors();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    68
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    69
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    70
        if (seed == 0) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    71
            seed = (new Random()).nextLong();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    72
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    73
        rand = new Random(seed);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    74
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    75
        l = new CyclicBarrier(numThreads + 1);
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
        System.out.printf("Threads: %d\n", numThreads);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    78
        System.out.printf("Seed: %d\n", seed);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    79
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    80
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    81
    final List<Loader> loaders = new ArrayList<>();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    82
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    83
    void prepare() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    84
        List<String> c = new ArrayList<>(Arrays.asList(classNames));
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    85
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    86
        // Split classes between loading threads
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    87
        int count = (classNames.length / numThreads) + 1;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    88
        for (int t = 0; t < numThreads; t++) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    89
            List<String> sel = new ArrayList<>();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    90
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    91
            System.out.printf("Thread #%d:\n", t);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    92
            for (int i = 0; i < count; i++) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    93
                if (c.size() == 0) break;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    94
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    95
                int k = rand.nextInt(c.size());
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    96
                String elem = c.remove(k);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    97
                sel.add(elem);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
    98
                System.out.printf("\t%s\n", elem);
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
            loaders.add(new Loader(sel));
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   101
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   102
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   103
        // Print diagnostic info when the test hangs
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   104
        Runtime.getRuntime().addShutdownHook(new Thread() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   105
            public void run() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   106
                boolean alive = false;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   107
                for (Loader l : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   108
                    if (!l.isAlive())  continue;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   109
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   110
                    if (!alive) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   111
                        System.out.println("Some threads are still alive:");
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   112
                        alive = true;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   113
                    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   114
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   115
                    System.out.println(l.getName());
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   116
                    for (StackTraceElement elem : l.getStackTrace()) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   117
                        System.out.println("\t"+elem.toString());
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
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   123
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   124
    public void run() throws Throwable {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   125
        init();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   126
        prepare();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   127
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   128
        for (Loader loader : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   129
            loader.start();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   130
        }
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
        l.await();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   133
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   134
        for (Loader loader : loaders) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   135
            loader.join();
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
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   138
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   139
    class Loader extends Thread {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   140
        List<String> classes;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   141
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   142
        public Loader(List<String> classes) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   143
            this.classes = classes;
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   144
            setDaemon(true);
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   145
        }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   146
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   147
        @Override
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   148
        public void run() {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   149
            try {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   150
                l.await();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   151
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   152
                for (String name : classes) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   153
                    Class.forName(name).getName();
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   154
                }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   155
            } catch (ClassNotFoundException | BrokenBarrierException | InterruptedException e) {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   156
                throw new Error(e);
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
    }
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   160
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   161
    final static String[] classNames = {
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   162
            "java.lang.invoke.AbstractValidatingLambdaMetafactory",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   163
            "java.lang.invoke.BoundMethodHandle",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   164
            "java.lang.invoke.CallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   165
            "java.lang.invoke.ConstantCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   166
            "java.lang.invoke.DirectMethodHandle",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   167
            "java.lang.invoke.InnerClassLambdaMetafactory",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   168
            "java.lang.invoke.InvokeDynamic",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   169
            "java.lang.invoke.InvokeGeneric",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   170
            "java.lang.invoke.InvokerBytecodeGenerator",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   171
            "java.lang.invoke.Invokers",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   172
            "java.lang.invoke.LambdaConversionException",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   173
            "java.lang.invoke.LambdaForm",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   174
            "java.lang.invoke.LambdaMetafactory",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   175
            "java.lang.invoke.MagicLambdaImpl",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   176
            "java.lang.invoke.MemberName",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   177
            "java.lang.invoke.MethodHandle",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   178
            "java.lang.invoke.MethodHandleImpl",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   179
            "java.lang.invoke.MethodHandleInfo",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   180
            "java.lang.invoke.MethodHandleNatives",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   181
            "java.lang.invoke.MethodHandleProxies",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   182
            "java.lang.invoke.MethodHandles",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   183
            "java.lang.invoke.MethodHandleStatics",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   184
            "java.lang.invoke.MethodType",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   185
            "java.lang.invoke.MethodTypeForm",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   186
            "java.lang.invoke.MutableCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   187
            "java.lang.invoke.SerializedLambda",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   188
            "java.lang.invoke.SimpleMethodHandle",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   189
            "java.lang.invoke.SwitchPoint",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   190
            "java.lang.invoke.TypeConvertingMethodAdapter",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   191
            "java.lang.invoke.VolatileCallSite",
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   192
            "java.lang.invoke.WrongMethodTypeException"
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   193
    };
8ef23b417f55 8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff changeset
   194
}