Mon, 23 Sep 2013 17:27:38 +0400
7154966: CRs found to be in Fixed state with no test and no noreg- keyword.
Reviewed-by: ksrini
1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 7005371
27 * @summary Multicatch: assertion error while generating LocalVariableTypeTable attribute
28 * @compile -g SubTest.java
29 * @run main T7005371
30 */
32 import com.sun.tools.classfile.Attribute;
33 import com.sun.tools.classfile.ClassFile;
34 import com.sun.tools.classfile.Code_attribute;
35 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
36 import com.sun.tools.classfile.Method;
38 import java.io.*;
40 public class T7005371 {
42 static final String SUBTEST_NAME = SubTest.class.getName() + ".class";
43 static final String TEST_METHOD_NAME = "test";
44 static final int LVT_LENGTH = 1;
45 static final String LVT_SIG_TYPE = "Ljava/util/List<Ljava/lang/String;>;";
48 public static void main(String... args) throws Exception {
49 new T7005371().run();
50 }
52 public void run() throws Exception {
53 String workDir = System.getProperty("test.classes");
54 System.out.println(workDir);
55 File compiledTest = new File(workDir, SUBTEST_NAME);
56 verifyLocalVariableTypeTableAttr(compiledTest);
57 }
59 void verifyLocalVariableTypeTableAttr(File f) {
60 System.err.println("verify: " + f);
61 try {
62 ClassFile cf = ClassFile.read(f);
63 Method testMethod = null;
64 for (Method m : cf.methods) {
65 if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) {
66 testMethod = m;
67 break;
68 }
69 }
70 if (testMethod == null) {
71 throw new Error("Missing method: " + TEST_METHOD_NAME);
72 }
73 Code_attribute code = (Code_attribute)testMethod.attributes.get(Attribute.Code);
74 if (code == null) {
75 throw new Error("Missing Code attribute for method: " + TEST_METHOD_NAME);
76 }
77 LocalVariableTypeTable_attribute lvt_table =
78 (LocalVariableTypeTable_attribute)code.attributes.get(Attribute.LocalVariableTypeTable);
79 if (lvt_table == null) {
80 throw new Error("Missing LocalVariableTypeTable attribute for method: " + TEST_METHOD_NAME);
81 }
82 if (lvt_table.local_variable_table_length != LVT_LENGTH) {
83 throw new Error("LocalVariableTypeTable has wrong size" +
84 "\nfound: " + lvt_table.local_variable_table_length +
85 "\nrequired: " + LVT_LENGTH);
86 }
87 String sig =
88 cf.constant_pool.getUTF8Value(lvt_table.local_variable_table[0].signature_index);
90 if (sig == null || !sig.equals(LVT_SIG_TYPE)) {
91 throw new Error("LocalVariableTypeTable has wrong signature" +
92 "\nfound: " + sig +
93 "\nrequired: " + LVT_SIG_TYPE);
94 }
95 } catch (Exception e) {
96 e.printStackTrace();
97 throw new Error("error reading " + f +": " + e);
98 }
99 }
100 }