src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileProperties.java

Print this page
rev 2819 : imported patch my-classpath-deps-00


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.sjavac;
  27 
  28 import java.io.*;







  29 import java.net.URI;
  30 import java.text.MessageFormat;
  31 import java.util.ArrayList;
  32 import java.util.Collections;

  33 import java.util.Iterator;
  34 import java.util.List;

  35 import java.util.Properties;
  36 import java.util.Set;
  37 import java.util.HashSet;
  38 import java.util.Map;
  39 
  40 import com.sun.tools.sjavac.options.Options;

  41 import com.sun.tools.sjavac.server.Sjavac;
  42 
  43 /**
  44  * Compile properties transform a properties file into a Java source file.
  45  * Java has built in support for reading properties from either a text file
  46  * in the source or a compiled java source file.
  47  *
  48  *  <p><b>This is NOT part of any supported API.
  49  *  If you write code that depends on this, you do so at your own risk.
  50  *  This code and its internal interfaces are subject to change or
  51  *  deletion without notice.</b>
  52  */
  53 public class CompileProperties implements Transformer {
  54     // Any extra information passed from the command line, for example if:
  55     // -tr .proppp=com.sun.tools.javac.smart.CompileProperties,sun.util.resources.LocaleNamesBundle
  56     // then extra will be "sun.util.resources.LocaleNamesBundle"
  57     String extra;
  58 
  59     public void setExtra(String e) {
  60         extra = e;
  61     }
  62 
  63     public void setExtra(Options a) {
  64     }
  65 
  66     public boolean transform(Sjavac sjavac,
  67                              Map<String,Set<URI>> pkgSrcs,
  68                              Set<URI>             visibleSrcs,
  69                              Map<URI,Set<String>> visibleClasses,
  70                              Map<String,Set<String>> oldPackageDependents,
  71                              URI destRoot,
  72                              Map<String,Set<URI>>    packageArtifacts,
  73                              Map<String,Set<String>> packageDependencies,
  74                              Map<String,String>      packagePublicApis,


  75                              int debugLevel,
  76                              boolean incremental,
  77                              int numCores,
  78                              PrintStream out,
  79                              PrintStream err) {
  80         boolean rc = true;
  81         for (String pkgName : pkgSrcs.keySet()) {
  82             String pkgNameF = Util.toFileSystemPath(pkgName);
  83             for (URI u : pkgSrcs.get(pkgName)) {
  84                 File src = new File(u);
  85                 boolean r = compile(pkgName, pkgNameF, src, new File(destRoot), debugLevel,
  86                                     packageArtifacts);
  87                 if (r == false) {
  88                     rc = false;
  89                 }
  90             }
  91         }
  92         return rc;
  93     }
  94 




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.sjavac;
  27 
  28 import java.io.BufferedWriter;
  29 import java.io.File;
  30 import java.io.FileInputStream;
  31 import java.io.FileOutputStream;
  32 import java.io.IOException;
  33 import java.io.OutputStreamWriter;
  34 import java.io.PrintStream;
  35 import java.io.Writer;
  36 import java.net.URI;
  37 import java.text.MessageFormat;
  38 import java.util.ArrayList;
  39 import java.util.Collections;
  40 import java.util.HashSet;
  41 import java.util.Iterator;
  42 import java.util.List;
  43 import java.util.Map;
  44 import java.util.Properties;
  45 import java.util.Set;


  46 
  47 import com.sun.tools.sjavac.options.Options;
  48 import com.sun.tools.sjavac.pubapi.PubApi;
  49 import com.sun.tools.sjavac.server.Sjavac;
  50 
  51 /**
  52  * Compile properties transform a properties file into a Java source file.
  53  * Java has built in support for reading properties from either a text file
  54  * in the source or a compiled java source file.
  55  *
  56  *  <p><b>This is NOT part of any supported API.
  57  *  If you write code that depends on this, you do so at your own risk.
  58  *  This code and its internal interfaces are subject to change or
  59  *  deletion without notice.</b>
  60  */
  61 public class CompileProperties implements Transformer {
  62     // Any extra information passed from the command line, for example if:
  63     // -tr .proppp=com.sun.tools.javac.smart.CompileProperties,sun.util.resources.LocaleNamesBundle
  64     // then extra will be "sun.util.resources.LocaleNamesBundle"
  65     String extra;
  66 
  67     public void setExtra(String e) {
  68         extra = e;
  69     }
  70 
  71     public void setExtra(Options a) {
  72     }
  73 
  74     public boolean transform(Sjavac sjavac,
  75                              Map<String,Set<URI>> pkgSrcs,
  76                              Set<URI>             visibleSrcs,
  77                              Map<URI,Set<String>> visibleClasses,
  78                              Map<String,Set<String>> oldPackageDependents,
  79                              URI destRoot,
  80                              Map<String,Set<URI>>    packageArtifacts,
  81                              Map<String,Map<String, Set<String>>> packageDependencies,
  82                              Map<String,Map<String, Set<String>>> packageCpDependencies,
  83                              Map<String, PubApi> packagePublicApis,
  84                              Map<String, PubApi> dependencyPublicApis,
  85                              int debugLevel,
  86                              boolean incremental,
  87                              int numCores,
  88                              PrintStream out,
  89                              PrintStream err) {
  90         boolean rc = true;
  91         for (String pkgName : pkgSrcs.keySet()) {
  92             String pkgNameF = Util.toFileSystemPath(pkgName);
  93             for (URI u : pkgSrcs.get(pkgName)) {
  94                 File src = new File(u);
  95                 boolean r = compile(pkgName, pkgNameF, src, new File(destRoot), debugLevel,
  96                                     packageArtifacts);
  97                 if (r == false) {
  98                     rc = false;
  99                 }
 100             }
 101         }
 102         return rc;
 103     }
 104