From 69e838ead8f5a8b7726310e36351e41d718e4719 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 29 Mar 2019 17:04:10 +0300 Subject: [PATCH] java: fix computation of path to jdkAnnotation for case when Java support is installed as a plugin (IDEA-195719) --- .../openapi/projectRoots/impl/JavaSdkImpl.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java index f0aea3d30ab2..e71da89a9843 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java @@ -272,9 +272,19 @@ public class JavaSdkImpl extends JavaSdk { pathsChecked.add(path); if (root == null) { // build - String url = "jar://" + FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar!/"; - root = VirtualFileManager.getInstance().findFileByUrl(url); - pathsChecked.add(FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar"); + String javaPluginClassesRootPath = PathManager.getJarPathForClass(JavaSdkImpl.class); + LOG.assertTrue(javaPluginClassesRootPath != null); + File javaPluginClassesRoot = new File(javaPluginClassesRootPath); + if (javaPluginClassesRoot.isFile()) { + String annotationsJarPath = FileUtil.toSystemIndependentName(new File(javaPluginClassesRoot.getParentFile(), "jdkAnnotations.jar").getAbsolutePath()); + root = VirtualFileManager.getInstance().findFileByUrl("jar://" + annotationsJarPath + "!/"); + pathsChecked.add(annotationsJarPath); + } + if (root == null) { + String url = "jar://" + FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar!/"; + root = VirtualFileManager.getInstance().findFileByUrl(url); + pathsChecked.add(FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar"); + } } if (root == null) {