8150632: jdk.jshell.TaskFactory should use jdk.Version to check for java.specification.version

Reviewed-by: rfield
This commit is contained in:
Volker Simonis 2016-03-10 08:54:29 +01:00
parent 0a352526f3
commit eb9a8ddcc4

View file

@ -61,6 +61,7 @@ import javax.lang.model.util.Elements;
import javax.tools.FileObject; import javax.tools.FileObject;
import jdk.jshell.MemoryFileManager.SourceMemoryJavaFileObject; import jdk.jshell.MemoryFileManager.SourceMemoryJavaFileObject;
import jdk.jshell.ClassTracker.ClassInfo; import jdk.jshell.ClassTracker.ClassInfo;
import jdk.Version;
/** /**
* The primary interface to the compiler API. Parsing, analysis, and * The primary interface to the compiler API. Parsing, analysis, and
@ -73,6 +74,7 @@ class TaskFactory {
private final MemoryFileManager fileManager; private final MemoryFileManager fileManager;
private final JShell state; private final JShell state;
private String classpath = System.getProperty("java.class.path"); private String classpath = System.getProperty("java.class.path");
private final static Version INITIAL_SUPPORTED_VER = Version.parse("9");
TaskFactory(JShell state) { TaskFactory(JShell state) {
this.state = state; this.state = state;
@ -80,7 +82,8 @@ class TaskFactory {
if (compiler == null) { if (compiler == null) {
throw new UnsupportedOperationException("Compiler not available, must be run with full JDK 9."); throw new UnsupportedOperationException("Compiler not available, must be run with full JDK 9.");
} }
if (!System.getProperty("java.specification.version").equals("9")) { Version current = Version.parse(System.getProperty("java.specification.version"));
if (INITIAL_SUPPORTED_VER.compareToIgnoreOpt(current) > 0) {
throw new UnsupportedOperationException("Wrong compiler, must be run with full JDK 9."); throw new UnsupportedOperationException("Wrong compiler, must be run with full JDK 9.");
} }
this.fileManager = new MemoryFileManager( this.fileManager = new MemoryFileManager(