41 import jdk.internal.jimage.ImageReader.Node;
42
43 /**
44 * @implNote This class needs to maintain JDK 8 source compatibility.
45 *
46 * It is used internally in the JDK to implement jimage/jrtfs access,
47 * but also compiled and delivered as part of the jrtfs.jar to support access
48 * to the jimage file provided by the shipped JDK by tools running on JDK 8.
49 */
50 @SuppressWarnings({ "removal", "suppression"} )
51 abstract class SystemImage {
52
53 abstract Node findNode(String path) throws IOException;
54 abstract byte[] getResource(Node node) throws IOException;
55 abstract void close() throws IOException;
56
57 static SystemImage open() throws IOException {
58 if (modulesImageExists) {
59 // open a .jimage and build directory structure
60 final ImageReader image = ImageReader.open(moduleImageFile);
61 image.getRootDirectory();
62 return new SystemImage() {
63 @Override
64 Node findNode(String path) throws IOException {
65 return image.findNode(path);
66 }
67 @Override
68 byte[] getResource(Node node) throws IOException {
69 return image.getResource(node);
70 }
71 @Override
72 void close() throws IOException {
73 image.close();
74 }
75 };
76 }
77 if (Files.notExists(explodedModulesDir))
78 throw new FileSystemNotFoundException(explodedModulesDir.toString());
79 return new ExplodedImage(explodedModulesDir);
80 }
81
|
41 import jdk.internal.jimage.ImageReader.Node;
42
43 /**
44 * @implNote This class needs to maintain JDK 8 source compatibility.
45 *
46 * It is used internally in the JDK to implement jimage/jrtfs access,
47 * but also compiled and delivered as part of the jrtfs.jar to support access
48 * to the jimage file provided by the shipped JDK by tools running on JDK 8.
49 */
50 @SuppressWarnings({ "removal", "suppression"} )
51 abstract class SystemImage {
52
53 abstract Node findNode(String path) throws IOException;
54 abstract byte[] getResource(Node node) throws IOException;
55 abstract void close() throws IOException;
56
57 static SystemImage open() throws IOException {
58 if (modulesImageExists) {
59 // open a .jimage and build directory structure
60 final ImageReader image = ImageReader.open(moduleImageFile);
61 return new SystemImage() {
62 @Override
63 Node findNode(String path) throws IOException {
64 return image.findNode(path);
65 }
66 @Override
67 byte[] getResource(Node node) throws IOException {
68 return image.getResource(node);
69 }
70 @Override
71 void close() throws IOException {
72 image.close();
73 }
74 };
75 }
76 if (Files.notExists(explodedModulesDir))
77 throw new FileSystemNotFoundException(explodedModulesDir.toString());
78 return new ExplodedImage(explodedModulesDir);
79 }
80
|