23 * questions. 24 */ 25 26 package com.sun.tools.javac.jvm; 27 28 import com.sun.tools.javac.util.Context; 29 import com.sun.tools.javac.util.Options; 30 import java.util.EnumSet; 31 import java.util.Set; 32 33 import static com.sun.tools.javac.main.Option.PROFILE; 34 35 /** The target profile. 36 * 37 * <p><b>This is NOT part of any supported API. 38 * If you write code that depends on this, you do so at your own risk. 39 * This code and its internal interfaces are subject to change or 40 * deletion without notice.</b> 41 */ 42 public enum Profile { 43 COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), 44 COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), 45 COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), 46 47 DEFAULT { 48 @Override 49 public boolean isValid(Target t) { 50 return true; 51 } 52 }; 53 54 private static final Context.Key<Profile> profileKey = new Context.Key<>(); 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 } 65 return instance; | 23 * questions. 24 */ 25 26 package com.sun.tools.javac.jvm; 27 28 import com.sun.tools.javac.util.Context; 29 import com.sun.tools.javac.util.Options; 30 import java.util.EnumSet; 31 import java.util.Set; 32 33 import static com.sun.tools.javac.main.Option.PROFILE; 34 35 /** The target profile. 36 * 37 * <p><b>This is NOT part of any supported API. 38 * If you write code that depends on this, you do so at your own risk. 39 * This code and its internal interfaces are subject to change or 40 * deletion without notice.</b> 41 */ 42 public enum Profile { 43 COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11), 44 COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11), 45 COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11), 46 47 DEFAULT { 48 @Override 49 public boolean isValid(Target t) { 50 return true; 51 } 52 }; 53 54 private static final Context.Key<Profile> profileKey = new Context.Key<>(); 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 } 65 return instance; |