Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change in Constructor and Finalize method

 
KRISH DOSS
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to track the number of objects created and number of objects finalized. Hence, I have made changes in java.lang.Object.java and moved the compiled class into boothpath. But, I am getting 'StackOverFlowError'. Is there any alternative way of doing this?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are certainly better ways, yes. There's a whole JVM debugger interface that can tell you this information, and Tiger (Java 5) has some great monitoring tools that come with it.

But what you tried to do should be workable; it would throw a StackOverflowException, though, if your overrides actually allocate (directly or indirectly) any objects.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic