Mon, 17 Oct 2011 12:57:36 +0100
7093325: Redundant entry in bytecode exception table
Summary: Inlining of finalizers does not update gaps list accordingly
Reviewed-by: jjg
jjg@86 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. |
jjg@86 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@86 | 4 | * |
jjg@86 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@86 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@86 | 7 | * published by the Free Software Foundation. |
jjg@86 | 8 | * |
jjg@86 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@86 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@86 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@86 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@86 | 13 | * accompanied this code). |
jjg@86 | 14 | * |
jjg@86 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@86 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@86 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@86 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jjg@86 | 22 | */ |
jjg@86 | 23 | |
jjg@86 | 24 | /* |
jjg@86 | 25 | * @test |
jjg@86 | 26 | * @bug 6627364 6627366 |
jjg@86 | 27 | * @summary Synthesize important classes if they are missing from the (boot)classpath |
jjg@86 | 28 | */ |
jjg@86 | 29 | |
jjg@86 | 30 | import java.io.*; |
jjg@86 | 31 | import java.util.*; |
jjg@86 | 32 | |
jjg@86 | 33 | public class Main |
jjg@86 | 34 | { |
jjg@86 | 35 | File testSrc = new File(System.getProperty("test.src")); |
jjg@86 | 36 | |
jjg@86 | 37 | public static void main(String[] args) throws Exception { |
jjg@86 | 38 | new Main().run(); |
jjg@86 | 39 | } |
jjg@86 | 40 | |
jjg@86 | 41 | public void run() throws Exception { |
jjg@86 | 42 | |
jjg@86 | 43 | // compile with standard bootclasspath |
jjg@86 | 44 | compile(true, "Test.java"); |
jjg@86 | 45 | |
jjg@86 | 46 | // compile with various missing system classes |
jjg@86 | 47 | |
jjg@86 | 48 | List<String> base_files = Arrays.asList( |
jjg@86 | 49 | "Boolean.java", |
jjg@86 | 50 | "Byte.java", |
jjg@86 | 51 | "Character.java", |
jjg@86 | 52 | "Integer.java", |
jjg@86 | 53 | "Long.java", |
jjg@86 | 54 | "Number.java", |
jjg@86 | 55 | "Object.java", |
jjg@86 | 56 | "Short.java", |
jjg@86 | 57 | "Void.java" |
jjg@86 | 58 | ); |
jjg@86 | 59 | |
jjg@86 | 60 | List<String> extra_files = Arrays.asList( |
jjg@86 | 61 | "Double.java", |
jjg@86 | 62 | "Float.java", |
jjg@86 | 63 | "Cloneable.java", |
jjg@86 | 64 | "Serializable.java" |
jjg@86 | 65 | ); |
jjg@86 | 66 | |
jjg@86 | 67 | List<String> files = new ArrayList<String>(); |
jjg@86 | 68 | files.addAll(base_files); |
jjg@86 | 69 | files.add("Test.java"); |
jjg@86 | 70 | |
jjg@86 | 71 | compile(false, files); |
jjg@86 | 72 | |
jjg@86 | 73 | for (String f: extra_files) { |
jjg@86 | 74 | files = new ArrayList<String>(); |
jjg@86 | 75 | files.addAll(base_files); |
jjg@86 | 76 | files.addAll(extra_files); |
jjg@86 | 77 | files.remove(f); |
jjg@86 | 78 | files.add("Test.java"); |
jjg@86 | 79 | compile(false, files); |
jjg@86 | 80 | } |
jjg@86 | 81 | |
jjg@86 | 82 | if (errors > 0) |
jjg@86 | 83 | throw new Exception(errors + " errors occurred"); |
jjg@86 | 84 | } |
jjg@86 | 85 | |
jjg@86 | 86 | void compile(boolean stdBootClassPath, String... files) { |
jjg@86 | 87 | compile(stdBootClassPath, Arrays.asList(files)); |
jjg@86 | 88 | } |
jjg@86 | 89 | |
jjg@86 | 90 | void compile(boolean stdBootClassPath, List<String> files) { |
jjg@86 | 91 | File empty = new File("empty"); |
jjg@86 | 92 | empty.mkdirs(); |
jjg@86 | 93 | |
jjg@86 | 94 | List<String> args = new ArrayList<String>(); |
jjg@86 | 95 | args.add("-classpath"); |
jjg@86 | 96 | args.add("empty"); |
jjg@86 | 97 | |
jjg@86 | 98 | if (!stdBootClassPath) { |
jjg@86 | 99 | args.add("-bootclasspath"); |
jjg@86 | 100 | args.add("empty"); |
jjg@86 | 101 | } |
jjg@86 | 102 | args.add("-d"); |
jjg@86 | 103 | args.add("."); |
jjg@86 | 104 | for (String f: files) |
jjg@86 | 105 | args.add(new File(testSrc, f).getPath()); |
jjg@86 | 106 | |
jjg@86 | 107 | System.out.println("Compile: " + args); |
jjg@86 | 108 | StringWriter out = new StringWriter(); |
jjg@86 | 109 | int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), |
jjg@86 | 110 | new PrintWriter(out)); |
jjg@86 | 111 | System.out.println(out.toString()); |
jjg@86 | 112 | System.out.println("result: " + rc); |
jjg@86 | 113 | System.out.println(); |
jjg@86 | 114 | |
jjg@86 | 115 | if (rc != 0) |
jjg@86 | 116 | errors++; |
jjg@86 | 117 | } |
jjg@86 | 118 | |
jjg@86 | 119 | private int errors; |
jjg@86 | 120 | } |
jjg@86 | 121 | |
jjg@86 | 122 |