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.
HOW TO REPRODUCE: 1. Create Java project with two classes: org/sample/Main.java: package org.sample; public class HelloApplication { private static Greeter getGreeter() { return new Greeter(1); } public static void main(String[] args) throws Exception { getGreeter().greet(); } } org/sample/Greeter.java: package org.sample; public class Greeter { public Greeter(int id) {} public void greet() { System.out.println("hello"); } } 2. Disable "Compile on save" feature. 3. Press "Run Project". Get expected "hello" output. 4. Change Greeter constructor signature Greeter(int id) -> Greeter(Integer id) 5. Press "Build Project". Only 1 class is compiled. Fragment from debug ant log: fileset: Setup scanner in dir /home/viktor/NetBeansProjects/JavaApplication1/src with patternSet{ includes: [**] excludes: [] } org/sample/Greeter.java added as org/sample/Greeter.class is outdated. org/sample/HelloApplication.java omitted as /home/viktor/NetBeansProjects/JavaApplication1/build/classes/org/sample/HelloApplication.class is up to date. 6. Press "Run Project". Get runtime error: Exception in thread "main" java.lang.NoSuchMethodError: org.sample.Greeter.<init>(Ljava/lang/Integer;)V at org.sample.HelloApplication.getGreeter(HelloApplication.java:14) at org.sample.HelloApplication.main(HelloApplication.java:18)
Reproducible even without "Compile on save" option: 2. Press "Build Project" 3. Run application from console > java -jar dist/JavaApplication1.jar hello 4. Change constructor Greeter(int id) -> Greeter(Integer id) 5. Press "Build Project" 6. Run application from console > java -jar dist/JavaApplication1.jar Exception in thread "main" java.lang.NoSuchMethodError: org.sample.Greeter.<init>(Ljava/lang/Integer;)V at org.sample.HelloApplication.getGreeter(HelloApplication.java:14) at org.sample.HelloApplication.main(HelloApplication.java:18)
Think, button "Build Project" should actually build project or at least compile all classes which call/refer to changed classes. Compiling of only changed *.java files results to broken project state. I found only one old similar issue with "cannot reproduce" resolution: https://netbeans.org/bugzilla/show_bug.cgi?id=133683 NetBeans About output: Product Version: NetBeans IDE 8.1 (Build 201510222201) Updates: NetBeans IDE is updated to version NetBeans 8.1 Patch 1 Java: 1.8.0_40; Java HotSpot(TM) 64-Bit Server VM 25.40-b25 Runtime: Java(TM) SE Runtime Environment 1.8.0_40-b25 System: Linux version 4.4.0-36-generic running on amd64; UTF-8; en_US (nb)
Created attachment 161945 [details] Sample project