Bug in BundleUtil.removeBundle? Driver classes do not unload

There seems to be a little bug or at least a documentation problem with the bundle util.
When i add a bundle in ModuleHook.setup with BundleUtil.get().addBundle(xxx.class); and remove it in ModuleHook.shutdown with BundleUtil.get().removeBundle(xxx.class); there is still a reference to my class on the heap. As the built in drivers seem to to use this remove method (the Modbus driver in the api example definitely does), you will always have duplicate classes after a driver restart. This causes problems when trying to debug in development mode, since the VM seems to use parts of the old jar file instead of the newly uploaded one.
When is use BundleUtil.get().removeBundle(xxx.class.getSimpleName(); instead, everything works as expected.

If this is a intended behavior of BundleUtil.remove(Class) it would be good to mention it in the javadocs.

By the way, is it correct that the 7.4 api still expects api version 3 in ModuleHook.startup?

Thanks for the heads up. The docs aren’t wrong (It is removing your bundle), but there is an implementation issue that’s leaving a reference to your module’s ClassLoader when you use the removeBundle(Class) overload, as you reported.

Yes, that's correct. I don't think anything in the Driver API changes in a backwards-incompatible way between 7.3 and 7.4, like it did between 7.2 and 7.3.

So I realise this thread is 12 years old but was this bug ever fixed? I just fixed a very weird issue with module restarts reporting it couldn't find some resources by adding the getSimpleName() fix to removeBundle.

Nope... :upside_down_face:

haha, ok, thanks for the prompt reply. Maybe a note in the documentation would be useful. Hopefully people facing similar issues will find this thread.

Getting burned by BundleUtil is a right of passage!

I suspect it won't be an issue anymore in 8.3 with module hot-loading on the chopping block.

Sigh. I've slowly shifted to the opinion that this is a mistake. :frowning_face:

Really? I thought you were always of the opinion it was a mistake.

I didn't think it was a mistake when first announced. It took a few months of paying attention to how often my clients and I would upgrade modules, or add newly licensed modules to running systems, or drop modules. Every one of those would have been a scheduling nightmare.

I was entirely convinced by last ICC.

Even with redundant systems, there's a data loss window during switchover. I'll take another stab at talking Carl out of this in September.

Does this mean that 8.3 will require a gateway restart to load modules? What will the new process look like?

Yeah, something like that. You will "install" or "uninstall" modules but they will be staged to take effect on the next restart.

This isn't a change I'm really championing or involved in. I see the benefits to both sides and can't really decide where I land.

Maybe we'll run out of time before 8.3 and never do it :man_shrugging:

So, your internal pre-alphas still hot-load? Yay! I'd say your odds of running out of time are now high. :grin: