Thu, 12 Jan 2012 15:28:34 +0000
7123100: javac fails with java.lang.StackOverflowError
Summary: Inference of under-constrained type-variables creates erroneous recursive wildcard types
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javadoc; |
duke@1 | 27 | |
duke@1 | 28 | import com.sun.javadoc.*; |
duke@1 | 29 | |
duke@1 | 30 | import com.sun.tools.javac.code.Symbol; |
duke@1 | 31 | import com.sun.tools.javac.code.Symbol.ClassSymbol; |
duke@1 | 32 | |
duke@1 | 33 | import com.sun.tools.javac.code.Type; |
duke@1 | 34 | import com.sun.tools.javac.code.TypeTags; |
duke@1 | 35 | import com.sun.tools.javac.code.Type.ClassType; |
duke@1 | 36 | |
duke@1 | 37 | class PrimitiveType implements com.sun.javadoc.Type { |
duke@1 | 38 | |
duke@1 | 39 | private final String name; |
duke@1 | 40 | |
duke@1 | 41 | static final PrimitiveType voidType = new PrimitiveType("void"); |
duke@1 | 42 | static final PrimitiveType booleanType = new PrimitiveType("boolean"); |
duke@1 | 43 | static final PrimitiveType byteType = new PrimitiveType("byte"); |
duke@1 | 44 | static final PrimitiveType charType = new PrimitiveType("char"); |
duke@1 | 45 | static final PrimitiveType shortType = new PrimitiveType("short"); |
duke@1 | 46 | static final PrimitiveType intType = new PrimitiveType("int"); |
duke@1 | 47 | static final PrimitiveType longType = new PrimitiveType("long"); |
duke@1 | 48 | static final PrimitiveType floatType = new PrimitiveType("float"); |
duke@1 | 49 | static final PrimitiveType doubleType = new PrimitiveType("double"); |
duke@1 | 50 | |
duke@1 | 51 | // error type, should never actually be used |
duke@1 | 52 | static final PrimitiveType errorType = new PrimitiveType(""); |
duke@1 | 53 | |
duke@1 | 54 | PrimitiveType(String name) { |
duke@1 | 55 | this.name = name; |
duke@1 | 56 | } |
duke@1 | 57 | |
duke@1 | 58 | /** |
duke@1 | 59 | * Return unqualified name of type excluding any dimension information. |
duke@1 | 60 | * <p> |
duke@1 | 61 | * For example, a two dimensional array of String returns 'String'. |
duke@1 | 62 | */ |
duke@1 | 63 | public String typeName() { |
duke@1 | 64 | return name; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * Return qualified name of type excluding any dimension information. |
duke@1 | 69 | *<p> |
duke@1 | 70 | * For example, a two dimensional array of String |
duke@1 | 71 | * returns 'java.lang.String'. |
duke@1 | 72 | */ |
duke@1 | 73 | public String qualifiedTypeName() { |
duke@1 | 74 | return name; |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | /** |
duke@1 | 78 | * Return the simple name of this type. |
duke@1 | 79 | */ |
duke@1 | 80 | public String simpleTypeName() { |
duke@1 | 81 | return name; |
duke@1 | 82 | } |
duke@1 | 83 | |
duke@1 | 84 | /** |
duke@1 | 85 | * Return the type's dimension information, as a string. |
duke@1 | 86 | * <p> |
duke@1 | 87 | * For example, a two dimensional array of String returns '[][]'. |
duke@1 | 88 | */ |
duke@1 | 89 | public String dimension() { |
duke@1 | 90 | return ""; |
duke@1 | 91 | } |
duke@1 | 92 | |
duke@1 | 93 | /** |
duke@1 | 94 | * Return this type as a class. Array dimensions are ignored. |
duke@1 | 95 | * |
duke@1 | 96 | * @return a ClassDocImpl if the type is a Class. |
duke@1 | 97 | * Return null if it is a primitive type.. |
duke@1 | 98 | */ |
duke@1 | 99 | public ClassDoc asClassDoc() { |
duke@1 | 100 | return null; |
duke@1 | 101 | } |
duke@1 | 102 | |
duke@1 | 103 | /** |
duke@1 | 104 | * Return null, as this is not an annotation type. |
duke@1 | 105 | */ |
duke@1 | 106 | public AnnotationTypeDoc asAnnotationTypeDoc() { |
duke@1 | 107 | return null; |
duke@1 | 108 | } |
duke@1 | 109 | |
duke@1 | 110 | /** |
duke@1 | 111 | * Return null, as this is not an instantiation. |
duke@1 | 112 | */ |
duke@1 | 113 | public ParameterizedType asParameterizedType() { |
duke@1 | 114 | return null; |
duke@1 | 115 | } |
duke@1 | 116 | |
duke@1 | 117 | /** |
duke@1 | 118 | * Return null, as this is not a type variable. |
duke@1 | 119 | */ |
duke@1 | 120 | public TypeVariable asTypeVariable() { |
duke@1 | 121 | return null; |
duke@1 | 122 | } |
duke@1 | 123 | |
duke@1 | 124 | /** |
duke@1 | 125 | * Return null, as this is not a wildcard type; |
duke@1 | 126 | */ |
duke@1 | 127 | public WildcardType asWildcardType() { |
duke@1 | 128 | return null; |
duke@1 | 129 | } |
duke@1 | 130 | |
duke@1 | 131 | /** |
duke@1 | 132 | * Returns a string representation of the type. |
duke@1 | 133 | * |
duke@1 | 134 | * Return name of type including any dimension information. |
duke@1 | 135 | * <p> |
duke@1 | 136 | * For example, a two dimensional array of String returns |
duke@1 | 137 | * <code>String[][]</code>. |
duke@1 | 138 | * |
duke@1 | 139 | * @return name of type including any dimension information. |
duke@1 | 140 | */ |
duke@1 | 141 | public String toString() { |
duke@1 | 142 | return qualifiedTypeName(); |
duke@1 | 143 | } |
duke@1 | 144 | |
duke@1 | 145 | /** |
duke@1 | 146 | * Return true if this is a primitive type. |
duke@1 | 147 | */ |
duke@1 | 148 | public boolean isPrimitive() { |
duke@1 | 149 | return true; |
duke@1 | 150 | } |
duke@1 | 151 | } |