...
 
Commits (4)
class FirstMain {
public static void main(String[] args) {}
}
class AnotherMain {
public static void main(String[] args) {}
}
class IfElseTypeMismatch {
public static void main(String[] args) {
foo(true)
foo(true);
}
public int foo(boolean b) {
......
class ClassWithNonstaticMain {
/* String is a valid type */
public void main() { }
public void foo() {
main();
}
}
class ClassWithStaticVoidMainStringArgs {
public static void main(String[] args) {
ClassWithNonstaticMain x = new ClassWithNonstaticMain();
x.main();
}
}
/* 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) {}
}
class MissingMain {
int x;
public int x;
public void foo() {}
}
class Foo {
Foo Foo;
public Foo Foo;
Foo Foo(Foo Foo) {
public Foo Foo(Foo Foo) {
Foo.Foo = new Foo();
return Foo;
}
......
class VoidField {
void foo;
public void foo;
public static void main(String[] args) {
}
}