Part of their job is to make sure that important parts of the Java runtime environment are not replaced by impostor code. The fake Security Manager shown in Figure 2.4 must be disallowed from loading into the Java environment and replacing the real Security Manager. This is known as class spoofing. Spoofing occurs when someone or something pretends to be something it is not. If external code were allowed to do this, Java's security system would be trivial to break.
Class loaders perform two functions.
First, when the VM needs to load the byte code for a particular class, it asks a class loader to find the byte code. This flexibility is not a security problem as long as the class loader is trusted by the party who wrote the code that is being loaded. Second, class loaders define the namespaces seen by different classes and how those namespaces relate to each other. Namespaces are a subtle and security-critical issue that we'll have a lot more to say about later. Problems with namespace management have led to a number of serious security holes.