@CallerSensitive
public static Class<?> forName (Module module, String name)

Returns the Class with the given binary name in the given module.

This method attempts to locate, load, and link the class or interface. It does not run the class initializer. If the class is not found, this method returns null.

If the class loader of the given module defines other modules and the given name is a class defined in a different module, this method returns null after the class is loaded.

This method does not check whether the requested class is accessible to its caller.

Parameters:
module    A module
name    The binary name of the class

Returns:  Class object of the given name defined in the given module; null if not found.

Exceptions:
NullPointerException    if the given module or name is null
LinkageError    if the linkage fails
SecurityException    
  • if the caller is not the specified module and RuntimePermission("getClassLoader") permission is denied; or
  • access to the module content is denied. For example, permission check will be performed when a class loader calls ModuleReader.open(String) to read the bytes of a class file in a module.

Since:  9

@apiNote This method returns null on failure rather than throwing a ClassNotFoundException, as is done by the forName(String, boolean, ClassLoader) method. The security check is a stack-based permission check if the caller loads a class in another module.
@spec JPMS