diff --git a/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java b/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java index d965b2723079..34c220c83abf 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/cl/PluginClassLoader.java @@ -91,10 +91,13 @@ public class PluginClassLoader extends UrlClassLoader { } private static boolean mustBeLoadedByPlatform(String className) { - //FunctionX interfaces from kotlin-runtime must be loaded by the platform classloader. Otherwise if a plugin bundles its own version - // of kotlin-runtime.jar it won't be possible to call platform's methods with Kotlin functional types in signatures from such a plugin. - //We assume that FunctionX interfaces don't change between Kotlin versions so it's safe to always load them from platform's kotlin-runtime. - return className.startsWith("kotlin.jvm.functions."); + //some commonly used classes from kotlin-runtime must be loaded by the platform classloader. Otherwise if a plugin bundles its own version + // of kotlin-runtime.jar it won't be possible to call platform's methods with these types in signatures from such a plugin. + //We assume that these classes don't change between Kotlin versions so it's safe to always load them from platform's kotlin-runtime. + return className.startsWith("kotlin.") && (className.startsWith("kotlin.jvm.functions.") + || className.equals("kotlin.sequences.Sequence") + || className.equals("kotlin.Pair") + || className.equals("kotlin.Triple")); } @Nullable diff --git a/platform/util/src/com/intellij/util/io/DirectBufferWrapper.java b/platform/util/src/com/intellij/util/io/DirectBufferWrapper.java index f87c70f826e7..db4b89c7ba75 100644 --- a/platform/util/src/com/intellij/util/io/DirectBufferWrapper.java +++ b/platform/util/src/com/intellij/util/io/DirectBufferWrapper.java @@ -83,19 +83,13 @@ abstract class DirectBufferWrapper extends ByteBufferWrapper { throw new RuntimeException(e); } } - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - @Nullable - public Object run() { - try { - Cleaner cleaner = ((DirectBuffer)buffer).cleaner(); - if (cleaner != null) cleaner.clean(); // Already cleaned otherwise - return null; - } - catch (Throwable e) { - return buffer; - } - } - }) == null; + try { + Cleaner cleaner = ((DirectBuffer)buffer).cleaner(); + if (cleaner != null) cleaner.clean(); // Already cleaned otherwise + return true; + } + catch (Throwable e) { + return false; + } } } diff --git a/plugins/devkit/src/inspections/RegistrationProblemsInspection.java b/plugins/devkit/src/inspections/RegistrationProblemsInspection.java index f37675ba82db..b288812eb227 100644 --- a/plugins/devkit/src/inspections/RegistrationProblemsInspection.java +++ b/plugins/devkit/src/inspections/RegistrationProblemsInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,17 +112,17 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase { final PsiIdentifier nameIdentifier = checkedClass.getNameIdentifier(); if (CHECK_JAVA_CODE && - nameIdentifier != null && - checkedClass.getQualifiedName() != null && - checkedClass.getContainingFile().getVirtualFile() != null) - { + nameIdentifier != null && + checkedClass.getQualifiedName() != null && + checkedClass.getContainingFile().getVirtualFile() != null) { final Set componentClasses = RegistrationCheckerUtil.getRegistrationTypes(checkedClass, CHECK_ACTIONS); if (componentClasses != null && !componentClasses.isEmpty()) { - List problems = null; + List problems = new SmartList<>(); for (PsiClass compClass : componentClasses) { - if (!checkedClass.isInheritor(compClass, true)) { - problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier, + if (ActionType.ACTION.myClassName.equals(compClass.getQualifiedName()) && + !checkedClass.isInheritor(compClass, true)) { + problems.add(manager.createProblemDescriptor(nameIdentifier, DevKitBundle.message("inspections.registration.problems.incompatible.message", compClass.isInterface() ? DevKitBundle.message("keyword.implement") : @@ -133,28 +133,23 @@ public class RegistrationProblemsInspection extends DevKitInspectionBase { } if (ActionType.ACTION.isOfType(checkedClass)) { if (ConstructorType.getNoArgCtor(checkedClass) == null) { - problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier, - DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"), - new CreateConstructorFix(checkedClass, isOnTheFly), - ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly)); + problems.add(manager.createProblemDescriptor(nameIdentifier, + DevKitBundle.message("inspections.registration.problems.missing.noarg.ctor"), + new CreateConstructorFix(checkedClass, isOnTheFly), + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly)); } } if (isAbstract(checkedClass)) { - problems = addProblem(problems, manager.createProblemDescriptor(nameIdentifier, - DevKitBundle.message("inspections.registration.problems.abstract"), isOnTheFly, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); + problems.add(manager.createProblemDescriptor(nameIdentifier, + DevKitBundle.message("inspections.registration.problems.abstract"), isOnTheFly, + LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } - return problems != null ? problems.toArray(new ProblemDescriptor[problems.size()]) : null; + return ArrayUtil.toObjectArray(problems, ProblemDescriptor.class); } } return null; } - private static List addProblem(List problems, ProblemDescriptor problemDescriptor) { - if (problems == null) problems = new SmartList<>(); - problems.add(problemDescriptor); - return problems; - } - @Nullable private static ProblemDescriptor[] checkPluginXml(XmlFile xmlFile, InspectionManager manager, boolean isOnTheFly) { final XmlDocument document = xmlFile.getDocument(); diff --git a/plugins/devkit/testData/inspections/registrationProblems/code/ApplicationComponentWrongClass.xml b/plugins/devkit/testData/inspections/registrationProblems/code/ApplicationComponentMustNotInherit.xml similarity index 100% rename from plugins/devkit/testData/inspections/registrationProblems/code/ApplicationComponentWrongClass.xml rename to plugins/devkit/testData/inspections/registrationProblems/code/ApplicationComponentMustNotInherit.xml diff --git a/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentMustNotInherit.java b/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentMustNotInherit.java new file mode 100644 index 000000000000..620a2f0a0fe2 --- /dev/null +++ b/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentMustNotInherit.java @@ -0,0 +1 @@ +public class MyApplicationComponentMustNotInherit {} \ No newline at end of file diff --git a/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentWrongClass.java b/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentWrongClass.java deleted file mode 100644 index 21f7577a2c98..000000000000 --- a/plugins/devkit/testData/inspections/registrationProblems/code/MyApplicationComponentWrongClass.java +++ /dev/null @@ -1 +0,0 @@ -public class MyApplicationComponentWrongClass {} \ No newline at end of file diff --git a/plugins/devkit/testSources/inspections/RegistrationProblemsInspectionCodeTest.java b/plugins/devkit/testSources/inspections/RegistrationProblemsInspectionCodeTest.java index ab4439905551..446400d688c1 100644 --- a/plugins/devkit/testSources/inspections/RegistrationProblemsInspectionCodeTest.java +++ b/plugins/devkit/testSources/inspections/RegistrationProblemsInspectionCodeTest.java @@ -42,9 +42,9 @@ public class RegistrationProblemsInspectionCodeTest extends PluginModuleTestCase myFixture.testHighlighting("AbstractApplicationComponent.java"); } - public void testComponentWrongClass() { - setPluginXml("ApplicationComponentWrongClass.xml"); - myFixture.testHighlighting("MyApplicationComponentWrongClass.java"); + public void testApplicationComponentMustNotInherit() { + setPluginXml("ApplicationComponentMustNotInherit.xml"); + myFixture.testHighlighting("MyApplicationComponentMustNotInherit.java"); } public void testActionAbstractClass() { diff --git a/python/src/com/jetbrains/python/testing/PyTestsShared.kt b/python/src/com/jetbrains/python/testing/PyTestsShared.kt index 578a168567e2..27bc2f301f28 100644 --- a/python/src/com/jetbrains/python/testing/PyTestsShared.kt +++ b/python/src/com/jetbrains/python/testing/PyTestsShared.kt @@ -613,6 +613,7 @@ object PyTestsConfigurationProducer : com.jetbrains.python.testing.AbstractPytho configuration.workingDirectory = targetForConfig.second } } + configuration.module = context?.module configuration.setGeneratedName() return true }