Revised handling of missing data class arguments
Includes unified detection of Kotlin's optional parameters in MethodParameter.isOptional(), reduces BeanUtils.findPrimaryConstructor to Kotlin semantics (for reuse in AutowiredAnnotationBeanPostProcessor), and finally introduces a common KotlinDetector delegate with an isKotlinType(Class) check. Issue: SPR-15877 Issue: SPR-16020
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -275,23 +274,6 @@ public class BeanUtilsTests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindDefaultConstructorAndInstantiate() {
|
||||
Constructor<Bean> ctor = BeanUtils.findPrimaryConstructor(Bean.class);
|
||||
assertNotNull(ctor);
|
||||
Bean bean = BeanUtils.instantiateClass(ctor);
|
||||
assertNotNull(bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindSingleNonDefaultConstructorAndInstantiate() {
|
||||
Constructor<BeanWithSingleNonDefaultConstructor> ctor = BeanUtils.findPrimaryConstructor(BeanWithSingleNonDefaultConstructor.class);
|
||||
assertNotNull(ctor);
|
||||
BeanWithSingleNonDefaultConstructor bean = BeanUtils.instantiateClass(ctor, "foo");
|
||||
assertNotNull(bean);
|
||||
assertEquals("foo", bean.getName());
|
||||
}
|
||||
|
||||
private void assertSignatureEquals(Method desiredMethod, String signature) {
|
||||
assertEquals(desiredMethod, BeanUtils.resolveSignature(signature, MethodSignatureBean.class));
|
||||
|
||||
Reference in New Issue
Block a user