Thank you Casper. I wasn't aware of the sun.misc.Unsafe class, that
does the trick.
Here's what I came up with:
{code}
public class ForceCoreDump
{
public static void main( String[] args ) throws Exception
{
java.lang.reflect.Field field =
sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
field.setAccessible(true);
sun.misc.Unsafe $ = (sun.misc.Unsafe) field.get(null);
$.putAddress(0, 0);
}
}
{code}
runAfterCoreDump.sh:
{code}
#! /bin/sh
HOST=`/bin/uname -n`
PWD=`pwd`
CRASHED_HOST_SUBJECT="ForceCoreDump Crashed: $HOST $PWD"
PROCESSID=$1
cat hs_err_pid$PROCESSID.log|/bin/mailx -s "$CRASHED_HOST_SUBJECT"
myjv...@corporation.com
{code}
Here's my command which successfully invokes the runAfterCoreDump
script.
/usr/java6/binjava -cp . -XX:OnError="runAfterCoreDump.sh %p"
ForceCoreDump
Here's the output of the command
{code}
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xfebd4230, pid=8471, tid=2
#
# JRE version: 6.0_14-b08
# Java VM: Java HotSpot(TM) Server VM (14.0-b16 mixed mode)
# Problematic frame:
# V [libjvm.so+0x7d4230]
#
# An error report file with more information is saved as:
# /tmp/hs_err_pid8471.log
#
# -XX:OnError="runAfterCoreDump.sh %p"
# Executing /usr/bin/sh -c "runAfterCoreDump.sh 8471" ...
#
# If you would like to submit a bug report, please visit:
#
http://java.sun.com/webapps/bugreport/crash.jsp
#
Abort - core dumped
{code}