Consistently use class literals for primitive types
To improve consistency and avoid confusion regarding primitive types and their wrapper types, this commit ensures that we always use class literals for primitive types. For example, instead of using the `Void.TYPE` constant, we now consistently use `void.class`.
This commit is contained in:
parent
95a3f3bb6e
commit
db535863dd
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -94,7 +94,7 @@ class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware {
|
|||
|
||||
@Override
|
||||
public Object convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (targetType.getType() == Void.class || targetType.getType() == Void.TYPE) {
|
||||
if (targetType.getType() == Void.class || targetType.getType() == void.class) {
|
||||
return null;
|
||||
}
|
||||
if (conversionService.canConvert(sourceType, targetType)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -417,7 +417,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
|||
returnValue = proxy;
|
||||
}
|
||||
Class<?> returnType = method.getReturnType();
|
||||
if (returnValue == null && returnType != Void.TYPE && returnType.isPrimitive()) {
|
||||
if (returnValue == null && returnType != void.class && returnType.isPrimitive()) {
|
||||
throw new AopInvocationException(
|
||||
"Null return value from advice does not match primitive return type for: " + method);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -230,7 +230,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
|||
// a reference to itself in another returned object.
|
||||
retVal = proxy;
|
||||
}
|
||||
else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
|
||||
else if (retVal == null && returnType != void.class && returnType.isPrimitive()) {
|
||||
throw new AopInvocationException(
|
||||
"Null return value from advice does not match primitive return type for: " + method);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -101,7 +101,7 @@ public abstract class Pointcuts {
|
|||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
return (method.getName().startsWith("set") &&
|
||||
method.getParameterCount() == 1 &&
|
||||
method.getReturnType() == Void.TYPE);
|
||||
method.getReturnType() == void.class);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
|
@ -127,7 +127,7 @@ public abstract class Pointcuts {
|
|||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
return (method.getName().startsWith("get") &&
|
||||
method.getParameterCount() == 0 &&
|
||||
method.getReturnType() != Void.TYPE);
|
||||
method.getReturnType() != void.class);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -68,7 +68,7 @@ abstract class PropertyDescriptorUtils {
|
|||
setter = true;
|
||||
nameIndex = 3;
|
||||
}
|
||||
else if (methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != Void.TYPE) {
|
||||
else if (methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != void.class) {
|
||||
setter = false;
|
||||
nameIndex = 3;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ abstract class PropertyDescriptorUtils {
|
|||
throw new IntrospectionException("Bad read method arg count: " + readMethod);
|
||||
}
|
||||
propertyType = readMethod.getReturnType();
|
||||
if (propertyType == Void.TYPE) {
|
||||
if (propertyType == void.class) {
|
||||
throw new IntrospectionException("Read method returns void: " + readMethod);
|
||||
}
|
||||
}
|
||||
|
@ -197,11 +197,11 @@ abstract class PropertyDescriptorUtils {
|
|||
if (params.length != 1) {
|
||||
throw new IntrospectionException("Bad indexed read method arg count: " + indexedReadMethod);
|
||||
}
|
||||
if (params[0] != Integer.TYPE) {
|
||||
if (params[0] != int.class) {
|
||||
throw new IntrospectionException("Non int index to indexed read method: " + indexedReadMethod);
|
||||
}
|
||||
indexedPropertyType = indexedReadMethod.getReturnType();
|
||||
if (indexedPropertyType == Void.TYPE) {
|
||||
if (indexedPropertyType == void.class) {
|
||||
throw new IntrospectionException("Indexed read method returns void: " + indexedReadMethod);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ abstract class PropertyDescriptorUtils {
|
|||
if (params.length != 2) {
|
||||
throw new IntrospectionException("Bad indexed write method arg count: " + indexedWriteMethod);
|
||||
}
|
||||
if (params[0] != Integer.TYPE) {
|
||||
if (params[0] != int.class) {
|
||||
throw new IntrospectionException("Non int index to indexed write method: " + indexedWriteMethod);
|
||||
}
|
||||
if (indexedPropertyType != null) {
|
||||
|
|
|
@ -698,7 +698,7 @@ class ProxyFactoryBeanTests {
|
|||
setPointcut(new DynamicMethodMatcherPointcut() {
|
||||
@Override
|
||||
public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
|
||||
return m.getReturnType() == Void.TYPE;
|
||||
return m.getReturnType() == void.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -107,7 +107,7 @@ public class BindingReflectionHintsRegistrar {
|
|||
if (methodName.startsWith("set") && method.getParameterCount() == 1) {
|
||||
registerPropertyHints(hints, seen, method, 0);
|
||||
}
|
||||
else if ((methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != Void.TYPE) ||
|
||||
else if ((methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != void.class) ||
|
||||
(methodName.startsWith("is") && method.getParameterCount() == 0 && method.getReturnType() == boolean.class)) {
|
||||
registerPropertyHints(hints, seen, method, -1);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class AnnotatedMethod {
|
|||
* Return {@code true} if the method's return type is void, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isVoid() {
|
||||
return Void.TYPE.equals(getReturnType().getParameterType());
|
||||
return (getReturnType().getParameterType() == void.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -52,7 +52,7 @@ class MethodParameterTests {
|
|||
|
||||
@BeforeEach
|
||||
void setup() throws NoSuchMethodException {
|
||||
method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
method = getClass().getMethod("method", String.class, long.class);
|
||||
stringParameter = new MethodParameter(method, 0);
|
||||
longParameter = new MethodParameter(method, 1);
|
||||
intReturnType = new MethodParameter(method, -1);
|
||||
|
@ -72,7 +72,7 @@ class MethodParameterTests {
|
|||
assertThat(intReturnType).isNotEqualTo(stringParameter);
|
||||
assertThat(intReturnType).isNotEqualTo(longParameter);
|
||||
|
||||
Method method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
Method method = getClass().getMethod("method", String.class, long.class);
|
||||
MethodParameter methodParameter = new MethodParameter(method, 0);
|
||||
assertThat(methodParameter).isEqualTo(stringParameter);
|
||||
assertThat(stringParameter).isEqualTo(methodParameter);
|
||||
|
@ -86,7 +86,7 @@ class MethodParameterTests {
|
|||
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
|
||||
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
|
||||
|
||||
Method method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
Method method = getClass().getMethod("method", String.class, long.class);
|
||||
MethodParameter methodParameter = new MethodParameter(method, 0);
|
||||
assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode());
|
||||
assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,7 +43,7 @@ class SynthesizingMethodParameterTests {
|
|||
|
||||
@BeforeEach
|
||||
void setUp() throws NoSuchMethodException {
|
||||
method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
method = getClass().getMethod("method", String.class, long.class);
|
||||
stringParameter = new SynthesizingMethodParameter(method, 0);
|
||||
longParameter = new SynthesizingMethodParameter(method, 1);
|
||||
intReturnType = new SynthesizingMethodParameter(method, -1);
|
||||
|
@ -63,7 +63,7 @@ class SynthesizingMethodParameterTests {
|
|||
assertThat(intReturnType).isNotEqualTo(stringParameter);
|
||||
assertThat(intReturnType).isNotEqualTo(longParameter);
|
||||
|
||||
Method method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
Method method = getClass().getMethod("method", String.class, long.class);
|
||||
MethodParameter methodParameter = new SynthesizingMethodParameter(method, 0);
|
||||
assertThat(methodParameter).isEqualTo(stringParameter);
|
||||
assertThat(stringParameter).isEqualTo(methodParameter);
|
||||
|
@ -83,7 +83,7 @@ class SynthesizingMethodParameterTests {
|
|||
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
|
||||
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
|
||||
|
||||
Method method = getClass().getMethod("method", String.class, Long.TYPE);
|
||||
Method method = getClass().getMethod("method", String.class, long.class);
|
||||
SynthesizingMethodParameter methodParameter = new SynthesizingMethodParameter(method, 0);
|
||||
assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode());
|
||||
assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -303,7 +303,7 @@ class TypeDescriptorTests {
|
|||
void fieldArray() throws Exception {
|
||||
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("intArray"));
|
||||
assertThat(typeDescriptor.isArray()).isTrue();
|
||||
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE);
|
||||
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(int.class);
|
||||
assertThat(typeDescriptor.toString()).isEqualTo("int[]");
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ class TypeDescriptorTests {
|
|||
assertThat(typeDescriptor.isArray()).isFalse();
|
||||
assertThat(typeDescriptor.isCollection()).isFalse();
|
||||
assertThat(typeDescriptor.isMap()).isFalse();
|
||||
assertThat(typeDescriptor.getType()).isEqualTo(Integer.TYPE);
|
||||
assertThat(typeDescriptor.getType()).isEqualTo(int.class);
|
||||
assertThat(typeDescriptor.getObjectType()).isEqualTo(Integer.class);
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ class TypeDescriptorTests {
|
|||
assertThat(typeDescriptor.isArray()).isTrue();
|
||||
assertThat(typeDescriptor.isCollection()).isFalse();
|
||||
assertThat(typeDescriptor.isMap()).isFalse();
|
||||
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE);
|
||||
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(int.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -454,31 +454,31 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
}
|
||||
if (clazz.isPrimitive()) {
|
||||
if (clazz == Boolean.TYPE) {
|
||||
if (clazz == boolean.class) {
|
||||
sb.append('Z');
|
||||
}
|
||||
else if (clazz == Byte.TYPE) {
|
||||
else if (clazz == byte.class) {
|
||||
sb.append('B');
|
||||
}
|
||||
else if (clazz == Character.TYPE) {
|
||||
else if (clazz == char.class) {
|
||||
sb.append('C');
|
||||
}
|
||||
else if (clazz == Double.TYPE) {
|
||||
else if (clazz == double.class) {
|
||||
sb.append('D');
|
||||
}
|
||||
else if (clazz == Float.TYPE) {
|
||||
else if (clazz == float.class) {
|
||||
sb.append('F');
|
||||
}
|
||||
else if (clazz == Integer.TYPE) {
|
||||
else if (clazz == int.class) {
|
||||
sb.append('I');
|
||||
}
|
||||
else if (clazz == Long.TYPE) {
|
||||
else if (clazz == long.class) {
|
||||
sb.append('J');
|
||||
}
|
||||
else if (clazz == Short.TYPE) {
|
||||
else if (clazz == short.class) {
|
||||
sb.append('S');
|
||||
}
|
||||
else if (clazz == Void.TYPE) {
|
||||
else if (clazz == void.class) {
|
||||
sb.append('V');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -385,49 +385,49 @@ public class Indexer extends SpelNodeImpl {
|
|||
|
||||
private Object accessArrayElement(Object ctx, int idx) throws SpelEvaluationException {
|
||||
Class<?> arrayComponentType = ctx.getClass().componentType();
|
||||
if (arrayComponentType == Boolean.TYPE) {
|
||||
if (arrayComponentType == boolean.class) {
|
||||
boolean[] array = (boolean[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "Z";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Byte.TYPE) {
|
||||
else if (arrayComponentType == byte.class) {
|
||||
byte[] array = (byte[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "B";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Character.TYPE) {
|
||||
else if (arrayComponentType == char.class) {
|
||||
char[] array = (char[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "C";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Double.TYPE) {
|
||||
else if (arrayComponentType == double.class) {
|
||||
double[] array = (double[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "D";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Float.TYPE) {
|
||||
else if (arrayComponentType == float.class) {
|
||||
float[] array = (float[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "F";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Integer.TYPE) {
|
||||
else if (arrayComponentType == int.class) {
|
||||
int[] array = (int[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "I";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Long.TYPE) {
|
||||
else if (arrayComponentType == long.class) {
|
||||
long[] array = (long[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "J";
|
||||
return array[idx];
|
||||
}
|
||||
else if (arrayComponentType == Short.TYPE) {
|
||||
else if (arrayComponentType == short.class) {
|
||||
short[] array = (short[]) ctx;
|
||||
checkAccess(array.length, idx);
|
||||
this.exitTypeDescriptor = "S";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,42 +33,42 @@ public enum TypeCode {
|
|||
/**
|
||||
* A {@code boolean}.
|
||||
*/
|
||||
BOOLEAN(Boolean.TYPE),
|
||||
BOOLEAN(boolean.class),
|
||||
|
||||
/**
|
||||
* A {@code char}.
|
||||
*/
|
||||
CHAR(Character.TYPE),
|
||||
CHAR(char.class),
|
||||
|
||||
/**
|
||||
* A {@code byte}.
|
||||
*/
|
||||
BYTE(Byte.TYPE),
|
||||
BYTE(byte.class),
|
||||
|
||||
/**
|
||||
* A {@code short}.
|
||||
*/
|
||||
SHORT(Short.TYPE),
|
||||
SHORT(short.class),
|
||||
|
||||
/**
|
||||
* An {@code int}.
|
||||
*/
|
||||
INT(Integer.TYPE),
|
||||
INT(int.class),
|
||||
|
||||
/**
|
||||
* A {@code long}.
|
||||
*/
|
||||
LONG(Long.TYPE),
|
||||
LONG(long.class),
|
||||
|
||||
/**
|
||||
* A {@code float}.
|
||||
*/
|
||||
FLOAT(Float.TYPE),
|
||||
FLOAT(float.class),
|
||||
|
||||
/**
|
||||
* A {@code double}.
|
||||
*/
|
||||
DOUBLE(Double.TYPE);
|
||||
DOUBLE(double.class);
|
||||
|
||||
|
||||
private final Class<?> type;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -102,28 +102,28 @@ public class TypeReference extends SpelNodeImpl {
|
|||
// TODO Future optimization - if followed by a static method call, skip generating code here
|
||||
Assert.state(this.type != null, "No type available");
|
||||
if (this.type.isPrimitive()) {
|
||||
if (this.type == Boolean.TYPE) {
|
||||
if (this.type == boolean.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Byte.TYPE) {
|
||||
else if (this.type == byte.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Character.TYPE) {
|
||||
else if (this.type == char.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Double.TYPE) {
|
||||
else if (this.type == double.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Float.TYPE) {
|
||||
else if (this.type == float.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Integer.TYPE) {
|
||||
else if (this.type == int.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Long.TYPE) {
|
||||
else if (this.type == long.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
else if (this.type == Short.TYPE) {
|
||||
else if (this.type == short.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -73,7 +73,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
|
||||
private static final Set<Class<?>> ANY_TYPES = Collections.emptySet();
|
||||
|
||||
private static final Set<Class<?>> BOOLEAN_TYPES = Set.of(Boolean.class, Boolean.TYPE);
|
||||
private static final Set<Class<?>> BOOLEAN_TYPES = Set.of(Boolean.class, boolean.class);
|
||||
|
||||
private final boolean allowWrite;
|
||||
|
||||
|
@ -338,7 +338,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
Class<?> type = (target instanceof Class<?> clazz ? clazz : target.getClass());
|
||||
|
||||
if (type.isArray() && name.equals("length")) {
|
||||
return TypeDescriptor.valueOf(Integer.TYPE);
|
||||
return TypeDescriptor.valueOf(int.class);
|
||||
}
|
||||
PropertyCacheKey cacheKey = new PropertyCacheKey(type, name, target instanceof Class);
|
||||
TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey);
|
||||
|
|
|
@ -260,7 +260,7 @@ public abstract class AbstractExpressionTests {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
if (value.getClass().componentType().isPrimitive()) {
|
||||
Class<?> primitiveType = value.getClass().componentType();
|
||||
if (primitiveType == Integer.TYPE) {
|
||||
if (primitiveType == int.class) {
|
||||
int[] l = (int[]) value;
|
||||
sb.append("int[").append(l.length).append("]{");
|
||||
for (int j = 0; j < l.length; j++) {
|
||||
|
@ -271,7 +271,7 @@ public abstract class AbstractExpressionTests {
|
|||
}
|
||||
sb.append('}');
|
||||
}
|
||||
else if (primitiveType == Long.TYPE) {
|
||||
else if (primitiveType == long.class) {
|
||||
long[] l = (long[]) value;
|
||||
sb.append("long[").append(l.length).append("]{");
|
||||
for (int j = 0; j < l.length; j++) {
|
||||
|
|
|
@ -894,38 +894,38 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// double
|
||||
e = parser.parseExpression("ddd++");
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
double return_ddd = e.getValue(ctx, Double.TYPE);
|
||||
double return_ddd = e.getValue(ctx, double.class);
|
||||
assertThat((float) return_ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 3.0d, within((float) 0d));
|
||||
|
||||
// float
|
||||
e = parser.parseExpression("fff++");
|
||||
assertThat(helper.fff).isCloseTo(3.0f, within((float) 0d));
|
||||
float return_fff = e.getValue(ctx, Float.TYPE);
|
||||
float return_fff = e.getValue(ctx, float.class);
|
||||
assertThat(return_fff).isCloseTo(3.0f, within((float) 0d));
|
||||
assertThat(helper.fff).isCloseTo(4.0f, within((float) 0d));
|
||||
|
||||
// long
|
||||
e = parser.parseExpression("lll++");
|
||||
assertThat(helper.lll).isEqualTo(66666L);
|
||||
long return_lll = e.getValue(ctx, Long.TYPE);
|
||||
long return_lll = e.getValue(ctx, long.class);
|
||||
assertThat(return_lll).isEqualTo(66666L);
|
||||
assertThat(helper.lll).isEqualTo(66667L);
|
||||
|
||||
// int
|
||||
e = parser.parseExpression("iii++");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
int return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(43);
|
||||
assertThat(helper.iii).isEqualTo(44);
|
||||
|
||||
// short
|
||||
e = parser.parseExpression("sss++");
|
||||
assertThat(helper.sss).isEqualTo((short) 15);
|
||||
short return_sss = e.getValue(ctx, Short.TYPE);
|
||||
short return_sss = e.getValue(ctx, short.class);
|
||||
assertThat(return_sss).isEqualTo((short) 15);
|
||||
assertThat(helper.sss).isEqualTo((short) 16);
|
||||
}
|
||||
|
@ -947,31 +947,31 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// double
|
||||
e = parser.parseExpression("++ddd");
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
double return_ddd = e.getValue(ctx, Double.TYPE);
|
||||
double return_ddd = e.getValue(ctx, double.class);
|
||||
assertThat((float) return_ddd).isCloseTo((float) 3.0d, within((float) 0d));
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 3.0d, within((float) 0d));
|
||||
|
||||
// float
|
||||
e = parser.parseExpression("++fff");
|
||||
assertThat(helper.fff).isCloseTo(3.0f, within((float) 0d));
|
||||
float return_fff = e.getValue(ctx, Float.TYPE);
|
||||
float return_fff = e.getValue(ctx, float.class);
|
||||
assertThat(return_fff).isCloseTo(4.0f, within((float) 0d));
|
||||
assertThat(helper.fff).isCloseTo(4.0f, within((float) 0d));
|
||||
|
||||
// long
|
||||
e = parser.parseExpression("++lll");
|
||||
assertThat(helper.lll).isEqualTo(66666L);
|
||||
long return_lll = e.getValue(ctx, Long.TYPE);
|
||||
long return_lll = e.getValue(ctx, long.class);
|
||||
assertThat(return_lll).isEqualTo(66667L);
|
||||
assertThat(helper.lll).isEqualTo(66667L);
|
||||
|
||||
// int
|
||||
e = parser.parseExpression("++iii");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
int return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(43);
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(44);
|
||||
assertThat(helper.iii).isEqualTo(44);
|
||||
|
||||
|
@ -991,12 +991,12 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
|
||||
Expression e1 = parser.parseExpression("m()++");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e1.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e1.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.OPERAND_NOT_INCREMENTABLE));
|
||||
|
||||
Expression e2 = parser.parseExpression("++m()");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e2.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e2.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.OPERAND_NOT_INCREMENTABLE));
|
||||
}
|
||||
|
||||
|
@ -1007,11 +1007,11 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
Expression e1 = parser.parseExpression("++1");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e1.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e1.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.NOT_ASSIGNABLE));
|
||||
Expression e2 = parser.parseExpression("1++");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e2.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e2.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.NOT_ASSIGNABLE));
|
||||
}
|
||||
|
||||
|
@ -1044,38 +1044,38 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// double
|
||||
e = parser.parseExpression("ddd--");
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
double return_ddd = e.getValue(ctx, Double.TYPE);
|
||||
double return_ddd = e.getValue(ctx, double.class);
|
||||
assertThat((float) return_ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 1.0d, within((float) 0d));
|
||||
|
||||
// float
|
||||
e = parser.parseExpression("fff--");
|
||||
assertThat(helper.fff).isCloseTo(3.0f, within((float) 0d));
|
||||
float return_fff = e.getValue(ctx, Float.TYPE);
|
||||
float return_fff = e.getValue(ctx, float.class);
|
||||
assertThat(return_fff).isCloseTo(3.0f, within((float) 0d));
|
||||
assertThat(helper.fff).isCloseTo(2.0f, within((float) 0d));
|
||||
|
||||
// long
|
||||
e = parser.parseExpression("lll--");
|
||||
assertThat(helper.lll).isEqualTo(66666L);
|
||||
long return_lll = e.getValue(ctx, Long.TYPE);
|
||||
long return_lll = e.getValue(ctx, long.class);
|
||||
assertThat(return_lll).isEqualTo(66666L);
|
||||
assertThat(helper.lll).isEqualTo(66665L);
|
||||
|
||||
// int
|
||||
e = parser.parseExpression("iii--");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
int return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(41);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(41);
|
||||
assertThat(helper.iii).isEqualTo(40);
|
||||
|
||||
// short
|
||||
e = parser.parseExpression("sss--");
|
||||
assertThat(helper.sss).isEqualTo((short) 15);
|
||||
short return_sss = e.getValue(ctx, Short.TYPE);
|
||||
short return_sss = e.getValue(ctx, short.class);
|
||||
assertThat(return_sss).isEqualTo((short) 15);
|
||||
assertThat(helper.sss).isEqualTo((short) 14);
|
||||
}
|
||||
|
@ -1097,31 +1097,31 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// double
|
||||
e = parser.parseExpression("--ddd");
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 2.0d, within((float) 0d));
|
||||
double return_ddd = e.getValue(ctx, Double.TYPE);
|
||||
double return_ddd = e.getValue(ctx, double.class);
|
||||
assertThat((float) return_ddd).isCloseTo((float) 1.0d, within((float) 0d));
|
||||
assertThat((float) helper.ddd).isCloseTo((float) 1.0d, within((float) 0d));
|
||||
|
||||
// float
|
||||
e = parser.parseExpression("--fff");
|
||||
assertThat(helper.fff).isCloseTo(3.0f, within((float) 0d));
|
||||
float return_fff = e.getValue(ctx, Float.TYPE);
|
||||
float return_fff = e.getValue(ctx, float.class);
|
||||
assertThat(return_fff).isCloseTo(2.0f, within((float) 0d));
|
||||
assertThat(helper.fff).isCloseTo(2.0f, within((float) 0d));
|
||||
|
||||
// long
|
||||
e = parser.parseExpression("--lll");
|
||||
assertThat(helper.lll).isEqualTo(66666L);
|
||||
long return_lll = e.getValue(ctx, Long.TYPE);
|
||||
long return_lll = e.getValue(ctx, long.class);
|
||||
assertThat(return_lll).isEqualTo(66665L);
|
||||
assertThat(helper.lll).isEqualTo(66665L);
|
||||
|
||||
// int
|
||||
e = parser.parseExpression("--iii");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
int return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(41);
|
||||
assertThat(helper.iii).isEqualTo(41);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(40);
|
||||
assertThat(helper.iii).isEqualTo(40);
|
||||
|
||||
|
@ -1141,12 +1141,12 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
|
||||
Expression e1 = parser.parseExpression("m()--");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e1.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e1.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.OPERAND_NOT_DECREMENTABLE));
|
||||
|
||||
Expression e2 = parser.parseExpression("--m()");
|
||||
assertThatExceptionOfType(SpelEvaluationException.class)
|
||||
.isThrownBy(() -> e2.getValue(ctx, Double.TYPE))
|
||||
.isThrownBy(() -> e2.getValue(ctx, double.class))
|
||||
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.OPERAND_NOT_DECREMENTABLE));
|
||||
}
|
||||
|
||||
|
@ -1349,26 +1349,26 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// iii=42
|
||||
e = parser.parseExpression("iii=iii++");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
int return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
assertThat(return_iii).isEqualTo(42);
|
||||
|
||||
// Identifier
|
||||
e = parser.parseExpression("iii++");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
|
||||
e = parser.parseExpression("--iii");
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
|
||||
e = parser.parseExpression("iii=99");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
return_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_iii).isEqualTo(99);
|
||||
assertThat(helper.iii).isEqualTo(99);
|
||||
|
||||
|
@ -1376,19 +1376,19 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
// foo.iii == 99
|
||||
e = parser.parseExpression("foo.iii++");
|
||||
assertThat(helper.foo.iii).isEqualTo(99);
|
||||
int return_foo_iii = e.getValue(ctx, Integer.TYPE);
|
||||
int return_foo_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_foo_iii).isEqualTo(99);
|
||||
assertThat(helper.foo.iii).isEqualTo(100);
|
||||
|
||||
e = parser.parseExpression("--foo.iii");
|
||||
assertThat(helper.foo.iii).isEqualTo(100);
|
||||
return_foo_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_foo_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_foo_iii).isEqualTo(99);
|
||||
assertThat(helper.foo.iii).isEqualTo(99);
|
||||
|
||||
e = parser.parseExpression("foo.iii=999");
|
||||
assertThat(helper.foo.iii).isEqualTo(99);
|
||||
return_foo_iii = e.getValue(ctx, Integer.TYPE);
|
||||
return_foo_iii = e.getValue(ctx, int.class);
|
||||
assertThat(return_foo_iii).isEqualTo(999);
|
||||
assertThat(helper.foo.iii).isEqualTo(999);
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
expectFailSetValueNotSupported(parser, ctx, "('abc' matches '^a..')=('abc' matches '^a..')");
|
||||
|
||||
// Selection
|
||||
ctx.registerFunction("isEven", Spr9751.class.getDeclaredMethod("isEven", Integer.TYPE));
|
||||
ctx.registerFunction("isEven", Spr9751.class.getDeclaredMethod("isEven", int.class));
|
||||
|
||||
expectFailNotIncrementable(parser, ctx, "({1,2,3}.?[#isEven(#this)])++");
|
||||
expectFailNotDecrementable(parser, ctx, "--({1,2,3}.?[#isEven(#this)])");
|
||||
|
@ -1440,19 +1440,19 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
ctx.setVariable("wobble", 3);
|
||||
e = parser.parseExpression("#wobble++");
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
|
||||
int r = e.getValue(ctx, Integer.TYPE);
|
||||
int r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(3);
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(4);
|
||||
|
||||
e = parser.parseExpression("--#wobble");
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(4);
|
||||
r = e.getValue(ctx, Integer.TYPE);
|
||||
r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(3);
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
|
||||
|
||||
e = parser.parseExpression("#wobble=34");
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(3);
|
||||
r = e.getValue(ctx, Integer.TYPE);
|
||||
r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(34);
|
||||
assertThat(((Integer) ctx.lookupVariable("wobble"))).isEqualTo(34);
|
||||
|
||||
|
@ -1487,19 +1487,19 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
helper.iii = 42;
|
||||
e = parser.parseExpression("iii++");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
r = e.getValue(ctx, Integer.TYPE);
|
||||
r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
|
||||
e = parser.parseExpression("--iii");
|
||||
assertThat(helper.iii).isEqualTo(43);
|
||||
r = e.getValue(ctx, Integer.TYPE);
|
||||
r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(42);
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
|
||||
e = parser.parseExpression("iii=100");
|
||||
assertThat(helper.iii).isEqualTo(42);
|
||||
r = e.getValue(ctx, Integer.TYPE);
|
||||
r = e.getValue(ctx, int.class);
|
||||
assertThat(r).isEqualTo(100);
|
||||
assertThat(helper.iii).isEqualTo(100);
|
||||
}
|
||||
|
|
|
@ -156,44 +156,44 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
assertThat(expression.getValue()).isEqualTo(int[][].class);
|
||||
|
||||
expression = parse("T(int)");
|
||||
assertThat(expression.getValue()).isEqualTo(Integer.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(int.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Integer.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(int.class);
|
||||
|
||||
expression = parse("T(byte)");
|
||||
assertThat(expression.getValue()).isEqualTo(Byte.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(byte.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Byte.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(byte.class);
|
||||
|
||||
expression = parse("T(char)");
|
||||
assertThat(expression.getValue()).isEqualTo(Character.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(char.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Character.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(char.class);
|
||||
|
||||
expression = parse("T(short)");
|
||||
assertThat(expression.getValue()).isEqualTo(Short.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(short.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Short.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(short.class);
|
||||
|
||||
expression = parse("T(long)");
|
||||
assertThat(expression.getValue()).isEqualTo(Long.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(long.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Long.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(long.class);
|
||||
|
||||
expression = parse("T(float)");
|
||||
assertThat(expression.getValue()).isEqualTo(Float.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(float.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Float.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(float.class);
|
||||
|
||||
expression = parse("T(double)");
|
||||
assertThat(expression.getValue()).isEqualTo(Double.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(double.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Double.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(double.class);
|
||||
|
||||
expression = parse("T(boolean)");
|
||||
assertThat(expression.getValue()).isEqualTo(Boolean.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(boolean.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue()).isEqualTo(Boolean.TYPE);
|
||||
assertThat(expression.getValue()).isEqualTo(boolean.class);
|
||||
|
||||
expression = parse("T(Missing)");
|
||||
assertGetValueFail(expression);
|
||||
|
@ -326,9 +326,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void realLiteral() {
|
||||
expression = parser.parseExpression("3.4d");
|
||||
double resultI = expression.getValue(new TestClass1(), Double.TYPE);
|
||||
double resultI = expression.getValue(new TestClass1(), double.class);
|
||||
assertCanCompile(expression);
|
||||
double resultC = expression.getValue(new TestClass1(), Double.TYPE);
|
||||
double resultC = expression.getValue(new TestClass1(), double.class);
|
||||
assertThat(resultI).isCloseTo(3.4d, within(0.1d));
|
||||
|
||||
assertThat(resultC).isCloseTo(3.4d, within(0.1d));
|
||||
|
@ -454,9 +454,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void intLiteral() {
|
||||
expression = parser.parseExpression("42");
|
||||
int resultI = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
int resultI = expression.getValue(new TestClass1(), int.class);
|
||||
assertCanCompile(expression);
|
||||
int resultC = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
int resultC = expression.getValue(new TestClass1(), int.class);
|
||||
assertThat(resultI).isEqualTo(42);
|
||||
assertThat(resultC).isEqualTo(42);
|
||||
|
||||
|
@ -485,9 +485,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void longLiteral() {
|
||||
expression = parser.parseExpression("99L");
|
||||
long resultI = expression.getValue(new TestClass1(), Long.TYPE);
|
||||
long resultI = expression.getValue(new TestClass1(), long.class);
|
||||
assertCanCompile(expression);
|
||||
long resultC = expression.getValue(new TestClass1(), Long.TYPE);
|
||||
long resultC = expression.getValue(new TestClass1(), long.class);
|
||||
assertThat(resultI).isEqualTo(99L);
|
||||
assertThat(resultC).isEqualTo(99L);
|
||||
}
|
||||
|
@ -495,26 +495,26 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void booleanLiteral() {
|
||||
expression = parser.parseExpression("true");
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultI = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(SpelCompiler.compile(expression)).isTrue();
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(SpelCompiler.compile(expression)).isTrue();
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultC).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void floatLiteral() {
|
||||
expression = parser.parseExpression("3.4f");
|
||||
float resultI = expression.getValue(new TestClass1(), Float.TYPE);
|
||||
float resultI = expression.getValue(new TestClass1(), float.class);
|
||||
assertCanCompile(expression);
|
||||
float resultC = expression.getValue(new TestClass1(), Float.TYPE);
|
||||
float resultC = expression.getValue(new TestClass1(), float.class);
|
||||
assertThat(resultI).isCloseTo(3.4f, within(0.1f));
|
||||
|
||||
assertThat(resultC).isCloseTo(3.4f, within(0.1f));
|
||||
|
@ -525,54 +525,54 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void opOr() {
|
||||
Expression expression = parser.parseExpression("false or false");
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultI = expression.getValue(1, boolean.class);
|
||||
SpelCompiler.compile(expression);
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("false or true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("true or false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
expression = parser.parseExpression("true or true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
TestClass4 tc = new TestClass4();
|
||||
expression = parser.parseExpression("getfalse() or gettrue()");
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCanCompile(expression);
|
||||
resultC = expression.getValue(tc, Boolean.TYPE);
|
||||
resultC = expression.getValue(tc, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
// Can't compile this as we aren't going down the getfalse() branch in our evaluation
|
||||
expression = parser.parseExpression("gettrue() or getfalse()");
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCantCompile(expression);
|
||||
|
||||
expression = parser.parseExpression("getA() or getB()");
|
||||
tc.a = true;
|
||||
tc.b = true;
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCantCompile(expression); // Haven't yet been into second branch
|
||||
tc.a = false;
|
||||
tc.b = true;
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCanCompile(expression); // Now been down both
|
||||
assertThat(resultI).isTrue();
|
||||
|
||||
|
@ -587,30 +587,30 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void opAnd() {
|
||||
Expression expression = parser.parseExpression("false and false");
|
||||
boolean resultI = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultI = expression.getValue(1, boolean.class);
|
||||
SpelCompiler.compile(expression);
|
||||
boolean resultC = expression.getValue(1, Boolean.TYPE);
|
||||
boolean resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("false and true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("true and false");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isFalse();
|
||||
assertThat(resultC).isFalse();
|
||||
|
||||
expression = parser.parseExpression("true and true");
|
||||
resultI = expression.getValue(1, Boolean.TYPE);
|
||||
resultI = expression.getValue(1, boolean.class);
|
||||
SpelCompiler.compile(expression);
|
||||
resultC = expression.getValue(1, Boolean.TYPE);
|
||||
resultC = expression.getValue(1, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
assertThat(resultC).isTrue();
|
||||
|
||||
|
@ -618,22 +618,22 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
|
||||
// Can't compile this as we aren't going down the gettrue() branch in our evaluation
|
||||
expression = parser.parseExpression("getfalse() and gettrue()");
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCantCompile(expression);
|
||||
|
||||
expression = parser.parseExpression("getA() and getB()");
|
||||
tc.a = false;
|
||||
tc.b = false;
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCantCompile(expression); // Haven't yet been into second branch
|
||||
tc.a = true;
|
||||
tc.b = false;
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertCanCompile(expression); // Now been down both
|
||||
assertThat(resultI).isFalse();
|
||||
tc.a = true;
|
||||
tc.b = true;
|
||||
resultI = expression.getValue(tc, Boolean.TYPE);
|
||||
resultI = expression.getValue(tc, boolean.class);
|
||||
assertThat(resultI).isTrue();
|
||||
|
||||
boolean b = true;
|
||||
|
@ -1021,7 +1021,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
ctx.setVariable("b", "boo");
|
||||
assertThat(expression.getValue(ctx)).isEqualTo("fooboo");
|
||||
|
||||
m = Math.class.getDeclaredMethod("pow", Double.TYPE, Double.TYPE);
|
||||
m = Math.class.getDeclaredMethod("pow", double.class, double.class);
|
||||
ctx.setVariable("kapow",m);
|
||||
expression = parser.parseExpression("#kapow(2.0d,2.0d)");
|
||||
assertThat(expression.getValue(ctx).toString()).isEqualTo("4.0");
|
||||
|
@ -1109,7 +1109,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
void functionReferenceNonCompilableArguments_SPR12359() throws Exception {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext(new Object[] {"1"});
|
||||
context.registerFunction("negate", SomeCompareMethod2.class.getDeclaredMethod(
|
||||
"negate", Integer.TYPE));
|
||||
"negate", int.class));
|
||||
context.setVariable("arg", "2");
|
||||
int[] ints = new int[] {1,2,3};
|
||||
context.setVariable("ints",ints);
|
||||
|
@ -3242,11 +3242,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
assertThat(expression.getValue()).isEqualTo(0);
|
||||
|
||||
expression = parse("payload%2==0");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(4), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(5), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(4), boolean.class)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(5), boolean.class)).isFalse();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(4), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(5), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(4), boolean.class)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper<>(5), boolean.class)).isFalse();
|
||||
|
||||
expression = parse("8%3");
|
||||
assertThat(expression.getValue()).isEqualTo(2);
|
||||
|
@ -4198,9 +4198,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void methodReference_staticMethod() {
|
||||
Expression expression = parser.parseExpression("T(Integer).valueOf(42)");
|
||||
int resultI = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
int resultI = expression.getValue(new TestClass1(), int.class);
|
||||
assertCanCompile(expression);
|
||||
int resultC = expression.getValue(new TestClass1(), Integer.TYPE);
|
||||
int resultC = expression.getValue(new TestClass1(), int.class);
|
||||
assertThat(resultI).isEqualTo(42);
|
||||
assertThat(resultC).isEqualTo(42);
|
||||
}
|
||||
|
@ -4228,19 +4228,19 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void methodReference_simpleInstanceMethodNoArgReturnPrimitive() {
|
||||
expression = parser.parseExpression("intValue()");
|
||||
int resultI = expression.getValue(42, Integer.TYPE);
|
||||
int resultI = expression.getValue(42, int.class);
|
||||
assertThat(resultI).isEqualTo(42);
|
||||
assertCanCompile(expression);
|
||||
int resultC = expression.getValue(42, Integer.TYPE);
|
||||
int resultC = expression.getValue(42, int.class);
|
||||
assertThat(resultC).isEqualTo(42);
|
||||
}
|
||||
|
||||
@Test
|
||||
void methodReference_simpleInstanceMethodOneArgReturnPrimitive1() {
|
||||
Expression expression = parser.parseExpression("indexOf('b')");
|
||||
int resultI = expression.getValue("abc", Integer.TYPE);
|
||||
int resultI = expression.getValue("abc", int.class);
|
||||
assertCanCompile(expression);
|
||||
int resultC = expression.getValue("abc", Integer.TYPE);
|
||||
int resultC = expression.getValue("abc", int.class);
|
||||
assertThat(resultI).isEqualTo(1);
|
||||
assertThat(resultC).isEqualTo(1);
|
||||
}
|
||||
|
@ -4248,10 +4248,10 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void methodReference_simpleInstanceMethodOneArgReturnPrimitive2() {
|
||||
expression = parser.parseExpression("charAt(2)");
|
||||
char resultI = expression.getValue("abc", Character.TYPE);
|
||||
char resultI = expression.getValue("abc", char.class);
|
||||
assertThat(resultI).isEqualTo('c');
|
||||
assertCanCompile(expression);
|
||||
char resultC = expression.getValue("abc", Character.TYPE);
|
||||
char resultC = expression.getValue("abc", char.class);
|
||||
assertThat(resultC).isEqualTo('c');
|
||||
}
|
||||
|
||||
|
@ -4877,44 +4877,44 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
@Test
|
||||
void compilerWithGenerics_12040_3() {
|
||||
expression = parser.parseExpression("payload >= 2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4), boolean.class)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isFalse();
|
||||
|
||||
expression = parser.parseExpression("2 >= payload");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(5), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(5), boolean.class)).isFalse();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isTrue();
|
||||
|
||||
expression = parser.parseExpression("payload > 2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(4), boolean.class)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isFalse();
|
||||
|
||||
expression = parser.parseExpression("2 > payload");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(5), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(5), boolean.class)).isFalse();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isTrue();
|
||||
|
||||
expression = parser.parseExpression("payload <=2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), boolean.class)).isFalse();
|
||||
|
||||
expression = parser.parseExpression("2 <= payload");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isFalse();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), boolean.class)).isTrue();
|
||||
|
||||
expression = parser.parseExpression("payload < 2");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isTrue();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), boolean.class)).isFalse();
|
||||
|
||||
expression = parser.parseExpression("2 < payload");
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), Boolean.TYPE)).isFalse();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(1), boolean.class)).isFalse();
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), Boolean.TYPE)).isTrue();
|
||||
assertThat(expression.getValue(new GenericMessageTestHelper2<>(6), boolean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -274,14 +274,14 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
// warmup
|
||||
for (int i = 0; i < count; i++) {
|
||||
b = expression.getValue(payload, Boolean.TYPE);
|
||||
b = expression.getValue(payload, boolean.class);
|
||||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
long stime = System.currentTimeMillis();
|
||||
for (int j = 0; j < count; j++) {
|
||||
b = expression.getValue(payload, Boolean.TYPE);
|
||||
b = expression.getValue(payload, boolean.class);
|
||||
}
|
||||
long etime = System.currentTimeMillis();
|
||||
long interpretedSpeed = (etime - stime);
|
||||
|
@ -292,12 +292,12 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
compile(expression);
|
||||
boolean bc = false;
|
||||
expression.getValue(payload, Boolean.TYPE);
|
||||
expression.getValue(payload, boolean.class);
|
||||
log("timing compiled: ");
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
long stime = System.currentTimeMillis();
|
||||
for (int j = 0; j < count; j++) {
|
||||
bc = expression.getValue(payload, Boolean.TYPE);
|
||||
bc = expression.getValue(payload, boolean.class);
|
||||
}
|
||||
long etime = System.currentTimeMillis();
|
||||
long compiledSpeed = (etime - stime);
|
||||
|
@ -316,7 +316,7 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
// Verify if the input changes, the result changes
|
||||
payload.DR[0].DRFixedSection.duration = 0.04d;
|
||||
bc = expression.getValue(payload, Boolean.TYPE);
|
||||
bc = expression.getValue(payload, boolean.class);
|
||||
assertThat(bc).isTrue();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,15 +57,15 @@ class TestScenarioCreator {
|
|||
private static void populateFunctions(StandardEvaluationContext testContext) {
|
||||
try {
|
||||
testContext.registerFunction("isEven",
|
||||
TestScenarioCreator.class.getDeclaredMethod("isEven", Integer.TYPE));
|
||||
TestScenarioCreator.class.getDeclaredMethod("isEven", int.class));
|
||||
testContext.registerFunction("reverseInt",
|
||||
TestScenarioCreator.class.getDeclaredMethod("reverseInt", Integer.TYPE, Integer.TYPE, Integer.TYPE));
|
||||
TestScenarioCreator.class.getDeclaredMethod("reverseInt", int.class, int.class, int.class));
|
||||
testContext.registerFunction("reverseString",
|
||||
TestScenarioCreator.class.getDeclaredMethod("reverseString", String.class));
|
||||
testContext.registerFunction("varargsFunction",
|
||||
TestScenarioCreator.class.getDeclaredMethod("varargsFunction", String[].class));
|
||||
testContext.registerFunction("varargsFunction2",
|
||||
TestScenarioCreator.class.getDeclaredMethod("varargsFunction2", Integer.TYPE, String[].class));
|
||||
TestScenarioCreator.class.getDeclaredMethod("varargsFunction2", int.class, String[].class));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -128,16 +128,16 @@ class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
StandardTypeConverter tc = new StandardTypeConverter();
|
||||
|
||||
// Calling foo(String,int) with (String,Integer) requires boxing conversion of argument one
|
||||
checkMatch(new Class<?>[] {String.class, Integer.TYPE}, new Class<?>[] {String.class,Integer.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {String.class, int.class}, new Class<?>[] {String.class,Integer.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,String) on call to foo(Integer,String) requires boxing conversion of argument zero
|
||||
checkMatch(new Class<?>[] {Integer.TYPE, String.class}, new Class<?>[] {Integer.class, String.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {int.class, String.class}, new Class<?>[] {Integer.class, String.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,Sub) on call to foo(Integer,Super) requires boxing conversion of argument zero
|
||||
checkMatch(new Class<?>[] {Integer.TYPE, Sub.class}, new Class<?>[] {Integer.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {int.class, Sub.class}, new Class<?>[] {Integer.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,Sub,boolean) on call to foo(Integer,Super,Boolean) requires boxing conversion of arguments zero and two
|
||||
// TODO checkMatch(new Class<?>[] {Integer.TYPE, Sub.class, Boolean.TYPE}, new Class<?>[] {Integer.class, Super.class, Boolean.class}, tc, ArgsMatchKind.REQUIRES_CONVERSION);
|
||||
// TODO checkMatch(new Class<?>[] {int.class, Sub.class, boolean.class}, new Class<?>[] {Integer.class, Super.class, Boolean.class}, tc, ArgsMatchKind.REQUIRES_CONVERSION);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -207,7 +207,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements SyncHa
|
|||
@Nullable
|
||||
private Object handleNullValue(String name, @Nullable Object value, Class<?> paramType) {
|
||||
if (value == null) {
|
||||
if (Boolean.TYPE.equals(paramType)) {
|
||||
if (paramType == boolean.class) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if (paramType.isPrimitive()) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -219,7 +219,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
@Nullable
|
||||
private Object handleNullValue(String name, @Nullable Object value, Class<?> paramType) {
|
||||
if (value == null) {
|
||||
if (Boolean.TYPE.equals(paramType)) {
|
||||
if (paramType == boolean.class) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if (paramType.isPrimitive()) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -214,7 +214,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
|||
}
|
||||
Method method = returnType.getMethod();
|
||||
return method != null && KotlinDetector.isSuspendingFunction(method) &&
|
||||
Void.TYPE.equals(returnType.getParameterType());
|
||||
(returnType.getParameterType() == void.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -619,12 +619,12 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
|||
parameterizedType.getActualTypeArguments().length == 1) {
|
||||
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
|
||||
if (typeArgument instanceof Class<?> classArgument) {
|
||||
return ((classArgument.isArray() && Byte.TYPE == classArgument.componentType()) ||
|
||||
return ((classArgument.isArray() && byte.class == classArgument.componentType()) ||
|
||||
isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
|
||||
supportsInternal(classArgument, false));
|
||||
}
|
||||
else if (typeArgument instanceof GenericArrayType arrayType) {
|
||||
return (Byte.TYPE == arrayType.getGenericComponentType());
|
||||
return (byte.class == arrayType.getGenericComponentType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -230,7 +230,7 @@ class XStreamMarshallerTests {
|
|||
|
||||
@Test
|
||||
void useAttributesFor() throws Exception {
|
||||
marshaller.setUseAttributeForTypes(Long.TYPE);
|
||||
marshaller.setUseAttributeForTypes(long.class);
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight flightNumber=\"42\" />";
|
||||
|
@ -239,7 +239,7 @@ class XStreamMarshallerTests {
|
|||
|
||||
@Test
|
||||
void useAttributesForStringClassMap() throws Exception {
|
||||
marshaller.setUseAttributeFor(Collections.singletonMap("flightNumber", Long.TYPE));
|
||||
marshaller.setUseAttributeFor(Collections.singletonMap("flightNumber", long.class));
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight flightNumber=\"42\" />";
|
||||
|
|
|
@ -203,7 +203,7 @@ class AnnotationTransactionAttributeSourceTests {
|
|||
|
||||
assertThat(actual.getLabels()).containsOnly("retryable", "long-running");
|
||||
|
||||
method = TestBean11.class.getMethod("setAge", Integer.TYPE);
|
||||
method = TestBean11.class.getMethod("setAge", int.class);
|
||||
actual = atas.getTransactionAttribute(method, method.getDeclaringClass());
|
||||
|
||||
assertThat(actual.getLabels()).containsOnly("short-running");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -263,7 +263,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
|
|||
@Nullable
|
||||
private Object handleNullValue(String name, @Nullable Object value, Class<?> paramType) {
|
||||
if (value == null) {
|
||||
if (Boolean.TYPE.equals(paramType)) {
|
||||
if (paramType == boolean.class) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if (paramType.isPrimitive()) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -53,7 +53,7 @@ class WebArgumentResolverAdapterTests {
|
|||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
parameter = new MethodParameter(getClass().getMethod("handle", Integer.TYPE), 0);
|
||||
parameter = new MethodParameter(getClass().getMethod("handle", int.class), 0);
|
||||
|
||||
// Expose request to the current thread (for SpEL expressions)
|
||||
RequestContextHolder.setRequestAttributes(webRequest);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -272,7 +272,7 @@ public abstract class AbstractNamedValueArgumentResolver extends HandlerMethodAr
|
|||
@Nullable
|
||||
private Object handleNullValue(String name, @Nullable Object value, Class<?> paramType) {
|
||||
if (value == null) {
|
||||
if (Boolean.TYPE.equals(paramType)) {
|
||||
if (paramType == boolean.class) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
else if (paramType.isPrimitive()) {
|
||||
|
|
|
@ -160,7 +160,7 @@ class HttpEntityMethodProcessorMockTests {
|
|||
stringHttpMessageConverter, resourceMessageConverter, resourceRegionMessageConverter, jsonMessageConverter));
|
||||
|
||||
Method handle1 = getClass().getMethod("handle1", HttpEntity.class, ResponseEntity.class,
|
||||
Integer.TYPE, RequestEntity.class);
|
||||
int.class, RequestEntity.class);
|
||||
|
||||
paramHttpEntity = new MethodParameter(handle1, 0);
|
||||
paramRequestEntity = new MethodParameter(handle1, 3);
|
||||
|
|
|
@ -121,7 +121,7 @@ class RequestResponseBodyMethodProcessorMockTests {
|
|||
|
||||
servletRequest.setMethod("POST");
|
||||
|
||||
Method methodHandle1 = getClass().getMethod("handle1", String.class, Integer.TYPE);
|
||||
Method methodHandle1 = getClass().getMethod("handle1", String.class, int.class);
|
||||
paramRequestBodyString = new MethodParameter(methodHandle1, 0);
|
||||
paramInt = new MethodParameter(methodHandle1, 1);
|
||||
paramValidBean = new MethodParameter(getClass().getMethod("handle2", SimpleBean.class), 0);
|
||||
|
|
Loading…
Reference in New Issue