src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java
changeset 49580 62b908c9f0e6
parent 49278 31c5e0d5f4c3
child 49822 53aae0c219e6
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Thu Apr 12 09:23:34 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Thu Apr 12 13:55:20 2018 +0100
@@ -536,6 +536,20 @@
             }
         }
 
+        if (options.isSet(Option.PREVIEW)) {
+            if (sourceString == null) {
+                //enable-preview must be used with explicit -source or --release
+                error("err.preview.without.source.or.release");
+                return false;
+            } else if (source != Source.DEFAULT) {
+                //enable-preview must be used with latest source version
+                error("err.preview.not.latest",
+                        sourceString,
+                        Source.DEFAULT.name);
+                return false;
+            }
+        }
+
         String profileString = options.get(Option.PROFILE);
         if (profileString != null) {
             Profile profile = Profile.lookup(profileString);