< prev index next >

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

Print this page
@@ -60,11 +60,10 @@
  import com.sun.tools.javac.code.Source.Feature;
  import com.sun.tools.javac.file.CacheFSInfo;
  import com.sun.tools.javac.file.JavacFileManager;
  import com.sun.tools.javac.jvm.Target;
  import com.sun.tools.javac.main.Option;
- import com.sun.tools.javac.util.Assert;
  import com.sun.tools.javac.util.Context;
  import com.sun.tools.javac.util.Log;
  import com.sun.tools.javac.util.StringUtils;
  
  /** PlatformProvider for JDK N.

@@ -74,25 +73,40 @@
   *  This code and its internal interfaces are subject to change or
   *  deletion without notice.</b>
   */
  public class JDKPlatformProvider implements PlatformProvider {
  
+     public static final String PREVIEW_OPTION = "preview";
+     private static final String CT_SYM_PREVIEW_VERSION = "@";
+ 
      @Override
      public Iterable<String> getSupportedPlatformNames() {
          return SUPPORTED_JAVA_PLATFORM_VERSIONS;
      }
  
      @Override
      public PlatformDescription getPlatform(String platformName, String options) throws PlatformNotSupported {
          if (!SUPPORTED_JAVA_PLATFORM_VERSIONS.contains(platformName)) {
              throw new PlatformNotSupported();
          }
-         return getPlatformTrusted(platformName);
+         if (PREVIEW_OPTION.equals(options) && !Source.DEFAULT.name.equals(platformName)) {
+             throw new PlatformNotSupported();
+         }
+         return getPlatformTrusted(platformName, options);
      }
  
-     public PlatformDescription getPlatformTrusted(String platformName) {
-         return new PlatformDescriptionImpl(platformName);
+     public PlatformDescription getPlatformTrusted(String platformName, String options) {
+         String ctSymVersion;
+ 
+         if (PREVIEW_OPTION.equals(options)) {
+             ctSymVersion = CT_SYM_PREVIEW_VERSION;
+         } else {
+             ctSymVersion =
+                     StringUtils.toUpperCase(Integer.toString(Integer.parseInt(platformName), Character.MAX_RADIX));
+         }
+ 
+         return new PlatformDescriptionImpl(platformName, ctSymVersion);
      }
  
      private static final String[] symbolFileLocation = { "lib", "ct.sym" };
  
      // These must match attributes defined in ZipFileSystem.java.

@@ -130,10 +144,15 @@
                  for (Path section : dir) {
                      if (section.getFileName().toString().contains("-"))
                          continue;
                      for (char ver : section.getFileName().toString().toCharArray()) {
                          String verString = Character.toString(ver);
+ 
+                         if (CT_SYM_PREVIEW_VERSION.equals(verString)) {
+                             continue; //ignore - preview is just an option
+                         }
+ 
                          Target t = Target.lookup("" + Integer.parseInt(verString, Character.MAX_RADIX));
  
                          if (t != null) {
                              SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(t));
                          }

@@ -152,14 +171,13 @@
  
          private final Map<Path, FileSystem> ctSym2FileSystem = new HashMap<>();
          private final String sourceVersion;
          private final String ctSymVersion;
  
-         PlatformDescriptionImpl(String sourceVersion) {
+         PlatformDescriptionImpl(String sourceVersion, String ctSymVersion) {
              this.sourceVersion = sourceVersion;
-             this.ctSymVersion =
-                     StringUtils.toUpperCase(Integer.toString(Integer.parseInt(sourceVersion), Character.MAX_RADIX));
+             this.ctSymVersion = ctSymVersion;
          }
  
          @Override
          public JavaFileManager getFileManager() {
              Context context = new Context();
< prev index next >