< prev index next >

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

Print this page




  69     /** JDK 11. */
  70     JDK1_11("11", 55, 0),
  71 
  72     /** JDK 12. */
  73     JDK1_12("12", 56, 0);
  74 
  75     private static final Context.Key<Target> targetKey = new Context.Key<>();
  76 
  77     public static Target instance(Context context) {
  78         Target instance = context.get(targetKey);
  79         if (instance == null) {
  80             Options options = Options.instance(context);
  81             String targetString = options.get(TARGET);
  82             if (targetString != null) instance = lookup(targetString);
  83             if (instance == null) instance = DEFAULT;
  84             context.put(targetKey, instance);
  85         }
  86         return instance;
  87     }
  88 
  89     public static final Target MIN = Target.JDK1_6;
  90 
  91     private static final Target MAX = values()[values().length - 1];
  92 
  93     private static final Map<String,Target> tab = new HashMap<>();
  94     static {
  95         for (Target t : values()) {
  96             tab.put(t.name, t);
  97         }
  98         tab.put("5", JDK1_5);
  99         tab.put("6", JDK1_6);
 100         tab.put("7", JDK1_7);
 101         tab.put("8", JDK1_8);
 102         tab.put("9", JDK1_9);
 103         tab.put("10", JDK1_10);
 104         tab.put("11", JDK1_11);
 105         tab.put("12", JDK1_12);
 106     }
 107 
 108     public final String name;
 109     public final int majorVersion;
 110     public final int minorVersion;
 111     private Target(String name, int majorVersion, int minorVersion) {
 112         this.name = name;
 113         this.majorVersion = majorVersion;
 114         this.minorVersion = minorVersion;
 115     }
 116 
 117     public static final Target DEFAULT = values()[values().length - 1];
 118 
 119     public static Target lookup(String name) {
 120         return tab.get(name);
 121     }
 122 
 123     /** Return the character to be used in constructing synthetic
 124      *  identifiers, where not specified by the JLS.
 125      */
 126     public char syntheticNameChar() {
 127         return '$';
 128     }
 129 
 130     /** Does the VM support an invokedynamic instruction?
 131      */
 132     public boolean hasInvokedynamic() {
 133         return compareTo(JDK1_7) >= 0;
 134     }
 135 
 136     /** Does the target JDK contains the java.util.Objects class?
 137      */
 138     public boolean hasObjects() {
 139         return compareTo(JDK1_7) >= 0;
 140     }
 141 
 142     /** Does the target VM expect MethodParameters attributes?
 143      */
 144     public boolean hasMethodParameters() {
 145         return compareTo(JDK1_8) >= 0;
 146     }
 147 
 148     /** Does the VM support polymorphic method handle invocation?
 149      *  Affects the linkage information output to the classfile.
 150      *  An alias for {@code hasInvokedynamic}, since all the JSR 292 features appear together.
 151      */
 152     public boolean hasMethodHandles() {
 153         return hasInvokedynamic();
 154     }
 155 
 156     /** Does the target JDK contain StringConcatFactory class?
 157      */
 158     public boolean hasStringConcatFactory() {
 159         return compareTo(JDK1_9) >= 0;
 160     }
 161 
 162     /** Value of platform release used to access multi-release jar files
 163      */
 164     public String multiReleaseValue() {
 165         return Integer.toString(this.ordinal() - Target.JDK1_1.ordinal() + 1);
 166     }
 167 
 168     /** All modules that export an API are roots when compiling code in the unnamed
 169      *  module and targeting 11 or newer.
 170      */
 171     public boolean allApiModulesAreRoots() {
 172         return compareTo(JDK1_11) >= 0;
 173     }


  69     /** JDK 11. */
  70     JDK1_11("11", 55, 0),
  71 
  72     /** JDK 12. */
  73     JDK1_12("12", 56, 0);
  74 
  75     private static final Context.Key<Target> targetKey = new Context.Key<>();
  76 
  77     public static Target instance(Context context) {
  78         Target instance = context.get(targetKey);
  79         if (instance == null) {
  80             Options options = Options.instance(context);
  81             String targetString = options.get(TARGET);
  82             if (targetString != null) instance = lookup(targetString);
  83             if (instance == null) instance = DEFAULT;
  84             context.put(targetKey, instance);
  85         }
  86         return instance;
  87     }
  88 
  89     public static final Target MIN = Target.JDK1_7;
  90 
  91     private static final Target MAX = values()[values().length - 1];
  92 
  93     private static final Map<String,Target> tab = new HashMap<>();
  94     static {
  95         for (Target t : values()) {
  96             tab.put(t.name, t);
  97         }
  98         tab.put("5", JDK1_5);
  99         tab.put("6", JDK1_6);
 100         tab.put("7", JDK1_7);
 101         tab.put("8", JDK1_8);
 102         tab.put("9", JDK1_9);
 103         tab.put("10", JDK1_10);
 104         tab.put("11", JDK1_11);
 105         tab.put("12", JDK1_12);
 106     }
 107 
 108     public final String name;
 109     public final int majorVersion;
 110     public final int minorVersion;
 111     private Target(String name, int majorVersion, int minorVersion) {
 112         this.name = name;
 113         this.majorVersion = majorVersion;
 114         this.minorVersion = minorVersion;
 115     }
 116 
 117     public static final Target DEFAULT = values()[values().length - 1];
 118 
 119     public static Target lookup(String name) {
 120         return tab.get(name);
 121     }
 122 
 123     /** Return the character to be used in constructing synthetic
 124      *  identifiers, where not specified by the JLS.
 125      */
 126     public char syntheticNameChar() {
 127         return '$';
 128     }
 129 












 130     /** Does the target VM expect MethodParameters attributes?
 131      */
 132     public boolean hasMethodParameters() {
 133         return compareTo(JDK1_8) >= 0;








 134     }
 135 
 136     /** Does the target JDK contain StringConcatFactory class?
 137      */
 138     public boolean hasStringConcatFactory() {
 139         return compareTo(JDK1_9) >= 0;
 140     }
 141 
 142     /** Value of platform release used to access multi-release jar files
 143      */
 144     public String multiReleaseValue() {
 145         return Integer.toString(this.ordinal() - Target.JDK1_1.ordinal() + 1);
 146     }
 147 
 148     /** All modules that export an API are roots when compiling code in the unnamed
 149      *  module and targeting 11 or newer.
 150      */
 151     public boolean allApiModulesAreRoots() {
 152         return compareTo(JDK1_11) >= 0;
 153     }
< prev index next >