Skip to content

Commit b9b6dac

Browse files
authored
Merge pull request #4329 from smowton/smowton/fix/tolerate-nil-names
Java: tolerate fields and classes with the name "nil"
2 parents a151280 + 796f7e1 commit b9b6dac

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed
332 Bytes
Binary file not shown.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class nil {
2+
3+
int nil;
4+
5+
public int getNil() {
6+
return nil;
7+
}
8+
9+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
nil.class
3+
--function nil.getNil
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
std::bad_cast

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class fieldref_exprt : public exprt
352352
template <>
353353
inline bool can_cast_expr<fieldref_exprt>(const exprt &base)
354354
{
355-
return base.get(ID_class) != ID_nil && base.get(ID_component_name) != ID_nil;
355+
return !base.get(ID_class).empty() && !base.get(ID_component_name).empty();
356356
}
357357

358358
#endif // CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSE_TREE_H

0 commit comments

Comments
 (0)