mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8007907: javap, method com.sun.tools.javap.Main.run returns 0 even in case of class not found error
Reviewed-by: jjg
This commit is contained in:
parent
4836bfbcf1
commit
3596018eb7
6 changed files with 117 additions and 43 deletions
|
@ -25,26 +25,25 @@
|
|||
* @test
|
||||
* @bug 4645152 4785453
|
||||
* @summary javac compiler incorrectly inserts <clinit> when -g is specified
|
||||
* @library /tools/javac/lib
|
||||
* @build ToolBox
|
||||
* @run compile -g ConstDebugTest.java
|
||||
* @run main ConstDebugTest
|
||||
*/
|
||||
import java.nio.file.Paths;
|
||||
import com.sun.tools.classfile.ClassFile;
|
||||
import com.sun.tools.classfile.Method;
|
||||
|
||||
//original test: test/tools/javac/constDebug/ConstDebug.sh
|
||||
public class ConstDebugTest {
|
||||
|
||||
public static final long l = 12;
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
|
||||
// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
|
||||
ToolBox.JavaToolArgs javapArgs =
|
||||
new ToolBox.JavaToolArgs().setAllArgs("-v",
|
||||
"-classpath", System.getProperty("test.classes"), "ConstDebugTest.class");
|
||||
if (ToolBox.javap(javapArgs).contains("clinit")) {
|
||||
throw new AssertionError(
|
||||
"javac should not create a <clinit> method for ConstDebugTest class");
|
||||
ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"),
|
||||
ConstDebugTest.class.getSimpleName() + ".class"));
|
||||
for (Method method: classFile.methods) {
|
||||
if (method.getName(classFile.constant_pool).equals("<clinit>")) {
|
||||
throw new AssertionError(
|
||||
"javac should not create a <clinit> method for ConstDebugTest class");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue