0

Does java create an object in runtime or in compiletime ?

Another Question :

For embeded system [i.e. mobile phone] that have small memory, what happened if I created large number of objects ? Does JME [Java Micro Edition] uses Garbage Collector to free memory ? and how Virtual Machine knows that this object is dead ?

4
Contributors
10
Replies
11
Views
9 Years
Discussion Span
Last Post by majestic0110
0

I believe that if you want to create objects at runtime you need the reflection api, although I am not certain of this. With regards to JME I am unsure of whether it uses the GC but my guess would be yes. A VM knows when an object is dead when all references to it are gone. Hope this helps!

0

think about it.
If all object instances were created at compile time, how could you ever create a program that deals with information the amount of which is not known at compile time?

0

After some research I have discovered that JME does in fact use the Garbage collection algorithm. However, there is no finalize method(to simplify garbage collection) when interacting with objects to prevent object resurrection. HTH

0

think about it.
If all object instances were created at compile time, how could you ever create a program that deals with information the amount of which is not known at compile time?

So my suspicion is correct? That.....

I believe that if you want to create objects at runtime you need the reflection api

0

So my suspicion is correct? That.....

No. The point was that all objects are runtime constructs. Classes are created at compile time. This has nothing to do with reflection.

0

Oh I see, so objects can NEVER be created at compile time simply because there is no need for them to be constructed at compile time?

0

Correct. An object is an instance in memory of a class. It has no context at compile time because nothing is running. An object by definition is a runtime entity.

0

OK Thanks for clearing that up, I had thought objects were runtime creatures but read somewhere that reflection may change this......Obviously my source was incorrect!

0

Ok Ezzaral thanks a lot for the link, have checked it out and that has cleared up the confusion I had there. I guess my source was confused too or I misread it. Thanks again!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.