Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uydwl
mjtest-tests
Commits
109671e4
Commit
109671e4
authored
Nov 15, 2018
by
Christian Schwarz
Browse files
main_with_local_string_class should be invalid, see comment why
parent
21d4e131
Changes
2
Hide whitespace changes
Inline
Side-by-side
semantic/main_with_local_string_class.invalid.java
0 → 100644
View file @
109671e4
/* 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
)
{}
}
semantic/main_with_local_string_class_compiles.java
deleted
100644 → 0
View file @
21d4e131
/* 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
)
{}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment