diff --git a/mrbean/src/main/java/com/fasterxml/jackson/module/mrbean/BeanBuilder.java b/mrbean/src/main/java/com/fasterxml/jackson/module/mrbean/BeanBuilder.java index e19282f5..038ccfc1 100644 --- a/mrbean/src/main/java/com/fasterxml/jackson/module/mrbean/BeanBuilder.java +++ b/mrbean/src/main/java/com/fasterxml/jackson/module/mrbean/BeanBuilder.java @@ -181,16 +181,28 @@ protected boolean hasConcreteOverride(Method m0, JavaType implementedType) { final String name = m0.getName(); final Class[] argTypes = m0.getParameterTypes(); + try { + // getMethod returns the most-specific method implementation, for public methods only (which is any method in an interface) + Method effectiveMethod = implementedType.getRawClass().getMethod(name, argTypes); + if (BeanUtil.isConcrete(effectiveMethod)) { + return true; + } + } catch (NoSuchMethodException e) { + // method must be non-public, fallback to using getDeclaredMethod + } + for (JavaType curr = implementedType; (curr != null) && !curr.isJavaLangObject(); curr = curr.getSuperClass()) { // 29-Nov-2015, tatu: Avoiding exceptions would be good, so would linear scan // be better here? try { Method effectiveMethod = curr.getRawClass().getDeclaredMethod(name, argTypes); - if (effectiveMethod != null && BeanUtil.isConcrete(effectiveMethod)) { + if (BeanUtil.isConcrete(effectiveMethod)) { return true; } - } catch (NoSuchMethodException e) { } + } catch (NoSuchMethodException e) { + // method must exist on a superclass, continue searching... + } } return false; } @@ -245,7 +257,7 @@ protected final static boolean returnsBoolean(Method m) Class rt = m.getReturnType(); return (rt == Boolean.class || rt == Boolean.TYPE); } - + /* /********************************************************** /* Internal methods, bytecode generation @@ -354,7 +366,7 @@ protected void createUnimplementedMethod(ClassWriter cw, String internalClassNam /* Internal methods, other /********************************************************** */ - + protected String decap(String name) { char c = name.charAt(0); if (name.length() > 1