File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
main/java/org/springframework/data/util
test/kotlin/org/springframework/data/util Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 2828import java .beans .PropertyDescriptor ;
2929import java .beans .SimpleBeanInfo ;
3030import java .lang .reflect .Method ;
31+ import java .lang .reflect .Modifier ;
3132import java .util .Arrays ;
3233import java .util .LinkedHashSet ;
3334import java .util .Set ;
@@ -68,6 +69,10 @@ public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
6869 Method getter = ReflectJvmMapping .getJavaGetter (property );
6970 Method setter = property instanceof KMutableProperty <?> kmp ? ReflectJvmMapping .getJavaSetter (kmp ) : null ;
7071
72+ if (getter != null && (Modifier .isStatic (getter .getModifiers ()) || getter .getParameterCount () != 0 )) {
73+ continue ;
74+ }
75+
7176 if (getter != null && setter != null && setter .getParameterCount () == 1 ) {
7277 if (!getter .getReturnType ().equals (setter .getParameters ()[0 ].getType ())) {
7378 // 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 {
4848 }
4949 }
5050
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+
5159 @Test
5260 internal fun determinesInlineClassConsumerProperties () {
5361
You can’t perform that action at this time.
0 commit comments