Sat, 13 Apr 2013 12:25:44 +0100
8010659: Javac Crashes while building OpenJFX
Reviewed-by: jjg
Contributed-by: maurizio.cimadamore@oracle.com
jjg@1521 | 1 | /* |
darcy@1534 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
jjg@1521 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@1521 | 4 | * |
jjg@1521 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@1521 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@1521 | 7 | * published by the Free Software Foundation. |
jjg@1521 | 8 | * |
jjg@1521 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@1521 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@1521 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@1521 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@1521 | 13 | * accompanied this code). |
jjg@1521 | 14 | * |
jjg@1521 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@1521 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@1521 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@1521 | 18 | * |
jjg@1521 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jjg@1521 | 20 | * or visit www.oracle.com if you need additional information or have any |
jjg@1521 | 21 | * questions. |
jjg@1521 | 22 | */ |
jjg@1521 | 23 | |
jjg@1521 | 24 | import static com.sun.tools.classfile.TypeAnnotation.TargetType.*; |
jjg@1521 | 25 | |
jjg@1521 | 26 | /* |
jjg@1521 | 27 | * @test |
jjg@1521 | 28 | * @summary Test population of reference info for type casts |
jjg@1521 | 29 | * @compile -g Driver.java ReferenceInfoUtil.java TypeCasts.java |
jjg@1521 | 30 | * @run main Driver TypeCasts |
jjg@1521 | 31 | */ |
jjg@1521 | 32 | public class TypeCasts { |
jjg@1521 | 33 | |
jjg@1563 | 34 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 35 | typeIndex = 0) |
jjg@1521 | 36 | public String returnObject() { |
jjg@1521 | 37 | return "Object returnObject() { return (@TA String)null; }"; |
jjg@1521 | 38 | } |
jjg@1521 | 39 | |
jjg@1521 | 40 | @TADescriptions({ |
jjg@1563 | 41 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 42 | typeIndex = 0), |
jjg@1521 | 43 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 44 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 45 | typeIndex = 0), |
jjg@1521 | 46 | @TADescription(annotation = "TC", type = CAST, |
jjg@1563 | 47 | genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 48 | typeIndex = 0) |
jjg@1521 | 49 | }) |
jjg@1521 | 50 | public String returnObjectArray() { |
jjg@1521 | 51 | return "Object returnObjectArray() { return (@TC String @TA [] @TB [])null; }"; |
jjg@1521 | 52 | } |
jjg@1521 | 53 | |
jjg@1521 | 54 | @TADescriptions({ |
jjg@1563 | 55 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 56 | typeIndex = 0), |
jjg@1521 | 57 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 58 | genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 59 | typeIndex = 0) |
jjg@1521 | 60 | }) |
jjg@1521 | 61 | public String returnObjectGeneric() { |
jjg@1521 | 62 | return "Object returnObjectGeneric() { return (@TA List<@TB String>)null; }"; |
jjg@1521 | 63 | } |
jjg@1521 | 64 | |
jjg@1563 | 65 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 66 | typeIndex = 0) |
jjg@1521 | 67 | public String returnPrim() { |
jjg@1521 | 68 | return "Object returnPrim() { return (@TA int)0; }"; |
jjg@1521 | 69 | } |
jjg@1521 | 70 | |
jjg@1521 | 71 | @TADescriptions({ |
jjg@1563 | 72 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 73 | typeIndex = 0), |
jjg@1521 | 74 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 75 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 76 | typeIndex = 0) |
jjg@1521 | 77 | }) |
jjg@1521 | 78 | public String returnPrimArray() { |
jjg@1521 | 79 | return "Object returnPrimArray() { return (@TB int @TA [])null; }"; |
jjg@1521 | 80 | } |
jjg@1521 | 81 | |
jjg@1563 | 82 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 83 | typeIndex = 0) |
jjg@1521 | 84 | public String initObject() { |
jjg@1521 | 85 | return "void initObject() { Object a = (@TA String)null; }"; |
jjg@1521 | 86 | } |
jjg@1521 | 87 | |
jjg@1521 | 88 | @TADescriptions({ |
jjg@1563 | 89 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 90 | typeIndex = 0), |
jjg@1521 | 91 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 92 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 93 | typeIndex = 0) |
jjg@1521 | 94 | }) |
jjg@1521 | 95 | public String initObjectArray() { |
jjg@1521 | 96 | return "void initObjectArray() { Object a = (@TB String @TA [])null; }"; |
jjg@1521 | 97 | } |
jjg@1521 | 98 | |
jjg@1521 | 99 | @TADescriptions({ |
jjg@1563 | 100 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 101 | typeIndex = 0), |
jjg@1521 | 102 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 103 | genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 104 | typeIndex = 0) |
jjg@1521 | 105 | }) |
jjg@1521 | 106 | public String initObjectGeneric() { |
jjg@1521 | 107 | return "void initObjectGeneric() { Object a = (@TA List<@TB String>)null; }"; |
jjg@1521 | 108 | } |
jjg@1521 | 109 | |
jjg@1563 | 110 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 111 | typeIndex = 0) |
jjg@1521 | 112 | public String initPrim() { |
jjg@1521 | 113 | return "void initPrim() { Object a = (@TA int)0; }"; |
jjg@1521 | 114 | } |
jjg@1521 | 115 | |
jjg@1521 | 116 | @TADescriptions({ |
jjg@1563 | 117 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 118 | typeIndex = 0), |
jjg@1521 | 119 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 120 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 121 | typeIndex = 0) |
jjg@1521 | 122 | }) |
jjg@1521 | 123 | public String initPrimArray() { |
jjg@1521 | 124 | return "void initPrimArray() { Object a = (@TB int @TA [])null; }"; |
jjg@1521 | 125 | } |
jjg@1521 | 126 | |
jjg@1563 | 127 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 128 | typeIndex = 0) |
jjg@1521 | 129 | public String eqtestObject() { |
jjg@1521 | 130 | return "void eqtestObject() { if (null == (@TA String)null); }"; |
jjg@1521 | 131 | } |
jjg@1521 | 132 | |
jjg@1521 | 133 | @TADescriptions({ |
jjg@1563 | 134 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 135 | typeIndex = 0), |
jjg@1521 | 136 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 137 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 138 | typeIndex = 0) |
jjg@1521 | 139 | }) |
jjg@1521 | 140 | public String eqtestObjectArray() { |
jjg@1521 | 141 | return "void eqtestObjectArray() { if (null == (@TB String @TA [])null); }"; |
jjg@1521 | 142 | } |
jjg@1521 | 143 | |
jjg@1521 | 144 | @TADescriptions({ |
jjg@1563 | 145 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 146 | typeIndex = 0), |
jjg@1521 | 147 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 148 | genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 149 | typeIndex = 0) |
jjg@1521 | 150 | }) |
jjg@1521 | 151 | public String eqtestObjectGeneric() { |
jjg@1521 | 152 | return "void eqtestObjectGeneric() { if (null == (@TA List<@TB String >)null); }"; |
jjg@1521 | 153 | } |
jjg@1521 | 154 | |
jjg@1563 | 155 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 156 | typeIndex = 0) |
jjg@1521 | 157 | // compiler optimizes away compile time constants casts |
jjg@1521 | 158 | public String eqtestPrim() { |
jjg@1521 | 159 | return "void eqtestPrim(int a) { if (0 == (@TA int)a); }"; |
jjg@1521 | 160 | } |
jjg@1521 | 161 | |
jjg@1521 | 162 | @TADescriptions({ |
jjg@1563 | 163 | @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 164 | typeIndex = 0), |
jjg@1521 | 165 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 166 | genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE, |
jjg@1563 | 167 | typeIndex = 0) |
jjg@1521 | 168 | }) |
jjg@1521 | 169 | public String eqtestPrimArray() { |
jjg@1521 | 170 | return "void eqtestPrimArray() { if (null == (@TB int @TA [])null); }"; |
jjg@1521 | 171 | } |
jjg@1521 | 172 | |
jjg@1563 | 173 | @TADescriptions({ |
jjg@1563 | 174 | @TADescription(annotation = "TA", type = CAST, |
jjg@1563 | 175 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0), |
jjg@1563 | 176 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 177 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1), |
jjg@1563 | 178 | @TADescription(annotation = "TC", type = CAST, |
jjg@1563 | 179 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1, |
jjg@1563 | 180 | genericLocation = {3, 0}) |
jjg@1563 | 181 | }) |
jjg@1563 | 182 | public String intersection1() { |
jjg@1563 | 183 | return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String>) null; }"; |
jjg@1563 | 184 | } |
jjg@1563 | 185 | |
jjg@1563 | 186 | @TADescriptions({ |
jjg@1563 | 187 | @TADescription(annotation = "TA", type = CAST, |
jjg@1563 | 188 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0), |
jjg@1563 | 189 | @TADescription(annotation = "TB", type = CAST, |
jjg@1563 | 190 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1), |
jjg@1563 | 191 | @TADescription(annotation = "TC", type = CAST, |
jjg@1563 | 192 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1, |
jjg@1563 | 193 | genericLocation = {3, 0}), |
jjg@1563 | 194 | @TADescription(annotation = "TD", type = CAST, |
jjg@1563 | 195 | offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 2), |
jjg@1563 | 196 | }) |
jjg@1563 | 197 | public String intersection2() { |
jjg@1563 | 198 | return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String> & @TD CharSequence) null; }"; |
jjg@1563 | 199 | } |
jjg@1521 | 200 | } |