From 09e47fff7b6e3e675989b0cde169918e469edbcf Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 29 Jul 2020 17:13:51 +0300 Subject: [PATCH] Fix KotlinGradleIT.testCustomCompilerFile Referencing org.jetbrains.annotations.{Nullable, NotNull} classes in static initializer causes ClassNotFoundError in testCustomCompilerFile. --- .../jetbrains/kotlin/codegen/AnnotationCodegen.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 980d9ba1c47..17af71ee5a8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -50,9 +50,6 @@ import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getA public abstract class AnnotationCodegen { - private static final String ORG_JETBRAINS_ANNOTATIONS_NOTNULL = Type.getType(NotNull.class).getDescriptor(); - private static final String ORG_JETBRAINS_ANNOTATIONS_NULLABLE = Type.getType(Nullable.class).getDescriptor(); - public static final class JvmFlagAnnotation { private final FqName fqName; private final int jvmFlag; @@ -251,15 +248,17 @@ public abstract class AnnotationCodegen { if (!TypeUtils.isNullableType(flexibleType.getLowerBound()) && TypeUtils.isNullableType(flexibleType.getUpperBound())) { AnnotationDescriptor notNull = type.getAnnotations().findAnnotation(JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION); if (notNull != null) { - generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, ORG_JETBRAINS_ANNOTATIONS_NOTNULL, false); + generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, Type.getType(NotNull.class).getDescriptor(), false); } return; } } - String annotationDescriptor = - TypeUtils.isNullableType(type) ? ORG_JETBRAINS_ANNOTATIONS_NULLABLE : ORG_JETBRAINS_ANNOTATIONS_NOTNULL; - generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationDescriptor, false); + generateAnnotationIfNotPresent( + annotationDescriptorsAlreadyPresent, + TypeUtils.isNullableType(type) ? Type.getType(Nullable.class).getDescriptor() : Type.getType(NotNull.class).getDescriptor(), + false + ); } private static final Map> annotationTargetMaps = new EnumMap<>(JvmTarget.class);