--- old/src/share/classes/sun/misc/VM.java 2014-01-27 11:51:03.941799692 -0800 +++ new/src/share/classes/sun/misc/VM.java 2014-01-27 11:51:03.741799683 -0800 @@ -189,7 +189,7 @@ // Returns the maximum amount of allocatable direct buffer memory. // The directMemory variable is initialized during system initialization - // in the saveAndRemoveProperties method. + // in the saveVMSystemProperties method. // public static long maxDirectMemory() { return directMemory; @@ -201,7 +201,7 @@ private static boolean pageAlignDirectMemory; // Returns {@code true} if the direct buffers should be page aligned. This - // variable is initialized by saveAndRemoveProperties. + // variable is initialized by saveVMSystemProperties. public static boolean isDirectMemoryPageAligned() { return pageAlignDirectMemory; } @@ -210,8 +210,8 @@ // accept array syntax. This value may be changed during VM initialization // via the system property "sun.lang.ClassLoader.allowArraySyntax". // - // The default for 1.5 is "true", array syntax is allowed. In 1.6, the - // default will be "false". The presence of this system property to + // The default for 1.5 is "true", array syntax is allowed. In 1.6+, the + // default is "false". The presence of this system property to // control array syntax allows applications the ability to preview this new // behaviour. // @@ -219,11 +219,11 @@ private static boolean allowArraySyntax = defaultAllowArraySyntax; // The allowArraySyntax boolean is initialized during system initialization - // in the saveAndRemoveProperties method. + // in the saveVMSystemProperties method. // // It is initialized based on the value of the system property // "sun.lang.ClassLoader.allowArraySyntax". If the system property is not - // provided, the default for 1.5 is "true". In 1.6, the default will be + // provided, the default for 1.5 is "true". In 1.6+, the default is // "false". If the system property is provided, then the value of // allowArraySyntax will be equal to "true" if Boolean.parseBoolean() // returns "true". Otherwise, the field will be set to "false". @@ -264,11 +264,12 @@ // calling classes to avoid duplication of keys. private static final Properties savedProps = new Properties(); - // Save a private copy of the system properties and remove - // the system properties that are not intended for public access. - // - // This method can only be invoked during system initialization. - public static void saveAndRemoveProperties(Properties props) { + /** + * Save a private copy of the system properties. + * + * @implNote This method can only be invoked during system initialization. + */ + public static void saveVMSystemProperties(Properties props) { if (booted) throw new IllegalStateException("System initialization has completed"); @@ -279,7 +280,7 @@ // The maximum amount of allocatable direct buffer memory (in bytes) // from the system property sun.nio.MaxDirectMemorySize set by the VM. // The system property will be removed. - String s = (String)props.remove("sun.nio.MaxDirectMemorySize"); + String s = savedProps.getProperty("sun.nio.MaxDirectMemorySize"); if (s != null) { if (s.equals("-1")) { // -XX:MaxDirectMemorySize not given, take default @@ -292,28 +293,46 @@ } // Check if direct buffers should be page aligned - s = (String)props.remove("sun.nio.PageAlignDirectMemory"); - if ("true".equals(s)) - pageAlignDirectMemory = true; + s = savedProps.getProperty("sun.nio.PageAlignDirectMemory"); + pageAlignDirectMemory = Boolean.parseBoolean(s); // Set a boolean to determine whether ClassLoader.loadClass accepts // array syntax. This value is controlled by the system property // "sun.lang.ClassLoader.allowArraySyntax". - s = props.getProperty("sun.lang.ClassLoader.allowArraySyntax"); - allowArraySyntax = (s == null - ? defaultAllowArraySyntax - : Boolean.parseBoolean(s)); + s = savedProps.getProperty("sun.lang.ClassLoader.allowArraySyntax"); + allowArraySyntax = Boolean.parseBoolean(s); + } + + /** + * Returns a copy of the saved system properties with private implementation + * properties removed. + * + * @return a newly created Properties instance containing only sanitized + */ + public static Properties getSanitizedSavedProperties() { + Properties sanitized = new Properties(); + + sanitized.putAll(savedProps); + + // Remove implementation private system properties + + sanitized.remove("sun.nio.MaxDirectMemorySize"); + + sanitized.remove("sun.nio.PageAlignDirectMemory"); + + sanitized.remove("sun.lang.ClassLoader.allowArraySyntax"); - // Remove other private system properties // used by java.lang.Integer.IntegerCache - props.remove("java.lang.Integer.IntegerCache.high"); + sanitized.remove("java.lang.Integer.IntegerCache.high"); // used by java.util.zip.ZipFile - props.remove("sun.zip.disableMemoryMapping"); + sanitized.remove("sun.zip.disableMemoryMapping"); // used by sun.launcher.LauncherHelper - props.remove("sun.java.launcher.diag"); - } + sanitized.remove("sun.java.launcher.diag"); + + return sanitized; + } // Initialize any miscellenous operating system settings that need to be // set for the class libraries.