test/tools/javap/classfile/deps/T6907575.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

jjg@451 1 /*
ohair@554 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
jjg@451 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@451 4 *
jjg@451 5 * This code is free software; you can redistribute it and/or modify it
jjg@451 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
jjg@451 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
jjg@451 10 *
jjg@451 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@451 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@451 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@451 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@451 15 * accompanied this code).
jjg@451 16 *
jjg@451 17 * You should have received a copy of the GNU General Public License version
jjg@451 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@451 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@451 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
jjg@451 24 */
jjg@451 25
jjg@451 26 /*
jjg@451 27 * @test
jjg@451 28 * @bug 6907575
jjg@451 29 * @build GetDeps p.C1
jjg@451 30 * @run main T6907575
jjg@451 31 */
jjg@451 32
jjg@451 33 import java.io.*;
jjg@451 34
jjg@451 35 public class T6907575 {
jjg@451 36 public static void main(String... args) throws Exception {
jjg@451 37 new T6907575().run();
jjg@451 38 }
jjg@451 39
jjg@451 40 void run() throws Exception {
jjg@451 41 String testSrc = System.getProperty("test.src");
jjg@451 42 String testClasses = System.getProperty("test.classes");
jjg@451 43
jjg@451 44 StringWriter sw = new StringWriter();
jjg@451 45 PrintWriter pw = new PrintWriter(sw);
jjg@451 46 GetDeps gd = new GetDeps();
jjg@451 47 gd.run(pw, "-classpath", testClasses, "-t", "-p", "p", "p/C1");
jjg@451 48 pw.close();
jjg@451 49 System.out.println(sw);
jjg@451 50
jjg@451 51 String ref = readFile(new File(testSrc, "T6907575.out"));
jjg@451 52 diff(sw.toString().replaceAll("[\r\n]+", "\n"), ref);
jjg@451 53 }
jjg@451 54
jjg@451 55 void diff(String actual, String ref) throws Exception {
jjg@451 56 System.out.println("EXPECT:>>>" + ref + "<<<");
jjg@451 57 System.out.println("ACTUAL:>>>" + actual + "<<<");
jjg@451 58 if (!actual.equals(ref))
jjg@451 59 throw new Exception("output not as expected");
jjg@451 60 }
jjg@451 61
jjg@451 62 String readFile(File f) throws IOException {
jjg@451 63 Reader r = new FileReader(f);
jjg@451 64 char[] buf = new char[(int) f.length()];
jjg@451 65 int offset = 0;
jjg@451 66 int n;
jjg@451 67 while (offset < buf.length && (n = r.read(buf, offset, buf.length - offset)) != -1)
jjg@451 68 offset += n;
jjg@451 69 return new String(buf, 0, offset);
jjg@451 70 }
jjg@451 71 }

mercurial