Bug report
Suppose there is a file structure:
folder1/
Main.java
folder2/
Main.java
// folder1/Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Main 1");
}
}
// folder2/Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Main 2");
}
}
No package statements; the projects are not connected at all.
When folder1/Main.java is run first, it gives the correct output Main 1.
But if folder2/Main.java is then run, it gives the wrong output of Main 1 instead of Main 2; the first built file is run instead.
folder1/Main.java 'shadows' folder2/Main.java, since the class name is the same and there are no package statements.
Another file structure that causes this is ./Main.java, ./folder/Main.java
This bug is inconvenient when multiple different, unrelated Java projects are in the same workspace.