Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>ClassLoader.loadClass</code> or <code>Class.forName</code> seem to be synonyms for the same basic operation: request a dynamic class load. Yet calling <code>Class.forName</code> does additional "checking" which is not very useful (certainly in OSGi).</p> <p>When doing a dynamic class load, the returned type has no implied type by the code. The code must use reflection to access static members or to create an instance. A created instance can either be reflected upon or cast to a type which must already implicitly know by the code. This cast will result in a runtime type check which will ensure type safety.</p> <p>This is very different than an implicit class load done by the VM to resolve a class constant pool entry. Since it is the goal of these implicit class loads to avoid runtime type checks, the loader constraints are used to ensure type safety.</p> <p>It does not seem necessary or reasonable to impose loader constraint checks on some dynamic class load requests. That is, code calling <code>Class.forName</code> (or <code>ClassLoader.loadClass</code>) and the VM resolving a class constant pool entry have different type safety needs. The former does not require loader constraint checks since that will be done at runtime by a type cast if needed. The latter does require loader constraint checks to avoid the need for runtime type checks.</p> <p><strong>So it does seem reasonable to have <code>Class.forName</code> behavior altered to avoid loader constraint checks</strong>. Only internal <code>VM</code> class load requests need to check loader constraints.</p> <p>For more understanding <a href="http://java-career.blogspot.in/2012/10/classforname-vs-classloaderloadclass.html" rel="nofollow">Click here</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload