annotate test/testlibrary/ClassFileInstaller.java @ 19299:8e4f683e16d9

Truffle-DSL: fixed warning
author Christian Humer <christian.humer@gmail.com>
date Wed, 11 Feb 2015 18:10:02 +0100
parents 43083e670adf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8098
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
1 /*
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
4 *
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
7 * published by the Free Software Foundation.
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
8 *
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
13 * accompanied this code).
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
14 *
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
18 *
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
21 * questions.
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
22 */
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
23
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
24 import java.io.InputStream;
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
25 import java.nio.file.Files;
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
26 import java.nio.file.Path;
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
27 import java.nio.file.Paths;
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
28 import java.nio.file.StandardCopyOption;
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
29
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
30 /**
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
31 * Dump a class file for a class on the class path in the current directory
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
32 */
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
33 public class ClassFileInstaller {
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
34 /**
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
35 * @param args The names of the classes to dump
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
36 * @throws Exception
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
37 */
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
38 public static void main(String... args) throws Exception {
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
39 for (String arg : args) {
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
40 ClassLoader cl = ClassFileInstaller.class.getClassLoader();
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
41
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
42 // Convert dotted class name to a path to a class file
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
43 String pathName = arg.replace('.', '/').concat(".class");
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
44 InputStream is = cl.getResourceAsStream(pathName);
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
45
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
46 // Create the class file's package directory
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
47 Path p = Paths.get(pathName);
10268
43083e670adf 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents: 8098
diff changeset
48 if (pathName.contains("/")) {
43083e670adf 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents: 8098
diff changeset
49 Files.createDirectories(p.getParent());
43083e670adf 8005056: NPG: Crash after redefining java.lang.Object
coleenp
parents: 8098
diff changeset
50 }
8098
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
51 // Create the class file
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
52 Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
53 }
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
54 }
1b0dc9f87e75 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
55 }