HHH-11136 - Reduce memory consumption caused by Method.getParameterTypes()
This commit is contained in:
parent
e3bee9eede
commit
d2d947068d
|
@ -89,7 +89,7 @@ public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
|
||||||
private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
|
private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
|
||||||
public boolean isHandled(Method m) {
|
public boolean isHandled(Method m) {
|
||||||
// skip finalize methods
|
// skip finalize methods
|
||||||
return !( m.getParameterTypes().length == 0 && m.getName().equals( "finalize" ) );
|
return !( m.getParameterCount() == 0 && m.getName().equals( "finalize" ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
|
||||||
return System.identityHashCode( object );
|
return System.identityHashCode( object );
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean hasGetterSignature = method.getParameterTypes().length == 0
|
final boolean hasGetterSignature = method.getParameterCount() == 0
|
||||||
&& method.getReturnType() != null;
|
&& method.getReturnType() != null;
|
||||||
final boolean hasSetterSignature = method.getParameterTypes().length == 1
|
final boolean hasSetterSignature = method.getParameterCount() == 1
|
||||||
&& ( method.getReturnType() == null || method.getReturnType() == void.class );
|
&& ( method.getReturnType() == null || method.getReturnType() == void.class );
|
||||||
|
|
||||||
if ( name.startsWith( "get" ) && hasGetterSignature ) {
|
if ( name.startsWith( "get" ) && hasGetterSignature ) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class BlobProxy implements InvocationHandler {
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
final String methodName = method.getName();
|
final String methodName = method.getName();
|
||||||
final int argCount = method.getParameterTypes().length;
|
final int argCount = method.getParameterCount();
|
||||||
|
|
||||||
if ( "length".equals( methodName ) && argCount == 0 ) {
|
if ( "length".equals( methodName ) && argCount == 0 ) {
|
||||||
return getLength();
|
return getLength();
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ClobProxy implements InvocationHandler {
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
final String methodName = method.getName();
|
final String methodName = method.getName();
|
||||||
final int argCount = method.getParameterTypes().length;
|
final int argCount = method.getParameterCount();
|
||||||
|
|
||||||
if ( "length".equals( methodName ) && argCount == 0 ) {
|
if ( "length".equals( methodName ) && argCount == 0 ) {
|
||||||
return getLength();
|
return getLength();
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class ResultSetWrapperProxy implements InvocationHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// method should have arguments, and have same number as incoming arguments
|
// method should have arguments, and have same number as incoming arguments
|
||||||
if ( ! ( method.getParameterTypes().length > 0 && args.length == method.getParameterTypes().length ) ) {
|
if ( ! ( method.getParameterCount() > 0 && args.length == method.getParameterCount() ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +125,14 @@ public class ResultSetWrapperProxy implements InvocationHandler {
|
||||||
* @throws NoSuchMethodException Should never happen, but...
|
* @throws NoSuchMethodException Should never happen, but...
|
||||||
*/
|
*/
|
||||||
private Method locateCorrespondingColumnIndexMethod(Method columnNameMethod) throws NoSuchMethodException {
|
private Method locateCorrespondingColumnIndexMethod(Method columnNameMethod) throws NoSuchMethodException {
|
||||||
final Class[] actualParameterTypes = new Class[columnNameMethod.getParameterTypes().length];
|
final Class[] actualParameterTypes = new Class[columnNameMethod.getParameterCount()];
|
||||||
actualParameterTypes[0] = int.class;
|
actualParameterTypes[0] = int.class;
|
||||||
System.arraycopy(
|
System.arraycopy(
|
||||||
columnNameMethod.getParameterTypes(),
|
columnNameMethod.getParameterTypes(),
|
||||||
1,
|
1,
|
||||||
actualParameterTypes,
|
actualParameterTypes,
|
||||||
1,
|
1,
|
||||||
columnNameMethod.getParameterTypes().length - 1
|
columnNameMethod.getParameterCount() - 1
|
||||||
);
|
);
|
||||||
return columnNameMethod.getDeclaringClass().getMethod( columnNameMethod.getName(), actualParameterTypes );
|
return columnNameMethod.getDeclaringClass().getMethod( columnNameMethod.getName(), actualParameterTypes );
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SQLExceptionConverterFactory {
|
||||||
// First, try to find a matching constructor accepting a ViolatedConstraintNameExtracter param...
|
// First, try to find a matching constructor accepting a ViolatedConstraintNameExtracter param...
|
||||||
final Constructor[] ctors = converterClass.getDeclaredConstructors();
|
final Constructor[] ctors = converterClass.getDeclaredConstructors();
|
||||||
for ( Constructor ctor : ctors ) {
|
for ( Constructor ctor : ctors ) {
|
||||||
if ( ctor.getParameterTypes() != null && ctor.getParameterTypes().length == 1 ) {
|
if ( ctor.getParameterTypes() != null && ctor.getParameterCount() == 1 ) {
|
||||||
if ( ViolatedConstraintNameExtracter.class.isAssignableFrom( ctor.getParameterTypes()[0] ) ) {
|
if ( ViolatedConstraintNameExtracter.class.isAssignableFrom( ctor.getParameterTypes()[0] ) ) {
|
||||||
try {
|
try {
|
||||||
return (SQLExceptionConverter) ctor.newInstance( violatedConstraintNameExtracter );
|
return (SQLExceptionConverter) ctor.newInstance( violatedConstraintNameExtracter );
|
||||||
|
|
|
@ -421,7 +421,7 @@ public final class ReflectHelper {
|
||||||
private static Method getGetterOrNull(Class containerClass, String propertyName) {
|
private static Method getGetterOrNull(Class containerClass, String propertyName) {
|
||||||
for ( Method method : containerClass.getDeclaredMethods() ) {
|
for ( Method method : containerClass.getDeclaredMethods() ) {
|
||||||
// if the method has parameters, skip it
|
// if the method has parameters, skip it
|
||||||
if ( method.getParameterTypes().length != 0 ) {
|
if ( method.getParameterCount() != 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ public final class ReflectHelper {
|
||||||
|
|
||||||
for ( Method method : theClass.getDeclaredMethods() ) {
|
for ( Method method : theClass.getDeclaredMethods() ) {
|
||||||
final String methodName = method.getName();
|
final String methodName = method.getName();
|
||||||
if ( method.getParameterTypes().length == 1 && methodName.startsWith( "set" ) ) {
|
if ( method.getParameterCount() == 1 && methodName.startsWith( "set" ) ) {
|
||||||
final String testOldMethod = methodName.substring( 3 );
|
final String testOldMethod = methodName.substring( 3 );
|
||||||
final String testStdMethod = Introspector.decapitalize( testOldMethod );
|
final String testStdMethod = Introspector.decapitalize( testOldMethod );
|
||||||
if ( testStdMethod.equals( propertyName ) || testOldMethod.equals( propertyName ) ) {
|
if ( testStdMethod.equals( propertyName ) || testOldMethod.equals( propertyName ) ) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable {
|
||||||
private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
|
private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
|
||||||
public boolean isHandled(Method m) {
|
public boolean isHandled(Method m) {
|
||||||
// skip finalize methods
|
// skip finalize methods
|
||||||
return !( m.getParameterTypes().length == 0 && m.getName().equals( "finalize" ) );
|
return !( m.getParameterCount() == 0 && m.getName().equals( "finalize" ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,7 @@ public abstract class AbstractServiceRegistryImpl
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) {
|
private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService) {
|
||||||
if ( injectionMethod.getParameterTypes() == null || injectionMethod.getParameterTypes().length != 1 ) {
|
if ( injectionMethod.getParameterTypes() == null || injectionMethod.getParameterCount() != 1 ) {
|
||||||
throw new ServiceDependencyException(
|
throw new ServiceDependencyException(
|
||||||
"Encountered @InjectService on method with unexpected number of parameters"
|
"Encountered @InjectService on method with unexpected number of parameters"
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class BeanUtils {
|
||||||
}
|
}
|
||||||
final String getterName = sb.toString();
|
final String getterName = sb.toString();
|
||||||
for ( Method m : bean.getClass().getMethods() ) {
|
for ( Method m : bean.getClass().getMethods() ) {
|
||||||
if ( getterName.equals( m.getName() ) && m.getParameterTypes().length == 0 ) {
|
if ( getterName.equals( m.getName() ) && m.getParameterCount() == 0 ) {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class CustomParameterized extends Suite {
|
||||||
for (FrameworkMethod each : methods) {
|
for (FrameworkMethod each : methods) {
|
||||||
if (each.isPublic()) {
|
if (each.isPublic()) {
|
||||||
if (!each.isStatic()) {
|
if (!each.isStatic()) {
|
||||||
if (getTestClass().getOnlyConstructor().getParameterTypes().length != 0) {
|
if (getTestClass().getOnlyConstructor().getParameterCount() != 0) {
|
||||||
throw new Exception("Method " + each.getMethod() + " is annotated with @Parameters, it is not static and there is no parameter-less constructor!");
|
throw new Exception("Method " + each.getMethod() + " is annotated with @Parameters, it is not static and there is no parameter-less constructor!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class TestClassMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateCallbackMethod(Method method, CallbackType type, List<Throwable> errors) {
|
private void validateCallbackMethod(Method method, CallbackType type, List<Throwable> errors) {
|
||||||
if ( method.getParameterTypes().length > 0 ) {
|
if ( method.getParameterCount() > 0 ) {
|
||||||
errors.add(
|
errors.add(
|
||||||
new InvalidMethodForAnnotationException(
|
new InvalidMethodForAnnotationException(
|
||||||
type.buildTypeMarker() + " callback only valid on no-arg methods : "
|
type.buildTypeMarker() + " callback only valid on no-arg methods : "
|
||||||
|
|
Loading…
Reference in New Issue