Skip to content

Commit 3bd8dd1

Browse files
committed
Remove access for jClass in UtMockFieldInfo
1 parent 7becfd0 commit 3bd8dd1

File tree

1 file changed

+9
-3
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/engine

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,18 @@ class Mocker(
203203
return false
204204
}
205205

206+
val sootField = sootDeclaringClass.getFieldByName(mockInfo.fieldId.name)
207+
val sootFieldType = sootField.type
208+
206209
return when {
207-
declaringClass.packageName.startsWith("java.lang") -> false
208-
!mockInfo.fieldId.type.isRefType -> false // mocks are allowed for ref fields only
209-
else -> return strategy.eligibleToMock(mockInfo.fieldId.type, classUnderTest) // if we have a field with Integer type, we should not mock it
210+
sootDeclaringClass.packageName.startsWith("java.lang") -> false
211+
sootFieldType !is RefType -> false // mocks are allowed for ref fields only
212+
else -> strategy.eligibleToMock(sootFieldType.id, classUnderTest) // if we have a field with Integer type, we should not mock it
210213
}
211214
}
215+
216+
// Note that eligibleToMock can use information retrieved from jClass
217+
// Therefore, such classes should be already processed at this point
212218
return strategy.eligibleToMock(type.id, classUnderTest) // strategy to decide
213219
}
214220

0 commit comments

Comments
 (0)