In my RCP app, I'm using the WeavingHook service to modify a third party class at load time. I'm not able to make any changes to the third party code, so my weaving implementation has to work with it as-is.
I have it working except for one issue. For one of the mods I made, I instantiated an inner class. It has to be an inner class because it depends on an inner class defined in one of the superclasses.
Now when the third party code loads the modified class it doesn't have the file for the inner class on its classpath, which is only available in the plug-in where I implement the weaving. If the third party plug-in declared a buddy policy of registered
, I could add an Eclipse-RegisterBuddy
directive to the manifest, but that's not the case.
Is there some way with weaving to enable the modified class to be able to access an inner anonymous class that was added through a binary weave?
The only solution I can think of is to copy the inner class file to the bin/ directory of the third party code when the binary weave occurs. Seems like a hack, so I'm hoping there's a better way.
Here's a solution that works, copying the inner class's class file to the bin/ directory of the third party plug-in containing the weave target. If anyone knows a less hacky way to do this, please post a separate answer.
Edit: Made the original solution more general, discovering all inner class files for the class being woven, and copying them to the weave target plug-in if missing there or if the sizes differ.