On Wednesday, 09/04/2002 at 04:13 AST, Neil Graham <[EMAIL PROTECTED]>
wrote:
> I guess that first and foremost it's about what works--and if there are
> non-edgecase situations where a static method won't do the trick, it
won't
> make sense to go that way.
Actually, I would be sorta shocked if Java really did optimize away
if(Version.getVersion().equals("Xerces 2.0.2"))
... since the compiler has no way of knowing that getVersion(), even if it
*is* static, does not have side-effects. It may not in the current
implementation of the Version class, but it might in the next release. I
suspect the assertion that this might Go Away is actually someone getting
confused about the difference between static fields and static methods.
***MAYBE*** that inlining might be performed at JIT time, but that's not a
problem. So I would want to see some support for this statement before
accepting it as a reason to avoid static methods.
However, even if we grant that point, there are two different needs to be
addressed here.
One is the run-time check for testing and invocation in an application.
That may want to be a non-static method for the reasons discussed --
though of course it may be accessing static data to develop its answer.
The other is the "Which jarfile is currenly installed on the system"
report, for diagnosis and error reporting -- which generally means a
static Version.main(). Presumably, Java compilers are smart enough not to
try to optimize away _that_ call!
So this sounds like we need both Version.main() and
Version.getVersion()... and I, at least, am not convinced that the latter
can't be as static as the former.
> There are other reasons for preferring the status quo too: If we moved
the
> Version class in line with this proposed standard (which never did get
much
> support, IIRC)
I don't think there was ever any objection; it was just a matter of
everyone being lazy.
> then it becomes difficult for people to tell which Xerces
> comes first on their classpaths if two happen to be there and they have
> different Version conventions.
Oh, THAT's no problem. Xalan itself solved this, quite trivially, when we
changed our own Version APIs to the new convention: We carried both
classes, with the old one as a (deprecated) front-end for the new one so
we didn't have to maintain the data in duplicate... I'm not sure whether
we ever got around to actually discontinuing the old class, though at this
point I think we've been through enough generations of the code that we
could declare that anyone who's still issuing the old call is no longer
part of our customer base.
>
> So we're probably stuck for the time being...
>
> Cheers,
> Neil
> Neil Graham
> XML Parser Development
> IBM Toronto Lab
> Phone: 905-413-3519, T/L 969-3519
> E-mail: [EMAIL PROTECTED]
>
>
>
>
> |---------+---------------------------->
> | | "Stefan Geelen" |
> | | <stefan.geelen@xe|
> | | ntri.com> |
> | | |
> | | 09/04/2002 03:53 |
> | | PM |
> | | Please respond to|
> | | xerces-j-dev |
> | | |
> |---------+---------------------------->
>
>-------------------------------------------------------------------------------
> --------------------------------------------------------------|
> |
> |
> | To:
> <[EMAIL PROTECTED]>
> |
> |
> cc:
> |
> | Subject: Re: org.apache.xerces.impl.Version.getVersion() should
be
> static ? |
> |
> |
> |
> |
>
>-------------------------------------------------------------------------------
> --------------------------------------------------------------|
>
>
>
> OK,
>
> but what about (from the Xalan javadoc api org.apache.xalan.Version):
>
> 'This class implements the --> upcoming standard of having
> org.apache.project-name.Version.getVersion() be a standard way to get
> version information <-- ???? . '
>
> What will be the standard ? A static or non-static class ?
>
> I prefer the non-static method (much more easy to call).
>
> Stefan
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, September 04, 2002 9:43 PM
> Subject: Re: org.apache.xerces.impl.Version.getVersion() should be
static ?
>
>
> > I wrote:
> >
> > > Yes, this sure makes sense to me. Wonder why I didn't do that in
the >
> > first place...
> >
> > Ah; now I think I recall. If getVersion is static, then the compiler
can
> > convert a check like:
> >
> > if(Version.getVersion().equals("Xerces 2.0.2")) {
> > // take account of some bug
> > }
> >
> > into a compile-time check, not a run-time check as would be desired.
The
> > only way to get around this is by making getVersion a dynamic method.
> >
> > Does that make sense?
> >
> > Cheers,
> > Neil
> > Neil Graham
> > XML Parser Development
> > IBM Toronto Lab
> > Phone: 905-413-3519, T/L 969-3519
> > E-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> ______________________________________
Joe Kesselman / IBM Research
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]