langtools/test/tools/javac/nio/compileTest/CompileTest.java
author jjg
Mon, 11 Jan 2010 14:12:10 -0800
changeset 4701 39e13c0d8d75
parent 4548 bc0d5b3c3b2d
child 4702 bb3925c7b58a
permissions -rw-r--r--
6915476: java.util.regex.PatternSyntaxException in com.sun.tools.javac.nio.PathFileObject Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4548
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     1
/*
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     4
 *
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     8
 *
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    13
 * accompanied this code).
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    14
 *
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    18
 *
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    21
 * have any questions.
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    22
 */
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    23
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    24
/**
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    25
 * @test
4701
39e13c0d8d75 6915476: java.util.regex.PatternSyntaxException in com.sun.tools.javac.nio.PathFileObject
jjg
parents: 4548
diff changeset
    26
 * @bug 6906175 6915476
39e13c0d8d75 6915476: java.util.regex.PatternSyntaxException in com.sun.tools.javac.nio.PathFileObject
jjg
parents: 4548
diff changeset
    27
 * @summary Path-based JavaFileManager
4548
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    28
 * @compile HelloPathWorld.java
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    29
 * @run main CompileTest
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    30
 */
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    31
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    32
import java.io.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    33
import java.nio.file.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    34
import java.util.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    35
import java.util.jar.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    36
import javax.tools.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    37
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    38
import com.sun.tools.javac.nio.*;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    39
import com.sun.tools.javac.util.Context;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    40
import java.nio.file.spi.FileSystemProvider;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    41
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    42
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    43
public class CompileTest {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    44
    public static void main(String[] args) throws Exception {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    45
        new CompileTest().run();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    46
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    47
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    48
    public void run() throws Exception {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    49
        File rtDir = new File("rt.dir");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    50
        File javaHome = new File(System.getProperty("java.home"));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    51
        if (javaHome.getName().equals("jre"))
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    52
            javaHome = javaHome.getParentFile();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    53
        File rtJar = new File(new File(new File(javaHome, "jre"), "lib"), "rt.jar");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    54
        expand(rtJar, rtDir);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    55
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    56
        String[] rtDir_opts = {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    57
            "-bootclasspath", rtDir.toString(),
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    58
            "-classpath", "",
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    59
            "-sourcepath", "",
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    60
            "-extdirs", ""
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    61
        };
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    62
        test(rtDir_opts, "HelloPathWorld");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    63
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    64
        if (isJarFileSystemAvailable()) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    65
            String[] rtJar_opts = {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    66
                "-bootclasspath", rtJar.toString(),
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    67
                "-classpath", "",
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    68
                "-sourcepath", "",
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    69
                "-extdirs", ""
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    70
            };
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    71
            test(rtJar_opts, "HelloPathWorld");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    72
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    73
            String[] default_opts = { };
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    74
            test(default_opts, "HelloPathWorld");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    75
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    76
            // finally, a non-trivial program
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    77
            test(default_opts, "CompileTest");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    78
        } else
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    79
            System.err.println("jar file system not available: test skipped");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    80
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    81
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    82
    void test(String[] opts, String className) throws Exception {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    83
        count++;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    84
        System.err.println("Test " + count + " " + Arrays.asList(opts) + " " + className);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    85
        Path testSrcDir = Paths.get(System.getProperty("test.src"));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    86
        Path testClassesDir = Paths.get(System.getProperty("test.classes"));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    87
        Path classes = Paths.get("classes." + count);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    88
        classes.createDirectory();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    89
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    90
        Context ctx = new Context();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    91
        PathFileManager fm = new JavacPathFileManager(ctx, true, null);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    92
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    93
        List<String> options = new ArrayList<String>();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    94
        options.addAll(Arrays.asList(opts));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    95
        options.addAll(Arrays.asList(
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    96
                "-verbose", "-XDverboseCompilePolicy",
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    97
                "-d", classes.toString()
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    98
        ));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
    99
        Iterable<? extends JavaFileObject> compilationUnits =
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   100
                fm.getJavaFileObjects(testSrcDir.resolve(className + ".java"));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   101
        StringWriter sw = new StringWriter();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   102
        PrintWriter out = new PrintWriter(sw);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   103
        JavaCompiler.CompilationTask t =
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   104
                compiler.getTask(out, fm, null, options, null, compilationUnits);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   105
        boolean ok = t.call();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   106
        System.err.println(sw.toString());
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   107
        if (!ok) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   108
            throw new Exception("compilation failed");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   109
        }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   110
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   111
        File expect = new File("classes." + count + "/" + className + ".class");
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   112
        if (!expect.exists())
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   113
            throw new Exception("expected file not found: " + expect);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   114
        long expectedSize = new File(testClassesDir.toString(), className + ".class").length();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   115
        long actualSize = expect.length();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   116
        if (expectedSize != actualSize)
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   117
            throw new Exception("wrong size found: " + actualSize + "; expected: " + expectedSize);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   118
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   119
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   120
    boolean isJarFileSystemAvailable() {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   121
        boolean result = false;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   122
        for (FileSystemProvider fsp: FileSystemProvider.installedProviders()) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   123
            String scheme = fsp.getScheme();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   124
            System.err.println("Provider: " + scheme + " " + fsp);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   125
            if (scheme.equalsIgnoreCase("jar") || scheme.equalsIgnoreCase("zip"))
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   126
                result = true;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   127
        }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   128
        return result;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   129
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   130
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   131
    void expand(File jar, File dir) throws IOException {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   132
        JarFile jarFile = new JarFile(jar);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   133
        try {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   134
            Enumeration<JarEntry> entries = jarFile.entries();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   135
            while (entries.hasMoreElements()) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   136
                JarEntry je = entries.nextElement();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   137
                if (!je.isDirectory()) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   138
                    copy(jarFile.getInputStream(je), new File(dir, je.getName()));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   139
                }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   140
            }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   141
        } finally {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   142
            jarFile.close();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   143
        }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   144
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   145
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   146
    void copy(InputStream in, File dest) throws IOException {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   147
        dest.getParentFile().mkdirs();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   148
        OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   149
        try {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   150
            byte[] data = new byte[8192];
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   151
            int n;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   152
            while ((n = in.read(data, 0, data.length)) > 0)
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   153
                out.write(data, 0, n);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   154
        } finally {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   155
            out.close();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   156
            in.close();
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   157
        }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   158
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   159
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   160
    void error(String message) {
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   161
        System.err.println("Error: " + message);
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   162
        errors++;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   163
    }
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   164
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   165
    int errors;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   166
    int count;
bc0d5b3c3b2d 6906175: bridge JSR199 and JSR 203 APIs
jjg
parents:
diff changeset
   167
}