Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 100622

Summary: [Browser] Opening Applet crashes Eclipse
Product: [Eclipse Project] Platform Reporter: Kevin Barnes <cocoakevin>
Component: SWTAssignee: Grant Gayed <grant_gayed>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: carolynmacleod4, ggaren, mrowe, Silenio_Quarti, snorthov
Version: 3.1Keywords: helpwanted
Target Milestone: 3.3 RC2   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch none

Description Kevin Barnes CLA 2005-06-17 13:12:28 EDT
1. create an HTML file with contents:
<html>
<body>
<applet code=testpass.MyApplet.class width="200" height="200">
</applet>
</body>
</html>

2. open with/web browser
3. Eclipse crashes.

From console:
2005-06-17 12:11:00.816 java[1114] GrP not requesting _registerDragTypes because the window is 
dying already
2005-06-17 12:11:46.057 java[1114] Apple Java Plugin: Java Plugin isn't first to load JVM. (src/plugin/
src/macosx/native/apple/applet/JavaInstance.m - -[JavaInstance init] : 124)
2005-06-17 12:11:46.059 java[1114] Apple Applet Plugin: JNI exception (registerNatives, 334)
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: sun/plugin/javascript/webkit/JSObject
Comment 1 Dejan Glozic CLA 2005-06-17 18:17:00 EDT
Moving to SWT to comment - this seems to be a Java applet in a page loaded by 
the SWT browser.
Comment 2 Steve Northover CLA 2005-06-20 14:36:32 EDT
I believe this is a well known problem that Applets don't run in a Browser due 
to multiple VM's in the same address space issues but Eclipse shouldn't 
crash.  Grant?
Comment 3 Grant Gayed CLA 2005-06-20 14:55:30 EDT
We don't currently run away from applets on Safari like we do on IE.  I can 
reproduce the crash on SSQ's Tiger.
Comment 4 Grant Gayed CLA 2005-06-21 10:00:51 EDT
Will investigate how hard it is to make safari run away from applets like IE.
Comment 5 Grant Gayed CLA 2005-08-23 13:24:35 EDT
Todd, does WebKit give any kind of notification/indication that a page being
shown, or about to be shown, contains an applet?  Or alternatively, that an
applet is about to be loaded?  I tried looking into aborting these cases, but I
could not find a way to detect any of them.
Comment 6 Grant Gayed CLA 2007-05-17 17:34:49 EDT
Mark and Geoffrey, do either of you know the answer to comment 5?
Comment 7 Geoffrey Garen CLA 2007-05-17 18:17:34 EDT
The code to load an applet is in WebFrameBridge.mm:546 (http://trac.webkit.org/projects/webkit/browser/trunk/WebKit/WebCoreSupport/WebFrameBridge.mm#L546).

- (NSView *)viewForJavaAppletWithFrame:(NSRect)theFrame
                        attributeNames:(NSArray *)attributeNames
                       attributeValues:(NSArray *)attributeValues
                               baseURL:(NSURL *)baseURL
                            DOMElement:(DOMElement *)element

I don't believe there's any specific notification or delegate message sent to indicate that the plug-in will load. The WebPluginDatabase determines which plug-ins will load for a given MIME type, but I don't see a public API that allows you to override its behavior.

However, I think you can just use the -[WebPreferences setJavaEnabled:] API to disable all applets from the start. I believe I see a bug where this setting applies to <applet> elements only, and not <object> elements. You could work around that by disabling all plug-ins (-[WebPreferences setPlugInsEnabled:]).
Comment 8 Grant Gayed CLA 2007-05-18 15:25:16 EDT
Created attachment 67855 [details]
patch

Thanks for your help Geoffrey!  I've confirmed that this fixes <applet> tags.  Strangely, applets that are embedded with <object> tags don't seem to launch properly with Safari (nor with the Browser, no surprise here), but they do not crash the Browser either.  So at least on the machines around here it does not seem like <object> tags are causing a problem.

I've attached a patch with the change for <applet>s, hopefully it can go in for 3.3RC2.
Comment 9 Silenio Quarti CLA 2007-05-23 15:38:24 EDT
+1
Comment 10 Carolyn MacLeod CLA 2007-05-23 16:54:05 EDT
+1
Comment 11 Grant Gayed CLA 2007-05-23 16:59:31 EDT
fixed > 0523