From d5178dc78b33c1d97af57b9ab047aa69717bc039 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Mon, 20 Apr 2015 20:22:42 -0700 Subject: Document behavior of Class.forName with a null ClassLoader Change-Id: I65cdec4c0ad15fd4b9ecdf3ef076bb0ac02d9ccc --- libart/src/main/java/java/lang/Class.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'libart') diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java index 4ea0bb5..c25e58c 100644 --- a/libart/src/main/java/java/lang/Class.java +++ b/libart/src/main/java/java/lang/Class.java @@ -124,16 +124,16 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe private static final long serialVersionUID = 3206093459760846163L; - /** defining class loader, or NULL for the "bootstrap" system loader. */ + /** defining class loader, or null for the "bootstrap" system loader. */ private transient ClassLoader classLoader; /** * For array classes, the component class object for instanceof/checkcast (for String[][][], - * this will be String[][]). NULL for non-array classes. + * this will be String[][]). null for non-array classes. */ private transient Class componentType; /** - * DexCache of resolved constant pool entries. Will be null for certain VM-generated classes + * DexCache of resolved constant pool entries. Will be null for certain runtime-generated classes * e.g. arrays and primitive classes. */ private transient DexCache dexCache; @@ -163,7 +163,7 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe /** Lazily computed name of this class; always prefer calling getName(). */ private transient String name; - /** The superclass, or NULL if this is java.lang.Object, an interface or primitive type. */ + /** The superclass, or null if this is java.lang.Object, an interface or primitive type. */ private transient Class superClass; /** If class verify fails, we must return same error on subsequent tries. */ @@ -253,7 +253,8 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe private transient int status; private Class() { - // Prevent this class to be instantiated, instance should be created by JVM only + // Prevent this class from being instantiated, + // instances should be created by the runtime only. } /** @@ -291,6 +292,9 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe * If the class has not yet been initialized and {@code shouldInitialize} is true, * the class will be initialized. * + *

If the provided {@code classLoader} is null, the bootstrap + * class loader will be used to load the class. + * * @throws ClassNotFoundException * if the requested class cannot be found. * @throws LinkageError @@ -707,7 +711,7 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe // return a non-synthetic method in such situations. We may // still return a synthetic method to handle situations like // escalated visibility. We never return miranda methods that - // were synthesized by the VM. + // were synthesized by the runtime. int skipModifiers = Modifier.MIRANDA | Modifier.SYNTHETIC; ArtMethod artMethodResult = null; if (virtualMethods != null) { @@ -1603,7 +1607,7 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe * object was created by the class loader of the class. */ public Package getPackage() { - // TODO This might be a hack, but the VM doesn't have the necessary info. + // TODO This might be a hack, but the runtime doesn't have the necessary info. ClassLoader loader = getClassLoader(); if (loader != null) { String packageName = getPackageName$(); -- cgit v1.1