Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2008, 09:01 PM
Member
 
Join Date: Oct 2008
Posts: 31
Rep Power: 0
piyu.sha is on a distinguished road
Question [SOLVED] Hacking Singleton- Multiple instance of a Singleton class
I was reading about singleton patter on web and there was a mention about a hacking technique which can create multiple instances of a Singleton class.

As far as I know java, we can not access private methods or constructor of a class outside it so how can a object be created.

Just wanted to know if this is possible or not?

Any help or pointers please....
__________________
Live life king size
[
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-06-2008, 09:03 PM
Member
 
Join Date: Oct 2008
Posts: 68
Rep Power: 0
priyanka.dandekar is on a distinguished road
Default
I think that is possible through Reflection APIs, have a look at the Reflection APIs in details you should find something.

I have seen some code by which you can access private member of a class.

____________________________________________
Priya,
Cooking is Fun | Eat Healthy Stay Fit | Sweets | Raita | Bread | Dal
__________________
Cheers,

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 09:06 PM
Member
 
Join Date: Oct 2008
Location: US
Posts: 44
Rep Power: 0
kzvi.kzvi.1 is on a distinguished road
Default
+1 on Priyanka's post, here is the exact Example code which demonstrates how you can do this.

Try it out and play with it for various other tricks you can do with same API.

____________________________________________
Software Wiki | Interview FAQs | Lucene Search | Oracle | ORM | Struts2 | Job Seeker
__________________
Have fun....

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
singleton object ... haiforhussain Advanced Java 8 06-23-2008 06:43 AM
Whether to make Bean Singleton or non Singleton (prototype) Java Tip Java Tips 0 03-29-2008 12:41 PM
Singleton Pattern Java Tip Java Tips 0 01-24-2008 03:21 PM
Whether to make Bean Singleton or non Singleton (prototype) JavaBean Java Tips 0 09-26-2007 08:32 PM
singleton pattern Peter Advanced Java 1 07-09-2007 04:45 AM


All times are GMT +2. The time now is 01:56 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org