Refine KotlinDetector for compliance with ConstantFieldFeature

After this commit, KotlinDetector#kotlinPresent is
computed at build time.

See gh-28624
This commit is contained in:
Sébastien Deleuze 2022-06-27 17:43:45 +02:00
parent 798dd4fec0
commit f8508c805f
1 changed files with 6 additions and 2 deletions

View File

@ -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<? extends Annotation> 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<? extends Annotation>) 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;
}
/**