565N/A/*
2320N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
565N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
565N/A *
565N/A * This code is free software; you can redistribute it and/or modify it
565N/A * under the terms of the GNU General Public License version 2 only, as
565N/A * published by the Free Software Foundation.
565N/A *
565N/A * This code is distributed in the hope that it will be useful, but WITHOUT
565N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
565N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
565N/A * version 2 for more details (a copy is included in the LICENSE file that
565N/A * accompanied this code).
565N/A *
565N/A * You should have received a copy of the GNU General Public License version
565N/A * 2 along with this work; if not, write to the Free Software Foundation,
565N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
565N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
565N/A */
565N/A
565N/A/*
565N/A * @test
565N/A * @bug 4459541
565N/A * @summary "javap -l" shows line numbers as signed short; they should be unsigned.
565N/A */
4502N/A
565N/Aimport java.io.*;
565N/A
565N/Apublic class T4459541 {
565N/A public static void main(String[] args) throws Exception {
565N/A new T4459541().run();
565N/A }
565N/A
565N/A public void run() throws IOException {
565N/A File javaFile = writeTestFile();
565N/A File classFile = compileTestFile(javaFile);
565N/A String output = javap(classFile);
565N/A verify(output);
565N/A }
565N/A
565N/A File writeTestFile() throws IOException {
565N/A File f = new File("Test.java");
565N/A out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
565N/A println("class Test {");
565N/A println("void begin(int i) {");
565N/A println("i++;");
565N/A println("i++;");
565N/A println("}");
565N/A while (line < 32750)
565N/A println("// " + line);
565N/A println("void before_32767(int i) {");
565N/A println("i++;");
565N/A println("i++;");
565N/A println("}");
565N/A while (line < 32768-4)
565N/A println("// " + line);
565N/A println("void straddle_32768(int i) {");
while (line < 32768+4)
println("i++;");
println("}");
while (line < 65520)
println("// " + line);
println("void between_32768_and_65536(int i) {");
println("i++;");
println("i++;");
println("}");
while (line < 65536-4)
println("// " + line);
println("void straddle_65536(int i) {");
while (line < 65536+4)
println("i++;");
println("}");
println("}");
out.close();
return f;
}
File compileTestFile(File f) {
int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
if (rc != 0)
throw new Error("compilation failed. rc=" + rc);
String path = f.getPath();
return new File(path.substring(0, path.length() - 5) + ".class");
}
String javap(File f) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(new String[] { "-l", f.getPath() }, out);
if (rc != 0)
throw new Error("javap failed. rc=" + rc);
out.close();
return sw.toString();
}
void verify(String output) {
System.out.println(output);
if (output.indexOf("-") >= 0)
throw new Error("- found in output");
}
void println(String text) {
out.println(text);
line++;
}
PrintWriter out;
int line = 1;
}