TempFileHelper java.lang.IllegalArgumentException: Invalid prefix or suffix

Alan Bateman Alan.Bateman at oracle.com
Tue Aug 31 17:39:25 UTC 2021


On 31/08/2021 18:27, Michael Hall wrote:
> :
>
> Slightly different results…
>
> public class SecTemp {
>
> public static void main(String... args) throws java.io.IOException {
> System.setSecurityManager(new SecurityManager());
> java.io.File tmpfile = 
> java.nio.file.Files.createTempFile("AppleScriptEngine.", 
> ".scpt").toFile();
> }
> }
>
> java SecTemp
> WARNING: A terminally deprecated method in java.lang.System has been 
> called
> WARNING: System::setSecurityManager has been called by SecTemp 
> (file:/Users/mjh/)
> WARNING: Please consider reporting this to the maintainers of SecTemp
> WARNING: System::setSecurityManager will be removed in a future release
> Exception in thread "main" java.lang.SecurityException: Unable to 
> create temporary file or directory
> at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:141)
> at 
> java.base/java.nio.file.TempFileHelper.createTempFile(TempFileHelper.java:159)
> at java.base/java.nio.file.Files.createTempFile(Files.java:923)
> at SecTemp.main(SecTemp.java:6)

This is because it hasn't been granted permission to create files in 
${java.io.tmpdir}. I would expect this behavior is every JDK release.

-Alan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20210831/6f65f52e/attachment-0001.htm>


More information about the nio-dev mailing list