117 * <h3> <a name="builtinLoaders">Run-time Built-in Class Loaders</a></h3> |
117 * <h3> <a name="builtinLoaders">Run-time Built-in Class Loaders</a></h3> |
118 * |
118 * |
119 * The Java run-time has the following built-in class loaders: |
119 * The Java run-time has the following built-in class loaders: |
120 * |
120 * |
121 * <ul> |
121 * <ul> |
122 * <li>Bootstrap class loader. |
122 * <li><p>Bootstrap class loader. |
123 * It is the virtual machine's built-in class loader, typically represented |
123 * It is the virtual machine's built-in class loader, typically represented |
124 * as {@code null}, and does not have a parent.</li> |
124 * as {@code null}, and does not have a parent.</li> |
125 * <li>{@linkplain #getPlatformClassLoader() Platform class loader}. |
125 * <li><p>{@linkplain #getPlatformClassLoader() Platform class loader}. |
126 * All <em>platform classes</em> are visible to the platform class loader |
126 * All <em>platform classes</em> are visible to the platform class loader |
127 * that can be used as the parent of a {@code ClassLoader} instance. |
127 * that can be used as the parent of a {@code ClassLoader} instance. |
128 * Platform classes include Java SE platform APIs, their implementation |
128 * Platform classes include Java SE platform APIs, their implementation |
129 * classes and JDK-specific run-time classes that are defined by the |
129 * classes and JDK-specific run-time classes that are defined by the |
130 * platform class loader or its ancestors.</li> |
130 * platform class loader or its ancestors. |
131 * <li>{@linkplain #getSystemClassLoader() System class loader}. |
131 * <p> To allow for upgrading/overriding of modules defined to the platform |
132 * It is also known as <em>application class |
132 * class loader, and where classes in the upgraded version link to |
133 * loader</em> and is distinct from the platform class loader. |
133 * classes in modules defined to the application class loader, the |
|
134 * platform class loader may delegate to the application class loader. |
|
135 * In other words, classes in named modules defined to the application |
|
136 * class loader may be visible to the platform class loader. </li> |
|
137 * <li><p>{@linkplain #getSystemClassLoader() System class loader}. |
|
138 * It is also known as <em>application class loader</em> and is distinct |
|
139 * from the platform class loader. |
134 * The system class loader is typically used to define classes on the |
140 * The system class loader is typically used to define classes on the |
135 * application class path, module path, and JDK-specific tools. |
141 * application class path, module path, and JDK-specific tools. |
136 * The platform class loader is a parent or an ancestor of the system class |
142 * The platform class loader is a parent or an ancestor of the system class |
137 * loader that all platform classes are visible to it.</li> |
143 * loader that all platform classes are visible to it.</li> |
138 * </ul> |
144 * </ul> |
366 |
372 |
367 /** |
373 /** |
368 * Creates a new class loader of the specified name and using the |
374 * Creates a new class loader of the specified name and using the |
369 * specified parent class loader for delegation. |
375 * specified parent class loader for delegation. |
370 * |
376 * |
|
377 * @apiNote If the parent is specified as {@code null} (for the |
|
378 * bootstrap class loader) then there is no guarantee that all platform |
|
379 * classes are visible. |
|
380 * |
371 * @param name class loader name; or {@code null} if not named |
381 * @param name class loader name; or {@code null} if not named |
372 * @param parent the parent class loader |
382 * @param parent the parent class loader |
373 * |
383 * |
374 * @throws IllegalArgumentException if the given name is empty. |
384 * @throws IllegalArgumentException if the given name is empty. |
375 * |
385 * |
388 /** |
398 /** |
389 * Creates a new class loader using the specified parent class loader for |
399 * Creates a new class loader using the specified parent class loader for |
390 * delegation. |
400 * delegation. |
391 * |
401 * |
392 * <p> If there is a security manager, its {@link |
402 * <p> If there is a security manager, its {@link |
393 * SecurityManager#checkCreateClassLoader() |
403 * SecurityManager#checkCreateClassLoader() checkCreateClassLoader} method |
394 * checkCreateClassLoader} method is invoked. This may result in |
404 * is invoked. This may result in a security exception. </p> |
395 * a security exception. </p> |
405 * |
|
406 * @apiNote If the parent is specified as {@code null} (for the |
|
407 * bootstrap class loader) then there is no guarantee that all platform |
|
408 * classes are visible. |
396 * |
409 * |
397 * @param parent |
410 * @param parent |
398 * The parent class loader |
411 * The parent class loader |
399 * |
412 * |
400 * @throws SecurityException |
413 * @throws SecurityException |
2204 * If this class loader defines a {@code Package} of the given name, |
2217 * If this class loader defines a {@code Package} of the given name, |
2205 * the {@code Package} is returned. Otherwise, the ancestors of |
2218 * the {@code Package} is returned. Otherwise, the ancestors of |
2206 * this class loader are searched recursively (parent by parent) |
2219 * this class loader are searched recursively (parent by parent) |
2207 * for a {@code Package} of the given name. |
2220 * for a {@code Package} of the given name. |
2208 * |
2221 * |
|
2222 * @apiNote The {@link #getPlatformClassLoader() platform class loader} |
|
2223 * may delegate to the application class loader but the application class |
|
2224 * loader is not its ancestor. When invoked on the platform class loader, |
|
2225 * this method will not find packages defined to the application |
|
2226 * class loader. |
|
2227 * |
2209 * @param name |
2228 * @param name |
2210 * The <a href="#name">package name</a> |
2229 * The <a href="#name">package name</a> |
2211 * |
2230 * |
2212 * @return The {@code Package} corresponding to the given name defined by |
2231 * @return The {@code Package} corresponding to the given name defined by |
2213 * this class loader or its ancestors, or {@code null} if not found. |
2232 * this class loader or its ancestors, or {@code null} if not found. |
2248 /** |
2267 /** |
2249 * Returns all of the {@code Package}s defined by this class loader |
2268 * Returns all of the {@code Package}s defined by this class loader |
2250 * and its ancestors. The returned array may contain more than one |
2269 * and its ancestors. The returned array may contain more than one |
2251 * {@code Package} object of the same package name, each defined by |
2270 * {@code Package} object of the same package name, each defined by |
2252 * a different class loader in the class loader hierarchy. |
2271 * a different class loader in the class loader hierarchy. |
|
2272 * |
|
2273 * @apiNote The {@link #getPlatformClassLoader() platform class loader} |
|
2274 * may delegate to the application class loader. In other words, |
|
2275 * packages in modules defined to the application class loader may be |
|
2276 * visible to the platform class loader. On the other hand, |
|
2277 * the application class loader is not its ancestor and hence |
|
2278 * when invoked on the platform class loader, this method will not |
|
2279 * return any packages defined to the application class loader. |
2253 * |
2280 * |
2254 * @return The array of {@code Package} objects defined by this |
2281 * @return The array of {@code Package} objects defined by this |
2255 * class loader and its ancestors |
2282 * class loader and its ancestors |
2256 * |
2283 * |
2257 * @since 1.2 |
2284 * @since 1.2 |