Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8184165

sun.security.provider.PolicyFile$PolicyEntry.toString() throws MissingResourceException

XMLWordPrintable

    • b15
    • Not verified

      sun.security.provider.PolicyFile$PolicyEntry.toString() throws MissingResourceException because there is NO resource for "SPACE" in sun.security.util.Resources

      Exception is thrown when run below code, "java.util.MissingResourceException: Can't find resource for bundle sun.security.util.Resources, key SPACE"

          public static void printPolicy() throws Exception {
              Policy policy = Policy.getPolicy();
              System.out.println("should be PolicyFile: " + policy.getClass().getName());
              Class policyFileClass = Policy.getPolicy().getClass();

              // private AtomicReference<PolicyInfo> policyInfo = new AtomicReference<>();
              Field policyInfoField = policyFileClass.getDeclaredField("policyInfo");
              policyInfoField.setAccessible(true);

              Object policyInfo = ((AtomicReference)policyInfoField.get(policy)).get();
              Class policyInfoClass = policyInfo.getClass();
              System.out.println("should be PolicyInfo: " + policyInfoClass.getName());

              Field policyEntriesField = policyInfoClass.getDeclaredField("policyEntries");
              policyEntriesField.setAccessible(true);
              List policyEntries = (List)policyEntriesField.get(policyInfo);
              for (Object entry : policyEntries) {
                  System.out.println("**** PolicyEntry: " + entry);
              }
          }

            mli Hamlin Li
            mli Hamlin Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: