@@ -31,13 +31,14 @@ private fun isIgnored(type: ClassId): Boolean {
31
31
|| (type.isInner && ! type.isStatic)
32
32
}
33
33
34
- fun anyObjectValueProvider (idGenerator : IdentityPreservingIdGenerator <Int >) =
35
- ObjectValueProvider (idGenerator).letIf(UtSettings .fuzzingImplementationOfAbstractClasses) { ovp ->
34
+ fun anyObjectValueProvider (idGenerator : IdentityPreservingIdGenerator <Int >, isSpringProject : Boolean = false ) =
35
+ ObjectValueProvider (idGenerator, isSpringProject ).letIf(UtSettings .fuzzingImplementationOfAbstractClasses) { ovp ->
36
36
ovp.withFallback(AbstractsObjectValueProvider (idGenerator))
37
37
}
38
38
39
39
class ObjectValueProvider (
40
40
val idGenerator : IdGenerator <Int >,
41
+ private val isSpringProject : Boolean ,
41
42
) : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescription> {
42
43
43
44
override fun accept (type : FuzzedType ) = ! isIgnored(type.classId)
@@ -100,16 +101,18 @@ class ObjectValueProvider(
100
101
}
101
102
}
102
103
}
103
- findAllPublicMethods(description, classId, description.description.packageName).forEach { md ->
104
- yield (Routine .Call (md.parameterTypes) { self, values ->
105
- val model = self.model as UtAssembleModel
106
- model.modificationsChain as MutableList + =
107
- UtExecutableCallModel (
108
- model,
109
- md.executable,
110
- values.map { it.model }
111
- )
112
- })
104
+ if (isSpringProject) {
105
+ findAllPublicMethods(description, classId, description.description.packageName).forEach { md ->
106
+ yield (Routine .Call (md.parameterTypes) { self, values ->
107
+ val model = self.model as UtAssembleModel
108
+ model.modificationsChain as MutableList + =
109
+ UtExecutableCallModel (
110
+ model,
111
+ md.method.executableId,
112
+ values.map { it.model }
113
+ )
114
+ })
115
+ }
113
116
}
114
117
},
115
118
empty = nullRoutine(classId)
@@ -233,7 +236,7 @@ internal class FieldDescription(
233
236
internal class MethodDescription (
234
237
val name : String ,
235
238
val parameterTypes : List <FuzzedType >,
236
- val executable : ExecutableId
239
+ val method : Method
237
240
)
238
241
239
242
internal fun findAccessibleModifiableFields (description : FuzzedDescription ? , classId : ClassId , packageName : String? ): List <FieldDescription > {
@@ -264,6 +267,7 @@ internal fun findAllPublicMethods(
264
267
): List <MethodDescription > =
265
268
classId.jClass.declaredMethods.mapNotNull { method ->
266
269
if (isAccessible(method, packageName)) {
270
+ if (method.genericParameterTypes.any { it !is Class <* > }) return @mapNotNull null
267
271
val parameterTypes =
268
272
method
269
273
.parameterTypes
@@ -279,11 +283,16 @@ internal fun findAllPublicMethods(
279
283
MethodDescription (
280
284
name = method.name,
281
285
parameterTypes = parameterTypes,
282
- executable = method.executableId
286
+ method = method
283
287
)
284
288
} else null
285
289
}
286
290
291
+ internal fun List<MethodDescription>.removeSetters (): List <MethodDescription > =
292
+ filterNot { md ->
293
+ md.method.name.startsWith(" set" ) && md.method.parameterCount == 1
294
+ }
295
+
287
296
internal fun Class <* >.findPublicSetterGetterIfHasPublicGetter (field : Field , packageName : String? ): PublicSetterGetter ? {
288
297
@Suppress(" DEPRECATION" ) val postfixName = field.name.capitalize()
289
298
val setterName = " set$postfixName "
0 commit comments