src/share/classes/com/sun/tools/javac/jvm/Profile.java

Print this page




  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.tools.javac.jvm;
  26 
  27 import com.sun.tools.javac.util.Context;
  28 import com.sun.tools.javac.util.Options;
  29 import java.util.EnumSet;
  30 import java.util.Set;
  31 
  32 import static com.sun.tools.javac.main.Option.PROFILE;
  33 
  34 /** The target profile.
  35  *
  36  *  <p><b>This is NOT part of any supported API.
  37  *  If you write code that depends on this, you do so at your own risk.
  38  *  This code and its internal interfaces are subject to change or
  39  *  deletion without notice.</b>
  40  */
  41 public enum Profile {
  42     COMPACT1("compact1", 1, Target.JDK1_8),
  43     COMPACT2("compact2", 2, Target.JDK1_8),
  44     COMPACT3("compact3", 3, Target.JDK1_8),
  45 
  46     DEFAULT {
  47         @Override
  48         public boolean isValid(Target t) {
  49             return true;
  50         }
  51     };
  52 
  53     private static final Context.Key<Profile> profileKey =
  54         new Context.Key<Profile>();
  55 
  56     public static Profile instance(Context context) {
  57         Profile instance = context.get(profileKey);
  58         if (instance == null) {
  59             Options options = Options.instance(context);
  60             String profileString = options.get(PROFILE);
  61             if (profileString != null) instance = lookup(profileString);
  62             if (instance == null) instance = DEFAULT;
  63             context.put(profileKey, instance);
  64         }




  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.tools.javac.jvm;
  26 
  27 import com.sun.tools.javac.util.Context;
  28 import com.sun.tools.javac.util.Options;
  29 import java.util.EnumSet;
  30 import java.util.Set;
  31 
  32 import static com.sun.tools.javac.main.Option.PROFILE;
  33 
  34 /** The target profile.
  35  *
  36  *  <p><b>This is NOT part of any supported API.
  37  *  If you write code that depends on this, you do so at your own risk.
  38  *  This code and its internal interfaces are subject to change or
  39  *  deletion without notice.</b>
  40  */
  41 public enum Profile {
  42     COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9),
  43     COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9),
  44     COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9),
  45 
  46     DEFAULT {
  47         @Override
  48         public boolean isValid(Target t) {
  49             return true;
  50         }
  51     };
  52 
  53     private static final Context.Key<Profile> profileKey =
  54         new Context.Key<Profile>();
  55 
  56     public static Profile instance(Context context) {
  57         Profile instance = context.get(profileKey);
  58         if (instance == null) {
  59             Options options = Options.instance(context);
  60             String profileString = options.get(PROFILE);
  61             if (profileString != null) instance = lookup(profileString);
  62             if (instance == null) instance = DEFAULT;
  63             context.put(profileKey, instance);
  64         }