8245847: Update Profile.java to not require per-release updates

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2020-05-26 13:25:23 -07:00
parent 0400119e5b
commit aabcf9f792
3 changed files with 11 additions and 24 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac
test/langtools/tools/javac/profiles

@ -40,12 +40,9 @@ import static com.sun.tools.javac.main.Option.PROFILE;
* deletion without notice.</b>
*/
public enum Profile {
COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10,
Target.JDK1_11, Target.JDK1_12, Target.JDK1_13, Target.JDK1_14, Target.JDK1_15),
COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10,
Target.JDK1_11, Target.JDK1_12, Target.JDK1_13, Target.JDK1_14, Target.JDK1_15),
COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10,
Target.JDK1_11, Target.JDK1_12, Target.JDK1_13, Target.JDK1_14, Target.JDK1_15),
COMPACT1("compact1", 1, Target.JDK1_8),
COMPACT2("compact2", 2, Target.JDK1_8),
COMPACT3("compact3", 3, Target.JDK1_8),
DEFAULT {
@Override

@ -547,7 +547,8 @@ public class Arguments {
String profileString = options.get(Option.PROFILE);
if (profileString != null) {
Profile profile = Profile.lookup(profileString);
if (!profile.isValid(target)) {
if (target.compareTo(Target.JDK1_8) <= 0 && !profile.isValid(target)) {
// note: -profile not permitted for target >= 9, so error (below) not warning (here)
reportDiag(Warnings.ProfileTargetConflict(profile, target));
}

@ -147,28 +147,17 @@ public class ProfileOptionTest {
if (ise != null)
error("unexpected exception from compiler: " + ise);
break;
case JDK1_9:
case JDK1_10:
case JDK1_11:
case JDK1_12:
case JDK1_13:
case JDK1_14:
case JDK1_15:
if (p == Profile.DEFAULT)
break;
if (ise == null)
error("IllegalStateException not thrown as expected");
else if (!ise.getMessage().contains("option -profile " +
"not allowed with target " + t.name)) {
error("exception not thrown as expected: " + ise);
}
break;
default:
if (p == Profile.DEFAULT)
break;
if (ise == null)
error("IllegalStateException not thrown as expected");
else if (!ise.getMessage().contains("profile " + p.name
else if (t.compareTo(Target.JDK1_9) >= 0) {
if (!ise.getMessage().contains("option -profile " +
"not allowed with target " + t.name)) {
error("exception not thrown as expected: " + ise);
}
} else if (!ise.getMessage().contains("profile " + p.name
+ " is not valid for target release " + t.name)) {
error("exception not thrown as expected: " + ise);
}