< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  96     public static final Comparator<String> NUMERICAL_COMPARATOR = (s1, s2) -> {
  97         int i1;
  98         try {
  99             i1 = Integer.parseInt(s1);
 100         } catch (NumberFormatException ex) {
 101             i1 = Integer.MAX_VALUE;
 102         }
 103         int i2;
 104         try {
 105             i2 = Integer.parseInt(s2);
 106         } catch (NumberFormatException ex) {
 107             i2 = Integer.MAX_VALUE;
 108         }
 109         return i1 != i2 ? i1 - i2 : s1.compareTo(s2);
 110     };
 111 
 112     static {
 113         SUPPORTED_JAVA_PLATFORM_VERSIONS = new TreeSet<>(NUMERICAL_COMPARATOR);
 114         Path ctSymFile = findCtSym();
 115         if (Files.exists(ctSymFile)) {
 116             try (FileSystem fs = FileSystems.newFileSystem(ctSymFile, null);
 117                  DirectoryStream<Path> dir =
 118                          Files.newDirectoryStream(fs.getRootDirectories().iterator().next())) {
 119                 for (Path section : dir) {
 120                     if (section.getFileName().toString().contains("-"))
 121                         continue;
 122                     for (char ver : section.getFileName().toString().toCharArray()) {
 123                         String verString = Character.toString(ver);
 124                         Target t = Target.lookup("" + Integer.parseInt(verString, 16));
 125 
 126                         if (t != null) {
 127                             SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(t));
 128                         }
 129                     }
 130                 }
 131             } catch (IOException | ProviderNotFoundException ex) {
 132             }
 133         }
 134     }
 135 
 136     private static String targetNumericVersion(Target target) {


 235 
 236                     };
 237                 }
 238 
 239                 @Override
 240                 public String inferBinaryName(Location location, JavaFileObject file) {
 241                     if (file instanceof SigJavaFileObject) {
 242                         file = ((SigJavaFileObject) file).getDelegate();
 243                     }
 244                     return super.inferBinaryName(location, file);
 245                 }
 246 
 247             };
 248 
 249             Path file = findCtSym();
 250             // file == ${jdk.home}/lib/ct.sym
 251             if (Files.exists(file)) {
 252                 try {
 253                     FileSystem fs = ctSym2FileSystem.get(file);
 254                     if (fs == null) {
 255                         ctSym2FileSystem.put(file, fs = FileSystems.newFileSystem(file, null));
 256                     }
 257 
 258                     Path root = fs.getRootDirectories().iterator().next();
 259                     boolean hasModules =
 260                             Feature.MODULES.allowedInSource(Source.lookup(sourceVersion));
 261                     Path systemModules = root.resolve(ctSymVersion).resolve("system-modules");
 262                     Charset utf8 = Charset.forName("UTF-8");
 263 
 264                     if (!hasModules) {
 265                         List<Path> paths = new ArrayList<>();
 266 
 267                         try (DirectoryStream<Path> dir = Files.newDirectoryStream(root)) {
 268                             for (Path section : dir) {
 269                                 if (section.getFileName().toString().contains(ctSymVersion) &&
 270                                     !section.getFileName().toString().contains("-")) {
 271                                     try (DirectoryStream<Path> modules = Files.newDirectoryStream(section)) {
 272                                         for (Path module : modules) {
 273                                             paths.add(module);
 274                                         }
 275                                     }


   1 /*
   2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  96     public static final Comparator<String> NUMERICAL_COMPARATOR = (s1, s2) -> {
  97         int i1;
  98         try {
  99             i1 = Integer.parseInt(s1);
 100         } catch (NumberFormatException ex) {
 101             i1 = Integer.MAX_VALUE;
 102         }
 103         int i2;
 104         try {
 105             i2 = Integer.parseInt(s2);
 106         } catch (NumberFormatException ex) {
 107             i2 = Integer.MAX_VALUE;
 108         }
 109         return i1 != i2 ? i1 - i2 : s1.compareTo(s2);
 110     };
 111 
 112     static {
 113         SUPPORTED_JAVA_PLATFORM_VERSIONS = new TreeSet<>(NUMERICAL_COMPARATOR);
 114         Path ctSymFile = findCtSym();
 115         if (Files.exists(ctSymFile)) {
 116             try (FileSystem fs = FileSystems.newFileSystem(ctSymFile, (ClassLoader)null);
 117                  DirectoryStream<Path> dir =
 118                          Files.newDirectoryStream(fs.getRootDirectories().iterator().next())) {
 119                 for (Path section : dir) {
 120                     if (section.getFileName().toString().contains("-"))
 121                         continue;
 122                     for (char ver : section.getFileName().toString().toCharArray()) {
 123                         String verString = Character.toString(ver);
 124                         Target t = Target.lookup("" + Integer.parseInt(verString, 16));
 125 
 126                         if (t != null) {
 127                             SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(t));
 128                         }
 129                     }
 130                 }
 131             } catch (IOException | ProviderNotFoundException ex) {
 132             }
 133         }
 134     }
 135 
 136     private static String targetNumericVersion(Target target) {


 235 
 236                     };
 237                 }
 238 
 239                 @Override
 240                 public String inferBinaryName(Location location, JavaFileObject file) {
 241                     if (file instanceof SigJavaFileObject) {
 242                         file = ((SigJavaFileObject) file).getDelegate();
 243                     }
 244                     return super.inferBinaryName(location, file);
 245                 }
 246 
 247             };
 248 
 249             Path file = findCtSym();
 250             // file == ${jdk.home}/lib/ct.sym
 251             if (Files.exists(file)) {
 252                 try {
 253                     FileSystem fs = ctSym2FileSystem.get(file);
 254                     if (fs == null) {
 255                         ctSym2FileSystem.put(file, fs = FileSystems.newFileSystem(file, (ClassLoader)null));
 256                     }
 257 
 258                     Path root = fs.getRootDirectories().iterator().next();
 259                     boolean hasModules =
 260                             Feature.MODULES.allowedInSource(Source.lookup(sourceVersion));
 261                     Path systemModules = root.resolve(ctSymVersion).resolve("system-modules");
 262                     Charset utf8 = Charset.forName("UTF-8");
 263 
 264                     if (!hasModules) {
 265                         List<Path> paths = new ArrayList<>();
 266 
 267                         try (DirectoryStream<Path> dir = Files.newDirectoryStream(root)) {
 268                             for (Path section : dir) {
 269                                 if (section.getFileName().toString().contains(ctSymVersion) &&
 270                                     !section.getFileName().toString().contains("-")) {
 271                                     try (DirectoryStream<Path> modules = Files.newDirectoryStream(section)) {
 272                                         for (Path module : modules) {
 273                                             paths.add(module);
 274                                         }
 275                                     }


< prev index next >