73 static {
74 SUPPORTED_JAVA_PLATFORM_VERSIONS = new TreeSet<>();
75 Path ctSymFile = findCtSym();
76 if (Files.exists(ctSymFile)) {
77 try (FileSystem fs = FileSystems.newFileSystem(ctSymFile, null);
78 DirectoryStream<Path> dir =
79 Files.newDirectoryStream(fs.getRootDirectories().iterator().next())) {
80 for (Path section : dir) {
81 for (char ver : section.getFileName().toString().toCharArray()) {
82 String verString = Character.toString(ver);
83 Target t = Target.lookup(verString);
84
85 if (t != null) {
86 SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(t));
87 }
88 }
89 }
90 } catch (IOException | ProviderNotFoundException ex) {
91 }
92 }
93 SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.DEFAULT));
94 }
95
96 private static String targetNumericVersion(Target target) {
97 return Integer.toString(target.ordinal() - Target.JDK1_1.ordinal() + 1);
98 }
99
100 static class PlatformDescriptionImpl implements PlatformDescription {
101
102 private final Map<Path, FileSystem> ctSym2FileSystem = new HashMap<>();
103 private final String version;
104
105 PlatformDescriptionImpl(String version) {
106 this.version = version;
107 }
108
109 @Override
110 public Collection<Path> getPlatformPath() {
111 if (Target.lookup(version) == Target.DEFAULT) {
112 return null;
113 }
114
115 List<Path> paths = new ArrayList<>();
116 Path file = findCtSym();
117 // file == ${jdk.home}/lib/ct.sym
118 if (Files.exists(file)) {
119 FileSystem fs = ctSym2FileSystem.get(file);
120 if (fs == null) {
121 try {
122 ctSym2FileSystem.put(file, fs = FileSystems.newFileSystem(file, null));
123 } catch (IOException ex) {
124 throw new IllegalStateException(ex);
125 }
126 }
127 Path root = fs.getRootDirectories().iterator().next();
128 try (DirectoryStream<Path> dir = Files.newDirectoryStream(root)) {
129 for (Path section : dir) {
130 if (section.getFileName().toString().contains(version)) {
131 paths.add(section);
|
73 static {
74 SUPPORTED_JAVA_PLATFORM_VERSIONS = new TreeSet<>();
75 Path ctSymFile = findCtSym();
76 if (Files.exists(ctSymFile)) {
77 try (FileSystem fs = FileSystems.newFileSystem(ctSymFile, null);
78 DirectoryStream<Path> dir =
79 Files.newDirectoryStream(fs.getRootDirectories().iterator().next())) {
80 for (Path section : dir) {
81 for (char ver : section.getFileName().toString().toCharArray()) {
82 String verString = Character.toString(ver);
83 Target t = Target.lookup(verString);
84
85 if (t != null) {
86 SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(t));
87 }
88 }
89 }
90 } catch (IOException | ProviderNotFoundException ex) {
91 }
92 }
93 // Workaround until full support for --release 9 distinct from --release 10
94 SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.JDK1_9));
95 SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.DEFAULT));
96 }
97
98 private static String targetNumericVersion(Target target) {
99 return Integer.toString(target.ordinal() - Target.JDK1_1.ordinal() + 1);
100 }
101
102 static class PlatformDescriptionImpl implements PlatformDescription {
103
104 private final Map<Path, FileSystem> ctSym2FileSystem = new HashMap<>();
105 private final String version;
106
107 PlatformDescriptionImpl(String version) {
108 this.version = version;
109 }
110
111 @Override
112 public Collection<Path> getPlatformPath() {
113 // Comparison should be == Target.DEFAULT once --release 9
114 // is distinct from 10
115 if (Target.lookup(version).compareTo(Target.JDK1_9) >= 0) {
116 return null;
117 }
118
119 List<Path> paths = new ArrayList<>();
120 Path file = findCtSym();
121 // file == ${jdk.home}/lib/ct.sym
122 if (Files.exists(file)) {
123 FileSystem fs = ctSym2FileSystem.get(file);
124 if (fs == null) {
125 try {
126 ctSym2FileSystem.put(file, fs = FileSystems.newFileSystem(file, null));
127 } catch (IOException ex) {
128 throw new IllegalStateException(ex);
129 }
130 }
131 Path root = fs.getRootDirectories().iterator().next();
132 try (DirectoryStream<Path> dir = Files.newDirectoryStream(root)) {
133 for (Path section : dir) {
134 if (section.getFileName().toString().contains(version)) {
135 paths.add(section);
|