equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
68 JDK1_7("1.7"), |
68 JDK1_7("1.7"), |
69 |
69 |
70 /** 1.8 lambda expressions and default methods. */ |
70 /** 1.8 lambda expressions and default methods. */ |
71 JDK1_8("1.8"), |
71 JDK1_8("1.8"), |
72 |
72 |
73 /** 1.9 covers the to be determined language features that will be added in JDK 9. */ |
73 /** 1.9 modularity. */ |
74 JDK1_9("1.9"); |
74 JDK1_9("1.9"), |
|
75 |
|
76 /** 1.10 covers the to be determined language features that will be added in JDK 10. */ |
|
77 JDK1_10("1.10"); |
75 |
78 |
76 private static final Context.Key<Source> sourceKey = new Context.Key<>(); |
79 private static final Context.Key<Source> sourceKey = new Context.Key<>(); |
77 |
80 |
78 public static Source instance(Context context) { |
81 public static Source instance(Context context) { |
79 Source instance = context.get(sourceKey); |
82 Source instance = context.get(sourceKey); |
97 tab.put("5", JDK1_5); // Make 5 an alias for 1.5 |
100 tab.put("5", JDK1_5); // Make 5 an alias for 1.5 |
98 tab.put("6", JDK1_6); // Make 6 an alias for 1.6 |
101 tab.put("6", JDK1_6); // Make 6 an alias for 1.6 |
99 tab.put("7", JDK1_7); // Make 7 an alias for 1.7 |
102 tab.put("7", JDK1_7); // Make 7 an alias for 1.7 |
100 tab.put("8", JDK1_8); // Make 8 an alias for 1.8 |
103 tab.put("8", JDK1_8); // Make 8 an alias for 1.8 |
101 tab.put("9", JDK1_9); // Make 9 an alias for 1.9 |
104 tab.put("9", JDK1_9); // Make 9 an alias for 1.9 |
|
105 tab.put("10", JDK1_10); // Make 10 an alias for 1.10 |
102 } |
106 } |
103 |
107 |
104 private Source(String name) { |
108 private Source(String name) { |
105 this.name = name; |
109 this.name = name; |
106 } |
110 } |
114 public static Source lookup(String name) { |
118 public static Source lookup(String name) { |
115 return tab.get(name); |
119 return tab.get(name); |
116 } |
120 } |
117 |
121 |
118 public Target requiredTarget() { |
122 public Target requiredTarget() { |
|
123 if (this.compareTo(JDK1_10) >= 0) return Target.JDK1_10; |
119 if (this.compareTo(JDK1_9) >= 0) return Target.JDK1_9; |
124 if (this.compareTo(JDK1_9) >= 0) return Target.JDK1_9; |
120 if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8; |
125 if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8; |
121 if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7; |
126 if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7; |
122 if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6; |
127 if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6; |
123 if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5; |
128 if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5; |
238 return RELEASE_7; |
243 return RELEASE_7; |
239 case JDK1_8: |
244 case JDK1_8: |
240 return RELEASE_8; |
245 return RELEASE_8; |
241 case JDK1_9: |
246 case JDK1_9: |
242 return RELEASE_9; |
247 return RELEASE_9; |
|
248 case JDK1_10: |
|
249 return RELEASE_10; |
243 default: |
250 default: |
244 return null; |
251 return null; |
245 } |
252 } |
246 } |
253 } |
247 } |
254 } |