src/share/tools/ProjectCreator/BuildConfig.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  31     String[] context;
  32 
  33     static CompilerInterface ci;
  34     static CompilerInterface getCI() {
  35         if (ci == null) {
  36             String comp = (String)getField(null, "CompilerVersion");
  37             try {
  38                 ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance();
  39             } catch (Exception cnfe) {
  40                 System.err.println("Cannot find support for compiler " + comp);
  41                 throw new RuntimeException(cnfe.toString());
  42             }
  43         }
  44         return ci;
  45     }
  46 
  47     protected void initNames(String flavour, String build, String outDll) {
  48         if (vars == null) vars = new Hashtable();
  49 
  50         String flavourBuild =  flavour + "_" + build;



  51         put("Name", getCI().makeCfgName(flavourBuild));
  52         put("Flavour", flavour);
  53         put("Build", build);
  54 
  55         // ones mentioned above were needed to expand format
  56         String buildBase = expandFormat(getFieldString(null, "BuildBase"));
  57         String jdkDir =  getFieldString(null, "JdkTargetRoot");
  58         String sourceBase = getFieldString(null, "SourceBase");
  59         String outDir = buildBase;
  60 
  61         put("Id", flavourBuild);
  62         put("OutputDir", outDir);
  63         put("SourceBase", sourceBase);
  64         put("BuildBase", buildBase);
  65         put("OutputDll", jdkDir + Util.sep + outDll);
  66 
  67         context = new String [] {flavourBuild, flavour, build, null};
  68     }
  69 
  70     protected void init(Vector includes, Vector defines) {
  71         initDefaultDefines(defines);
  72         initDefaultCompilerFlags(includes);
  73         initDefaultLinkerFlags();
  74         handleDB((String)getFieldInContext("IncludeDB"));
  75     }
  76 
  77 
  78     protected void initDefaultCompilerFlags(Vector includes) {
  79         Vector compilerFlags = new Vector();
  80 
  81         compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
  82                                                           includes,
  83                                                           get("OutputDir")));
  84 
  85         put("CompilerFlags", compilerFlags);
  86     }
  87 
  88     protected void initDefaultLinkerFlags() {
  89         Vector linkerFlags = new Vector();
  90 
  91         linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll")));
  92 
  93         put("LinkerFlags", linkerFlags);
  94     }
  95 
  96     DirectoryTree getSourceTree(String sourceBase, String startAt) {
  97         DirectoryTree tree = new DirectoryTree();
  98 
  99         tree.addSubdirToIgnore("Codemgr_wsdata");
 100         tree.addSubdirToIgnore("deleted_files");
 101         tree.addSubdirToIgnore("SCCS");
 102         tree.setVerbose(true);
 103         if (startAt != null) {
 104             tree.readDirectory(sourceBase + File.separator + startAt);
 105         } else {
 106             tree.readDirectory(sourceBase);
 107         }
 108 
 109         return tree;
 110     }
 111 
 112 
 113     Vector getPreferredPaths(Database currentDB) {
 114         Vector preferredPaths = new Vector();
 115         // In the case of multiple files with the same name in
 116         // different subdirectories, prefer the versions specified in
 117         // the platform file as the "os_family" and "arch" macros.
 118         for (Iterator iter = currentDB.getMacros(); iter.hasNext(); ) {
 119             Macro macro = (Macro) iter.next();
 120             if (macro.name.equals("os_family") ||
 121                 macro.name.equals("arch")) {
 122                 preferredPaths.add(macro.contents);
 123             }
 124         }
 125         // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
 126         preferredPaths.add("opto");
 127 
 128         return preferredPaths;
 129     }
 130 
 131 
 132     void handleDB(String dbFile) {
 133         WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");
 134         Database db = new Database(platform, platform.defaultGrandIncludeThreshold());
 135 
 136         try {
 137             File incls = new File(get("OutputDir")+Util.sep+"incls");
 138             FileName oldInclTempl = platform.getInclFileTemplate();
 139             FileName oldGITempl = platform.getGIFileTemplate();
 140             FileName oldGDTempl = platform.getGDFileTemplate();
 141 
 142             platform.setInclFileTemplate(new FileName(platform, incls.getPath()+Util.sep,
 143                                                       "_", "", ".incl", "", ""));
 144             platform.setGIFileTemplate(new FileName(platform, incls.getPath()+Util.sep,
 145                                                     "",  "_precompiled", ".incl", "", ""));
 146 
 147             incls.mkdirs();
 148 
 149             db.get(getFieldString(null, "Platform"), dbFile);
 150             db.compute();
 151 
 152             db.put();
 153 
 154             //platform.setInclFileTemplate(oldInclTempl);
 155             //platform.setGIFileTemplate(oldInclTempl);
 156         } catch (Exception e) {
 157             e.printStackTrace();
 158             throw new RuntimeException("cannot do db: "+e);
 159         }
 160 
 161         putSpecificField("AllFilesHash", computeAllFiles(platform, db));
 162     }
 163 
 164 












 165     void addAll(Iterator i, Hashtable hash,
 166                 WinGammaPlatform platform, DirectoryTree tree,
 167                 Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) {
 168         for (; i.hasNext(); ) {
 169             String fileName = (String) i.next();
 170             if (lookupHashFieldInContext("IgnoreFile", fileName) == null) {
 171                 String prefixedName = platform.envVarPrefixedFileName(fileName,
 172                                                                       0, /* ignored */
 173                                                                       tree,
 174                                                                       preferredPaths,
 175                                                                       filesNotFound,
 176                                                                       filesDuplicate);
 177                 if (prefixedName != null) {
 178                     addTo(hash, Util.normalize(prefixedName), fileName);



 179                 }
 180             }
 181         }
 182     }
 183 
 184     void addTo(Hashtable ht, String key, String value) {
 185         ht.put(expandFormat(key), expandFormat(value));
 186     }
 187 
 188     Hashtable computeAllFiles(WinGammaPlatform platform, Database db) {
 189         Hashtable rv = new Hashtable();
 190         DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt"));
 191         Vector preferredPaths = getPreferredPaths(db);
 192 
 193         // Hold errors until end
 194         Vector filesNotFound = new Vector();
 195         Vector filesDuplicate = new Vector();
 196 

 197 
 198         // find all files
 199         Vector dbFiles = new Vector();
 200         for (Iterator i=db.getAllFiles().iterator(); i.hasNext(); ) {
 201             FileList fl = (FileList) i.next();
 202             dbFiles.add(fl.getName());



 203         }
 204         addAll(dbFiles.iterator(), rv,

 205                platform, tree,
 206                preferredPaths, filesNotFound, filesDuplicate);
 207 
 208         Vector addFiles = new Vector();
 209         collectRelevantVectors(addFiles, "AdditionalFile");
 210         addAll(addFiles.iterator(), rv,
 211                platform, tree,
 212                preferredPaths, filesNotFound, filesDuplicate);
 213 
 214         collectRelevantHashes(rv, "AdditionalGeneratedFile");
 215 
 216         if ((filesNotFound.size() != 0) ||
 217             (filesDuplicate.size() != 0)) {
 218             System.err.println("Error: some files were not found or " +
 219                                "appeared in multiple subdirectories of " +
 220                                "directory " + get("SourceBase") + " and could not " +
 221                                "be resolved with the os_family and arch " +
 222                                "macros in the platform file.");
 223             if (filesNotFound.size() != 0) {
 224                 System.err.println("Files not found:");


 339             if (v != null) {
 340                 for (Enumeration e=v.keys(); e.hasMoreElements(); ) {
 341                     String key = (String)e.nextElement();
 342                     String val =  (String)v.get(key);
 343                     addTo(rv, key, val);
 344                 }
 345             }
 346         }
 347     }
 348 
 349 
 350     Vector getDefines() {
 351         Vector rv = new Vector();
 352         collectRelevantVectors(rv, "Define");
 353         return rv;
 354     }
 355 
 356     Vector getIncludes() {
 357         Vector rv = new Vector();
 358 
 359         // for generated includes
 360         rv.add(get("OutputDir"));
 361 
 362         collectRelevantVectors(rv, "AbsoluteInclude");
 363 







 364         Vector ri = new Vector();
 365         String sourceBase = getFieldString(null, "SourceBase");
 366         collectRelevantVectors(ri, "RelativeInclude");
 367         for (Iterator i = ri.iterator(); i.hasNext(); ) {
 368             String f = (String)i.next();
 369             rv.add(sourceBase + Util.sep + f);
 370         }
 371 
 372         return rv;
 373     }
 374 
 375     static Hashtable cfgData = new Hashtable();
 376     static Hashtable globalData = new Hashtable();
 377 
 378     static boolean appliesToTieredBuild(String cfg) {
 379         return (cfg != null &&
 380                 (cfg.startsWith("compiler1") ||
 381                  cfg.startsWith("compiler2")));
 382     }
 383 
 384     // Filters out the IncludeDB statement, which is the only command-
 385     // line argument we explicitly specialize for the tiered build
 386     static boolean appliesToTieredBuild(String cfg, String key) {
 387         return (appliesToTieredBuild(cfg) &&
 388                 (key != null &&
 389                  !key.equals("IncludeDB")));
 390     }
 391 
 392     static String getTieredBuildCfg(String cfg) {
 393         assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg;
 394         return "tiered" + cfg.substring(9);
 395     }
 396 
 397     static Object getField(String cfg, String field) {
 398         if (cfg == null) {
 399             return globalData.get(field);
 400         }
 401 
 402         Hashtable ht =  (Hashtable)cfgData.get(cfg);
 403         return ht == null ? null : ht.get(field);
 404     }
 405 
 406     static String getFieldString(String cfg, String field) {
 407         return (String)getField(cfg, field);
 408     }
 409 


 424             return;
 425         }
 426 
 427         Hashtable ht = (Hashtable)cfgData.get(cfg);
 428         if (ht == null) {
 429             ht = new Hashtable();
 430             cfgData.put(cfg, ht);
 431         }
 432 
 433         ht.put(field, value);
 434     }
 435 
 436     static Object getFieldHash(String cfg, String field, String name) {
 437         Hashtable ht = (Hashtable)getField(cfg, field);
 438 
 439         return ht == null ? null : ht.get(name);
 440     }
 441 
 442     static void putFieldHash(String cfg, String field, String name, Object val) {
 443         putFieldHashImpl(cfg, field, name, val);
 444         if (appliesToTieredBuild(cfg)) {
 445             putFieldHashImpl(getTieredBuildCfg(cfg), field, name, val);
 446         }
 447     }
 448 
 449     private static void putFieldHashImpl(String cfg, String field, String name, Object val) {
 450         Hashtable ht = (Hashtable)getField(cfg, field);
 451 
 452         if (ht == null) {
 453             ht = new Hashtable();
 454             putFieldImpl(cfg, field, ht);
 455         }
 456 
 457         ht.put(name, val);
 458     }
 459 
 460     static void addFieldVector(String cfg, String field, String element) {
 461         addFieldVectorImpl(cfg, field, element);
 462         if (appliesToTieredBuild(cfg)) {
 463             addFieldVectorImpl(getTieredBuildCfg(cfg), field, element);
 464         }
 465     }
 466 
 467     private static void addFieldVectorImpl(String cfg, String field, String element) {
 468         Vector v = (Vector)getField(cfg, field);
 469 
 470         if (v == null) {
 471             v = new Vector();
 472             putFieldImpl(cfg, field, v);
 473         }
 474 
 475         v.add(element);
 476     }
 477 
 478     String expandFormat(String format) {
 479         if (format == null) {
 480             return null;
 481         }
 482 


   1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  31     String[] context;
  32     
  33     static CompilerInterface ci;
  34     static CompilerInterface getCI() {
  35         if (ci == null) {
  36             String comp = (String)getField(null, "CompilerVersion");
  37             try {
  38                 ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance();
  39             } catch (Exception cnfe) {
  40                 System.err.println("Cannot find support for compiler " + comp);
  41                 throw new RuntimeException(cnfe.toString());
  42             }
  43         }
  44         return ci;
  45     }
  46 
  47     protected void initNames(String flavour, String build, String outDll) {
  48         if (vars == null) vars = new Hashtable();
  49 
  50         String flavourBuild =  flavour + "_" + build;
  51         System.out.println();
  52         System.out.println(flavourBuild);
  53         
  54         put("Name", getCI().makeCfgName(flavourBuild));
  55         put("Flavour", flavour);
  56         put("Build", build);
  57 
  58         // ones mentioned above were needed to expand format
  59         String buildBase = expandFormat(getFieldString(null, "BuildBase"));
  60         String jdkDir =  getFieldString(null, "JdkTargetRoot");
  61         String sourceBase = getFieldString(null, "SourceBase");
  62         String outDir = buildBase;
  63 
  64         put("Id", flavourBuild);
  65         put("OutputDir", outDir);
  66         put("SourceBase", sourceBase);
  67         put("BuildBase", buildBase);
  68         put("OutputDll", jdkDir + Util.sep + outDll);
  69 
  70         context = new String [] {flavourBuild, flavour, build, null};
  71     }
  72 
  73     protected void init(Vector includes, Vector defines) {
  74         initDefaultDefines(defines);
  75         initDefaultCompilerFlags(includes);
  76         initDefaultLinkerFlags();
  77         handleDB();
  78     }
  79 
  80 
  81     protected void initDefaultCompilerFlags(Vector includes) {
  82         Vector compilerFlags = new Vector();
  83 
  84         compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
  85                                                           includes,
  86                                                           get("OutputDir")));
  87 
  88         put("CompilerFlags", compilerFlags);
  89     }
  90 
  91     protected void initDefaultLinkerFlags() {
  92         Vector linkerFlags = new Vector();
  93 
  94         linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll")));
  95 
  96         put("LinkerFlags", linkerFlags);
  97     }
  98 
  99     DirectoryTree getSourceTree(String sourceBase, String startAt) {
 100         DirectoryTree tree = new DirectoryTree();
 101 
 102         tree.addSubdirToIgnore("Codemgr_wsdata");
 103         tree.addSubdirToIgnore("deleted_files");
 104         tree.addSubdirToIgnore("SCCS");
 105         tree.setVerbose(true);
 106         if (startAt != null) {
 107             tree.readDirectory(sourceBase + File.separator + startAt);
 108         } else {
 109             tree.readDirectory(sourceBase);
 110         }
 111 
 112         return tree;
 113     }
 114 
 115 
 116     Vector getPreferredPaths(MacroDefinitions macros) {
 117         Vector preferredPaths = new Vector();
 118         // In the case of multiple files with the same name in
 119         // different subdirectories, prefer the versions specified in
 120         // the platform file as the "os_family" and "arch" macros.
 121         for (Iterator iter = macros.getMacros(); iter.hasNext(); ) {
 122             Macro macro = (Macro) iter.next();
 123             if (macro.name.equals("os_family") ||
 124                 macro.name.equals("arch")) {
 125                 preferredPaths.add(macro.contents);
 126             }
 127         }
 128         // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
 129         preferredPaths.add("opto");
 130 
 131         return preferredPaths;
 132     }
 133 
 134 
 135     void handleDB() {
 136         WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");

 137         

 138         File incls = new File(get("OutputDir")+Util.sep+"incls");








 139 
 140         incls.mkdirs();
 141 
 142         MacroDefinitions macros = new MacroDefinitions();
 143         try {
 144             macros.readFrom(getFieldString(null, "Platform"), false);




 145         } catch (Exception e) {
 146             throw new RuntimeException(e);

 147         }
 148 
 149         putSpecificField("AllFilesHash", computeAllFiles(platform, macros));
 150     }
 151 
 152     
 153     private boolean matchesIgnoredPath(String prefixedName) {
 154         Vector rv = new Vector();
 155         collectRelevantVectors(rv, "IgnorePath");
 156         for (Iterator i = rv.iterator(); i.hasNext(); ) {
 157             String pathPart = (String) i.next();
 158             if (prefixedName.contains(Util.normalize(pathPart)))  {
 159                 return true;
 160             }
 161         }
 162         return false;
 163     }
 164 
 165     void addAll(Iterator i, Hashtable hash,
 166                 WinGammaPlatform platform, DirectoryTree tree,
 167                 Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) {
 168         for (; i.hasNext(); ) {
 169             String fileName = (String) i.next();
 170             if (lookupHashFieldInContext("IgnoreFile", fileName) == null) {
 171                 String prefixedName = platform.envVarPrefixedFileName(fileName,
 172                                                                       0, /* ignored */
 173                                                                       tree,
 174                                                                       preferredPaths,
 175                                                                       filesNotFound,
 176                                                                       filesDuplicate);
 177                 if (prefixedName != null) {
 178                     prefixedName = Util.normalize(prefixedName);
 179                     if (!matchesIgnoredPath(prefixedName)) {
 180                         addTo(hash, prefixedName, fileName);
 181                     }
 182                 }
 183             }
 184         }
 185     }
 186 
 187     void addTo(Hashtable ht, String key, String value) {
 188         ht.put(expandFormat(key), expandFormat(value));
 189     }
 190 
 191     Hashtable computeAllFiles(WinGammaPlatform platform, MacroDefinitions macros) {
 192         Hashtable rv = new Hashtable();
 193         DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt"));
 194         Vector preferredPaths = getPreferredPaths(macros);
 195 
 196         // Hold errors until end
 197         Vector filesNotFound = new Vector();
 198         Vector filesDuplicate = new Vector();
 199 
 200         Vector includedFiles = new Vector();
 201 
 202         // find all files
 203         Vector dirs = getSourceIncludes();
 204         for (Iterator i = dirs.iterator(); i.hasNext(); ) {
 205             String dir = (String)i.next();
 206             DirectoryTree subtree = getSourceTree(dir, null);
 207             for (Iterator fi = subtree.getFileIterator(); fi.hasNext(); ) {
 208                 String name = ((File)fi.next()).getName();
 209                 includedFiles.add(name);
 210             }
 211         }
 212         addAll(includedFiles.iterator(), rv,
 213                platform, tree,
 214                preferredPaths, filesNotFound, filesDuplicate);
 215 
 216         Vector addFiles = new Vector();
 217         collectRelevantVectors(addFiles, "AdditionalFile");
 218         addAll(addFiles.iterator(), rv,
 219                platform, tree,
 220                preferredPaths, filesNotFound, filesDuplicate);
 221 
 222         collectRelevantHashes(rv, "AdditionalGeneratedFile");
 223 
 224         if ((filesNotFound.size() != 0) ||
 225             (filesDuplicate.size() != 0)) {
 226             System.err.println("Error: some files were not found or " +
 227                                "appeared in multiple subdirectories of " +
 228                                "directory " + get("SourceBase") + " and could not " +
 229                                "be resolved with the os_family and arch " +
 230                                "macros in the platform file.");
 231             if (filesNotFound.size() != 0) {
 232                 System.err.println("Files not found:");


 347             if (v != null) {
 348                 for (Enumeration e=v.keys(); e.hasMoreElements(); ) {
 349                     String key = (String)e.nextElement();
 350                     String val =  (String)v.get(key);
 351                     addTo(rv, key, val);
 352                 }
 353             }
 354         }
 355     }
 356 
 357 
 358     Vector getDefines() {
 359         Vector rv = new Vector();
 360         collectRelevantVectors(rv, "Define");
 361         return rv;
 362     }
 363 
 364     Vector getIncludes() {
 365         Vector rv = new Vector();
 366 



 367         collectRelevantVectors(rv, "AbsoluteInclude");
 368 
 369         rv.addAll(getSourceIncludes());
 370 
 371         return rv;
 372     }
 373 
 374     private Vector getSourceIncludes() {
 375         Vector rv = new Vector();
 376         Vector ri = new Vector();
 377         String sourceBase = getFieldString(null, "SourceBase");
 378         collectRelevantVectors(ri, "RelativeInclude");
 379         for (Iterator i = ri.iterator(); i.hasNext(); ) {
 380             String f = (String)i.next();
 381             rv.add(sourceBase + Util.sep + f);
 382         }

 383         return rv;
 384     }
 385 
 386     static Hashtable cfgData = new Hashtable();
 387     static Hashtable globalData = new Hashtable();
 388 
 389     static boolean appliesToTieredBuild(String cfg) {
 390         return (cfg != null &&
 391                 (cfg.startsWith("compiler1") ||
 392                  cfg.startsWith("compiler2")));
 393     }
 394 
 395     // Filters out the IgnoreFile and IgnorePaths since they are
 396     // handled specially for tiered builds.
 397     static boolean appliesToTieredBuild(String cfg, String key) {
 398         return (appliesToTieredBuild(cfg))&& (key != null && !key.startsWith("Ignore"));


 399     }
 400 
 401     static String getTieredBuildCfg(String cfg) {
 402         assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg;
 403         return "tiered" + cfg.substring(9);
 404     }
 405 
 406     static Object getField(String cfg, String field) {
 407         if (cfg == null) {
 408             return globalData.get(field);
 409         }
 410 
 411         Hashtable ht =  (Hashtable)cfgData.get(cfg);
 412         return ht == null ? null : ht.get(field);
 413     }
 414 
 415     static String getFieldString(String cfg, String field) {
 416         return (String)getField(cfg, field);
 417     }
 418 


 433             return;
 434         }
 435 
 436         Hashtable ht = (Hashtable)cfgData.get(cfg);
 437         if (ht == null) {
 438             ht = new Hashtable();
 439             cfgData.put(cfg, ht);
 440         }
 441 
 442         ht.put(field, value);
 443     }
 444 
 445     static Object getFieldHash(String cfg, String field, String name) {
 446         Hashtable ht = (Hashtable)getField(cfg, field);
 447 
 448         return ht == null ? null : ht.get(name);
 449     }
 450 
 451     static void putFieldHash(String cfg, String field, String name, Object val) {
 452         putFieldHashImpl(cfg, field, name, val);
 453         if (appliesToTieredBuild(cfg, field)) {
 454             putFieldHashImpl(getTieredBuildCfg(cfg), field, name, val);
 455         }
 456     }
 457 
 458     private static void putFieldHashImpl(String cfg, String field, String name, Object val) {
 459         Hashtable ht = (Hashtable)getField(cfg, field);
 460 
 461         if (ht == null) {
 462             ht = new Hashtable();
 463             putFieldImpl(cfg, field, ht);
 464         }
 465 
 466         ht.put(name, val);
 467     }
 468 
 469     static void addFieldVector(String cfg, String field, String element) {
 470         addFieldVectorImpl(cfg, field, element);
 471         if (appliesToTieredBuild(cfg, field)) {
 472             addFieldVectorImpl(getTieredBuildCfg(cfg), field, element);
 473         }
 474     }
 475 
 476     private static void addFieldVectorImpl(String cfg, String field, String element) {
 477         Vector v = (Vector)getField(cfg, field);
 478 
 479         if (v == null) {
 480             v = new Vector();
 481             putFieldImpl(cfg, field, v);
 482         }
 483 
 484         v.add(element);
 485     }
 486 
 487     String expandFormat(String format) {
 488         if (format == null) {
 489             return null;
 490         }
 491