Skip to content

Commit f8508c8

Browse files
committed
Refine KotlinDetector for compliance with ConstantFieldFeature
After this commit, KotlinDetector#kotlinPresent is computed at build time. See gh-28624
1 parent 798dd4f commit f8508c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-core/src/main/java/org/springframework/core/KotlinDetector.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,9 @@ public abstract class KotlinDetector {
3535
@Nullable
3636
private static final Class<? extends Annotation> kotlinMetadata;
3737

38+
// For ConstantFieldFeature compliance, otherwise could be deduced from kotlinMetadata
39+
private static final boolean kotlinPresent;
40+
3841
private static final boolean kotlinReflectPresent;
3942

4043
static {
@@ -48,6 +51,7 @@ public abstract class KotlinDetector {
4851
metadata = null;
4952
}
5053
kotlinMetadata = (Class<? extends Annotation>) metadata;
54+
kotlinPresent = (kotlinMetadata != null);
5155
kotlinReflectPresent = ClassUtils.isPresent("kotlin.reflect.full.KClasses", classLoader);
5256
}
5357

@@ -56,7 +60,7 @@ public abstract class KotlinDetector {
5660
* Determine whether Kotlin is present in general.
5761
*/
5862
public static boolean isKotlinPresent() {
59-
return (kotlinMetadata != null);
63+
return kotlinPresent;
6064
}
6165

6266
/**

0 commit comments

Comments
 (0)