From f8508c805f2d24b1bf558d3becfb8ca8626d4d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 27 Jun 2022 17:43:45 +0200 Subject: [PATCH] Refine KotlinDetector for compliance with ConstantFieldFeature After this commit, KotlinDetector#kotlinPresent is computed at build time. See gh-28624 --- .../java/org/springframework/core/KotlinDetector.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/KotlinDetector.java b/spring-core/src/main/java/org/springframework/core/KotlinDetector.java index 8a6c072d44d..fde4e10a6c9 100644 --- a/spring-core/src/main/java/org/springframework/core/KotlinDetector.java +++ b/spring-core/src/main/java/org/springframework/core/KotlinDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -35,6 +35,9 @@ public abstract class KotlinDetector { @Nullable private static final Class kotlinMetadata; + // For ConstantFieldFeature compliance, otherwise could be deduced from kotlinMetadata + private static final boolean kotlinPresent; + private static final boolean kotlinReflectPresent; static { @@ -48,6 +51,7 @@ public abstract class KotlinDetector { metadata = null; } kotlinMetadata = (Class) metadata; + kotlinPresent = (kotlinMetadata != null); kotlinReflectPresent = ClassUtils.isPresent("kotlin.reflect.full.KClasses", classLoader); } @@ -56,7 +60,7 @@ public abstract class KotlinDetector { * Determine whether Kotlin is present in general. */ public static boolean isKotlinPresent() { - return (kotlinMetadata != null); + return kotlinPresent; } /**