jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Cost of Class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cost of Class.forName()" Watch "Cost of Class.forName()" New topic

Cost of Class.forName()

mohamed zafer
Ranch Hand

Joined: Nov 03, 2000
Posts: 62
Hello There,
How efficient is the usage of
Class class = Class.forName("MyClass");
to create a class dynamically.
Mohamed Zafer
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
It's much slower than static instaciation but ... it's dynamic as you said !
You could create a little script creating thousands of classes (see below) & instanciating them one after the other ?
Or just try to access all the instances from the java / javax package.
Perl or Python are good at that
In the example here below, I used innerclasses but I am not sure it is the best approaches.
If you can do it also with normal classes.

Thomas Smets
Just another developper
I agree. Here's the link: http://aspose.com/file-tools
subject: Cost of Class.forName()
Similar Threads
JDBC, mysql connector/j, face a problem to connect mysql 5.1 and JSE.
Loading of Classes
How to instanciate a class by name?
what this method do in JDBC?
Dynamically loading a class