< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java

Print this page




  44     JDK1_1("1.1", 45, 3),
  45     JDK1_2("1.2", 46, 0),
  46     JDK1_3("1.3", 47, 0),
  47 
  48     /** J2SE1.4 = Merlin. */
  49     JDK1_4("1.4", 48, 0),
  50 
  51     /** JDK 5, codename Tiger. */
  52     JDK1_5("1.5", 49, 0),
  53 
  54     /** JDK 6. */
  55     JDK1_6("1.6", 50, 0),
  56 
  57     /** JDK 7. */
  58     JDK1_7("1.7", 51, 0),
  59 
  60     /** JDK 8. */
  61     JDK1_8("1.8", 52, 0),
  62 
  63     /** JDK 9. */
  64     JDK1_9("1.9", 53, 0);



  65 
  66     private static final Context.Key<Target> targetKey = new Context.Key<>();
  67 
  68     public static Target instance(Context context) {
  69         Target instance = context.get(targetKey);
  70         if (instance == null) {
  71             Options options = Options.instance(context);
  72             String targetString = options.get(TARGET);
  73             if (targetString != null) instance = lookup(targetString);
  74             if (instance == null) instance = DEFAULT;
  75             context.put(targetKey, instance);
  76         }
  77         return instance;
  78     }
  79 
  80     public static final Target MIN = Target.JDK1_6;
  81 
  82     private static final Target MAX = values()[values().length - 1];
  83 
  84     private static final Map<String,Target> tab = new HashMap<>();
  85     static {
  86         for (Target t : values()) {
  87             tab.put(t.name, t);
  88         }
  89         tab.put("5", JDK1_5);
  90         tab.put("6", JDK1_6);
  91         tab.put("7", JDK1_7);
  92         tab.put("8", JDK1_8);
  93         tab.put("9", JDK1_9);

  94     }
  95 
  96     public final String name;
  97     public final int majorVersion;
  98     public final int minorVersion;
  99     private Target(String name, int majorVersion, int minorVersion) {
 100         this.name = name;
 101         this.majorVersion = majorVersion;
 102         this.minorVersion = minorVersion;
 103     }
 104 
 105     public static final Target DEFAULT = JDK1_9;
 106 
 107     public static Target lookup(String name) {
 108         return tab.get(name);
 109     }
 110 
 111     /** Return the character to be used in constructing synthetic
 112      *  identifiers, where not specified by the JLS.
 113      */
 114     public char syntheticNameChar() {
 115         return '$';
 116     }
 117 
 118     /** Does the VM support an invokedynamic instruction?
 119      */
 120     public boolean hasInvokedynamic() {
 121         return compareTo(JDK1_7) >= 0;
 122     }
 123 
 124     /** Does the target JDK contains the java.util.Objects class?
 125      */




  44     JDK1_1("1.1", 45, 3),
  45     JDK1_2("1.2", 46, 0),
  46     JDK1_3("1.3", 47, 0),
  47 
  48     /** J2SE1.4 = Merlin. */
  49     JDK1_4("1.4", 48, 0),
  50 
  51     /** JDK 5, codename Tiger. */
  52     JDK1_5("1.5", 49, 0),
  53 
  54     /** JDK 6. */
  55     JDK1_6("1.6", 50, 0),
  56 
  57     /** JDK 7. */
  58     JDK1_7("1.7", 51, 0),
  59 
  60     /** JDK 8. */
  61     JDK1_8("1.8", 52, 0),
  62 
  63     /** JDK 9. */
  64     JDK1_9("1.9", 53, 0),
  65 
  66     /** JDK 10, initially an alias for 9 */
  67     JDK1_10("1.10", 53, 0);
  68 
  69     private static final Context.Key<Target> targetKey = new Context.Key<>();
  70 
  71     public static Target instance(Context context) {
  72         Target instance = context.get(targetKey);
  73         if (instance == null) {
  74             Options options = Options.instance(context);
  75             String targetString = options.get(TARGET);
  76             if (targetString != null) instance = lookup(targetString);
  77             if (instance == null) instance = DEFAULT;
  78             context.put(targetKey, instance);
  79         }
  80         return instance;
  81     }
  82 
  83     public static final Target MIN = Target.JDK1_6;
  84 
  85     private static final Target MAX = values()[values().length - 1];
  86 
  87     private static final Map<String,Target> tab = new HashMap<>();
  88     static {
  89         for (Target t : values()) {
  90             tab.put(t.name, t);
  91         }
  92         tab.put("5", JDK1_5);
  93         tab.put("6", JDK1_6);
  94         tab.put("7", JDK1_7);
  95         tab.put("8", JDK1_8);
  96         tab.put("9", JDK1_9);
  97         tab.put("10", JDK1_10);
  98     }
  99 
 100     public final String name;
 101     public final int majorVersion;
 102     public final int minorVersion;
 103     private Target(String name, int majorVersion, int minorVersion) {
 104         this.name = name;
 105         this.majorVersion = majorVersion;
 106         this.minorVersion = minorVersion;
 107     }
 108 
 109     public static final Target DEFAULT = values()[values().length - 1];
 110 
 111     public static Target lookup(String name) {
 112         return tab.get(name);
 113     }
 114 
 115     /** Return the character to be used in constructing synthetic
 116      *  identifiers, where not specified by the JLS.
 117      */
 118     public char syntheticNameChar() {
 119         return '$';
 120     }
 121 
 122     /** Does the VM support an invokedynamic instruction?
 123      */
 124     public boolean hasInvokedynamic() {
 125         return compareTo(JDK1_7) >= 0;
 126     }
 127 
 128     /** Does the target JDK contains the java.util.Objects class?
 129      */


< prev index next >