< prev index next >

test/jdk/java/lang/management/ManagementFactory/ThreadMXBeanProxy.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2005, 2016, 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. --- 1,7 ---- /* ! * Copyright (c) 2005, 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.
*** 21,31 **** * questions. */ /* * @test ! * @bug 5086470 6358247 7193302 * @summary Test type conversion when invoking ThreadMXBean.dumpAllThreads * through proxy. * @author Mandy Chung * * @run main ThreadMXBeanProxy --- 21,31 ---- * questions. */ /* * @test ! * @bug 5086470 6358247 7193302 8048215 * @summary Test type conversion when invoking ThreadMXBean.dumpAllThreads * through proxy. * @author Mandy Chung * * @run main ThreadMXBeanProxy
*** 43,52 **** --- 43,53 ---- private static MBeanServer server = ManagementFactory.getPlatformMBeanServer(); private static ThreadMXBean mbean; static Mutex mutex = new Mutex(); static Object lock = new Object(); + static Object waiter = new Object(); static MyThread thread = new MyThread(); public static void main(String[] argv) throws Exception { mbean = newPlatformMXBeanProxy(server, THREAD_MXBEAN_NAME, ThreadMXBean.class);
*** 66,75 **** --- 67,82 ---- } catch (InterruptedException e) { throw new RuntimeException(e); } } + // 'thread' holds the mutex, which means it must also have the monitor of + // 'waiter' at least until it does the wait(). So we acquire the monitor of + // 'waiter' here, which ensures that 'thread' must be in wait() + synchronized(waiter) { + } + long[] ids = new long[] { thread.getId() }; // validate the local access ThreadInfo[] infos = getThreadMXBean().getThreadInfo(ids, true, true); if (infos.length != 1) {
*** 106,120 **** public MyThread() { super("MyThread"); } public void run() { synchronized (lock) { mutex.lock(); - Object o = new Object(); - synchronized(o) { try { ! o.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } } } --- 113,126 ---- public MyThread() { super("MyThread"); } public void run() { synchronized (lock) { + synchronized(waiter) { mutex.lock(); try { ! waiter.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
< prev index next >