@@ -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)
@@ -213,7 +216,7 @@ internal class FieldDescription(
213
216
internal class MethodDescription (
214
217
val name : String ,
215
218
val parameterTypes : List <FuzzedType >,
216
- val executable : ExecutableId
219
+ val method : Method
217
220
)
218
221
219
222
internal fun findAccessibleModifiableFields (description : FuzzedDescription ? , classId : ClassId , packageName : String? ): List <FieldDescription > {
@@ -244,6 +247,7 @@ internal fun findAllPublicMethods(
244
247
): List <MethodDescription > =
245
248
classId.jClass.declaredMethods.mapNotNull { method ->
246
249
if (isAccessible(method, packageName)) {
250
+ if (method.genericParameterTypes.any { it !is Class <* > }) return @mapNotNull null
247
251
val parameterTypes =
248
252
method
249
253
.parameterTypes
@@ -259,11 +263,16 @@ internal fun findAllPublicMethods(
259
263
MethodDescription (
260
264
name = method.name,
261
265
parameterTypes = parameterTypes,
262
- executable = method.executableId
266
+ method = method
263
267
)
264
268
} else null
265
269
}
266
270
271
+ internal fun List<MethodDescription>.removeSetters (): List <MethodDescription > =
272
+ filterNot { md ->
273
+ md.method.name.startsWith(" set" ) && md.method.parameterCount == 1
274
+ }
275
+
267
276
internal fun Class <* >.findPublicSetterGetterIfHasPublicGetter (field : Field , packageName : String? ): PublicSetterGetter ? {
268
277
@Suppress(" DEPRECATION" ) val postfixName = field.name.capitalize()
269
278
val setterName = " set$postfixName "
0 commit comments