This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 154320 - Java project properties/Libraries/Add Jar/Path from Variable
Summary: Java project properties/Libraries/Add Jar/Path from Variable
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-02 09:59 UTC by dlatt
Modified: 2009-02-19 21:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dlatt 2008-12-02 09:59:57 UTC
On Windows XP, in the "Add Jar/Folder" dialog under Project Properties/Libraries, the path to a jar can only be
specified as "Path from Variable" if the variable points exactly to the directory where the jar file is located. It
cannot be used as a prefix with additional subdirectories which would result in {variable}/path/to/file.jar, only
{variable}/file.jar.  When trying, the text field shows <no suitable variable>.

On Linux, it works as expected.
Comment 1 David Konecny 2008-12-02 22:05:26 UTC
Very strange. I do not have Win box handy so I cannot test this. Looking at code I cannot see any obvious problem:
selected java.io.File from JFileChooser is taken and its getAbsolutePath is tested if it starts with any of the
getAbsolutePath of java.io.File of each variable. Can you see how this could get broken on your PC? What are concrete
paths in your scenario? Perhaps I should normalize java.io.File before comparing their absolute paths. But even then it
should get broken only in certain scenarios. Thanks.

QA - could you test this please on Windows?
Comment 2 dlatt 2008-12-03 09:04:18 UTC
Your mentioning normalization rang a bell.  I took care to capitalize the path components correctly as a mismatch in
case can bite you in cross-platform tools, even if Windows doesn't care.  I have experienced this several times.

However, I used a lower case drive letter in the variable (d:\dev-java\lib) while the file chooser returns an upper case
letter. I failed to notice that, presumably because drive letters are used on Windows only and case doesn't matter there!

So, I experimented a bit.  Using a capital drive letter works!  If the file name components or the drive letter is
incorrectly capitalized, it doesn't work, even though it means the same file on Windows.  It could be a matter of taste
if this should be considered a bug.  I don't know if there is an easy way to "normalize" the file name in order to avoid
this upper/lower case dependency.

I ran into another bug which maybe has the same cause: While trying to edit the variable to change the drive letter to
upper case, this change is first shown in the variables list, but when re-opening the variables dialog, the old value is
displayed.  Same for changes in case only for file name components.  Should I submit this as another bug or can it be
worked on here?
Comment 3 Jiri Prox 2008-12-03 11:23:34 UTC
Yes I can reproduce this behavior - the case of drive letter is important and it is impossible to edit case of the drive
letter directly 
Comment 4 David Konecny 2008-12-03 20:03:38 UTC
Thanks guys for the help. I will fix both problems you've identified. It it my mistake not to normalize java.io.File -
we've had this problem before in other areas. In NB code base it is easy - there is FileUtil.normalizeFile() which does
all the tricks.
Comment 5 David Konecny 2008-12-11 20:51:27 UTC
Fixed locally as e85fe59b5245. Please verify on Windows once fix gets into build. Thanks.
Comment 6 Quality Engineering 2008-12-12 17:33:05 UTC
Integrated into 'main-golden', will be available in build *200812121401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/e85fe59b5245
User: David Konecny <dkonecny@netbeans.org>
Log: #154320 - normalize File before using it
Comment 7 dlatt 2008-12-17 14:22:25 UTC
I tested nightly build 200812150201, and it works for me! Thanks.
Comment 8 Tomas Danek 2009-01-12 13:10:06 UTC
verified.
Comment 9 pgebauer 2009-01-12 15:21:03 UTC
The fix has been ported into the release65_fixes repository.

http://hg.netbeans.org/release65_fixes/rev/35829a98b272
Comment 10 Tomas Danek 2009-01-16 14:18:26 UTC
verified in 6.5patch2