filtering incorrect annotation from idea jdk annotations, filtering problematic class javax.management.openmbean.TabularDataSupport from ValidityTest

This commit is contained in:
Ilya Klyuchnikov
2013-12-29 17:41:30 +04:00
committed by Andrey Breslav
parent ca5cf6f3cc
commit 5fb81aaa8b
2 changed files with 30 additions and 4 deletions
@@ -78,6 +78,11 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
for (FqName classFqName : JdkAnnotationsValidityTest.getAffectedClasses("jar://ideaSDK/lib/jdkAnnotations.jar!/")) {
if (new FqName("org.jdom").equals(classFqName.parent())) continue; // filter unrelated jdom annotations
if (new FqName("java.util.concurrent.TransferQueue").equals(classFqName)) continue; // filter JDK7-specific class
// the following idea annotation is incorrect
// <item name="java.io.StringWriter void write(java.lang.String) 0">
// <annotation name="org.jetbrains.annotations.NotNull" />
// </item>
if (new FqName("java.io.StringWriter").equals(classFqName)) continue;
PsiClass psiClass = javaPsiFacade.findClass(classFqName.asString(), allScope);
assertNotNull("Class has annotation, but it is not found: " + classFqName, psiClass);
@@ -53,9 +53,7 @@ import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -65,6 +63,26 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
private static final int CLASSES_IN_CHUNK = 500;
// KT-4359 Alternative signature checking problem: Set<?> is incompatible with Set<Object>
//
// <item name='javax.management.openmbean.TabularDataSupport java.util.Set&lt;java.lang.Object&gt; keySet()'>
// <annotation name='org.jetbrains.annotations.NotNull'/>
// </item>
// <item name='java.util.Map java.util.Set&lt;K&gt; keySet()'>
// <annotation name='org.jetbrains.annotations.NotNull'/>
// <annotation name='jet.runtime.typeinfo.KotlinSignature'>
// <val name="value" val="&quot;fun keySet() : Set&lt;K&gt;&quot;"/>
// </annotation>
// </item>
// <item name='javax.management.openmbean.TabularData java.util.Set&lt;?&gt; keySet()'>
// <annotation name='org.jetbrains.annotations.NotNull'/>
// </item>
//
// KAnnotator produces above annotations and validation of TabularDataSupport results into:
// public open fun keySet(): jet.MutableSet<jet.Any> defined in javax.management.openmbean.TabularDataSupport :
// [Incompatible types in superclasses: [Any?, Any, Any], Incompatible projection kinds in type arguments of super methods' return types: [out Any?, Any, Any]]
private static final Set<String> classesToIgnore = new HashSet<String>(Arrays.asList("javax.management.openmbean.TabularDataSupport"));
private static JetCoreEnvironment createEnvironment(Disposable parentDisposable) {
CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(
ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar());
@@ -152,7 +170,10 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
String text = StreamUtil.readText(file.getInputStream());
Matcher matcher = Pattern.compile("<item name=['\"]([\\w\\d\\.]+)[\\s'\"]").matcher(text);
while (matcher.find()) {
result.add(new FqName(matcher.group(1)));
String className = matcher.group(1);
if (!classesToIgnore.contains(className)) {
result.add(new FqName(className));
}
}
}
catch (IOException e) {