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

System.getProperties after setProperties(null) causes NPE

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5



      Name: mgC56079 Date: 06/08/99



      Javadoc for System.setProperties(Properties) says:
      ----------------------
      If the argument is null, then the current set of system properties is forgotten
      ----------------------

      Javadoc for System.getProperties() says:
      ----------------------
      If there is no current set of system properties, a set of system properties is
      first created and initialized.
      ----------------------

      Javadoc for System.getProperty(String) says:
      -----------------------
      If there is no current set of system properties, a set of system properties is
      first created and initialized in the same manner as for the getProperties
      method.
      -----------------------

      But no creation and initialization happens.

      ----------------------Test.java
      import java.util.Properties;
      public class Test {

        public static void main(String [] argv) {
          System.setProperties((Properties)null);
          System.getProperties().containsKey("java.version");
        }

      }
      ----------------------Output
      Exception in thread "main" java.lang.NullPointerException
      at Test.main(Test.java, Compiled Code)
      ----------------------

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

            mmcclosksunw Michael Mccloskey (Inactive)
            gorsunw Gor Gor (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: