8051359: JPopupMenu creation in headless mode with JDK9b23 causes NPE
Reviewed-by: serb, pchelko
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Thu Aug 07 17:02:48 2014 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Fri Aug 08 16:05:52 2014 +0400
@@ -384,7 +384,7 @@
* null or the target can't be found, a null with be returned.
*/
public static AppContext targetToAppContext(Object target) {
- if (target == null || GraphicsEnvironment.isHeadless()) {
+ if (target == null) {
return null;
}
AppContext context = getAppContext(target);
@@ -458,12 +458,10 @@
* via targetToAppContext() above.
*/
public static void insertTargetMapping(Object target, AppContext appContext) {
- if (!GraphicsEnvironment.isHeadless()) {
- if (!setAppContext(target, appContext)) {
- // Target is not a Component/MenuComponent, use the private Map
- // instead.
- appContextMap.put(target, appContext);
- }
+ if (!setAppContext(target, appContext)) {
+ // Target is not a Component/MenuComponent, use the private Map
+ // instead.
+ appContextMap.put(target, appContext);
}
}