This discussion is archived
1 Reply Latest reply: Apr 2, 2012 8:25 AM by gimbal2 RSS

buggy 3rd Party library

927975 Newbie
Currently Being Moderated
Hi,

I am developing a midlet. In this I am including a third party jar file. There is one class in this library, which if it initialised once, freezes in this state. May be a simple code snippet would explain the problem better. Let us assume that the 3rd party library contains this class:

class DemoClass{
private static DemoClass inst = null;

private DemoClass(String aVal){}

public static DemoClass getInstance(String aVal){
if(inst == null){
inst = new DemoClass(aVal);
}
return inst;
}
}

In the above if I have initialised the object once, I could not re-initialise the class with a different value which I need in my project. I only have assumed that the third party jar would have been written as above or have given an example case for what I need.

I have little chance to request the 3rd party in a way I want this library.

What is the best way to overcome this? I am very new to java. I have just come across the custom classloader thing, which appears to be very complicated for my level. Is that the only way to solve this issue? If so, can anybody suggest a simple example that could cover the above class example?

Thanks
  • 1. Re: buggy 3rd Party library
    gimbal2 Guru
    Currently Being Moderated
    924972 wrote:
    What is the best way to overcome this? I am very new to java. I have just come across the custom classloader thing, which appears to be very complicated for my level. Is that the only way to solve this issue?
    Pick a different third party library. If none exist, create your own. Seriously there is no best way when you want to continue with a broken library, whatever you can come up with will suck.

    That being said reflection is an option, but that too is quite advanced material.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points