-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
1.1.6
-
x86
-
windows_nt
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2020881 | 1.2.0 | Deepa Viswanathan | P4 | Resolved | Fixed | 1.2beta4 |
Name: tb29552 Date: 05/28/98
The following method causes this message from
the JIT: A nonfatal internal JIT (3.00.039(x)) error
'MA_TryTempStore' has occurred in :
then it displays the package/class/method name followed
by: (JJ)V': Interpreting method. Please report this blah blah blah...
Code follows... It'll instantiate an
instance of the "Wait" class, which is where the problem will be
found, in a method called waitForSignal. I wrote this a while back
and never experienced any runtime problem on any platform (Linux,
AIX, OS/2, NT, Win95). JDK 1.1.6 works correctly, but the JIT
complains...
/* The following method causes this message from the
* JIT: A nonfatal internal JIT (3.00.039(x)) error
* 'MA_TryTempStore' has occurred in :
*
* then it displays the package/class/method name
* followed by: (JJ)V': Interpreting method. Please
* report this blah blah blah...
*
* Code follows... It'll instantiate an instance of the
* "Wait" class, which is where the problem will be
* found, in a method called waitForSignal. I wrote
* this a while back and never experienced any runtime
* problem on any platform (Linux, AIX, OS/2, NT,
* Win95). JDK 1.1.6 works correctly, but the JIT
* complains... */
public class tWait {
public tWait () {
}
public static void outputMessage(){
System.out.println("java.version = " +
System.getProperty("java.version"));
System.out.println("O/S Name = " +
System.getProperty("os.name"));
System.out.println("O/S architecture = " +
System.getProperty("os.arch"));
System.out.println("O/S version = " +
System.getProperty("os.version"));
}
public static void main(String args[]) {
outputMessage();
System.out.println("\nStarting up...");
try {
Wait wt = new Wait(5000);
}
catch(Exception e) {
}
System.out.println("Done...");
System.exit(0);
}
}
class TimeoutException extends Exception {
public TimeoutException () {
super("no additional information.");
}
public TimeoutException (String message) {
super(message);
}
}
class Wait {
public final static long FOREVER = -1;
public final static long ONESECOND = 1000l;
public final static long ONEMINUTE = 60000l;
public final static long ONEHOUR = 3600000l;
public final static long ONEDAY = 86400000l;
/** The Wait class is used as a blocking mechanism
* for acquire(). As this class supports custom
* sleep intervals between signal checks, this
* class exposes that for users to specify their
* own custom value. By default, 10 milliseconds is
* used as the delay factor between checks for
* signal(). */
private static long m_defaultWait = 10;
/** On some systems, the base timing mechanism used
* does not operate at the correct resolution. For
* example, calling waitForSignal( Wait.ONEMINUTE )
* doesn't actually wait for a true minute. It may
* take longer or shorter, depending on the Virtual
* Machine implementation. This variable,
* m_delayFactor, is used to adjust the timing
* value used in these types of calls to correct
* these implementation differences. */
private static long m_delayAdjustment = 0;
private static long calibrate() {
long sTime = System.currentTimeMillis();
try {
Wait wait = new Wait (100);
}
catch(Exception e) {
return System.currentTimeMillis() - sTime;
}
return 100;
}
/** Static initializer used to calibrate the
* waitForSignal() method to be accurate regardless
* of the virtual machine in use. */
static {
calibrate(); // throw the 1st number away (skews the avg)
long dFactor = calibrate();
dFactor += calibrate(); // all this may cause a slight delay
dFactor += calibrate(); // when 1st loading this class
dFactor += calibrate(); // could be as high as 2 seconds!
dFactor += calibrate();
double factor = ((double) dFactor / 5.0) / 100.0; // avg it out
m_delayAdjustment = (long) ((double) m_defaultWait * factor);
m_delayAdjustment -= m_defaultWait; // waitForSignal() uses this
}
private volatile boolean m_signal; // multi-threads access this
/**
* Create a new Wait object but don't block.
*/
public Wait () {
reset(); // initialize the state of our signal
}
/** Create a new Wait object and block for a
* signal/timeout.
*
* @param timeOut specifies the time in
* milliseconds to wait for a signal.
*
* @exception TimeoutException when the timeout
* parameter has expired. @exception
* InterruptedException when the system has
* interrupted the wait method. */
public Wait (long timeOut)
throws TimeoutException, InterruptedException
{
this(timeOut, m_defaultWait);
}
/** Create a new Wait object and block for a
* signal/timeout.
*
* @param timeOut specifies the time in
* milliseconds to wait for a signal.
*
* @param blockTime specifies the time in
* milliseconds to block between checks of a
* signal. Default constructor uses 10
* milliseconds.
*
* @exception TimeoutException when the timeout
* parameter has expired.
*
* @exception InterruptedException when the system
* has interrupted the wait method. */
public Wait (long timeOut, long blockTime)
throws TimeoutException, InterruptedException
{
this(); // base constructor
waitForSignal(timeOut, blockTime);
}
/** Retrieve the current default wait value used in
* calls to sleep() during the waitForSignal()
* method.
*
* @return long value containing the current
* default wait time. */
public final static long getDefaultWait() {
return m_defaultWait;
}
/** Reset the state of the signal for another call
* to waitForSignal(). */
public final void reset() {
m_signal = false;
}
/** Set the default wait value used in calls to
* sleep() during the waitForSignal() method.
*
* @param long value containing the default wait
* time to use. */
public final static void setDefaultWait(long delay) {
m_defaultWait = delay; // will be auto-adjusted for
// VM
} // in the waitForSignal() method
/**
* Signal the wait function to end.
*/
public final void signal() {
m_signal = true;
}
/** Provide a sleep method without worrying about
* Exceptions...
*
* @param timeOut is the amount of time to sleep.
* */
public static void sleep(long timeOut) {
// *** adjust value used for decrementing based on
// overhead time
// *** of try/catch or other quirks found in virtual
// machines
long timeLeft = timeOut;
long decrement = (timeOut != FOREVER) ?
m_defaultWait + m_delayAdjustment :
0; // don't decrement if FOREVER
while (true) { // this is a sleeping loop...
try { // wake up every 'n' milliseconds
Thread.sleep(m_defaultWait);
}
catch(InterruptedException interrupted) {
// caller won't know this happens...
return;
}
timeLeft -= decrement; // FOREVER results in no
// decrement
if (timeLeft < 1)
return; // we're done
}
}
/** Blocks the current thread from running until a
* signal or timeout occurs. If a timeout occurs,
* a TimeoutException is thrown
*
* @param timeOut specifies the time in
* milliseconds to wait for a signal.
*
* @param blockTime specifies the time in
* milliseconds to sleep between checks for the
* signal.
*
* @exception TimeoutException when the timeout
* parameter has expired.
*
* @exception InterruptedException when the system
* has interrupted the wait method. */
private volatile boolean m_blocked = false;
public final void waitForSignal(long timeOut, long blockTime)
throws TimeoutException, InterruptedException
{
long start = System.currentTimeMillis();
while (m_blocked) {
sleep(m_defaultWait);
if (System.currentTimeMillis() - start > (Wait.ONEMINUTE * 3)) {
System.out.println("Possible DEADLOCK detected in Wait.waitForSignal()");
start = System.currentTimeMillis(); // reset timeout!
}
}
m_blocked = true;
// *** adjust value used for decrementing based on overhead time
// *** of try/catch or other quirks found in virtual machines
long timeLeft = timeOut;
long decrement = (timeOut != FOREVER) ?
blockTime + m_delayAdjustment :
0; // don't decrement if FOREVER
while (!m_signal) { // until we're signalled...
try {
Thread.sleep(blockTime); // wake up every 'n'
// milliseconds
}
catch(InterruptedException interrupted) {
// let caller know why
m_blocked = false; // unblock
throw new InterruptedException("\nin Wait.waitForSignal( " +
timeOut +
", " +
blockTime +
" ) decr value: " +
decrement);
}
timeLeft -= decrement; // FOREVER results in no decrement
if (timeLeft < 1) {
m_blocked = false; // unblock
throw new TimeoutException ("\nin Wait.waitForSignal(" +
timeOut +
", " +
blockTime +
" ) decr value: " +
decrement); // we timed out
}
}
m_signal = false; // reset the signal right away
m_blocked = false; // drop out the bottom on success (signalled)
}
}
(Review ID: 32341)
======================================================================
- backported by
-
JDK-2020881 Nonfatal internal JIT (3.00.039(x)) error 'MA-TryTempStore'
- Resolved