Skip to content

Commit 3290592

Browse files
committed
Remove Kotlin field handling in DependencyDescriptor
The KotlinDelegate#isNullable invocation is unnecessary since this check is already done by the Nullness#forField one introduced by b5d153f. See gh-34952 See gh-34261
1 parent 26ee30e commit 3290592

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@
2424
import java.util.Map;
2525
import java.util.Optional;
2626

27-
import kotlin.reflect.KProperty;
28-
import kotlin.reflect.jvm.ReflectJvmMapping;
2927
import org.jspecify.annotations.Nullable;
3028

3129
import org.springframework.beans.BeansException;
3230
import org.springframework.beans.factory.BeanFactory;
3331
import org.springframework.beans.factory.InjectionPoint;
3432
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
35-
import org.springframework.core.KotlinDetector;
3633
import org.springframework.core.MethodParameter;
3734
import org.springframework.core.Nullness;
3835
import org.springframework.core.ParameterNameDiscoverer;
@@ -163,8 +160,7 @@ public boolean isRequired() {
163160
}
164161

165162
if (this.field != null) {
166-
return !(this.field.getType() == Optional.class || Nullness.forField(this.field) == Nullness.NULLABLE ||
167-
(KotlinDetector.isKotlinType(this.field.getDeclaringClass()) && KotlinDelegate.isNullable(this.field)));
163+
return !(this.field.getType() == Optional.class || Nullness.forField(this.field) == Nullness.NULLABLE);
168164
}
169165
else {
170166
return !obtainMethodParameter().isOptional();
@@ -446,19 +442,4 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
446442
}
447443
}
448444

449-
450-
/**
451-
* Inner class to avoid a hard dependency on Kotlin at runtime.
452-
*/
453-
private static class KotlinDelegate {
454-
455-
/**
456-
* Check whether the specified {@link Field} represents a nullable Kotlin type or not.
457-
*/
458-
public static boolean isNullable(Field field) {
459-
KProperty<?> property = ReflectJvmMapping.getKotlinProperty(field);
460-
return (property != null && property.getReturnType().isMarkedNullable());
461-
}
462-
}
463-
464445
}

0 commit comments

Comments
 (0)