Index: kernel/src/main/java/java/lang/System.java =================================================================== --- kernel/src/main/java/java/lang/System.java (revision 378758) +++ kernel/src/main/java/java/lang/System.java (working copy) @@ -663,14 +663,55 @@ } return (String) systemProperties.setProperty(prop, value); } + + /** + *
+ * Removes the system property indicated by the specified key. + *
+ *
+ * First, if a security manager exists, its
+ * SecurityManager.checkPermission method is called with a
+ * PropertyPermission(key, "write") permission. This may
+ * result in a SecurityException being thrown. If no
+ * exception is thrown, the specified property is removed.
+ *
null,
+ * if there was no value.
+ * @throws NullPointerException if the key argument is
+ * null.
+ * @throws IllegalArgumentException if the key argument is
+ * empty.
+ * @throws SecurityException if a security manager exists and write access
+ * to the specified property is not allowed.
+ * @since 1.5
+ * @see #getProperty(String)
+ * @see #setProperty(String, String)
+ * @see Properties
+ * @see SecurityException
+ * @see SecurityManager#checkPropertiesAccess()
+ */
+ public static String clearProperty(String key) {
+ if (key == null)
+ throw new NullPointerException();
+ if (key.length() == 0)
+ throw new IllegalArgumentException();
+
+ SecurityManager secMgr = System.getSecurityManager();
+ if (secMgr != null) {
+ secMgr.checkPermission(new PropertyPermission(key, "write"));
+ }
+ return (String) systemProperties.remove(key);
+ }
/**
- * Answers an array of Strings containing key..value pairs (in consecutive
- * array elements) which represent the starting values for the system
- * properties as provided by the virtual machine.
- *
- * @return the default values for the system properties.
- */
+ * Answers an array of Strings containing key..value pairs (in consecutive
+ * array elements) which represent the starting values for the system
+ * properties as provided by the virtual machine.
+ *
+ * @return the default values for the system properties.
+ */
private static native String[] getPropertyList();
/**