0N/A/*
3261N/A * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6868539 6868548
0N/A * @summary javap should use current names for constant pool entries,
0N/A * remove spurious ';' from constant pool entries
0N/A */
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
0N/Apublic class T6868539
0N/A
0N/A{
0N/A public static void main(String... args) {
0N/A new T6868539().run();
0N/A }
0N/A
0N/A void run() {
0N/A String output = javap("T6868539");
0N/A verify(output, "Utf8 +java/lang/String"); // 1: Utf8
0N/A // 2: currently unused
0N/A verify(output, "Integer +123456"); // 3: Integer
0N/A verify(output, "Float +123456.0f"); // 4: Float
0N/A verify(output, "Long +123456l"); // 5: Long
0N/A verify(output, "Double +123456.0d"); // 6: Double
0N/A verify(output, "Class +#[0-9]+ +// + T6868539"); // 7: Class
0N/A verify(output, "String +#[0-9]+ +// + not found"); // 8: String
0N/A verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref
0N/A verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref
0N/A verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
0N/A // 11: InterfaceMethodref
0N/A verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType
0N/A if (errors > 0)
0N/A throw new Error(errors + " found.");
0N/A }
0N/A
0N/A void verify(String output, String... expects) {
0N/A for (String expect: expects) {
0N/A if (!output.matches("(?s).*" + expect + ".*"))
0N/A error(expect + " not found");
0N/A }
0N/A }
0N/A
0N/A void error(String msg) {
0N/A System.err.println(msg);
0N/A errors++;
0N/A }
0N/A
0N/A int errors;
0N/A
0N/A String javap(String className) {
0N/A String testClasses = System.getProperty("test.classes", ".");
0N/A StringWriter sw = new StringWriter();
0N/A PrintWriter out = new PrintWriter(sw);
0N/A String[] args = { "-v", "-classpath", testClasses, className };
0N/A int rc = com.sun.tools.javap.Main.run(args, out);
0N/A if (rc != 0)
0N/A throw new Error("javap failed. rc=" + rc);
0N/A out.close();
0N/A String output = sw.toString();
0N/A System.out.println("class " + className);
0N/A System.out.println(output);
0N/A return output;
0N/A }
0N/A
0N/A int i = 123456;
0N/A float f = 123456.f;
0N/A double d = 123456.;
0N/A long l = 123456L;
0N/A
0N/A void m(Runnable r) { r.run(); }
0N/A}
0N/A
0N/A