Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-19229 Faster checks in ReflectHelper #9835

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -573,16 +573,15 @@ public static void verifyNoIsVariantExists(
Method getMethod,
String stemName) {
// verify that the Class<?> does not also define a method with the same stem name with 'is'
try {
final Method isMethod = containerClass.getDeclaredMethod( "is" + stemName );
if ( !Modifier.isStatic( isMethod.getModifiers() ) && isMethod.getAnnotation( Transient.class ) == null ) {
// No such method should throw the caught exception. So if we get here, there was
// such a method.
checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod );
for ( Method declaredMethod : containerClass.getDeclaredMethods() ) {
if ( declaredMethod.getParameterCount() == 0
&& !Modifier.isStatic( declaredMethod.getModifiers() )
&& declaredMethod.getName().startsWith( "is" )
&& declaredMethod.getName().regionMatches( 2, stemName, 0, stemName.length() )
&& declaredMethod.getAnnotation( Transient.class ) == null ) {
checkGetAndIsVariants( containerClass, propertyName, getMethod, declaredMethod );
}
}
catch (NoSuchMethodException ignore) {
}
}


@@ -613,17 +612,15 @@ public static void verifyNoGetVariantExists(
Method isMethod,
String stemName) {
// verify that the Class<?> does not also define a method with the same stem name with 'is'
try {
final Method getMethod = containerClass.getDeclaredMethod( "get" + stemName );
// No such method should throw the caught exception. So if we get here, there was
// such a method.
if ( !Modifier.isStatic( getMethod.getModifiers() )
&& getMethod.getAnnotation( Transient.class ) == null ) {
checkGetAndIsVariants( containerClass, propertyName, getMethod, isMethod );
for ( Method declaredMethod : containerClass.getDeclaredMethods() ) {
if ( declaredMethod.getParameterCount() == 0
&& !Modifier.isStatic( declaredMethod.getModifiers() )
&& declaredMethod.getName().startsWith( "get" )
&& declaredMethod.getName().regionMatches( 3, stemName, 0, stemName.length() )
&& declaredMethod.getAnnotation( Transient.class ) == null ) {
checkGetAndIsVariants( containerClass, propertyName, declaredMethod, isMethod );
}
}
catch (NoSuchMethodException ignore) {
}
}

public static Method getterMethodOrNull(Class<?> containerJavaType, String propertyName) {