Skip to content

Commit 248ec8e

Browse files
author
thk123
committed
Don't require pointers point to classes
Previously we had an invariant that all pointers were pointers to classes. This invariant is incorrect in at least two places: strings and exceptions. Instead, since if it isn't a pointer to a class, it certainly isn't a pointer to an abstract class, so we can just return false in the event it isn't a pointer to a class.
1 parent 90286a8 commit 248ec8e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/java_bytecode/select_pointer_type.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ pointer_typet select_pointer_typet::operator()(
4343
return resolved_type;
4444
}
4545

46-
/// Find out whether a pointer is pointing to an abstract class or interface
46+
/// Find out whether a pointer is pointing to an abstract type (either an
47+
/// abstract class or an interface).
4748
/// \param pointer_type: The type of the pointer
4849
/// \return True if the type pointed to is either an abstract class or an
4950
/// interface.
5051
bool select_pointer_typet::is_abstract_type(
5152
const pointer_typet &pointer_type) const
5253
{
5354
const typet &pointing_to_type=ns.follow(pointer_type.subtype());
54-
55-
// void* pointers should be not considered abstract
56-
// These happen in Java when initializing the exeception value.
57-
if(pointing_to_type.id()==ID_empty)
55+
if(pointing_to_type.id()==ID_struct)
56+
{
57+
const class_typet &class_type=to_class_type(pointing_to_type);
58+
return class_type.is_class() && class_type.is_abstract();
59+
}
60+
else
61+
{
62+
// we are dealing with some other type that a reference to a polymorphic
63+
// class so therefore we are definitely not abstract
5864
return false;
59-
60-
INVARIANT(
61-
pointing_to_type.id()==ID_struct,
62-
"All pointers in Java should be to classes");
63-
64-
const class_typet &class_type=to_class_type(pointing_to_type);
65-
return class_type.is_class() && class_type.is_abstract();
65+
}
6666
}

0 commit comments

Comments
 (0)