This is a Unix-only issue, found on Solaris. The problem is demonstrated by running a java program from within a setuid script; the method File.canWrite() is returning false when it should be returning true.
User1 owns a file "junk.txt"; only User1 can write this file. User1 has also enabled setuid permissions on a script "RunIt.sh". [chmod ug+s RunIt.sh]. RunIt.sh runs a java class FileBug, which calls File.canWrite().
According to the setuid man page, any user should be able to run RunIt.sh and assume the privileges of User1, and therefore, should be able to write 'junk.txt'. User2, which does not itself have write permission on "junk.txt", runs RunIt.sh, which make User2 effectively User1. But, File.canWrite returns false. In looking at the jdk source, File calls into an internal class FileSystem, which is implemented in native code.
The truss utility shows calls to 'access()', which we think FileSystem is calling. 'access()' is manpaged to test permissions against the "logged in" user (User2), not the effective user (User1), and so does not support a set uid script. We believe the fix is to check the file permissions using something other than 'access()'.