Skip to content

Commit cdf4cb3

Browse files
committed
AnnotatedCreatorCollector avoids processing synthetic methods
This implementation matches the AnnotatedMethodCollector which also avoids synthetic methods. In the debugger I found most iterations through _findPotentialFactories were checking synthetic methods rather than human-declared methods.
1 parent 199c4ef commit cdf4cb3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedCreatorCollector.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> pr
207207

208208
// First find all potentially relevant static methods
209209
for (Method m : ClassUtil.getClassMethods(type.getRawClass())) {
210-
if (!Modifier.isStatic(m.getModifiers())) {
210+
if (!_isIncludableFactoryMethod(m)) {
211211
continue;
212212
}
213213
// all factory methods are fine:
@@ -242,7 +242,7 @@ private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> pr
242242
if (primaryMixIn != null) {
243243
MemberKey[] methodKeys = null;
244244
for (Method mixinFactory : primaryMixIn.getDeclaredMethods()) {
245-
if (!Modifier.isStatic(mixinFactory.getModifiers())) {
245+
if (!_isIncludableFactoryMethod(mixinFactory)) {
246246
continue;
247247
}
248248
if (methodKeys == null) {
@@ -274,6 +274,14 @@ private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> pr
274274
return result;
275275
}
276276

277+
private boolean _isIncludableFactoryMethod(Method m)
278+
{
279+
return Modifier.isStatic(m.getModifiers())
280+
// 09-Nov-2020, ckozak: Avoid considering synthetic methods such as
281+
// lambdas used within methods because they're not relevant.
282+
&& !m.isSynthetic();
283+
}
284+
277285
protected AnnotatedConstructor constructDefaultConstructor(ClassUtil.Ctor ctor,
278286
ClassUtil.Ctor mixin)
279287
{

0 commit comments

Comments
 (0)