/* * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 7093325 8006694 8129962 * @summary Redundant entry in bytecode exception table * temporarily workaround combo tests are causing time out in several platforms * @library /tools/javac/lib * @modules jdk.jdeps/com.sun.tools.classfile * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.file * jdk.compiler/com.sun.tools.javac.util * @build combo.ComboTestHelper * @run main T7093325
*/
void verifyBytecode(Result<Iterable<? extends JavaFileObject>> result) { boolean lastInlined = false; boolean hasCode = false; int gapsCount = 0; for (int i = 0; i < ca.ordinal() + 1 ; i++) {
lastInlined = stmts[i].canInline;
hasCode = hasCode || !stmts[i].empty; if (lastInlined && hasCode) {
hasCode = false;
gapsCount++;
}
} if (!lastInlined) {
gapsCount++;
}
try (InputStream is = result.get().iterator().next().openInputStream()) {
ClassFile cf = ClassFile.read(is); if (cf == null) {
fail("Classfile not found: " + result.compilationInfo()); return;
}
Method test_method = null; for (Method m : cf.methods) { if (m.getName(cf.constant_pool).equals("test")) {
test_method = m; break;
}
}
if (test_method == null) {
fail("Method test() not found in class Test" + result.compilationInfo()); return;
}
Code_attribute code = null; for (Attribute a : test_method.attributes) { if (a.getName(cf.constant_pool).equals(Attribute.Code)) {
code = (Code_attribute)a; break;
}
}
if (code == null) {
fail("Code attribute not found in method test()"); return;
}
int actualGapsCount = 0; for (int i = 0; i < code.exception_table_length ; i++) { int catchType = code.exception_table[i].catch_type; if (catchType == 0) { //any
actualGapsCount++;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.