Results 1 to 3 of 3
  1. #1
    piyu.sha is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    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
    [Lucene]

  2. #2
    Join Date
    Oct 2008
    Posts
    68
    Rep Power
    0

    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

  3. #3
    kzvi.kzvi.1 is offline Member
    Join Date
    Oct 2008
    Location
    US
    Posts
    58
    Rep Power
    0

    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....
    JAVA FAQs

Similar Threads

  1. singleton object ...
    By haiforhussain in forum Advanced Java
    Replies: 8
    Last Post: 06-23-2008, 06:43 AM
  2. Replies: 0
    Last Post: 03-29-2008, 12:41 PM
  3. Singleton Pattern
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 03:21 PM
  4. Replies: 0
    Last Post: 09-26-2007, 08:32 PM
  5. singleton pattern
    By Peter in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •