annotate test/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java @ 18408:2c3666f44855

Truffle: initial commit of object API implementation
author Andreas Woess <andreas.woess@jku.at>
date Tue, 18 Nov 2014 23:19:43 +0100
parents 366c198c896d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17934
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
1 /*
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
4 *
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
7 * published by the Free Software Foundation.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
8 *
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
13 * accompanied this code).
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
14 *
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
18 *
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
21 * questions.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
22 */
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
23
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
24 /*
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
25 * @test TestEmptyBootstrapMethodsAttr
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
26 * @bug 8041918
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
27 * @library /testlibrary
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
28 * @summary Test empty bootstrap_methods table within BootstrapMethods attribute
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
29 * @compile TestEmptyBootstrapMethodsAttr.java
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
30 * @run main TestEmptyBootstrapMethodsAttr
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
31 */
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
32
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
33 import java.io.File;
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
34 import com.oracle.java.testlibrary.*;
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
35
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
36 public class TestEmptyBootstrapMethodsAttr {
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
37
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
38 public static void main(String args[]) throws Throwable {
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
39 System.out.println("Regression test for bug 8041918");
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
40 String jarFile = System.getProperty("test.src") + File.separator + "emptynumbootstrapmethods.jar";
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
41
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
42 // ====== extract the test case
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
43 ProcessBuilder pb = new ProcessBuilder(new String[] { JDKToolFinder.getJDKTool("jar"), "xvf", jarFile } );
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
44 OutputAnalyzer output = new OutputAnalyzer(pb.start());
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
45 output.shouldHaveExitValue(0);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
46
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
47 // Test case #1:
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
48 // Try loading class with empty bootstrap_methods table where no
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
49 // other attributes are following BootstrapMethods in attribute table.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
50 String className = "emptynumbootstrapmethods1";
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
51
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
52 // ======= execute test case #1
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
53 // Expect a lack of main method, this implies that the class loaded correctly
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
54 // with an empty bootstrap_methods and did not generate a ClassFormatError.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
55 pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
56 output = new OutputAnalyzer(pb.start());
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
57 output.shouldNotContain("java.lang.ClassFormatError");
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
58 output.shouldContain("Main method not found in class " + className);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
59 output.shouldHaveExitValue(1);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
60
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
61 // Test case #2:
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
62 // Try loading class with empty bootstrap_methods table where an
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
63 // AnnotationDefault attribute follows the BootstrapMethods in the attribute table.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
64 className = "emptynumbootstrapmethods2";
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
65
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
66 // ======= execute test case #2
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
67 // Expect a lack of main method, this implies that the class loaded correctly
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
68 // with an empty bootstrap_methods and did not generate ClassFormatError.
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
69 pb = ProcessTools.createJavaProcessBuilder("-cp", ".", className);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
70 output = new OutputAnalyzer(pb.start());
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
71 output.shouldNotContain("java.lang.ClassFormatError");
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
72 output.shouldContain("Main method not found in class " + className);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
73 output.shouldHaveExitValue(1);
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
74 }
366c198c896d 8041918: BootstrapMethods attribute cannot be empty.
lfoltan
parents:
diff changeset
75 }