Skip to content

Commit 3bd1eb3

Browse files
Java main method must be public
1 parent d050b3c commit 3bd1eb3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/java_bytecode/java_entry_point.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ exprt::operandst java_build_arguments(
177177
bool named_main=has_suffix(config.main, ".main");
178178
const typet &string_array_type=
179179
java_type_from_string("[Ljava.lang.String;");
180+
// checks whether the function is static and has a single String[] parameter
180181
bool has_correct_type=
181182
to_code_type(function.type).return_type().id()==ID_empty &&
182183
(!to_code_type(function.type).has_this()) &&
183184
parameters.size()==1 &&
184185
parameters[0].type().full_eq(string_array_type);
185-
is_main=(named_main && has_correct_type);
186+
bool public_access = function.type.get(ID_access) == ID_public;
187+
is_main=(named_main && has_correct_type && public_access);
186188
}
187189

188190
// we iterate through all the parameters of the function under test, allocate

0 commit comments

Comments
 (0)