jtreg creates wrong FilePermission line on cygwin
Jonathan Gibbons
jonathan.gibbons at oracle.com
Tue Jan 6 22:30:17 UTC 2015
On 12/31/2014 07:11 AM, Weijun Wang wrote:
> For every test with a policy file, jtreg creates a new one with some
> extra entries. On Windows, one of them is
>
> grant {
> permission java.io.FilePermission "C:\tmp\W\classes${/}-", "read";
> };
>
> (Here, I provide -w:C:/tmp/W on the jtreg command line.)
>
> The syntax of the file name is incorrect, it should be either
> "C:/tmp/..." or "C:\\tmp\\...". In fact, if I add
> -Djava.security.debug=policy to jtreg, I will see
>
> policy: granting ("java.io.FilePermission" "C: mpWclasses\-" "read")
>
> This seems to be harmless now, but in our experiment of implementing
> FilePermission with NIO Path, the path will be rejected because it
> contains the illegal char \t.
>
> I have a patch here.
>
> diff --git a/src/share/classes/com/sun/javatest/regtest/Action.java
> b/src/share/classes/com/sun/javatest/regtest/Action.java
> --- a/src/share/classes/com/sun/javatest/regtest/Action.java
> +++ b/src/share/classes/com/sun/javatest/regtest/Action.java
> @@ -182,7 +182,7 @@
> fw.write("// The following grant entries were added
> by JavaTest. Do not edit." + LINESEP);
> fw.write("grant {" + LINESEP);
> fw.write(" permission java.io.FilePermission \""
> - +
> script.absTestClsTopDir().getPath().replace('\\' + FILESEP, "{/}")
> + +
> script.absTestClsTopDir().getPath().replace(FILESEP, "${/}")
> + "${/}-\"" + ", \"read\";" + LINESEP);
> fw.write("};" + LINESEP);
> for (File f: script.getJavaTestClassPath().split()) {
>
> I have no idea why the old code substitutes \\ to {/}. I've changed it
> to \ to ${/}.
>
> Thanks
> Max
Max,
Noted.
-- Jon
More information about the jtreg-dev
mailing list