diff --git a/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp b/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp index 2801d4ced0e..cf12bf59607 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2018, 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 @@ -206,7 +206,10 @@ void AwtMenuBar::DeleteItem(UINT index) * this function must be called to draw the changed menu bar. */ void AwtMenuBar::RedrawMenuBar() { - VERIFY(::DrawMenuBar(GetOwnerHWnd())); + HWND hOwnerWnd = GetOwnerHWnd(); + if (hOwnerWnd != NULL) { + VERIFY(::DrawMenuBar(hOwnerWnd)); + } } void AwtMenuBar::_AddMenu(void *param) diff --git a/test/jdk/java/awt/Menu/WrongParentAfterRemoveMenu/WrongParentAfterRemoveMenu.java b/test/jdk/java/awt/Menu/WrongParentAfterRemoveMenu/WrongParentAfterRemoveMenu.java index 18dc47912aa..19f3c829fb7 100644 --- a/test/jdk/java/awt/Menu/WrongParentAfterRemoveMenu/WrongParentAfterRemoveMenu.java +++ b/test/jdk/java/awt/Menu/WrongParentAfterRemoveMenu/WrongParentAfterRemoveMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -29,7 +29,7 @@ import java.awt.Window; /** * @test - * @bug 8165769 + * @bug 8165769 8198001 * @key headful */ public final class WrongParentAfterRemoveMenu {