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

java.security.BasicPermission.BasicPermission() throws IllegalArgumentException

XMLWordPrintable

    • beta
    • generic, sparc
    • solaris_2.5.1, solaris_2.6, windows_nt



      Name: ksC84122 Date: 05/21/99


      JDK 1.3 java.security.BasicPermission.BasicPermission("") or
      java.security.BasicPermission.BasicPermission("", String) throw IllegalArgumentException,
      however it is not specified in the javadoc and not compatible with JDK1.2.2, where
      IllegalArgumentException is not thrown. This causes some other methods, like
      java.lang.System.setProperty("", String) also throw IllegalArgumentException, which is also
      not specified in the javadoc for the appropriate method and not compatible with JDK 1.2.2.


      A test example which demonstrates this problem.
      ===== test.java ========
      import java.security.Permission;

      public class test {

         public static void main (String argv[]) {

            String p = null;
            

            SecurityManager sm = new MySecurityManager();
            try {
                System.setSecurityManager(sm);
                System.setProperty("", "empty_name_value");
                p = System.getProperty("");
                System.out.println("Value set to: " + p);
                return;
            } catch (SecurityException se) {
                System.out.println("failed to setup test: SecurityException thrown");
                return;
            } catch (IllegalArgumentException iae) {
                System.out.println("Exception thrown: " + iae);
                iae.printStackTrace();
                return;
            }
         }
      }

      class MySecurityManager extends SecurityManager {
          public void checkPermission(Permission perm) {}
      }


      ========= Sample run (JDK1.2.2) ==========
      #>java test
      Value set to: empty_name_value

      ========= Sample run (JDK1.3) ==========
      #>java test
      Exception thrown: java.lang.IllegalArgumentException: name can't be empty
      java.lang.IllegalArgumentException: name can't be empty
              at java.security.BasicPermission.init(BasicPermission.java, Compiled Code)
              at java.security.BasicPermission.<init>(BasicPermission.java, Compiled Code)
              at java.util.PropertyPermission.<init>(PropertyPermission.java, Compiled Code)
              at java.lang.System.setProperty(System.java, Compiled Code)
              at test.main(test.java, Compiled Code)

      ======================================================================

            jlueheorcl Jan Luehe (Inactive)
            skosunw Sko Sko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: