/[classpath]/classpath/java/lang/System.java
ViewVC logotype

Diff of /classpath/java/lang/System.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38 by mark, Fri Jul 23 11:40:05 2004 UTC revision 1.38.2.1 by tromey, Sat Oct 9 23:34:45 2004 UTC
# Line 557  public final class System Line 557  public final class System
557     */     */
558    public static String getProperty(String key, String def)    public static String getProperty(String key, String def)
559    {    {
560        // This handles both the null pointer exception and the illegal
561        // argument exception.
562        if (key.equals(""))
563          throw new IllegalArgumentException("empty key");
564      SecurityManager sm = Runtime.securityManager; // Be thread-safe.      SecurityManager sm = Runtime.securityManager; // Be thread-safe.
565      if (sm != null)      if (sm != null)
566        sm.checkPropertyAccess(key);        sm.checkPropertyAccess(key);
# Line 577  public final class System Line 581  public final class System
581     */     */
582    public static String setProperty(String key, String value)    public static String setProperty(String key, String value)
583    {    {
584        // This handles both the null pointer exception and the illegal
585        // argument exception.
586        if (key.equals(""))
587          throw new IllegalArgumentException("empty key");
588      SecurityManager sm = Runtime.securityManager; // Be thread-safe.      SecurityManager sm = Runtime.securityManager; // Be thread-safe.
589      if (sm != null)      if (sm != null)
590        sm.checkPermission(new PropertyPermission(key, "write"));        sm.checkPermission(new PropertyPermission(key, "write"));
# Line 584  public final class System Line 592  public final class System
592    }    }
593    
594    /**    /**
595       * Remove a single system property by name. A security check may be
596       * performed, <code>checkPropertyAccess(key, "write")</code>.
597       *
598       * @param key the name of the system property to remove
599       * @return the previous value, or null
600       * @throws SecurityException if permission is denied
601       * @throws NullPointerException if key is null
602       * @throws IllegalArgumentException if key is ""
603       * @since 1.5
604       */
605      public static String clearProperty(String key)
606      {
607        // This handles both the null pointer exception and the illegal
608        // argument exception.
609        if (key.equals(""))
610          throw new IllegalArgumentException("empty key");
611        SecurityManager sm = Runtime.securityManager; // Be thread-safe.
612        if (sm != null)
613          sm.checkPermission(new PropertyPermission(key, "write"));
614        return (String) properties.remove(key);
615      }
616    
617      /**
618     * This used to get an environment variable, but following Sun's lead,     * This used to get an environment variable, but following Sun's lead,
619     * it now throws an Error. Use <code>getProperty</code> instead.     * it now throws an Error. Use <code>getProperty</code> instead.
620     *     *

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.38.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26