File tree 3 files changed +34
-0
lines changed
main/java/org/springframework/data/util
test/kotlin/org/springframework/data/util
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 28
28
import java .beans .PropertyDescriptor ;
29
29
import java .beans .SimpleBeanInfo ;
30
30
import java .lang .reflect .Method ;
31
+ import java .lang .reflect .Modifier ;
31
32
import java .util .Arrays ;
32
33
import java .util .LinkedHashSet ;
33
34
import java .util .Set ;
@@ -68,6 +69,10 @@ public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
68
69
Method getter = ReflectJvmMapping .getJavaGetter (property );
69
70
Method setter = property instanceof KMutableProperty <?> kmp ? ReflectJvmMapping .getJavaSetter (kmp ) : null ;
70
71
72
+ if (getter != null && (Modifier .isStatic (getter .getModifiers ()) || getter .getParameterCount () != 0 )) {
73
+ continue ;
74
+ }
75
+
71
76
if (getter != null && setter != null && setter .getParameterCount () == 1 ) {
72
77
if (!getter .getReturnType ().equals (setter .getParameters ()[0 ].getType ())) {
73
78
// filter asymmetric getters/setters from being considered a Java Beans property
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package org.springframework.data.util
17
+
18
+ @JvmInline
19
+ value class InlineClassWithProperty (val value : String ) {
20
+ val foo: String get() = " foo-$value "
21
+ }
Original file line number Diff line number Diff line change @@ -48,6 +48,14 @@ class KotlinBeanInfoFactoryUnitTests {
48
48
}
49
49
}
50
50
51
+ @Test // GH-3109
52
+ internal fun considersJavaBeansGettersOnly () {
53
+
54
+ val pds = BeanUtils .getPropertyDescriptors(InlineClassWithProperty ::class .java)
55
+
56
+ assertThat(pds).hasSize(1 ).extracting(" name" ).contains(" value" )
57
+ }
58
+
51
59
@Test
52
60
internal fun determinesInlineClassConsumerProperties () {
53
61
You can’t perform that action at this time.
0 commit comments