This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes When Class.forName() executes what internally happens? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "When Class.forName() executes what internally happens?" Watch "When Class.forName() executes what internally happens?" New topic
Author

When Class.forName() executes what internally happens?

Praveen palukuri
Ranch Hand

Joined: Feb 10, 2005
Posts: 65
Using Class.forName("****") we can load the class at runtime. Apart from this can any specify what happens internally when we call this ?

Thanks in Advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Class.forName(...) loads the class that you specify using the current ClassLoader.

What do you want to know more, what the JVM internally does when you call this?

You can have a look at the source code. In your JDK folder, you should have a file called src.zip. In this file, lookup the source code for class java.lang.Class. If you look at the implementation of forName(...) it looks like this:

So, it calls forName0. If you lookup the source for forName0, it looks like this:

It's a native method, so if you'd want to know what it does, you'd need to get the native source code of the JDK; have a look here if you're really interested.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
Don't get me started about those stupid light bulbs.
 
subject: When Class.forName() executes what internally happens?
 
Similar Threads
Load the class thru class.forName() method
What happens after sendredirect?
class.forname...working
class.forname...working
Worflow of jsp