• Post Reply Bookmark Topic Watch Topic
  • New Topic

class loading question  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello all,

when does actually java class loading happens. If i have a ear file with 1000 classes all these classes loaded into JVM while deploying to app server (i.e Jboss) or server start?

if classes loaded where does all loaded classes get stored in JVM ? how it will be in case of dynamic class loading ( using reflection)

Thanks
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Classes are loaded when they are first used by code in other classes, and not until then.

When a class is loaded it's stored... in memory, like all other data. I don't understand what you mean by "stored in JVM". And in case you thought that classes loaded via reflection were stored somewhere else, no, they aren't. Class loading is class loading.
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The loading of class Foo is probably implemented by creating an instance of the Class<Foo> class, and that will live on the heap. The BCEL framework is rather old, but I think you may find something useful there.
 
Ranch Hand
Posts: 231
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Classes are loaded when they are first used by code in other classes, and not until then.

This is generally true for most classes; however, a servlet in an application server like Jboss can be configured via the <load-on-startup> element in the deployment descriptor to be loaded into memory on server startup rather than when it is first used (on a client’s request).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!