langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java
changeset 39369 0469f052203d
parent 38908 f0c186d76c8a
child 39370 437ba9bd2582
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Thu Jun 30 22:39:09 2016 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Fri Jul 01 14:16:28 2016 -0700
@@ -89,6 +89,7 @@
     final Supplier<String> tempVariableNameGenerator;
     final BiFunction<Snippet, Integer, String> idGenerator;
     final List<String> extraRemoteVMOptions;
+    final List<String> extraCompilerOptions;
     final ExecutionControl executionControl;
 
     private int nextKeyIndex = 1;
@@ -112,6 +113,7 @@
         this.tempVariableNameGenerator = b.tempVariableNameGenerator;
         this.idGenerator = b.idGenerator;
         this.extraRemoteVMOptions = b.extraRemoteVMOptions;
+        this.extraCompilerOptions = b.extraCompilerOptions;
         this.executionControl = b.executionControl==null
                 ? new FailOverExecutionControl(
                         new JDIExecutionControl(),
@@ -151,6 +153,7 @@
         Supplier<String> tempVariableNameGenerator = null;
         BiFunction<Snippet, Integer, String> idGenerator = null;
         List<String> extraRemoteVMOptions = new ArrayList<>();
+        List<String> extraCompilerOptions = new ArrayList<>();
         ExecutionControl executionControl;
 
         Builder() { }
@@ -289,6 +292,21 @@
         }
 
         /**
+         * Adds compiler options.  These additional options will be used on
+         * parsing, analysis, and code generation calls to the compiler.
+         * Options which interfere with results are not supported and have
+         * undefined effects on JShell's operation.
+         *
+         * @param options the addition options for compiler invocations
+         * @return the {@code Builder} instance (for use in chained
+         * initialization)
+         */
+        public Builder compilerOptions(String... options) {
+            this.extraCompilerOptions.addAll(Arrays.asList(options));
+            return this;
+        }
+
+        /**
          * Sets the custom engine for execution. Snippet execution will be
          * provided by the specified {@link ExecutionControl} instance.
          *