7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8

Reviewed-by: serb, ant
This commit is contained in:
Semyon Sadetsky 2015-05-08 17:35:15 +03:00
parent 25b0a009bc
commit 3a2ff1374b
8 changed files with 26 additions and 15 deletions

View File

@ -413,9 +413,9 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
items.removeElementAt(index);
MenuPeer peer = (MenuPeer)this.peer;
if (peer != null) {
peer.delItem(index);
mi.removeNotify();
mi.parent = null;
peer.delItem(index);
}
}
}

View File

@ -222,7 +222,6 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
if (m.parent != null) {
m.parent.remove(m);
}
menus.addElement(m);
m.parent = this;
MenuBarPeer peer = (MenuBarPeer)this.peer;
@ -232,6 +231,7 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
}
peer.addMenu(m);
}
menus.addElement(m);
return m;
}
}
@ -248,9 +248,9 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
menus.removeElementAt(index);
MenuBarPeer peer = (MenuBarPeer)this.peer;
if (peer != null) {
peer.delMenu(index);
m.removeNotify();
m.parent = null;
peer.delMenu(index);
}
if (helpMenu == m) {
helpMenu = null;

View File

@ -77,7 +77,7 @@ public abstract class MenuComponent implements java.io.Serializable {
* @see #setFont(Font)
* @see #getFont()
*/
Font font;
volatile Font font;
/**
* The menu component's name, which defaults to <code>null</code>.
@ -302,11 +302,13 @@ public abstract class MenuComponent implements java.io.Serializable {
* @see java.awt.font.TextAttribute
*/
public void setFont(Font f) {
font = f;
//Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
MenuComponentPeer peer = this.peer;
if (peer != null) {
peer.setFont(f);
synchronized (getTreeLock()) {
font = f;
//Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
MenuComponentPeer peer = this.peer;
if (peer != null) {
peer.setFont(f);
}
}
}

View File

@ -31,9 +31,9 @@ abstract class WObjectPeer {
}
// The Windows handle for the native widget.
long pData;
volatile long pData;
// if the native peer has been destroyed
boolean destroyed = false;
volatile boolean destroyed = false;
// The associated AWT object.
Object target;

View File

@ -239,6 +239,7 @@ AwtMenuItem* AwtMenu::GetItem(jobject target, jint index)
}
jobject menuItem = env->CallObjectMethod(target, AwtMenu::getItemMID,
index);
if (!menuItem) return NULL; // menu item was removed concurrently
DASSERT(!safe_ExceptionOccurred(env));
jobject wMenuItemPeer = GetPeerForTarget(env, menuItem);
@ -264,9 +265,9 @@ void AwtMenu::DrawItems(DRAWITEMSTRUCT& drawInfo)
}
/* target is a java.awt.Menu */
jobject target = GetTarget(env);
if(!target || env->ExceptionCheck()) return;
int nCount = CountItem(target);
for (int i = 0; i < nCount; i++) {
for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
AwtMenuItem* awtMenuItem = GetItem(target, i);
if (awtMenuItem != NULL) {
SendDrawItem(awtMenuItem, drawInfo);
@ -294,8 +295,9 @@ void AwtMenu::MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo)
}
/* target is a java.awt.Menu */
jobject target = GetTarget(env);
if(!target || env->ExceptionCheck()) return;
int nCount = CountItem(target);
for (int i = 0; i < nCount; i++) {
for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
AwtMenuItem* awtMenuItem = GetItem(target, i);
if (awtMenuItem != NULL) {
SendMeasureItem(awtMenuItem, hDC, measureInfo);

View File

@ -156,13 +156,16 @@ AwtMenuItem* AwtMenuBar::GetItem(jobject target, long index)
}
jobject menu = env->CallObjectMethod(target, AwtMenuBar::getMenuMID,index);
if (!menu) return NULL; // menu item was removed concurrently
DASSERT(!safe_ExceptionOccurred(env));
jobject menuItemPeer = GetPeerForTarget(env, menu);
PDATA pData;
JNI_CHECK_PEER_RETURN_NULL(menuItemPeer);
JNI_CHECK_PEER_GOTO(menuItemPeer, done);
AwtMenuItem* awtMenuItem = (AwtMenuItem*)pData;
done:
env->DeleteLocalRef(menu);
env->DeleteLocalRef(menuItemPeer);

View File

@ -112,6 +112,7 @@ void AwtMenuItem::Dispose()
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (m_peerObject != NULL) {
JNI_SET_DESTROYED(m_peerObject);
JNI_SET_PDATA(m_peerObject, NULL);
env->DeleteGlobalRef(m_peerObject);
m_peerObject = NULL;

View File

@ -172,6 +172,9 @@ safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
env->ExceptionClear();
// rethrow exception
env->Throw(xcp);
// temp solution to reveal all concurrency issues in jtreg and JCK
// we will switch it back to silent mode before the release
env->ExceptionDescribe();
return xcp;
}
}