6516909: (cl spec) ClassLoader.loadClass() clarification to indicate it shouldn't be used for array classes
Reviewed-by: alanb
--- a/jdk/src/share/classes/java/lang/ClassLoader.java Thu Jan 23 14:04:52 2014 -0800
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java Thu Jan 23 14:06:58 2014 -0800
@@ -172,6 +172,10 @@
* "java.net.URLClassLoader$3$1"
* </pre></blockquote>
*
+ * {@code Class} objects for array classes are not created by {@code ClassLoader};
+ * use the {@link Class#forName} method instead.
+ *
+ * @jls 13.1 The Form of a Binary
* @see #resolveClass(Class)
* @since 1.0
*/
@@ -862,8 +866,7 @@
private boolean checkName(String name) {
if ((name == null) || (name.length() == 0))
return true;
- if ((name.indexOf('/') != -1)
- || (!VM.allowArraySyntax() && (name.charAt(0) == '[')))
+ if ((name.indexOf('/') != -1) || (name.charAt(0) == '['))
return false;
return true;
}
--- a/jdk/src/share/classes/sun/misc/VM.java Thu Jan 23 14:04:52 2014 -0800
+++ b/jdk/src/share/classes/sun/misc/VM.java Thu Jan 23 14:06:58 2014 -0800
@@ -206,32 +206,6 @@
return pageAlignDirectMemory;
}
- // A user-settable boolean to determine whether ClassLoader.loadClass should
- // 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
- // control array syntax allows applications the ability to preview this new
- // behaviour.
- //
- private static boolean defaultAllowArraySyntax = false;
- private static boolean allowArraySyntax = defaultAllowArraySyntax;
-
- // The allowArraySyntax boolean is initialized during system initialization
- // in the saveAndRemoveProperties 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
- // "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".
- //
- public static boolean allowArraySyntax() {
- return allowArraySyntax;
- }
-
/**
* Returns true if the given class loader is in the system domain
* in which all permissions are granted.
@@ -296,14 +270,6 @@
if ("true".equals(s))
pageAlignDirectMemory = true;
- // 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));
-
// Remove other private system properties
// used by java.lang.Integer.IntegerCache
props.remove("java.lang.Integer.IntegerCache.high");