Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 569537

Summary: The main method can still be run when the java file fails to compile
Product: [Eclipse Project] JDT Reporter: N S <gm65467>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: loskutov
Version: 4.17   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description N S CLA 2020-12-08 04:10:51 EST
Why can I still run the main method when the java file fails to compile.Below is the sample Java code:

//code start
public class Demo extends Super{

	public static void main(String[] args) {
		Super s = new Demo();
		System.out.print(s.get());
	}
	
	public long get() {//Compile Error
		return 456;
	}

}
class Super {
	public int get() {
		return 123;
	}
}
/*
output:
123
*/
//code end
Comment 1 Andrey Loskutov CLA 2020-12-08 06:43:40 EST
The code is wrong. You can't overload int get() with long get().