Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
vromero@1432 | 1 | /* |
vromero@1432 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
vromero@1432 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
vromero@1432 | 4 | * |
vromero@1432 | 5 | * This code is free software; you can redistribute it and/or modify it |
vromero@1432 | 6 | * under the terms of the GNU General Public License version 2 only, as |
vromero@1432 | 7 | * published by the Free Software Foundation. Oracle designates this |
vromero@1432 | 8 | * particular file as subject to the "Classpath" exception as provided |
vromero@1432 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
vromero@1432 | 10 | * |
vromero@1432 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
vromero@1432 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
vromero@1432 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
vromero@1432 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
vromero@1432 | 15 | * accompanied this code). |
vromero@1432 | 16 | * |
vromero@1432 | 17 | * You should have received a copy of the GNU General Public License version |
vromero@1432 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
vromero@1432 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
vromero@1432 | 20 | * |
vromero@1432 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
vromero@1432 | 22 | * or visit www.oracle.com if you need additional information or have any |
vromero@1432 | 23 | * questions. |
vromero@1432 | 24 | */ |
vromero@1432 | 25 | |
vromero@1432 | 26 | /* |
vromero@1432 | 27 | * @test |
vromero@1432 | 28 | * @bug 7153958 |
vromero@1432 | 29 | * @summary add constant pool reference to class containing inlined constants |
vromero@1451 | 30 | * @compile pkg/ClassToBeStaticallyImported.java CPoolRefClassContainingInlinedCts.java |
vromero@1432 | 31 | * @run main CPoolRefClassContainingInlinedCts |
vromero@1432 | 32 | */ |
vromero@1432 | 33 | |
vromero@1432 | 34 | import com.sun.tools.classfile.ClassFile; |
vromero@1432 | 35 | import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; |
vromero@1432 | 36 | import com.sun.tools.classfile.ConstantPool.CPInfo; |
vromero@1432 | 37 | import com.sun.tools.classfile.ConstantPoolException; |
vromero@1432 | 38 | import java.io.File; |
vromero@1432 | 39 | import java.io.IOException; |
vromero@1432 | 40 | |
vromero@1432 | 41 | import static pkg.ClassToBeStaticallyImported.staticField; |
vromero@1432 | 42 | |
vromero@1432 | 43 | public class CPoolRefClassContainingInlinedCts { |
vromero@1432 | 44 | |
vromero@1432 | 45 | public static void main(String args[]) throws Exception { |
vromero@1432 | 46 | new CPoolRefClassContainingInlinedCts().run(); |
vromero@1432 | 47 | } |
vromero@1432 | 48 | |
vromero@1432 | 49 | void run() throws Exception { |
vromero@1432 | 50 | checkReferences(); |
vromero@1432 | 51 | } |
vromero@1432 | 52 | |
vromero@1432 | 53 | int numberOfReferencedClassesToBeChecked = 0; |
vromero@1432 | 54 | |
vromero@1432 | 55 | void checkClassName(String className) { |
vromero@1432 | 56 | switch (className) { |
vromero@1432 | 57 | case "SimpleAssignClass" : case "BinaryExpClass": |
vromero@1432 | 58 | case "UnaryExpClass" : case "CastClass": |
vromero@1432 | 59 | case "ParensClass" : case "CondClass": |
vromero@1432 | 60 | case "IfClass" : case "pkg/ClassToBeStaticallyImported": |
vromero@1432 | 61 | numberOfReferencedClassesToBeChecked++; |
vromero@1432 | 62 | } |
vromero@1432 | 63 | } |
vromero@1432 | 64 | |
vromero@1432 | 65 | void checkReferences() throws IOException, ConstantPoolException { |
vromero@1432 | 66 | File testClasses = new File(System.getProperty("test.classes")); |
vromero@1432 | 67 | File file = new File(testClasses, |
vromero@1432 | 68 | CPoolRefClassContainingInlinedCts.class.getName() + ".class"); |
vromero@1432 | 69 | ClassFile classFile = ClassFile.read(file); |
vromero@1432 | 70 | int i = 1; |
vromero@1432 | 71 | CPInfo cpInfo; |
vromero@1432 | 72 | while (i < classFile.constant_pool.size()) { |
vromero@1432 | 73 | cpInfo = classFile.constant_pool.get(i); |
vromero@1432 | 74 | if (cpInfo instanceof CONSTANT_Class_info) { |
vromero@1432 | 75 | checkClassName(((CONSTANT_Class_info)cpInfo).getName()); |
vromero@1432 | 76 | } |
vromero@1432 | 77 | i += cpInfo.size(); |
vromero@1432 | 78 | } |
vromero@1432 | 79 | if (numberOfReferencedClassesToBeChecked != 8) { |
vromero@1432 | 80 | throw new AssertionError("Class reference missing in the constant pool"); |
vromero@1432 | 81 | } |
vromero@1432 | 82 | } |
vromero@1432 | 83 | |
vromero@1432 | 84 | private int assign = SimpleAssignClass.x; |
vromero@1432 | 85 | private int binary = BinaryExpClass.x + 1; |
vromero@1432 | 86 | private int unary = -UnaryExpClass.x; |
vromero@1432 | 87 | private int cast = (int)CastClass.x; |
vromero@1432 | 88 | private int parens = (ParensClass.x); |
vromero@1432 | 89 | private int cond = (CondClass.x == 1) ? 1 : 2; |
vromero@1432 | 90 | private static int ifConstant; |
vromero@1432 | 91 | private static int importStatic; |
vromero@1432 | 92 | static { |
vromero@1432 | 93 | if (IfClass.x == 1) { |
vromero@1432 | 94 | ifConstant = 1; |
vromero@1432 | 95 | } else { |
vromero@1432 | 96 | ifConstant = 2; |
vromero@1432 | 97 | } |
vromero@1432 | 98 | } |
vromero@1432 | 99 | static { |
vromero@1432 | 100 | if (staticField == 1) { |
vromero@1432 | 101 | importStatic = 1; |
vromero@1432 | 102 | } else { |
vromero@1432 | 103 | importStatic = 2; |
vromero@1432 | 104 | } |
vromero@1432 | 105 | } |
vromero@1432 | 106 | } |
vromero@1432 | 107 | |
vromero@1432 | 108 | class SimpleAssignClass { |
vromero@1432 | 109 | public static final int x = 1; |
vromero@1432 | 110 | } |
vromero@1432 | 111 | |
vromero@1432 | 112 | class BinaryExpClass { |
vromero@1432 | 113 | public static final int x = 1; |
vromero@1432 | 114 | } |
vromero@1432 | 115 | |
vromero@1432 | 116 | class UnaryExpClass { |
vromero@1432 | 117 | public static final int x = 1; |
vromero@1432 | 118 | } |
vromero@1432 | 119 | |
vromero@1432 | 120 | class CastClass { |
vromero@1432 | 121 | public static final int x = 1; |
vromero@1432 | 122 | } |
vromero@1432 | 123 | |
vromero@1432 | 124 | class ParensClass { |
vromero@1432 | 125 | public static final int x = 1; |
vromero@1432 | 126 | } |
vromero@1432 | 127 | |
vromero@1432 | 128 | class CondClass { |
vromero@1432 | 129 | public static final int x = 1; |
vromero@1432 | 130 | } |
vromero@1432 | 131 | |
vromero@1432 | 132 | class IfClass { |
vromero@1432 | 133 | public static final int x = 1; |
vromero@1432 | 134 | } |