Skip to content

Support for multi-file source launcher causes regressions for normal projects #6881

@matthiasblaesing

Description

@matthiasblaesing

Body

I noticed, that when I created a test.java file in my tmp directory, NetBeans suddenly started a massive scanning job. It turned out NetBeans scanned the whole folder, which also included an angular project with ~30.000 files in the node_modules folder. What is more, I noticed, that other projects in the folder were marked as broken.

My gut feeling led me to the changes for the mult-file source launcher and indeed it has problematic side effect. I could reproduce it like this:

  1. Checkout babcc3d (current master), clean dir and build NB and run with "ant tryme"

  2. Create an empty directory (PATH in the following)

  3. Inside the new directory create a new maven project ("Java with Maven -> Java Application", with default settings, just parent folder changed to PATH)

  4. Add gson to the pom.xml (as child element of the project node):

    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.10.1</version>
        </dependency>
    </dependencies>
  5. Ensure dependency is locally present by invoking "Download Declared Dependencies" on the "Dependencies" node

  6. Change class Mavenproject1 to:

    package test.mavenproject1;
    
    import com.google.gson.Gson;
    import java.util.Collections;
    
    public class Mavenproject1 {
    
        public static void main(String[] args) {
    	new Gson().toJson(Collections.singletonMap("Hello", "World"));
        }
    }
  7. Open Favorites tab and create test.java in the directory created in step 1

Mavenproject1.java is immediately marked as "has errors

  1. Open "Window -> Action Items" and open Mavenproject1.java

You'll see:

Error	Package com.google.gson ist nicht vorhanden	Mavenproject1.java	PATH/mavenproject1/src/main/java/test/mavenproject1/Mavenproject1.java:3
Error	Symbol nicht gefunden   Symbol: Klasse Gson   Ort: Klasse test.mavenproject1.Mavenproject1	Mavenproject1.java	PATH/mavenproject1/src/main/java/test/mavenproject1/Mavenproject1.java:9
  1. Remove the directory
  2. Revert multi-file launcher:
 git revert 192bb526a9f535485905998674460c1aaafb9b20
 git rm java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SharedRootData.java java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/queries/MultiSourceRootProvider.java
 git revert --continue
  1. Build again with git clean -f -x -d; ant
  2. Run with ant try
  3. Repeat steps 2-7 and observe, that problems are gone

Committer

  • I acknowledge that I am a maintainer/committer in the Apache NetBeans project.

Metadata

Metadata

Assignees

Labels

Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)RegressionThis used to work!priority:criticalShowstopper issue that requires fixing in next release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions