Path: blob/master/test/jdk/java/security/Security/ClassLoaderDeadlock/Deadlock.java
41152 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324// see Deadlock.sh2526import java.security.*;2728public class Deadlock implements Runnable {2930private volatile Exception exc;3132public void run() {33try {34SecureRandom random = SecureRandom.getInstance("SHA1PRNG");35System.out.println("getInstance() ok: " + random);36} catch (Exception e) {37System.out.println("Exception during getInstance() call: " + e);38this.exc = e;39}40}4142public static void main(String[] args) throws Exception {43Deadlock d = new Deadlock();44Thread t = new Thread(d);45t.start();46String className = (args.length == 0) ? "com.abc.Tst1" : args[0];47System.out.println("Loading class: " + className);48ClassLoader cl = ClassLoader.getSystemClassLoader();49System.out.println("SystemClassLoader: " + cl);50Class clazz = cl.loadClass(className);51System.out.println("OK: " + clazz);52t.join();53if (d.exc != null) {54throw d.exc;55}56}5758}596061