/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6467152 6716076 6829503
* @summary deadlock occurs in LogManager initialization and JVM termination
* @author Serguei Spitsyn / Hitachi / Martin Buchholz
*
* @build LoggingDeadlock2
*
* There is a clear deadlock between LogManager.<clinit> and
* Cleaner.run() methods.
* T1 thread:
* The LogManager.<clinit> creates LogManager.manager object,
* sets shutdown hook with the Cleaner class and then waits
* to lock the LogManager.manager monitor.
* T2 thread:
* It is started by the System.exit() as shutdown hook thread.
* It locks the LogManager.manager monitor and then calls the
* static methods of the LogManager class (in this particular
* case it is a trick of the inner classes implementation).
* It is waits when the LogManager.<clinit> is completed.
*
* This is a regression test for this bug.
*/
public class LoggingDeadlock2 {
try {
} catch (Throwable t) { unexpected(t); }
}
public static class JavaChild {
// Some random variation, to help tickle races.
final int JITTER = 1024;
public void run() {
try {
for (int i = 0; i < iters1; i++)
} catch (Throwable t) {
t.printStackTrace();
}
}};
for (int i = 0; i < iters2; i++)
// This may or may not result in a first call to
// Runtime.addShutdownHook after shutdown has already
// commenced.
if (dojoin) {
}
}
}
//----------------------------------------------------------------
// The rest of this test is copied from ProcessBuilder/Basic.java
//----------------------------------------------------------------
"LoggingDeadlock2$JavaChild"});
private static class ProcessResults {
private final int exitValue;
int exitValue,
}
}
}
throw throwable;
}
}
public void run() {
try {
char[] buf = new char[4096];
int n;
}
} catch (Throwable t) {
throwable = t;
} finally {
}
}
}
int exitValue = -1;
new StreamAccumulator(p.getInputStream());
new StreamAccumulator(p.getErrorStream());
try {
} catch (Throwable t) {
throwable = t;
}
}
//--------------------- Infrastructure ---------------------------
else fail(x + " not equal to " + y);}
}