Skip to content

Commit 088d101

Browse files
author
Joel Allred
committed
Unit tests for parsing of final methods
1 parent 848b526 commit 088d101

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class ClassWithFinalMethod {
2+
public final int finalFunc() {
3+
return 0;
4+
}
5+
public int nonFinalFunc() {
6+
return 0;
7+
}
8+
}

jbmc/unit/java_bytecode/java_bytecode_convert_method/convert_method.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,37 @@ SCENARIO(
5757
}
5858
}
5959
}
60+
61+
SCENARIO(
62+
"java_bytecode_convert_final_method",
63+
"[core][java_bytecode][java_bytecode_convert_method]")
64+
{
65+
GIVEN("A class with final and non-final methods")
66+
{
67+
const symbol_tablet symbol_table = load_java_class(
68+
"ClassWithFinalMethod", "./java_bytecode/java_bytecode_convert_method");
69+
70+
WHEN("When parsing a final method")
71+
{
72+
const symbolt function_symbol =
73+
symbol_table.lookup_ref("java::ClassWithFinalMethod.finalFunc:()I");
74+
const java_method_typet &function_type =
75+
require_type::require_java_method(function_symbol.type);
76+
THEN("The method should be marked as final")
77+
{
78+
REQUIRE(function_type.get_is_final());
79+
}
80+
}
81+
WHEN("When parsing a non-final method")
82+
{
83+
const symbolt function_symbol =
84+
symbol_table.lookup_ref("java::ClassWithFinalMethod.nonFinalFunc:()I");
85+
const java_method_typet &function_type =
86+
require_type::require_java_method(function_symbol.type);
87+
THEN("The method should not be marked as final")
88+
{
89+
REQUIRE(!function_type.get_is_final());
90+
}
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)