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 268259 - Incorrect evalation of path in ModuleList.scanNetBeansOrgStableSources()
Summary: Incorrect evalation of path in ModuleList.scanNetBeansOrgStableSources()
Status: NEW
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: Dev
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-28 22:12 UTC by NukemBy
Modified: 2016-09-28 22:12 UTC (History)
0 users

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 NukemBy 2016-09-28 22:12:27 UTC
While scanning, for example, NetBeans sources here
    src\libs.javafx\manifest.mf

This var-expression gets into ModuleList.scanNetBeansOrgStableSources()
    Class-Path: ${java.home}/lib/ext/jfxrt.jar

It is evaluated by this code 
    http://hg.netbeans.org/main/file/ef35591e2d0f/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java#l552

    } else {
        Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
        assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
        String reltext = XMLUtil.findText(runtimeRelativePath);
        // XXX assumes that module.jar is not overridden independently of module.jar.dir:
        text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
    }
    String evaluated = eval.evaluate(text);

into combined expression 

    text = "${cluster}/${module.jar.dir}/${java.home}/lib/ext/jfxrt.jar; // NOI18N

Actually - path is not relative there because ${java.home} is absolute path. Concatenation of strings generates invalid file path like this:

 "C:\NetBeans\src\nbbuild\netbeans/platform/modules/C:\Java\jdk8x32\jre/lib/ext/jfxrt.jar"

I guess there should be a check like following

    Element binaryOrigin = XMLUtil.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
    String jarPath;
    String relPath = null;

    if (binaryOrigin != null) {
        jarPath = XMLUtil.findText(binaryOrigin);
    } else {
        Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
        assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
        relPath = eval.evaluate(XMLUtil.findText(runtimeRelativePath));
        // XXX assumes that module.jar is not overridden independently of module.jar.dir:
        jarPath = (relPath == null) ? null : "${cluster}/${module.jar.dir}/" + relPath; // NOI18N
    }

    if( jarPath != null ) {
        File jarFile = (relPath == null) ? null : new File(relPath);

        if( jarFile != null && jarFile.isAbsolute() ) {
            jarFile = PropertyUtils.resolveFile(basedir, relPath);
        }
        else {
            String absPathEvaluated = eval.evaluate(jarPath);
            if (absPathEvaluated == null) {
                continue;
            }

            jarFile = PropertyUtils.resolveFile(basedir, absPathEvaluated);
        }

        if( jarFile != null ) {
            cpextra.append(File.pathSeparatorChar);
            cpextra.append(jarFile.getAbsolutePath());
        }
    }