Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Patch a plugin with a single class?

This is my situation: We have a third party feature in our Eclipse environment. The feature contains several plugins. The plugin contains a bunch of classes. One of the classes contains a bug.

We have been able to find a solution to the bug, so we have a working version of the class with the bug.

Unfortunately this plugin is covered by a 55 page long EULA (by IBM) so I think it's pretty safe to assume that decompiling the jar, exchanging class files, recompiling and distribute is legally out of the question. I'm no legal expert, but I'd guess we cannot tamper with the jar files in any way.

So this means I have a single class file that I want to be loaded instead of a class in a plugin, is this at all possible?

This page suggests using fragments, but this requires modifying the manifest in the plugin.

This question has the same problem as me, but in that case there is access to the source code and he is able to build a plugin.

This blogpost shows how use feature patches, but they require that I'm able to build my own plugin, which I cant since I have just the one class.

like image 966
Fredrik Avatar asked Oct 07 '11 14:10

Fredrik


Video Answer


2 Answers

I would not try using a fragment. In my experience, the cleanest thing to do would be to use a feature patch. I have successfully used feature patches to do exactly what you are looking to do. It's not simple, but it is robust. You need to do the following.

  1. create a plugin that encapsulates your single class file
  2. create a feature patch that includes your new plugin and that patches the feature that you are targeting.
  3. export your feature patch and create the p2 metadata (to create an update site).
  4. Install into your Eclipse using the install manager
  5. Rejoice!

  6. (optional) Feature patches by default only target a single version of the target feature. So, if the target feature bumps up its version number, the feature patch will silently no longer be applied. However, it is possible to relax the version constraints on the feature patch. This process is described in detail here: http://aniefer.blogspot.com/2009/06/patching-features-part-2.html

More information:

http://aniefer.blogspot.com/2009/06/patching-features-with-p2.html http://aniefer.blogspot.com/2009/06/patching-features-part-2.html

The benefit of using a feature patch over a fragment is that anyone can install the patch and get the patch working, but things are more difficult with a fragment in that end users must muck with manifests.

like image 96
Andrew Eisenberg Avatar answered Sep 28 '22 19:09

Andrew Eisenberg


So this means I have a single class file that I want to be loaded instead of a class in a plugin, is this at all possible?

Your first sentence is the answer. You can use a fragment, but that requires modifying the manifest in the plugin. Otherwise, Eclipse would have no idea which class to load.

My suggestion is that you write IBM with all of this information, including the patch. IBM should be able to release a maintenance fix which would solve your problem.

In the mean time, you could pursue the fragment option, which would require you to unpack the jar, add your fragment, modify the manifest, and repackage the jar. Whether or not this is legal is beyond my ability to determine.

like image 43
Gilbert Le Blanc Avatar answered Sep 28 '22 18:09

Gilbert Le Blanc