|
15 | 15 | import java.lang.reflect.TypeVariable;
|
16 | 16 | import java.lang.reflect.WildcardType;
|
17 | 17 | import java.util.Locale;
|
| 18 | +import java.util.Objects; |
18 | 19 | import java.util.function.Supplier;
|
19 | 20 |
|
20 | 21 | import org.hibernate.AssertionFailure;
|
@@ -573,16 +574,14 @@ public static void verifyNoIsVariantExists(
|
573 | 574 | Method getMethod,
|
574 | 575 | String stemName) {
|
575 | 576 | // verify that the Class<?> does not also define a method with the same stem name with 'is'
|
576 |
| - try { |
577 |
| - final Method isMethod = containerClass.getDeclaredMethod( "is" + stemName ); |
578 |
| - if ( !Modifier.isStatic( isMethod.getModifiers() ) && isMethod.getAnnotation( Transient.class ) == null ) { |
579 |
| - // No such method should throw the caught exception. So if we get here, there was |
580 |
| - // such a method. |
581 |
| - checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod ); |
| 577 | + for ( Method declaredMethod : containerClass.getDeclaredMethods() ) { |
| 578 | + if ( declaredMethod.getParameterCount() == 0 |
| 579 | + && !Modifier.isStatic( declaredMethod.getModifiers() ) |
| 580 | + && Objects.equals( declaredMethod.getName(), "is" + stemName ) |
| 581 | + && declaredMethod.getAnnotation( Transient.class ) == null ) { |
| 582 | + checkGetAndIsVariants( containerClass, propertyName, getMethod, declaredMethod ); |
582 | 583 | }
|
583 | 584 | }
|
584 |
| - catch (NoSuchMethodException ignore) { |
585 |
| - } |
586 | 585 | }
|
587 | 586 |
|
588 | 587 |
|
@@ -613,17 +612,14 @@ public static void verifyNoGetVariantExists(
|
613 | 612 | Method isMethod,
|
614 | 613 | String stemName) {
|
615 | 614 | // verify that the Class<?> does not also define a method with the same stem name with 'is'
|
616 |
| - try { |
617 |
| - final Method getMethod = containerClass.getDeclaredMethod( "get" + stemName ); |
618 |
| - // No such method should throw the caught exception. So if we get here, there was |
619 |
| - // such a method. |
620 |
| - if ( !Modifier.isStatic( getMethod.getModifiers() ) |
621 |
| - && getMethod.getAnnotation( Transient.class ) == null ) { |
622 |
| - checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod ); |
| 615 | + for ( Method declaredMethod : containerClass.getDeclaredMethods() ) { |
| 616 | + if ( declaredMethod.getParameterCount() == 0 |
| 617 | + && !Modifier.isStatic( declaredMethod.getModifiers() ) |
| 618 | + && Objects.equals( declaredMethod.getName(), "get" + stemName ) |
| 619 | + && declaredMethod.getAnnotation( Transient.class ) == null ) { |
| 620 | + checkGetAndIsVariants( containerClass, propertyName, declaredMethod, isMethod ); |
623 | 621 | }
|
624 | 622 | }
|
625 |
| - catch (NoSuchMethodException ignore) { |
626 |
| - } |
627 | 623 | }
|
628 | 624 |
|
629 | 625 | public static Method getterMethodOrNull(Class<?> containerJavaType, String propertyName) {
|
|
0 commit comments