[jdom-interest] JDOM with generics
Victor Toni
victor.toni at ebuconnect.de
Sun May 7 11:47:34 PDT 2006
Tatu Saloranta wrote:
> --- Victor Toni <victor.toni at ebuconnect.de> wrote:
>
>
>> Jason Hunter wrote:
>>
> ...
>
>>> The issue is what happens when your Java 5 program depends on JDOM 5 but also on a package that depends on JDOM 1.0? Serious question. You can't assume you can recompile the package because it's not yours. Assuming it was compiled against JDK 1.2, can it understand the JDOM 5 JAR adequately?
>>>
>> I would second the idea of having a JDOM 1.5 which is identical to 1.0 (or maybe better 1.0.1 ; -) ) expect that it uses Generics. It should be as compatible for older projects as is the 1.5 runtime.
>>
>
> Unless you mean "and use different package names for
> each", I think your sentences are contradictory here?
> The whole problem with adding generics (for example)
> is that resulting code most likely can not be used
> reliably with any prior JVMs (including 1.4), even
> with retroweaver (although, I am aware of people who
> have been able to run retroweaver processed code in
> 1.4 too, YMMV; just that it may not be quite as
> reliable).
> Many people even assume that it's just asking for
> trouble to try to even compile code using javac of a
> later JVM (using target modifier), much less to try to
> use new features; and thus compile the jars with the
> oldest JVM they can use.
>
> So the safest (or only safe?) way would be to use
> separate packages like Jason has mentioned, even if
> the same class names would still be used; there would
> be no (binary) conlicts. This would require
> recompilation to take benefit of new code, but that's
> needed no matter what, to benefit from generics.
> This would add a bit to maintenance overhead, but with
> the volume of patches for 1.0, it should be doable.
>
That's not correct.
Can you use already compiled libraries (against Java 1.4) with Java 1.5.
Yes, you can.
Could a library which was compiled against JDOM 1.0 be used with JDOM
1.0.1? It should. And it should work also with a reasonable Generics
implementation.
The only constraint is the JDK/runtime you are supposed to use.
You want Java 1.4 or below, use JDOM 1.0.1. You want shorter code and
fancy for-each loops, use JDOM 1.5.
If you have dependencies to APIs which themselves depend on JDOM 1.0 and
were compiled with 1.4 you still could use the JDOM 1.5 version as long
you use Java 1.5 or newer.
A reasonable implementation would contain only changes which are
compatible (as they were done in the Collections API).
One can think of Generics as of hints for the user. If you don't want
hints don't use them.
As I said earlier I would do a Generics implementation so people could
prove me wrong ;-)
I just would like to start from a "cleaned up" version (IMHO something
like JDOM 1.0.1)
Victor
More information about the jdom-interest
mailing list