Skip to content

Commit f15c312

Browse files
committed
Exclude j.l.O from possible static field hosts.
1 parent afa443c commit f15c312

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,15 @@ static void create_stub_global_symbol(
429429
!add_failed, "caller should have checked symbol not already in table");
430430
}
431431

432-
/// Find any incomplete ancestor of a given class
432+
/// Find any incomplete ancestor of a given class that can have a stub static
433+
/// field attached to it. This specifically excludes java.lang.Object, which we
434+
/// know cannot have static fields.
433435
/// \param start_class_id: class to start searching from
434436
/// \param symbol_table: global symbol table
435437
/// \param class_hierarchy: global class hierarchy
436438
/// \return first incomplete ancestor encountered,
437439
/// including start_class_id itself.
438-
static irep_idt get_any_incomplete_ancestor(
440+
static irep_idt get_any_incomplete_ancestor_for_stub_static_field(
439441
const irep_idt &start_class_id,
440442
const symbol_tablet &symbol_table,
441443
const class_hierarchyt &class_hierarchy)
@@ -450,8 +452,12 @@ static irep_idt get_any_incomplete_ancestor(
450452
irep_idt to_check = classes_to_check.back();
451453
classes_to_check.pop_back();
452454

453-
if(symbol_table.lookup_ref(to_check).type.get_bool(ID_incomplete_class))
455+
// Exclude java.lang.Object because it can
456+
if(symbol_table.lookup_ref(to_check).type.get_bool(ID_incomplete_class) &&
457+
to_check != "java::java.lang.Object")
458+
{
454459
return to_check;
460+
}
455461

456462
const class_hierarchyt::idst &parents =
457463
class_hierarchy.class_map.at(to_check).parents;
@@ -512,7 +518,7 @@ static void create_stub_global_symbols(
512518
// class that was referred to. This is just a guess, but we have no
513519
// better information to go on.
514520
irep_idt add_to_class_id =
515-
get_any_incomplete_ancestor(
521+
get_any_incomplete_ancestor_for_stub_static_field(
516522
class_id, symbol_table, class_hierarchy);
517523

518524
// If there are no incomplete ancestors to ascribe the missing field

0 commit comments

Comments
 (0)