forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit fixes a performance regression caused by spring-projectsgh-31698, and more specifically by KClass#isValue invocations which are slow since they load the whole module to find the class to get the descriptor. After discussing with the Kotlin team, it has been decided that only checking for the presence of `@JvmInline` annotation is enough for Spring use case. As a consequence, this commit introduces a new KotlinDetector#isInlineClass method that performs such check, and BeanUtils, CoroutinesUtils and WebMVC/WebFlux InvocableHandlerMethod have been refined to leverage it. Closes spring-projectsgh-32334
- Loading branch information
Showing
6 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
spring-core/src/test/kotlin/org/springframework/core/KotlinDetectorTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.core | ||
|
||
import org.assertj.core.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
|
||
/** | ||
* Kotlin tests for [KotlinDetector]. | ||
* | ||
* @author Sebastien Deleuze | ||
*/ | ||
class KotlinDetectorTests { | ||
|
||
@Test | ||
fun isKotlinType() { | ||
Assertions.assertThat(KotlinDetector.isKotlinType(KotlinDetectorTests::class.java)).isTrue() | ||
} | ||
|
||
@Test | ||
fun isNotKotlinType() { | ||
Assertions.assertThat(KotlinDetector.isKotlinType(KotlinDetector::class.java)).isFalse() | ||
} | ||
|
||
@Test | ||
fun isInlineClass() { | ||
Assertions.assertThat(KotlinDetector.isInlineClass(ValueClass::class.java)).isTrue() | ||
} | ||
|
||
@Test | ||
fun isNotInlineClass() { | ||
Assertions.assertThat(KotlinDetector.isInlineClass(KotlinDetector::class.java)).isFalse() | ||
Assertions.assertThat(KotlinDetector.isInlineClass(KotlinDetectorTests::class.java)).isFalse() | ||
} | ||
|
||
@JvmInline | ||
value class ValueClass(val value: String) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters