mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] uses "JDK_HOME/release" file to watch for JDK updates
This commit is contained in:
@@ -132,10 +132,9 @@ public class JrtFileSystemImpl extends JrtFileSystem {
|
||||
if (handler == null) {
|
||||
handler = isSupported() ? new JrtHandler(homePath) : new JrtHandlerStub(homePath);
|
||||
myHandlers.put(homePath, handler);
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
VirtualFile modules = LocalFileSystem.getInstance().refreshAndFindFileByPath(homePath + "/lib/modules");
|
||||
if (modules != null && modules.isDirectory()) modules.getChildren();
|
||||
}, ModalityState.defaultModalityState());
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(homePath + "/release"),
|
||||
ModalityState.defaultModalityState());
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
@@ -152,11 +151,9 @@ public class JrtFileSystemImpl extends JrtFileSystem {
|
||||
for (VFileEvent event : events) {
|
||||
if (event.getFileSystem() instanceof LocalFileSystem && event instanceof VFileContentChangeEvent) {
|
||||
VirtualFile file = event.getFile();
|
||||
if (file != null) {
|
||||
String homePath = null;
|
||||
if ("modules".equals(file.getName())) homePath = file.getParent().getParent().getPath();
|
||||
else if ("jimage".equals(file.getExtension())) homePath = file.getParent().getParent().getParent().getPath();
|
||||
if (homePath != null && myHandlers.remove(homePath) != null) {
|
||||
if (file != null && "release".equals(file.getName())) {
|
||||
String homePath = file.getParent().getPath();
|
||||
if (myHandlers.remove(homePath) != null) {
|
||||
VirtualFile root = findFileByPath(composeRootPath(homePath));
|
||||
if (root != null) {
|
||||
((NewVirtualFile)root).markDirtyRecursively();
|
||||
|
||||
@@ -52,6 +52,7 @@ public class JrtFileSystemTest extends BareTestFixtureTestCase {
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
myTestData = Paths.get(JavaTestUtil.getJavaTestDataPath(), "jrt");
|
||||
Files.write(myTempDir.getRoot().toPath().resolve("release"), "JAVA_VERSION=9\n".getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
Files.copy(myTestData.resolve("jrt-fs.jar"), myTempDir.getRoot().toPath().resolve("jrt-fs.jar"));
|
||||
Path lib = Files.createDirectory(myTempDir.getRoot().toPath().resolve("lib"));
|
||||
Files.copy(myTestData.resolve("image1"), lib.resolve("modules"));
|
||||
@@ -94,6 +95,7 @@ public class JrtFileSystemTest extends BareTestFixtureTestCase {
|
||||
Path modules = myTempDir.getRoot().toPath().resolve("lib/modules");
|
||||
Files.move(modules, myTempDir.getRoot().toPath().resolve("lib/modules.bak"));
|
||||
Files.copy(myTestData.resolve("image2"), modules, StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.write(myTempDir.getRoot().toPath().resolve("release"), "JAVA_VERSION=9.0.1\n".getBytes(CharsetToolkit.UTF8_CHARSET));
|
||||
|
||||
VirtualFile local = LocalFileSystem.getInstance().findFileByIoFile(myTempDir.getRoot());
|
||||
assertThat(local).isNotNull();
|
||||
|
||||
Reference in New Issue
Block a user