Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901802

Error generating policy files on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • jtreg4.2
    • None
    • tools
    • None
    • b04

      From Weijun Wang via jtreg-dev:

      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

            jjg Jonathan Gibbons
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: