Hi,

I would like to know when a class is loaded. I guess it is a bit different
depending on things like usage of static members and the like but... Say
java.util.Logger. I have a bundle that only consumes services. When the
bundle is started it is running a few background threads. When the bundle is
stopped, the background threads are cancelled. When they are cancelled, they
will post a task on the event dispatch thread (I'm using swing workers) and,
since they were cancelled, they will log just that ("Background thread
interrupted" or similar is written to log).

Now, everything worked fine up until the edt-task was about to log. At that
point, felix threw an exception. Sadly, I don't have the stack trace atm and
I'm not sure I can reproduce. I'm just curious if anyone knows what this can
be. The offending line was calling

java.util.Logger.getLogger(getClass().getName()).log(Level.INFO, "BG-thread
cancelled) //or similar

And remember that the bundle jar-file has been removed (with the help of
FileInstall) from the system. It might linger in the bundle cache (I don't
know how long it stays there) but the bundle is stopped and (presumably)
uninstalled.

I just removed the logger code to make it work. However, I'm suspecting that
the cause of the error is either

   1. getClass() must have a class loader and that is gone because the
   bundle is uninstalled.
   2. The static Logger isn't loaded yet or uses classes that aren't loaded
   yet and thus felix informs me that it cant find the class.

So, (a) when is a class loaded, (b) is there any good "pattern" for dealing
with disposing threads in OSGi, and (c) am I completely off here? :)

Ok, (d) would it help writing "MyClass.class.getName()"?

Regards,
Per-Erik Svensson

Reply via email to