Commit 109671e4 authored by Christian Schwarz's avatar Christian Schwarz

main_with_local_string_class should be invalid, see comment why

parent 21d4e131
/* String shadows the default String class.
* javac won't complain because the proper main method could be defined in another class file.
* However, since MiniJava files contain the entire program, it is reasonable to expect
* that the lack of a proper main method be detected at compile time.
* Analogy:
* If gcc is invoked _without_ '-c' on a set of .c files, gcc will also invoke the linker.
* If the linker cannot find a main, the gcc "user experience" is equivalent to a compiler error.
*/
class String { }
class MainWithLocalStringShadowingJavaString {
public static void main(String[] args) {}
}
/* String shadows the default String class.
* However, Java only detects the lack of a main() at runtime,
* failing with 'error: Main method not found'
*/
class String { }
class MainWithLocalStringShadowingJavaString {
public static void main(String[] args) {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment