FULL PRODUCT VERSION :
JDK 5.0
ADDITIONAL OS VERSION INFORMATION :
Windows 2000 SP 4, IE 6.
Windows XP SP@, IE 6.0.
A DESCRIPTION OF THE PROBLEM :
A signed applet that accesss the users local disk works fine, *until* a field in the applet had been changed and the diska-ccessor method is called again. This is only aproblem on IE; Mozilla works okay although the first re-read of the disk spins CPU for about 5 seconds (subsequent reads are fine)
Example provided (also at http://kensystem.com/JSOcwd )
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and sign applet source code provided. Run using provided HTML file, using both IE and Mozilla browsers.
ACTUAL -
AccessControlException is thrown only after changing a field-value in the applet, in this case the "current working directory".
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Java Plug-in 1.5.0
Using JRE version 1.5.0 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator
java.security.AccessControlException: access denied (java.io.FilePermission c:\ read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.list(Unknown Source)
at java.io.File.listFiles(Unknown Source)
at TestJSO.listDir(TestJSO.java:30)
at TestJSO.cd(TestJSO.java:24)
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.plugin.javascript.invoke.JSInvoke.invoke(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.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
java.lang.Exception: java.security.AccessControlException: access denied (java.io.FilePermission c:\ read)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Calling method cd(String) causes the exception to be thrown, only on IE.
/********TestJSO.java:*********/
import netscape.javascript.*;
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.util.*;
public class TestJSO extends Applet
{
public static String cwd = "c:/";
public static JSObject win;
public static void cd(String s)
{
cwd = s;
listDir();
}
public static void listDir()
{
File file = new File(cwd);
File[] dir = file.listFiles();
win.call("alert",new String[]{"Files: "+dir.length});
}
public void init() {
win = JSObject.getWindow(this);
//JSObject doc = (JSObject) win.getMember("document");
//JSObject loc = (JSObject) doc.getMember("location");
//String s = (String) loc.getMember("href"); // document.location.href
//win.call("alert", new String[]{"JSObject is connected to browser scripting!! :-)"});
}
public void start() {
listDir();
}
}
/********TestJSO.html:*********/
<html>
<head>
</head>
<body>
<applet code="TestJSO.class" archive="TestJSO.jar" id="test" width=50 height=30 background=#ffcccc mayscript>
</applet>
<a href="javascript:document.test.cd('c:/winnt')">Change dir /winnt</a>
<a href="javascript:document.test.cd('c:/')">Change dir /</a>
</html>
---------- END SOURCE ----------
###@###.### 10/18/04 20:17 GMT