Skip to content

Commit b17e6fb

Browse files
author
Daniel Kroening
committed
prettify Java null references
1 parent 18701cb commit b17e6fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/java_bytecode/expr2java.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,18 @@ std::string expr2javat::convert_constant(
230230
{
231231
if(src.type().id()==ID_bool)
232232
{
233-
// C++ has built-in Boolean constants, in contrast to C
233+
// Java has built-in Boolean constants, in contrast to C
234234
if(src.is_true())
235235
return "true";
236236
else if(src.is_false())
237237
return "false";
238238
}
239+
else if(src.type().id()==ID_pointer)
240+
{
241+
// Java writes 'null' for the null reference
242+
if(src.is_zero())
243+
return "null";
244+
}
239245

240246
return expr2ct::convert_constant(src, precedence);
241247
}

0 commit comments

Comments
 (0)