Duplicate :
|
Name: gm110360 Date: 06/17/2003 FULL PRODUCT VERSION : java version "1.4.1_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06) Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode) FULL OS VERSION : Microsoft Windows XP [Version 5.1.2600] EXTRA RELEVANT SYSTEM CONFIGURATION : ATI graphics card A DESCRIPTION OF THE PROBLEM : When an applet tag is written to an HTML document, the applet is loaded but a NullPointerException is thrown before init and getDocumentBase() returns null. If the applet tag appears in the HTML when it is loaded or on 1.3.x versions of the plug-in, everything works fine. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : - Compile AppletTest.java (source below) in the same directory as applet-inline.html and applet-written.html - Configure IE to use java plug-in 1.4.1_02 (or any previous 1.4.x) - Open applet-inline.html (source below) in IE. - Open the java console. It will show (as expected) something like: here in init ac = sun.plugin.viewer.context.IExplorerAppletContext@d6a05e db = file:/C:/at/applet-inline.html - Open applet-written.html (source below) in IE. - Open the java console. It will show something like: java.lang.NullPointerException at sun.plugin.viewer.context.IExplorerAppletContext.getJSObject(Unknown Source) at sun.plugin.AppletViewer.getDocumentBase(Unknown Source) at sun.plugin.AppletViewer.getCodeBase(Unknown Source) at sun.plugin.AppletViewer.appletInit(Unknown Source) at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source) at sun.plugin.viewer.IExplorerPluginObject$Initer.run(Unknown Source) here in init ac = sun.plugin.viewer.context.IExplorerAppletContext@1b3f8f6 db = null EXPECTED VERSUS ACTUAL BEHAVIOR : The console should contain something like: here in init ac = sun.plugin.viewer.context.IExplorerAppletContext@d6a05e db = file:/C:/at/applet-inline.html as it does for applet-inline.html and for both .html files using a 1.3.x plug-in. With applet-written.html and the 1.4.x plug-in, the console contains: java.lang.NullPointerException at sun.plugin.viewer.context.IExplorerAppletContext.getJSObject(Unknown Source) at sun.plugin.AppletViewer.getDocumentBase(Unknown Source) at sun.plugin.AppletViewer.getCodeBase(Unknown Source) at sun.plugin.AppletViewer.appletInit(Unknown Source) at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source) at sun.plugin.viewer.IExplorerPluginObject$Initer.run(Unknown Source) here in init ac = sun.plugin.viewer.context.IExplorerAppletContext@1b3f8f6 db = null ERROR MESSAGES/STACK TRACES THAT OCCUR : See results above. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- Here is AppletTest.java: ---------------------------------------------------------------------- import java.net.URL; import java.applet.Applet; public class AppletTest extends Applet { public void init() { System.err.println("here in init"); System.err.println("ac = " + getAppletContext()); URL db = getDocumentBase(); System.err.println("db = " + db); } } ---------------------------------------------------------------------- Here is applet-inline.html: ---------------------------------------------------------------------- <html> <head> <title>Applet Test</title> </head> <body> <applet name="AppletTest" code="AppletTest.class" width=100 height=40 mayscript></applet> </body> </html> ---------------------------------------------------------------------- Here is applet-written.html: ---------------------------------------------------------------------- <html> <head> <title>Applet Test</title> <script type='text/javascript'> <!-- function go() { var s = '<applet name="AppletTest" ' + 'code="AppletTest.class" ' + 'width=100 ' + 'height=40 ' + 'mayscript>' + '</applet>'; if (document.all) document.all.appletHolder.innerHTML = s; else if (document.getElementById) document.getElementById('appletHolder').innerHTML = s; else alert('This example doesn\'t work on your browser'); } //--> </script> </head> <body onload="go()"> <div id=appletHolder style="position: absolute;"></div> </body> </html> ---------- END SOURCE ---------- (Review ID: 184110) ======================================================================