1.1 --- a/test/tools/javac/constDebug/ConstDebugTest.java Tue Jun 11 09:35:58 2013 +0100 1.2 +++ b/test/tools/javac/constDebug/ConstDebugTest.java Tue Jun 11 09:59:34 2013 +0100 1.3 @@ -25,26 +25,25 @@ 1.4 * @test 1.5 * @bug 4645152 4785453 1.6 * @summary javac compiler incorrectly inserts <clinit> when -g is specified 1.7 - * @library /tools/javac/lib 1.8 - * @build ToolBox 1.9 * @run compile -g ConstDebugTest.java 1.10 * @run main ConstDebugTest 1.11 */ 1.12 +import java.nio.file.Paths; 1.13 +import com.sun.tools.classfile.ClassFile; 1.14 +import com.sun.tools.classfile.Method; 1.15 1.16 -//original test: test/tools/javac/constDebug/ConstDebug.sh 1.17 public class ConstDebugTest { 1.18 1.19 public static final long l = 12; 1.20 1.21 public static void main(String args[]) throws Exception { 1.22 -// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1} 1.23 -// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail 1.24 - ToolBox.JavaToolArgs javapArgs = 1.25 - new ToolBox.JavaToolArgs().setAllArgs("-v", 1.26 - "-classpath", System.getProperty("test.classes"), "ConstDebugTest.class"); 1.27 - if (ToolBox.javap(javapArgs).contains("clinit")) { 1.28 - throw new AssertionError( 1.29 - "javac should not create a <clinit> method for ConstDebugTest class"); 1.30 + ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"), 1.31 + ConstDebugTest.class.getSimpleName() + ".class")); 1.32 + for (Method method: classFile.methods) { 1.33 + if (method.getName(classFile.constant_pool).equals("<clinit>")) { 1.34 + throw new AssertionError( 1.35 + "javac should not create a <clinit> method for ConstDebugTest class"); 1.36 + } 1.37 } 1.38 } 1.39