VirtualFile (@NotNull List<? super String> pathsChecked, boolean refresh) { Path javaPluginClassesRootPath = PathManager.getJarForClass(JavaSdkImpl.class); LOG.assertTrue(javaPluginClassesRootPath != null); javaPluginClassesRootPath = javaPluginClassesRootPath.toAbsolutePath(); VirtualFile root; VirtualFileManager vfm = VirtualFileManager.getInstance(); LocalFileSystem lfs = LocalFileSystem.getInstance(); String pathInResources = "resources/jdkAnnotations.jar"; if (Files.isRegularFile(javaPluginClassesRootPath)) { Path annotationsJarPath = javaPluginClassesRootPath.resolveSibling(pathInResources); String annotationsJarPathString = FileUtil.toSystemIndependentName(annotationsJarPath.toString()); String url = "jar://" + annotationsJarPathString + "!/"; root = refresh ? vfm.refreshAndFindFileByUrl(url) : vfm.findFileByUrl(url); pathsChecked.add(annotationsJarPathString); } else { // when run against IDEA plugin JDK, something like this comes up: "$IDEA_HOME$/out/classes/production/intellij.java.impl" Path projectRoot = JBIterable.generate(javaPluginClassesRootPath, Path::getParent).get(4); if (projectRoot != null) { Path root1 = projectRoot.resolve("community/java/jdkAnnotations"); Path root2 = projectRoot.resolve("java/jdkAnnotations"); root = Files.isDirectory(root1) ? (refresh ? lfs.refreshAndFindFileByNioFile(root1) : lfs.findFileByNioFile(root1)) : Files.isDirectory(root2) ? (refresh ? lfs.refreshAndFindFileByNioFile(root2) : lfs.findFileByNioFile(root2)) : null; } else { root = null; } } if (root == null) { String url = "jar://" + FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/" + pathInResources + "!/"; root = refresh ? vfm.refreshAndFindFileByUrl(url) : vfm.findFileByUrl(url); pathsChecked.add(url); } if (root == null) { // community idea under idea String path = FileUtil.toSystemIndependentName(PathManager.getCommunityHomePath()) + "/java/jdkAnnotations"; root = refresh ? lfs.refreshAndFindFileByPath(path) : lfs.findFileByPath(path); pathsChecked.add(path); } if (root == null && !refresh) { pathsChecked.add("<refresh is on now>"); root = internalJdkAnnotationsPath(pathsChecked, true); } return root; }