changeset 59442:1bda088f2ed7

8245847: Update Profile.java to not require per-release updates Reviewed-by: darcy
author jjg
date Tue, 26 May 2020 13:25:23 -0700
parents 08a274c8b201
children 22c7504668c5
files src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java test/langtools/tools/javac/profiles/ProfileOptionTest.java
diffstat 3 files changed, 11 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java	Tue May 26 21:20:34 2020 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java	Tue May 26 13:25:23 2020 -0700
@@ -40,12 +40,9 @@
  *  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
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Tue May 26 21:20:34 2020 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Tue May 26 13:25:23 2020 -0700
@@ -547,7 +547,8 @@
         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));
             }
 
--- a/test/langtools/tools/javac/profiles/ProfileOptionTest.java	Tue May 26 21:20:34 2020 +0100
+++ b/test/langtools/tools/javac/profiles/ProfileOptionTest.java	Tue May 26 13:25:23 2020 -0700
@@ -147,28 +147,17 @@
                         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);
                         }