Other |
---|
1.4.2 b14Fixed |
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
According to the 1.3 API doc, getDocumentBase() is supposed to return the URL of the directory of the document in which an applet is embedded. According to the 1.3 API doc, getCodeBase is supposed to return the URL of the applet itself. The actual behavior is reversed and has been reversed for a long time. algol% cat SimpleApplet.java import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; public class SimpleApplet extends Applet{ public void init() { setBackground(Color.cyan); } public void start() { System.out.println("starting..."); } public void stop() { System.out.println("stopping..."); } public void destroy() { System.out.println("preparing to unload..."); } public void paint(Graphics g){ System.out.println("Paint"); g.setColor(Color.blue); g.drawRect(0, 0, getSize().width -1, getSize().height -1); g.setColor(Color.red); g.drawString("getDocumentBase: "+getDocumentBase(), 15, 25); g.drawString("getCodeBase: "+getCodeBase(), 15, 35); } } algol% cat SimpleApplet.html <HTML> <BODY> <APPLET CODE=SimpleApplet.class WIDTH=200 HEIGHT=100> </APPLET> </BODY> </HTML> I tested a large number of JDKs and found that the results have been stable for a long time (at least on Solaris/sparc): getDocumentBase file:/home/ajacobs/public_html/BasicJava1/SimpleApplet.html getCodeBase file:/home/ajacobs/public_html/BasicJava1/ The JDKs checked: 1.1.6, 1.1.7, 1.1.8_13, 1.2 FCS, 1.2.1_004, 1.2.2_008, 1.2.2_08, 1.3.1, and 1.4. Testing on Merlin (1.4) shows that behavior is consistent on Windows and Intel/Solaris. According to the JDK 1.3 API documentation, the results should have been getCodeBase file:/home/ajacobs/public_html/BasicJava1/SimpleApplet.html getDocumentBase file:/home/ajacobs/public_html/BasicJava1/ allan.jacobs@Eng 2001-05-09 Name: jk109818 Date: 11/05/2001 java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C) Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode) In the API, getDocumentBase() is listed as "Return(ing) an absolute URL naming the directory of the document in which the applet is embedded." However getDocumentBase(), when a toString() is used prints "the URL of the applet itself" -- the function listed for getCodeBase(). A Simalar screen print of the toString() of getCodeBase() displays the base directory of the applet. Please contact me if I have misinterpreted the API. I have found this discrepancy on VM's 1.3.1 and 1.3.0. (Review ID: 134789) ======================================================================
|