JDK-6976207 : Regression in java.lang.Throwable introduced in JDK7b102
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2010-08-11
  • Updated: 2012-03-22
  • Resolved: 2010-08-11
Related Reports
Duplicate :  
Description
Platforms : ALL
JDK6      : PASSES
JDK7 b101 : PASSES
JDK7 b102 : FAILS

The following code within the first try{} generates OutOfMemory error. 
When trying to print its stacktrace NPE is thrown from method of class Throwable

public class OME {
    public static void main(String[] args) {
        try {
            char[] chars = new char[Integer.MAX_VALUE];
        } catch (Throwable e) {
            try {
                e.printStackTrace();
            } catch (NullPointerException npe) {
                System.err.println("NPE thrown:");
                npe.printStackTrace();
            }
        }
    }
}

----------------------------------------

java.lang.OutOfMemoryError: Java heap space
	at OME.main(OME.java:5)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
NPE thrown:
java.lang.NullPointerException
	at java.lang.Throwable.printStackTrace(Throwable.java:563)
	at java.lang.Throwable.printStackTrace(Throwable.java:548)
	at java.lang.Throwable.printStackTrace(Throwable.java:539)
	at OME.main(OME.java:8)
...

Comments
EVALUATION This appears to be a duplicate of 6973831.
11-08-2010