Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cast error only when using JNLP

800485Jan 19 2011 — edited Jan 19 2011
Hi

I have written a draggable applet and it raises an unexpected cast error in particular conditions. When using the APPLET tag there is no problem, but when using a JNLP file and dragging twice the applet outside the browser, the restore method fails.

here is the restore method :

public void appletRestored() {
try {
Enumeration e = getAppletContext().getApplets();
while(e.hasMoreElements()) {
BuggedApplet theapplet = (BuggedApplet)e.nextElement();
}
}
catch (Exception e) {
e.printStackTrace();
}
}

the exception is :

java.lang.ClassCastException: BuggedApplet cannot be cast to BuggedApplet
at BuggedApplet.appletRestored(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo.sendAppletRestored(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo.restore(Unknown Source)
at sun.plugin2.applet.DragHelper.restore(Unknown Source)
at sun.plugin2.main.client.PluginMain$PluginMainDragListener.appletExternalWindowClosed(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo$CloseListener.actionPerformed(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo$6.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

how to reproduce :
load this page in browser : http://r35506.ovh.net/bug/splash.html
drag the applet outside the browser
reload the page
drag the applet outside the browser (you now have 2 applets dragged)
close the 2nd applet, it raises the exception

there is no problem when not using JNLP, you can check it at :
http://r35506.ovh.net/bug/index.html

Edited by: user1114974 on 18 janv. 2011 23:41
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2011
Added on Jan 19 2011
0 comments
132 views