KT-8206 java.lang.NoSuchFieldError: $kotlinClass for deprecated::class

Instantiate class literals for annotation classes as foreign.
This commit is contained in:
Dmitry Petrov
2015-07-09 10:41:47 +03:00
committed by Alexander Udalov
parent 95f5d24988
commit d540ff8890
3 changed files with 17 additions and 1 deletions
@@ -2795,7 +2795,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
//noinspection ConstantConditions
ModuleDescriptor module = DescriptorUtils.getContainingModule(descriptor);
if (descriptor instanceof JavaClassDescriptor || module == module.getBuiltIns().getBuiltInsModule()) {
// Instantiate annotation classes as foreign due to bug in JDK 6 and 7:
// http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6857918
if (descriptor instanceof JavaClassDescriptor || module == module.getBuiltIns().getBuiltInsModule() ||
DescriptorUtils.isAnnotationClass(descriptor)) {
putJavaLangClassInstance(v, classAsmType);
wrapJavaClassIntoKClass(v);
}
@@ -0,0 +1,7 @@
import kotlin.test.assertEquals
fun box(): String {
assertEquals("deprecated", deprecated::class.simpleName)
return "OK"
}
@@ -2751,6 +2751,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("annotationClassLiteral.kt")
public void testAnnotationClassLiteral() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("arrays.kt")
public void testArrays() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/arrays.kt");