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

Should use PrivilegedAction template in java doc

XMLWordPrintable

    • b03
    • generic
    • generic
    • Not verified

      Interface PrivilegedAction and PrivilegedExceptionAction has been changed to use template:
      public interface PrivilegedAction<T> {
          T run();
      }

      public interface PrivilegedExceptionAction<T> {
          T run();
      }

      However, some of our document still use the old style codes like:

      FileInputStream fis = (FileInputStream) AccessController.doPrivileged(
          new PrivilegedExceptionAction() {
              public Object run() throws FileNotFoundException {
                  return new FileInputStream("someFile");
              }
          }
      );

      The old style codes will cause compiling unchecked conversion warnings. I think the java security sample codes should use the template style, which would help to avoid warnings and help users writing safer codes.

            xuelei Xuelei Fan
            xuelei Xuelei Fan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: