Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added regression/cbmc-java/lazyloading5/other.class
Binary file not shown.
Binary file added regression/cbmc-java/lazyloading5/test.class
Binary file not shown.
6 changes: 6 additions & 0 deletions regression/cbmc-java/lazyloading5/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
test.class
--lazy-methods --function test.main
^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
21 changes: 21 additions & 0 deletions regression/cbmc-java/lazyloading5/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

public class test {

public static void main() {

assert(other.getx()==1);

}

}

class other {

public static int x;
public static int getx() { return x; }

static {
x=1;
}

}
4 changes: 4 additions & 0 deletions src/java_bytecode/java_bytecode_convert_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,11 @@ codet java_bytecode_convert_methodt::convert_instructions(
// static binding
call.function()=symbol_exprt(arg0.get(ID_identifier), arg0.type());
if(lazy_methods)
{
lazy_methods->add_needed_method(arg0.get(ID_identifier));
// Calling a static method causes static initialization:
lazy_methods->add_needed_class(arg0.get(ID_C_class));
}
}

call.function().add_source_location()=loc;
Expand Down