Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6678999
Votes 0
Synopsis Stacktrace missing after null string comparisons
Category hotspot:compiler2
Reported Against
Release Fixed
State 11-Closed, Will Not Fix, bug
Priority: 4-Low
Related Bugs 4292742
Submit Date 24-MAR-2008
Description
FULL PRODUCT VERSION :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

and

java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Ubuntu Gutsy 32-bits (reproduced on a  customer  Enterprise Edition)

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested on a Core 2 Duo (model 6400) 2.13Ghz with 2Gb RAM

A DESCRIPTION OF THE PROBLEM :
After comparing a string to null and catching the exception and repeating the operation, JVM starts throwing "stackless" NullPointerException (it occurs after 9000 loops but this is variable)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Stacktrace should be always be printed.
ACTUAL -
After around 9000 times the stacktrace is ommited.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Console output snippet:

java.lang.NullPointerException
	at java.lang.String.startsWith(String.java:1422)
	at java.lang.String.startsWith(String.java:1451)
	at Bug.main(Bug.java:8)
java.lang.NullPointerException
	at java.lang.String.startsWith(String.java:1422)
	at java.lang.String.startsWith(String.java:1451)
	at Bug.main(Bug.java:8)
java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
 public static void main(String[] args) {
        
        for (int i = 0; i < Integer.MAX_VALUE/100000; i++) {
            
            try {
                System.out.println(i);
                "ABC".startsWith(null);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Couldn't reproduce after adding a System.gc() before comparing the string.
Posted Date : 2008-03-24 09:05:40.0
Work Around
Use the -XX:-OmitStackTraceInFastThrow option.
Evaluation
Similar to 4292742 which was fixed in 1.3.1_14.  Routing to the owners of that issue for their evaluation.
Posted Date : 2008-04-07 16:02:39.0

When the server compiler compiles a method, the stack trace in an exception thrown
by that method may be omitted for performance purposes. 

In this case, the stacktrace disappears when the String.startsWith method is
compiled. If the user always wants stack traces, use the -XX:-OmitStackTraceInFastThrow option to the VM.
Posted Date : 2008-04-07 17:26:15.0
Comments
  
  Include a link with my name & email   

Submitted On 28-MAR-2008
ca_linux
Probably the same issue as bug 4966410.



PLEASE NOTE: JDK6 is formerly known as Project Mustang