提交 842c54ea 编写于 作者: C coffeys

8013196: TimeZone.getDefault() throws NPE due to sun.awt.AppContext.getAppContext()

Reviewed-by: mchung, okutsu
上级 4f0c833e
...@@ -814,16 +814,24 @@ public final class AppContext { ...@@ -814,16 +814,24 @@ public final class AppContext {
static { static {
sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() { sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() {
public Object get(Object key) { 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) { 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) { public void remove(Object key) {
getAppContext().remove(key); AppContext ac = getAppContext();
if (ac != null) {
ac.remove(key);
}
} }
public boolean isDisposed() { public boolean isDisposed() {
return getAppContext().isDisposed(); AppContext ac = getAppContext();
return (ac == null) ? true : ac.isDisposed();
} }
public boolean isMainAppContext() { public boolean isMainAppContext() {
return (numAppContexts.get() == 1 && mainAppContext != null); return (numAppContexts.get() == 1 && mainAppContext != null);
......
/* /*
* Copyright (c) 2002, 2011, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -170,6 +170,9 @@ public class SharedSecrets { ...@@ -170,6 +170,9 @@ public class SharedSecrets {
public static JavaAWTAccess getJavaAWTAccess() { public static JavaAWTAccess getJavaAWTAccess() {
// this may return null in which case calling code needs to // this may return null in which case calling code needs to
// provision for. // provision for.
if (javaAWTAccess == null || javaAWTAccess.getContext() == null) {
return null;
}
return javaAWTAccess; return javaAWTAccess;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册