Name: szR10253 Date: 10/06/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b22"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
/**
* Creates the directory named by this abstract pathname, including any
* necessary but nonexistent parent directories. Note that if this
* operation fails it may have succeeded in creating some of the necessary
* parent directories.
*
* @return <code>true</code> if and only if the directory was created,
* along with all necessary parent directories; <code>false</code>
* otherwise
*
* @throws SecurityException
* If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkWrite(java.lang.String)}</code>
* method does not permit the named directory and all necessary
* parent directories and to be created
*/
...
---------- end-of-excerpt ---------------
Problem description
===================
a File which was created as File("") is represented current directory, a call to mkdirs() should create directory structure from the current directory only. This method should work if all permissions are granted to the current directory, but the method throws a SecurityException with a parent directory.
Minimized test:
===============
------- Test.java -------
public class Test {
public static void main(String[] args) {
System.setSecurityManager(new SM());
new File("").mkdirs();
}
static class SM extends SecurityManager {
public void checkPropertyAccess(String key) {
}
public void checkRead(String file) {
File f = new File("");
if (file.equals("") || file.equals(f.getPath()) || file.equals(f.getAbsolutePath())) {
return;
}
super.checkRead(file);
}
public void checkWrite(String file) {
File f = new File("");
if (file.equals("") || file.equals(f.getPath()) || file.equals(f.getAbsolutePath())) {
return;
}
super.checkWrite(file);
}
}
}
------- end-of-Test.java -------
Minimized test output:
======================
Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission /home read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
at Test$SM.checkRead(Test.java:189)
at java.io.File.exists(File.java:692)
at java.io.File.mkdirs(File.java:1133)
at java.io.File.mkdirs(File.java:1146)
at Test.main(Test.java:178)
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
======================================================================