Merge jdk8-b31

Wed, 21 Mar 2012 12:18:06 -0700

author
katleman
date
Wed, 21 Mar 2012 12:18:06 -0700
changeset 345
1954151dfae8
parent 343
d6b04e3e40e2
parent 344
0b94487a30c6
child 346
5d820cb6b1af

Merge

make/tools/src/build/tools/stripproperties/StripProperties.java file | annotate | diff | comparison | revisions
     1.1 --- a/make/common/internal/Resources.gmk	Thu Mar 15 15:14:52 2012 -0700
     1.2 +++ b/make/common/internal/Resources.gmk	Wed Mar 21 12:18:06 2012 -0700
     1.3 @@ -149,8 +149,8 @@
     1.4  # Strip the properties files
     1.5  strip_all_props: $(STRIPPROPERTIES_JARFILE) $(STRIP_PROP_options)
     1.6  	@if [ -s $(STRIP_PROP_options) ] ; then \
     1.7 -          $(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options)" ; \
     1.8 -          $(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) -optionsfile $(STRIP_PROP_options) ; \
     1.9 +          $(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options)" ; \
    1.10 +          $(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options) ; \
    1.11          fi
    1.12  	@$(java-vm-cleanup)
    1.13  
     2.1 --- a/make/tools/src/build/tools/stripproperties/StripProperties.java	Thu Mar 15 15:14:52 2012 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,280 +0,0 @@
     2.4 -/*
     2.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
     2.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 - *
     2.8 - * This code is free software; you can redistribute it and/or modify it
     2.9 - * under the terms of the GNU General Public License version 2 only, as
    2.10 - * published by the Free Software Foundation.  Oracle designates this
    2.11 - * particular file as subject to the "Classpath" exception as provided
    2.12 - * by Oracle in the LICENSE file that accompanied this code.
    2.13 - *
    2.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 - * version 2 for more details (a copy is included in the LICENSE file that
    2.18 - * accompanied this code).
    2.19 - *
    2.20 - * You should have received a copy of the GNU General Public License version
    2.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 - *
    2.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.25 - * or visit www.oracle.com if you need additional information or have any
    2.26 - * questions.
    2.27 - */
    2.28 -
    2.29 -package build.tools.stripproperties;
    2.30 -
    2.31 -import java.io.BufferedInputStream;
    2.32 -import java.io.BufferedWriter;
    2.33 -import java.io.FileInputStream;
    2.34 -import java.io.FileNotFoundException;
    2.35 -import java.io.FileOutputStream;
    2.36 -import java.io.OutputStream;
    2.37 -import java.io.OutputStreamWriter;
    2.38 -import java.io.IOException;
    2.39 -import java.io.InputStream;
    2.40 -import java.util.ArrayList;
    2.41 -import java.util.Enumeration;
    2.42 -import java.util.List;
    2.43 -import java.util.Properties;
    2.44 -
    2.45 -/**
    2.46 - * Reads a properties file from standard input and writes an equivalent
    2.47 - * properties file without comments to standard output.
    2.48 - */
    2.49 -public class StripProperties {
    2.50 -
    2.51 -    private static void error(String msg, Exception e) {
    2.52 -        System.err.println("ERROR: stripproperties: " + msg);
    2.53 -        if ( e != null ) {
    2.54 -            System.err.println("EXCEPTION: " + e.toString());
    2.55 -            e.printStackTrace();
    2.56 -        }
    2.57 -    }
    2.58 -
    2.59 -    private static List<String> parseOptions(String args[]) {
    2.60 -        List<String> files = new ArrayList<String>();
    2.61 -        for ( int i = 0; i < args.length ; i++ ) {
    2.62 -            if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) {
    2.63 -                String filename = args[++i];
    2.64 -                FileInputStream finput = null;
    2.65 -                byte contents[] = null;
    2.66 -                try {
    2.67 -                    finput = new FileInputStream(filename);
    2.68 -                    int byteCount = finput.available();
    2.69 -                    if ( byteCount <= 0 ) {
    2.70 -                        error("The -optionsfile file is empty", null);
    2.71 -                        files = null;
    2.72 -                    } else {
    2.73 -                        contents = new byte[byteCount];
    2.74 -                        int bytesRead = finput.read(contents);
    2.75 -                        if ( byteCount != bytesRead ) {
    2.76 -                            error("Cannot read all of -optionsfile file", null);
    2.77 -                            files = null;
    2.78 -                        }
    2.79 -                    }
    2.80 -                } catch ( IOException e ) {
    2.81 -                    error("cannot open " + filename, e);
    2.82 -                    files = null;
    2.83 -                }
    2.84 -                if ( finput != null ) {
    2.85 -                    try {
    2.86 -                        finput.close();
    2.87 -                    } catch ( IOException e ) {
    2.88 -                        files = null;
    2.89 -                        error("cannot close " + filename, e);
    2.90 -                    }
    2.91 -                }
    2.92 -                if ( files != null && contents != null ) {
    2.93 -                    String tokens[] = (new String(contents)).split("\\s+");
    2.94 -                    if ( tokens.length > 0 ) {
    2.95 -                        List<String> ofiles = parseOptions(tokens);
    2.96 -                        if ( ofiles != null ) {
    2.97 -                            files.addAll(ofiles);
    2.98 -                        } else {
    2.99 -                            error("No files found in file", null);
   2.100 -                            files = null;
   2.101 -                        }
   2.102 -                    }
   2.103 -                }
   2.104 -                if ( files == null ) {
   2.105 -                    break;
   2.106 -                }
   2.107 -            } else {
   2.108 -                files.add(args[i]);
   2.109 -            }
   2.110 -        }
   2.111 -        return files;
   2.112 -    }
   2.113 -
   2.114 -    private static boolean stripFiles(List<String> files) {
   2.115 -        boolean ok = true;
   2.116 -        for ( String file : files ) {
   2.117 -
   2.118 -            Properties prop = new Properties();
   2.119 -            InputStream in = null;
   2.120 -            try {
   2.121 -                in = new BufferedInputStream(new FileInputStream(file));
   2.122 -                prop.load(in);
   2.123 -            } catch ( FileNotFoundException e ) {
   2.124 -                error("Cannot access file " + file, e);
   2.125 -                ok = false;
   2.126 -            } catch ( IOException e ) {
   2.127 -                error("IO exception processing file " + file, e);
   2.128 -                ok = false;
   2.129 -            }
   2.130 -            if ( in != null ) {
   2.131 -                try {
   2.132 -                    in.close();
   2.133 -                } catch ( IOException e ) {
   2.134 -                    error("IO exception closing file " + file, e);
   2.135 -                    ok = false;
   2.136 -                }
   2.137 -            }
   2.138 -            if ( !ok ) {
   2.139 -                break;
   2.140 -            }
   2.141 -
   2.142 -            OutputStream out = null;
   2.143 -            try {
   2.144 -                out = new FileOutputStream(file);
   2.145 -                storeProperties(prop, out);
   2.146 -                out.flush();
   2.147 -            } catch ( IOException e ) {
   2.148 -                error("IO exception processing file " + file, e);
   2.149 -                ok = false;
   2.150 -            }
   2.151 -            if ( out != null ) {
   2.152 -                try {
   2.153 -                    out.close();
   2.154 -                } catch ( IOException e ) {
   2.155 -                    error("IO exception closing file " + file, e);
   2.156 -                    ok = false;
   2.157 -                }
   2.158 -            }
   2.159 -            if ( !ok ) {
   2.160 -                break;
   2.161 -            }
   2.162 -
   2.163 -        }
   2.164 -        return ok;
   2.165 -    }
   2.166 -
   2.167 -    /**
   2.168 -     * Strip the properties filenames supplied, replacing their contents.
   2.169 -     * @param args Names of properties files to process and replace contents
   2.170 -     */
   2.171 -    public static void main(String args[]) {
   2.172 -        List<String> files = parseOptions(args);
   2.173 -        if ( files == null || !stripFiles(files) ) {
   2.174 -            System.exit(1);
   2.175 -        }
   2.176 -    }
   2.177 -
   2.178 -    // --- code below here is adapted from java.util.Properties ---
   2.179 -
   2.180 -    private static final String specialSaveChars = "=: \t\r\n\f#!";
   2.181 -
   2.182 -    /*
   2.183 -     * Converts unicodes to encoded &#92;uxxxx
   2.184 -     * and writes out any of the characters in specialSaveChars
   2.185 -     * with a preceding slash
   2.186 -     */
   2.187 -    private static String saveConvert(String theString, boolean escapeSpace) {
   2.188 -        int len = theString.length();
   2.189 -        StringBuffer outBuffer = new StringBuffer(len*2);
   2.190 -
   2.191 -        for(int x=0; x<len; x++) {
   2.192 -            char aChar = theString.charAt(x);
   2.193 -            switch(aChar) {
   2.194 -                case ' ':
   2.195 -                    if (x == 0 || escapeSpace) {
   2.196 -                        outBuffer.append('\\');
   2.197 -                    }
   2.198 -                    outBuffer.append(' ');
   2.199 -                    break;
   2.200 -                case '\\':
   2.201 -                    outBuffer.append('\\');
   2.202 -                    outBuffer.append('\\');
   2.203 -                    break;
   2.204 -                case '\t':
   2.205 -                    outBuffer.append('\\');
   2.206 -                    outBuffer.append('t');
   2.207 -                    break;
   2.208 -                case '\n':
   2.209 -                    outBuffer.append('\\');
   2.210 -                    outBuffer.append('n');
   2.211 -                    break;
   2.212 -                case '\r':
   2.213 -                    outBuffer.append('\\');
   2.214 -                    outBuffer.append('r');
   2.215 -                    break;
   2.216 -                case '\f':
   2.217 -                    outBuffer.append('\\');
   2.218 -                    outBuffer.append('f');
   2.219 -                    break;
   2.220 -                default:
   2.221 -                    if ((aChar < 0x0020) || (aChar == 0x007e) || (aChar > 0x00ff)) {
   2.222 -                        outBuffer.append('\\');
   2.223 -                        outBuffer.append('u');
   2.224 -                        outBuffer.append(toHex((aChar >> 12) & 0xF));
   2.225 -                        outBuffer.append(toHex((aChar >>  8) & 0xF));
   2.226 -                        outBuffer.append(toHex((aChar >>  4) & 0xF));
   2.227 -                        outBuffer.append(toHex( aChar        & 0xF));
   2.228 -                    } else {
   2.229 -                        if (specialSaveChars.indexOf(aChar) != -1) {
   2.230 -                            outBuffer.append('\\');
   2.231 -                        }
   2.232 -                        outBuffer.append(aChar);
   2.233 -                    }
   2.234 -            }
   2.235 -        }
   2.236 -        return outBuffer.toString();
   2.237 -    }
   2.238 -
   2.239 -    /**
   2.240 -     * Writes the content of <code>properties</code> to <code>out</code>.
   2.241 -     * The format is that of Properties.store with the following modifications:
   2.242 -     * <ul>
   2.243 -     * <li>No header or date is written
   2.244 -     * <li>Latin-1 characters are written as single bytes, not escape sequences
   2.245 -     * <li>Line breaks are indicated by a single \n independent of platform
   2.246 -     * <ul>
   2.247 -     */
   2.248 -    private static void storeProperties(Properties properties, OutputStream out)
   2.249 -    throws IOException {
   2.250 -        BufferedWriter awriter;
   2.251 -        awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
   2.252 -        for (Enumeration e = properties.keys(); e.hasMoreElements();) {
   2.253 -            String key = (String)e.nextElement();
   2.254 -            String val = (String)properties.get(key);
   2.255 -            key = saveConvert(key, true);
   2.256 -
   2.257 -            /* No need to escape embedded and trailing spaces for value, hence
   2.258 -             * pass false to flag.
   2.259 -             */
   2.260 -            val = saveConvert(val, false);
   2.261 -            writeln(awriter, key + "=" + val);
   2.262 -        }
   2.263 -        awriter.flush();
   2.264 -    }
   2.265 -
   2.266 -    private static void writeln(BufferedWriter bw, String s) throws IOException {
   2.267 -        bw.write(s);
   2.268 -        bw.write("\n");
   2.269 -    }
   2.270 -
   2.271 -    /**
   2.272 -     * Convert a nibble to a hex character
   2.273 -     * @param   nibble  the nibble to convert.
   2.274 -     */
   2.275 -    private static char toHex(int nibble) {
   2.276 -        return hexDigit[(nibble & 0xF)];
   2.277 -    }
   2.278 -
   2.279 -    /** A table of hex digits */
   2.280 -    private static final char[] hexDigit = {
   2.281 -        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
   2.282 -    };
   2.283 -}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/make/tools/src/build/tools/stripproperties/StripPropertiesCorba.java	Wed Mar 21 12:18:06 2012 -0700
     3.3 @@ -0,0 +1,288 @@
     3.4 +/*
     3.5 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.  Oracle designates this
    3.11 + * particular file as subject to the "Classpath" exception as provided
    3.12 + * by Oracle in the LICENSE file that accompanied this code.
    3.13 + *
    3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.17 + * version 2 for more details (a copy is included in the LICENSE file that
    3.18 + * accompanied this code).
    3.19 + *
    3.20 + * You should have received a copy of the GNU General Public License version
    3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.23 + *
    3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.25 + * or visit www.oracle.com if you need additional information or have any
    3.26 + * questions.
    3.27 + */
    3.28 +
    3.29 +package build.tools.stripproperties;
    3.30 +
    3.31 +import java.io.BufferedInputStream;
    3.32 +import java.io.BufferedWriter;
    3.33 +import java.io.FileInputStream;
    3.34 +import java.io.FileNotFoundException;
    3.35 +import java.io.FileOutputStream;
    3.36 +import java.io.OutputStream;
    3.37 +import java.io.OutputStreamWriter;
    3.38 +import java.io.IOException;
    3.39 +import java.io.InputStream;
    3.40 +import java.util.ArrayList;
    3.41 +import java.util.Enumeration;
    3.42 +import java.util.Iterator;
    3.43 +import java.util.List;
    3.44 +import java.util.Properties;
    3.45 +
    3.46 +/**
    3.47 + * Reads a properties file from standard input and writes an equivalent
    3.48 + * properties file without comments to standard output.
    3.49 + */
    3.50 +public class StripPropertiesCorba {
    3.51 +
    3.52 +    private static void error(String msg, Exception e) {
    3.53 +        System.err.println("ERROR: stripproperties: " + msg);
    3.54 +        if ( e != null ) {
    3.55 +            System.err.println("EXCEPTION: " + e.toString());
    3.56 +            e.printStackTrace();
    3.57 +        }
    3.58 +    }
    3.59 +
    3.60 +    private static List<String> infiles = new ArrayList<String>();
    3.61 +    private static List<String> outfiles = new ArrayList<String>();
    3.62 +
    3.63 +    private static boolean parseOptions(String args[]) {
    3.64 +        boolean ok = true;
    3.65 +
    3.66 +        for ( int i = 0; i < args.length ; i++ ) {
    3.67 +            if ( "-clean".equals(args[i]) && i+2 < args.length ) {
    3.68 +                infiles.add(args[++i]);
    3.69 +                outfiles.add(args[++i]);
    3.70 +            } else if ( args[i].charAt(0)=='@') {
    3.71 +                String filename = args[i].substring(1);
    3.72 +                FileInputStream finput = null;
    3.73 +                byte contents[] = null;
    3.74 +                try {
    3.75 +                    finput = new FileInputStream(filename);
    3.76 +                    int byteCount = finput.available();
    3.77 +                    if ( byteCount <= 0 ) {
    3.78 +                        error("The @file is empty", null);
    3.79 +                        ok = false;
    3.80 +                    } else {
    3.81 +                        contents = new byte[byteCount];
    3.82 +                        int bytesRead = finput.read(contents);
    3.83 +                        if ( byteCount != bytesRead ) {
    3.84 +                            error("Cannot read all of @file", null);
    3.85 +                            ok = false;
    3.86 +                        }
    3.87 +                    }
    3.88 +                } catch ( IOException e ) {
    3.89 +                    error("cannot open " + filename, e);
    3.90 +                    ok = false;
    3.91 +                }
    3.92 +                if ( finput != null ) {
    3.93 +                    try {
    3.94 +                        finput.close();
    3.95 +                    } catch ( IOException e ) {
    3.96 +                        ok = false;
    3.97 +                        error("cannot close " + filename, e);
    3.98 +                    }
    3.99 +                }
   3.100 +                if ( ok && contents != null ) {
   3.101 +                    String tokens[] = (new String(contents)).split("\\s+");
   3.102 +                    if ( tokens.length > 0 ) {
   3.103 +                        ok = parseOptions(tokens);
   3.104 +                    }
   3.105 +                }
   3.106 +                if ( !ok ) {
   3.107 +                    break;
   3.108 +                }
   3.109 +            } else {
   3.110 +                infiles.add(args[i]);
   3.111 +                outfiles.add(args[i]);
   3.112 +            }
   3.113 +        }
   3.114 +        return ok;
   3.115 +    }
   3.116 +
   3.117 +    private static boolean stripFiles(List<String> infiles, List<String> outfiles) {
   3.118 +        boolean ok = true;
   3.119 +        Iterator<String> inIter  = infiles.iterator();
   3.120 +        Iterator<String> outIter = outfiles.iterator();
   3.121 +
   3.122 +        for (; inIter.hasNext(); ) {
   3.123 +            String infile = inIter.next();
   3.124 +            String outfile = outIter.next();
   3.125 +
   3.126 +            Properties prop = new Properties();
   3.127 +            InputStream in = null;
   3.128 +            try {
   3.129 +                in = new BufferedInputStream(new FileInputStream(infile));
   3.130 +                prop.load(in);
   3.131 +            } catch ( FileNotFoundException e ) {
   3.132 +                error("Cannot access file " + infile, e);
   3.133 +                ok = false;
   3.134 +            } catch ( IOException e ) {
   3.135 +                error("IO exception processing file " + infile, e);
   3.136 +                ok = false;
   3.137 +            }
   3.138 +            if ( in != null ) {
   3.139 +                try {
   3.140 +                    in.close();
   3.141 +                } catch ( IOException e ) {
   3.142 +                    error("IO exception closing file " + infile, e);
   3.143 +                    ok = false;
   3.144 +                }
   3.145 +            }
   3.146 +            if ( !ok ) {
   3.147 +                break;
   3.148 +            }
   3.149 +
   3.150 +            OutputStream out = null;
   3.151 +            try {
   3.152 +                out = new FileOutputStream(outfile);
   3.153 +                storeProperties(prop, out);
   3.154 +                out.flush();
   3.155 +            } catch ( IOException e ) {
   3.156 +                error("IO exception processing file " + outfile, e);
   3.157 +                ok = false;
   3.158 +            }
   3.159 +            if ( out != null ) {
   3.160 +                try {
   3.161 +                    out.close();
   3.162 +                } catch ( IOException e ) {
   3.163 +                    error("IO exception closing file " + outfile, e);
   3.164 +                    ok = false;
   3.165 +                }
   3.166 +            }
   3.167 +            if ( !ok ) {
   3.168 +                break;
   3.169 +            }
   3.170 +
   3.171 +        }
   3.172 +        return ok;
   3.173 +    }
   3.174 +
   3.175 +    /**
   3.176 +     * Strip the properties filenames supplied, replacing their contents.
   3.177 +     * @param args Names of properties files to process and replace contents
   3.178 +     */
   3.179 +    public static void main(String args[]) {
   3.180 +        boolean ok = parseOptions(args);
   3.181 +        if ( !ok || !stripFiles(infiles, outfiles) ) {
   3.182 +            System.exit(1);
   3.183 +        }
   3.184 +    }
   3.185 +
   3.186 +    // --- code below here is adapted from java.util.Properties ---
   3.187 +
   3.188 +    private static final String specialSaveChars = "=: \t\r\n\f#!";
   3.189 +
   3.190 +    /*
   3.191 +     * Converts unicodes to encoded &#92;uxxxx
   3.192 +     * and writes out any of the characters in specialSaveChars
   3.193 +     * with a preceding slash
   3.194 +     */
   3.195 +    private static String saveConvert(String theString, boolean escapeSpace) {
   3.196 +        int len = theString.length();
   3.197 +        StringBuffer outBuffer = new StringBuffer(len*2);
   3.198 +
   3.199 +        for(int x=0; x<len; x++) {
   3.200 +            char aChar = theString.charAt(x);
   3.201 +            switch(aChar) {
   3.202 +                case ' ':
   3.203 +                    if (x == 0 || escapeSpace) {
   3.204 +                        outBuffer.append('\\');
   3.205 +                    }
   3.206 +                    outBuffer.append(' ');
   3.207 +                    break;
   3.208 +                case '\\':
   3.209 +                    outBuffer.append('\\');
   3.210 +                    outBuffer.append('\\');
   3.211 +                    break;
   3.212 +                case '\t':
   3.213 +                    outBuffer.append('\\');
   3.214 +                    outBuffer.append('t');
   3.215 +                    break;
   3.216 +                case '\n':
   3.217 +                    outBuffer.append('\\');
   3.218 +                    outBuffer.append('n');
   3.219 +                    break;
   3.220 +                case '\r':
   3.221 +                    outBuffer.append('\\');
   3.222 +                    outBuffer.append('r');
   3.223 +                    break;
   3.224 +                case '\f':
   3.225 +                    outBuffer.append('\\');
   3.226 +                    outBuffer.append('f');
   3.227 +                    break;
   3.228 +                default:
   3.229 +                    if ((aChar < 0x0020) || (aChar == 0x007e) || (aChar > 0x00ff)) {
   3.230 +                        outBuffer.append('\\');
   3.231 +                        outBuffer.append('u');
   3.232 +                        outBuffer.append(toHex((aChar >> 12) & 0xF));
   3.233 +                        outBuffer.append(toHex((aChar >>  8) & 0xF));
   3.234 +                        outBuffer.append(toHex((aChar >>  4) & 0xF));
   3.235 +                        outBuffer.append(toHex( aChar        & 0xF));
   3.236 +                    } else {
   3.237 +                        if (specialSaveChars.indexOf(aChar) != -1) {
   3.238 +                            outBuffer.append('\\');
   3.239 +                        }
   3.240 +                        outBuffer.append(aChar);
   3.241 +                    }
   3.242 +            }
   3.243 +        }
   3.244 +        return outBuffer.toString();
   3.245 +    }
   3.246 +
   3.247 +    /**
   3.248 +     * Writes the content of <code>properties</code> to <code>out</code>.
   3.249 +     * The format is that of Properties.store with the following modifications:
   3.250 +     * <ul>
   3.251 +     * <li>No header or date is written
   3.252 +     * <li>Latin-1 characters are written as single bytes, not escape sequences
   3.253 +     * <li>Line breaks are indicated by a single \n independent of platform
   3.254 +     * <ul>
   3.255 +     */
   3.256 +    private static void storeProperties(Properties properties, OutputStream out)
   3.257 +    throws IOException {
   3.258 +        BufferedWriter awriter;
   3.259 +        awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
   3.260 +        for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
   3.261 +            String key = (String)e.nextElement();
   3.262 +            String val = (String)properties.get(key);
   3.263 +            key = saveConvert(key, true);
   3.264 +
   3.265 +            /* No need to escape embedded and trailing spaces for value, hence
   3.266 +             * pass false to flag.
   3.267 +             */
   3.268 +            val = saveConvert(val, false);
   3.269 +            writeln(awriter, key + "=" + val);
   3.270 +        }
   3.271 +        awriter.flush();
   3.272 +    }
   3.273 +
   3.274 +    private static void writeln(BufferedWriter bw, String s) throws IOException {
   3.275 +        bw.write(s);
   3.276 +        bw.write("\n");
   3.277 +    }
   3.278 +
   3.279 +    /**
   3.280 +     * Convert a nibble to a hex character
   3.281 +     * @param   nibble  the nibble to convert.
   3.282 +     */
   3.283 +    private static char toHex(int nibble) {
   3.284 +        return hexDigit[(nibble & 0xF)];
   3.285 +    }
   3.286 +
   3.287 +    /** A table of hex digits */
   3.288 +    private static final char[] hexDigit = {
   3.289 +        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
   3.290 +    };
   3.291 +}
     4.1 --- a/make/tools/strip_properties/Makefile	Thu Mar 15 15:14:52 2012 -0700
     4.2 +++ b/make/tools/strip_properties/Makefile	Wed Mar 21 12:18:06 2012 -0700
     4.3 @@ -34,7 +34,7 @@
     4.4  include $(BUILDDIR)/common/Defs.gmk
     4.5  
     4.6  BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
     4.7 -BUILDTOOL_MAIN        = $(PKGDIR)/StripProperties.java
     4.8 +BUILDTOOL_MAIN        = $(PKGDIR)/StripPropertiesCorba.java
     4.9  
    4.10  #
    4.11  # Build tool jar rules.

mercurial