Skip to content

Commit 21db05f

Browse files
authored
Fixed creating chunk for field in wrapper with package-private type (#1633)
1 parent 630c765 commit 21db05f

File tree

1 file changed

+6
-1
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/engine

1 file changed

+6
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Hierarchy.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ class Hierarchy(private val typeRegistry: TypeRegistry) {
3636
// Since wrapper UtThread does not inherit java.lang.Thread, we cannot use this inheritance condition only.
3737
// The possible presence of hidden field is not important here - we just need
3838
// to know whether we have at least one such field.
39-
val realTypeHasFieldByName = realType.sootClass.getFieldUnsafe(field.subSignature) != null
39+
40+
// NOTE: we cannot use `getFieldByNameUnsafe` here because of possible hidden fields presence, and we also
41+
// cannot use `ClassId::hasField` here because it use classloader to check it but we cannot load our wrappers.
42+
// Also, we cannot `getFieldUnsafe` by signature of field, because, for example, `threadLocals` field in `UtThread`
43+
// is declared with `Object` type since its real type is package-private.
44+
val realTypeHasFieldByName = realType.sootClass.fields.any { it.name == field.name }
4045
val realTypeIsInheritor = realFieldDeclaringType.sootClass in ancestors(realType.sootClass.id)
4146

4247
if (!realTypeIsInheritor && !realTypeHasFieldByName) {

0 commit comments

Comments
 (0)