[jdom-interest] why did you change Element.addContent?
Jason Hunter
jhunter at xquery.com
Tue Mar 9 14:04:39 PST 2004
Alex Rosen wrote:
> There was some talk of changing it back, because the benefit of the
> Parent notion was not worth the cost in broken code. Jason, what did
> you decide on this?
>
> Alex
Nothing yet. This is in fact the thing I pondered during my morning
shower. :-)
The problem is Java 1.4 and earlier doesn't have covariant return types,
meaning an overridden version of a method can't return something more
specific than the parent version. That changes in Java 1.5 where this
problem goes away. In Java 1.5 the Parent interface can return Parent
while the Element implementation returns the more specific type of
Element. Thus one solution is to ship JDOM 1.0 including Parent as is
and craft a Java 1.5 version with covariant return types and other
niceties. I'm interested in a 1.5 version anyway since generics provide
some interesting features I'd like to fiddle with.
The other solution is to yank out Parent entirely, going back to the
older model. This gives us method chaining on older Java versions,
although we would lose the ability to do getParent().getParent() style
chaining that others wanted (since getParent() would return Object) --
unless we change the getParent() semantics which isn't good at this
stage. This change also requires things like DescendantIterator which
takes a Parent to take Element or Document versions. The biggest
downside to this solution is we'll have to do a lot of code and API
changes which would make me less comfortable doing a 1.0 release quickly.
-jh-
More information about the jdom-interest
mailing list