changeset 6011:c448f31eb138

8013196: TimeZone.getDefault() throws NPE due to sun.awt.AppContext.getAppContext() Reviewed-by: mchung, okutsu
author coffeys
date Wed, 01 May 2013 21:02:04 +0100
parents 431c2b754123
children c82ed89b21bc
files src/share/classes/sun/awt/AppContext.java src/share/classes/sun/misc/SharedSecrets.java
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/awt/AppContext.java	Wed May 01 00:49:21 2013 +0200
+++ b/src/share/classes/sun/awt/AppContext.java	Wed May 01 21:02:04 2013 +0100
@@ -801,16 +801,24 @@
     static {
         sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() {
             public Object get(Object key) {
-                return getAppContext().get(key);
+                AppContext ac = getAppContext();
+                return (ac == null) ? null : ac.get(key);
             }
             public void put(Object key, Object value) {
-                getAppContext().put(key, value);
+                AppContext ac = getAppContext();
+                if (ac != null) {
+                    ac.put(key, value);
+                }
             }
             public void remove(Object key) {
-                getAppContext().remove(key);
+                AppContext ac = getAppContext();
+                if (ac != null) {
+                    ac.remove(key);
+                }
             }
             public boolean isDisposed() {
-                return getAppContext().isDisposed();
+                AppContext ac = getAppContext();
+                return (ac == null) ? true : ac.isDisposed();
             }
             public boolean isMainAppContext() {
                 return (numAppContexts.get() == 1 && mainAppContext != null);
--- a/src/share/classes/sun/misc/SharedSecrets.java	Wed May 01 00:49:21 2013 +0200
+++ b/src/share/classes/sun/misc/SharedSecrets.java	Wed May 01 21:02:04 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -197,6 +197,9 @@
     public static JavaAWTAccess getJavaAWTAccess() {
         // this may return null in which case calling code needs to
         // provision for.
+        if (javaAWTAccess == null || javaAWTAccess.getContext() == null) {
+            return null;
+        }
         return javaAWTAccess;
     }
 }