You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "J. B. Rainsberger" <jb...@rogers.com> on 2003/11/28 23:55:26 UTC
Code Review (Re: "You must either set location or path on "
Exception Message)
Vincent Massol wrote:
> File toolsJar = new File(javaHome + "/../lib/tools.jar");
I think this could and /should/ be
new File(javaHome, "../lib/tools.jar");
--
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand
RE: Code Review (Re: "You must either set location or path on " Exception Message)
Posted by Vincent Massol <vm...@pivolis.com>.
> -----Original Message-----
> From: J. B. Rainsberger [mailto:jbrains@rogers.com]
> Sent: 29 November 2003 12:18
> To: Cactus Users List
> Subject: Re: Code Review (Re: "You must either set location or path on
> <pathelement>" Exception Message)
[snip]
> >>>>I think this could and /should/ be
> >>>>
> >>>> new File(javaHome, "../lib/tools.jar");
> >>>
> >>>
> >>>Are you confident javaHome will always contain a trailing "/"?
> >>
> >>No. That's the point of using 'new File(directory, relativePath)'.
The
> >>nice Java folks have already worried about trailing slash or not
> >>trailing slash. Why should /we/ worry about it?
> >
> >
> > Cool. I didn't know that :-) BTW, I've had a look at the JDK 1.4
javadoc
> > for File and I couldn't see this mentioned anywhere. Are you sure
this
> > is an exposed feature or simply an implementation detail of the
Sun's
> > JDK?
>
> The parent path (the first parameter) is "taken to be a directory"
> [Javadoc], so it doesn't matter whether the parent path you specify
ends
> in "/" -- File treats it like a directory, anyway. The relative path
is
> always taken from the directory represented by the parent path. The
> whole point of the constructor is to avoid this entire trailing slash
> issue! :)
yep. Sorry, I'm a bit slow this morning :-)
Thanks
-Vincent
Re: Code Review (Re: "You must either set location or path on "
Exception Message)
Posted by "J. B. Rainsberger" <jb...@rogers.com>.
Vincent Massol wrote:
>
>>-----Original Message-----
>>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
>>Sent: 29 November 2003 11:55
>>To: Cactus Users List
>>Subject: Re: Code Review (Re: "You must either set location or path on
>><pathelement>" Exception Message)
>>
>>Vincent Massol wrote:
>>
>>
>>>>-----Original Message-----
>>>>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
>>>>Sent: 28 November 2003 23:55
>>>>To: Cactus Users List
>>>>Subject: Code Review (Re: "You must either set location or path on
>>>><pathelement>" Exception Message)
>>>>
>>>>Vincent Massol wrote:
>>>>
>>>>
>>>>
>>>>> File toolsJar = new File(javaHome + "/../lib/tools.jar");
>>>>
>>>>I think this could and /should/ be
>>>>
>>>> new File(javaHome, "../lib/tools.jar");
>>>
>>>
>>>Are you confident javaHome will always contain a trailing "/"?
>>
>>No. That's the point of using 'new File(directory, relativePath)'. The
>>nice Java folks have already worried about trailing slash or not
>>trailing slash. Why should /we/ worry about it?
>
>
> Cool. I didn't know that :-) BTW, I've had a look at the JDK 1.4 javadoc
> for File and I couldn't see this mentioned anywhere. Are you sure this
> is an exposed feature or simply an implementation detail of the Sun's
> JDK?
The parent path (the first parameter) is "taken to be a directory"
[Javadoc], so it doesn't matter whether the parent path you specify ends
in "/" -- File treats it like a directory, anyway. The relative path is
always taken from the directory represented by the parent path. The
whole point of the constructor is to avoid this entire trailing slash
issue! :)
--
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand
RE: Code Review (Re: "You must either set location or path on " Exception Message)
Posted by Vincent Massol <vm...@pivolis.com>.
> -----Original Message-----
> From: J. B. Rainsberger [mailto:jbrains@rogers.com]
> Sent: 29 November 2003 11:55
> To: Cactus Users List
> Subject: Re: Code Review (Re: "You must either set location or path on
> <pathelement>" Exception Message)
>
> Vincent Massol wrote:
>
> >
> >>-----Original Message-----
> >>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
> >>Sent: 28 November 2003 23:55
> >>To: Cactus Users List
> >>Subject: Code Review (Re: "You must either set location or path on
> >><pathelement>" Exception Message)
> >>
> >>Vincent Massol wrote:
> >>
> >>
> >>> File toolsJar = new File(javaHome + "/../lib/tools.jar");
> >>
> >>I think this could and /should/ be
> >>
> >> new File(javaHome, "../lib/tools.jar");
> >
> >
> > Are you confident javaHome will always contain a trailing "/"?
>
> No. That's the point of using 'new File(directory, relativePath)'. The
> nice Java folks have already worried about trailing slash or not
> trailing slash. Why should /we/ worry about it?
Cool. I didn't know that :-) BTW, I've had a look at the JDK 1.4 javadoc
for File and I couldn't see this mentioned anywhere. Are you sure this
is an exposed feature or simply an implementation detail of the Sun's
JDK?
Thanks
-Vincent
>
> > In any case, I think this whole section should be rewritten as it
does
> > not support MAC OS and we could verify whether tools.jar is already
in
> > the executing classloaders and take it from there if it is (not sure
how
> > easy it is).
>
> Fair enough. I just saw a simple improvement. :)
> --
> J. B. Rainsberger,
> Diaspar Software Services
> http://www.diasparsoftware.com :: +1 416 791-8603
> Let's write software that people understand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
Re: Code Review (Re: "You must either set location or path on "
Exception Message)
Posted by "J. B. Rainsberger" <jb...@rogers.com>.
Vincent Massol wrote:
>
>>-----Original Message-----
>>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
>>Sent: 28 November 2003 23:55
>>To: Cactus Users List
>>Subject: Code Review (Re: "You must either set location or path on
>><pathelement>" Exception Message)
>>
>>Vincent Massol wrote:
>>
>>
>>> File toolsJar = new File(javaHome + "/../lib/tools.jar");
>>
>>I think this could and /should/ be
>>
>> new File(javaHome, "../lib/tools.jar");
>
>
> Are you confident javaHome will always contain a trailing "/"?
No. That's the point of using 'new File(directory, relativePath)'. The
nice Java folks have already worried about trailing slash or not
trailing slash. Why should /we/ worry about it?
> In any case, I think this whole section should be rewritten as it does
> not support MAC OS and we could verify whether tools.jar is already in
> the executing classloaders and take it from there if it is (not sure how
> easy it is).
Fair enough. I just saw a simple improvement. :)
--
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand
RE: Code Review (Re: "You must either set location or path on " Exception Message)
Posted by Vincent Massol <vm...@pivolis.com>.
> -----Original Message-----
> From: J. B. Rainsberger [mailto:jbrains@rogers.com]
> Sent: 28 November 2003 23:55
> To: Cactus Users List
> Subject: Code Review (Re: "You must either set location or path on
> <pathelement>" Exception Message)
>
> Vincent Massol wrote:
>
> > File toolsJar = new File(javaHome + "/../lib/tools.jar");
>
> I think this could and /should/ be
>
> new File(javaHome, "../lib/tools.jar");
Are you confident javaHome will always contain a trailing "/"?
In any case, I think this whole section should be rewritten as it does
not support MAC OS and we could verify whether tools.jar is already in
the executing classloaders and take it from there if it is (not sure how
easy it is).
Thanks
-Vincent
> --
> J. B. Rainsberger,
> Diaspar Software Services
> http://www.diasparsoftware.com :: +1 416 791-8603
> Let's write software that people understand
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org