langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java
changeset 26107 a4a156a33c94
parent 26098 32588700060b
parent 25874 83c19f00452c
child 29426 1e47176eefb9
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java	Wed Jul 05 19:56:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java	Mon Aug 18 10:59:44 2014 +0100
@@ -32,16 +32,23 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
 
 import com.sun.tools.sjavac.Transformer;
 
 /**
  * Instances of this class represent values for sjavac command line options.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
  */
 public class Options {
 
     // Output directories
-    private Path destDir, genSrcDir, headerDir;
+    private Path destDir, genSrcDir, headerDir, stateDir;
 
     // Input directories
     private List<SourceLocation> sources = new ArrayList<>();
@@ -51,7 +58,8 @@
 
     private String logLevel = "info";
 
-    private boolean permitUnidentifiedArtifact = false;
+    private Set<String> permitted_artifacts = new HashSet<>();
+    private boolean permitUnidentifiedArtifacts = false;
     private boolean permitSourcesInDefaultPackage = false;
 
     private Path sourceReferenceList;
@@ -86,6 +94,11 @@
         return headerDir;
     }
 
+    /** Get the path for the state directory, defaults to destDir. */
+    public Path getStateDir() {
+        return stateDir != null ? stateDir : destDir;
+    }
+
     /** Get all source locations for files to be compiled */
     public List<SourceLocation> getSources() {
         return sources;
@@ -114,10 +127,15 @@
         return logLevel;
     }
 
+    /** Returns true iff the artifact is permitted in the output dir. */
+    public boolean isUnidentifiedArtifactPermitted(String f) {
+        return permitted_artifacts.contains(f);
+    }
+
     /** Returns true iff artifacts in the output directories should be kept,
      * even if they would not be generated in a clean build. */
-    public boolean isUnidentifiedArtifactPermitted() {
-        return permitUnidentifiedArtifact;
+    public boolean areUnidentifiedArtifactsPermitted() {
+        return permitUnidentifiedArtifacts;
     }
 
     /** Returns true iff sources in the default package should be permitted. */
@@ -176,14 +194,6 @@
         return false;
     }
 
-    /** Returns true iff an @-file is among the javac arguments */
-    public boolean isAtFilePresent() {
-        for (String javacArg : javacArgs)
-            if (javacArg.startsWith("@"))
-                return true;
-        return false;
-    }
-
     /**
      * Returns a string representation of the options that affect the result of
      * the compilation. (Used for saving the state of the options used in a
@@ -239,6 +249,9 @@
         if (destDir != null)
             args.addArg(Option.D, destDir.normalize());
 
+        if (stateDir != null)
+            args.addArg(Option.STATE_DIR, stateDir.normalize());
+
         // Source roots
         args.addSourceLocations(Option.SRC, sources);
         args.addSourceLocations(Option.SOURCEPATH, sourceSearchPaths);
@@ -249,7 +262,11 @@
         if (permitSourcesInDefaultPackage)
             args.addArg(Option.PERMIT_SOURCES_WITHOUT_PACKAGE);
 
-        if (permitUnidentifiedArtifact)
+        for (String f : permitted_artifacts) {
+            args.addArg(Option.PERMIT_ARTIFACT, f);
+        }
+
+        if (permitUnidentifiedArtifacts)
             args.addArg(Option.PERMIT_UNIDENTIFIED_ARTIFACTS);
 
         // Translation rules
@@ -327,6 +344,7 @@
 
         boolean headerProvided = false;
         boolean genSrcProvided = false;
+        boolean stateProvided = false;
 
         @Override
         public void reportError(String msg) {
@@ -399,8 +417,13 @@
         }
 
         @Override
+        public void permitArtifact(String f) {
+            permitted_artifacts.add(f);
+        }
+
+        @Override
         public void permitUnidentifiedArtifacts() {
-            permitUnidentifiedArtifact = true;
+            permitUnidentifiedArtifacts = true;
         }
 
         @Override
@@ -465,6 +488,16 @@
             headerDir = dir.toAbsolutePath();
         }
 
+        @Override
+        public void stateDir(Path dir) {
+            if (stateProvided) {
+                reportError("State directory already specified.");
+                return;
+            }
+            stateProvided = true;
+            stateDir = dir.toAbsolutePath();
+        }
+
         private List<SourceLocation> createSourceLocations(List<Path> paths) {
             List<SourceLocation> result = new ArrayList<>();
             for (Path path : paths) {