Search |
||
Writing Java Applications that Work with Different Incompatible Versions of a Java API/LibraryPosted by garysweaver on July 31, 2008 at 10:57 AM PDT
If you're a Java developer and you've been around for any length of time, you've likely run into the issue of wanting to write something that can deal with different versions of the same Java API that may be incompatible. What got me thinking about this, is that I recently saw a forum post in the Atlassian Confluence Developer forum where someone was asking about how to get the version number of Confluence so that they could write their plugin to be compatible with different versions of Confluence that have incompatible APIs. And as background, in the past, Atlassian has been very quick to change their API (much quicker than in Apache/Apache Jakarta projects!) sometimes leaving plugin developers needing to update in order to work with the next minor version of Confluence. Really briefly, here are some options you might want to think about in this situation:
I'm sure people could think of others, but maybe this will give you a jump-start thinking about this, if you haven't recently. »
Related Topics >>
Programming Comments
Comments are listed in date ascending order (oldest first)
Submitted by samkass on Thu, 2008-07-31 11:15.
Is this one of the problems that a system like OSGi could solve? Expose each core API as a different bundle, then write your plugin as a collection of bundles that have explicit dependencies on specific host APIs. Then let it load the right one at runtime automatically.
Submitted by evernat on Mon, 2008-08-04 03:32.
In your option 2, saying that reflection is slow is a misconception. Reflection was not always the best speed option in 2000 but since jdk 1.4 reflection speed is excellent. You can check this with google.
For example, Spring or Hibernate do a lot of reflection and they are not slow because of reflection (event without classes instrumentation). Reflection is a viable option from the performance point of view.
Submitted by garysweaver on Mon, 2008-08-04 15:27.
@evernat - In response to your comment "saying that reflection is slow is a misconception"... you should should time it sometime- even in Java 5 and 6, it isn't always acceptably fast. I have absolutely no problem with reflection's common use by Spring, Hibernate, etc. because they commonly will cache instances created by reflection. There is still some extra time needed at startup, but it is definitely a good thing. I'm not trying to put-down reflection by any means. However, all of that said- there are still places out there where people are using reflection to instantiate classes a lot more than is necessary when they could be using Spring instead to instantiate a class only once. I've run into some examples in open-source projects recently where either examples or required code for setup involved unnecessary reflection on every call, which is what I was suggesting people try to avoid. Hope that helps...
Submitted by garysweaver on Mon, 2008-08-04 17:57.
> there are still places out there where people are using reflection to instantiate classes a lot more than is necessary when they could be using Spring instead to instantiate a class only once
Oops- I meant that there are still places where people are using reflection to instantiate classes on every method call when it's not needed. Although using Spring is not a bad thing- I just had to take-off to Target before I could double-check my comment! ;)
|
||
|
|