Skip to content

Commit 080be76

Browse files
committed
Annotated*Collector Method predicates are static
1 parent 627d118 commit 080be76

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
195195

196196
// First find all potentially relevant static methods
197197
for (Method m : ClassUtil.getClassMethods(type.getRawClass())) {
198-
if (!Modifier.isStatic(m.getModifiers())) {
198+
if (!_isIncludableFactoryMethod(m)) {
199199
continue;
200200
}
201201
// all factory methods are fine:
@@ -233,7 +233,7 @@ private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
233233
if (primaryMixIn != null) {
234234
MemberKey[] methodKeys = null;
235235
for (Method mixinFactory : primaryMixIn.getDeclaredMethods()) {
236-
if (!Modifier.isStatic(mixinFactory.getModifiers())) {
236+
if (!_isIncludableFactoryMethod(mixinFactory)) {
237237
continue;
238238
}
239239
if (methodKeys == null) {
@@ -270,6 +270,14 @@ private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
270270
return result;
271271
}
272272

273+
private static boolean _isIncludableFactoryMethod(Method m)
274+
{
275+
return Modifier.isStatic(m.getModifiers())
276+
// 09-Nov-2020, ckozak: Avoid considering synthetic methods such as
277+
// lambdas used within methods because they're not relevant.
278+
&& !m.isSynthetic();
279+
}
280+
273281
protected AnnotatedConstructor constructDefaultConstructor(ClassUtil.Ctor ctor,
274282
ClassUtil.Ctor mixin)
275283
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected void _addMethodMixIns(TypeResolutionContext tc, Class<?> targetClass,
174174
}
175175
}
176176

177-
private boolean _isIncludableMemberMethod(Method m)
177+
private static boolean _isIncludableMemberMethod(Method m)
178178
{
179179
if (Modifier.isStatic(m.getModifiers())
180180
// Looks like generics can introduce hidden bridge and/or synthetic methods.

0 commit comments

Comments
 (0)