This commit is contained in:
Lana Steuck 2014-05-15 10:40:27 -07:00
commit f1eb2bc57f
203 changed files with 8783 additions and 10260 deletions

View file

@ -1,3 +1,34 @@
#
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# - Neither the name of Oracle nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4

View file

@ -878,8 +878,9 @@ public class Util {
*/ */
static abstract class DocComparator<T extends Doc> implements Comparator<Doc> { static abstract class DocComparator<T extends Doc> implements Comparator<Doc> {
/** /**
* compares two parameter arrays by first comparing the length of the arrays, and * compares two parameter arrays by comparing each Type of the parameter in the array,
* then each Type of the parameter in the array. * as possible, if the matched strings are identical, and have mismatched array lengths
* then compare the lengths.
* @param params1 the first parameter array. * @param params1 the first parameter array.
* @param params2 the first parameter array. * @param params2 the first parameter array.
* @return a negative integer, zero, or a positive integer as the first * @return a negative integer, zero, or a positive integer as the first
@ -889,17 +890,14 @@ public class Util {
if (params1.length == 0 && params2.length == 0) { if (params1.length == 0 && params2.length == 0) {
return 0; return 0;
} }
int result = Integer.compare(params1.length, params2.length); // try to compare as many as possible
if (result != 0) { for (int i = 0; i < params1.length && i < params2.length; i++) {
return result; int result = compareStrings(params1[i].typeName(), params2[i].typeName());
}
for (int i = 0; i < params1.length; i++) {
result = compareStrings(params1[i].typeName(), params2[i].typeName());
if (result != 0) { if (result != 0) {
return result; return result;
} }
} }
return 0; return Integer.compare(params1.length, params2.length);
} }
/** /**

View file

@ -118,7 +118,8 @@ public abstract class Attribute implements AnnotationValue {
: types.erasure(type); : types.erasure(type);
return new Type.ClassType(types.syms.classType.getEnclosingType(), return new Type.ClassType(types.syms.classType.getEnclosingType(),
List.of(arg), List.of(arg),
types.syms.classType.tsym); types.syms.classType.tsym,
Type.noAnnotations);
} }
public String toString() { public String toString() {
return classType + ".class"; return classType + ".class";

View file

@ -28,7 +28,6 @@ package com.sun.tools.javac.code;
import java.util.Locale; import java.util.Locale;
import com.sun.tools.javac.api.Messages; import com.sun.tools.javac.api.Messages;
import com.sun.tools.javac.code.Type.AnnotatedType;
import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.code.Type.*;
@ -150,14 +149,16 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
@Override @Override
public String visitCapturedType(CapturedType t, Locale locale) { public String visitCapturedType(CapturedType t, Locale locale) {
if (seenCaptured.contains(t)) if (seenCaptured.contains(t))
return localize(locale, "compiler.misc.type.captureof.1", return printAnnotations(t) +
capturedVarId(t, locale)); localize(locale, "compiler.misc.type.captureof.1",
capturedVarId(t, locale));
else { else {
try { try {
seenCaptured = seenCaptured.prepend(t); seenCaptured = seenCaptured.prepend(t);
return localize(locale, "compiler.misc.type.captureof", return printAnnotations(t) +
capturedVarId(t, locale), localize(locale, "compiler.misc.type.captureof",
visit(t.wildcard, locale)); capturedVarId(t, locale),
visit(t.wildcard, locale));
} }
finally { finally {
seenCaptured = seenCaptured.tail; seenCaptured = seenCaptured.tail;
@ -167,15 +168,16 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
@Override @Override
public String visitForAll(ForAll t, Locale locale) { public String visitForAll(ForAll t, Locale locale) {
return "<" + visitTypes(t.tvars, locale) + ">" + visit(t.qtype, locale); return printAnnotations(t) + "<" + visitTypes(t.tvars, locale) +
">" + visit(t.qtype, locale);
} }
@Override @Override
public String visitUndetVar(UndetVar t, Locale locale) { public String visitUndetVar(UndetVar t, Locale locale) {
if (t.inst != null) { if (t.inst != null) {
return visit(t.inst, locale); return printAnnotations(t) + visit(t.inst, locale);
} else { } else {
return visit(t.qtype, locale) + "?"; return printAnnotations(t) + visit(t.qtype, locale) + "?";
} }
} }
@ -187,25 +189,34 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
return res.toString(); return res.toString();
} }
void printBaseElementType(Type t, StringBuilder sb, Locale locale) { private String printAnnotations(Type t) {
return printAnnotations(t, false);
}
private String printAnnotations(Type t, boolean prefix) {
StringBuilder sb = new StringBuilder();
List<Attribute.TypeCompound> annos = t.getAnnotationMirrors();
if (!annos.isEmpty()) {
if (prefix) sb.append(' ');
sb.append(annos);
sb.append(' ');
}
return sb.toString();
}
private void printBaseElementType(Type t, StringBuilder sb, Locale locale) {
Type arrel = t; Type arrel = t;
while (arrel.hasTag(TypeTag.ARRAY)) { while (arrel.hasTag(TypeTag.ARRAY)) {
arrel = arrel.unannotatedType();
arrel = ((ArrayType) arrel).elemtype; arrel = ((ArrayType) arrel).elemtype;
} }
sb.append(visit(arrel, locale)); sb.append(visit(arrel, locale));
} }
void printBrackets(Type t, StringBuilder sb, Locale locale) { private void printBrackets(Type t, StringBuilder sb, Locale locale) {
Type arrel = t; Type arrel = t;
while (arrel.hasTag(TypeTag.ARRAY)) { while (arrel.hasTag(TypeTag.ARRAY)) {
if (arrel.isAnnotated()) { sb.append(printAnnotations(arrel, true));
sb.append(' ');
sb.append(arrel.getAnnotationMirrors());
sb.append(' ');
}
sb.append("[]"); sb.append("[]");
arrel = arrel.unannotatedType();
arrel = ((ArrayType) arrel).elemtype; arrel = ((ArrayType) arrel).elemtype;
} }
} }
@ -216,8 +227,10 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == Kinds.TYP) { if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == Kinds.TYP) {
buf.append(visit(t.getEnclosingType(), locale)); buf.append(visit(t.getEnclosingType(), locale));
buf.append('.'); buf.append('.');
buf.append(printAnnotations(t));
buf.append(className(t, false, locale)); buf.append(className(t, false, locale));
} else { } else {
buf.append(printAnnotations(t));
buf.append(className(t, true, locale)); buf.append(className(t, true, locale));
} }
if (t.getTypeArguments().nonEmpty()) { if (t.getTypeArguments().nonEmpty()) {
@ -230,7 +243,8 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
@Override @Override
public String visitMethodType(MethodType t, Locale locale) { public String visitMethodType(MethodType t, Locale locale) {
return "(" + printMethodArgs(t.argtypes, false, locale) + ")" + visit(t.restype, locale); return "(" + printMethodArgs(t.argtypes, false, locale) + ")" +
visit(t.restype, locale);
} }
@Override @Override
@ -243,6 +257,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append(t.kind); s.append(t.kind);
if (t.kind != UNBOUND) { if (t.kind != UNBOUND) {
s.append(printAnnotations(t));
s.append(visit(t.type, locale)); s.append(visit(t.type, locale));
} }
return s.toString(); return s.toString();
@ -258,28 +273,6 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
return visitType(t, locale); return visitType(t, locale);
} }
@Override
public String visitAnnotatedType(AnnotatedType t, Locale locale) {
if (t.getAnnotationMirrors().nonEmpty()) {
if (t.unannotatedType().hasTag(TypeTag.ARRAY)) {
StringBuilder res = new StringBuilder();
printBaseElementType(t, res, locale);
printBrackets(t, res, locale);
return res.toString();
} else if (t.unannotatedType().hasTag(TypeTag.CLASS) &&
t.unannotatedType().getEnclosingType() != Type.noType) {
return visit(t.unannotatedType().getEnclosingType(), locale) +
". " +
t.getAnnotationMirrors() +
" " + className((ClassType)t.unannotatedType(), false, locale);
} else {
return t.getAnnotationMirrors() + " " + visit(t.unannotatedType(), locale);
}
} else {
return visit(t.unannotatedType(), locale);
}
}
public String visitType(Type t, Locale locale) { public String visitType(Type t, Locale locale) {
String s = (t.tsym == null || t.tsym.name == null) String s = (t.tsym == null || t.tsym.name == null)
? localize(locale, "compiler.misc.type.none") ? localize(locale, "compiler.misc.type.none")
@ -345,8 +338,8 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
args = args.tail; args = args.tail;
buf.append(','); buf.append(',');
} }
if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) { if (args.head.hasTag(TypeTag.ARRAY)) {
buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); buf.append(visit(((ArrayType) args.head).elemtype, locale));
if (args.head.getAnnotationMirrors().nonEmpty()) { if (args.head.getAnnotationMirrors().nonEmpty()) {
buf.append(' '); buf.append(' ');
buf.append(args.head.getAnnotationMirrors()); buf.append(args.head.getAnnotationMirrors());

View file

@ -234,7 +234,7 @@ public enum Source {
public boolean allowGraphInference() { public boolean allowGraphInference() {
return compareTo(JDK1_8) >= 0; return compareTo(JDK1_8) >= 0;
} }
public boolean allowStructuralMostSpecific() { public boolean allowFunctionalInterfaceMostSpecific() {
return compareTo(JDK1_8) >= 0; return compareTo(JDK1_8) >= 0;
} }
public static SourceVersion toSourceVersion(Source source) { public static SourceVersion toSourceVersion(Source source) {

View file

@ -956,7 +956,7 @@ public abstract class Symbol extends AnnoConstruct implements Element {
this( this(
flags, flags,
name, name,
new ClassType(Type.noType, null, null), new ClassType(Type.noType, null, null, Type.noAnnotations),
owner); owner);
this.type.tsym = this; this.type.tsym = this;
} }
@ -992,7 +992,8 @@ public abstract class Symbol extends AnnoConstruct implements Element {
public Type erasure(Types types) { public Type erasure(Types types) {
if (erasure_field == null) if (erasure_field == null)
erasure_field = new ClassType(types.erasure(type.getEnclosingType()), erasure_field = new ClassType(types.erasure(type.getEnclosingType()),
List.<Type>nil(), this); List.<Type>nil(), this,
type.getAnnotationMirrors());
return erasure_field; return erasure_field;
} }

View file

@ -80,6 +80,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
/** Constant type: special type to be used for marking stuck trees. */ /** Constant type: special type to be used for marking stuck trees. */
public static final JCNoType stuckType = new JCNoType(); public static final JCNoType stuckType = new JCNoType();
public static final List<Attribute.TypeCompound> noAnnotations =
List.nil();
/** If this switch is turned on, the names of type variables /** If this switch is turned on, the names of type variables
* and anonymous classes are printed with hashcodes appended. * and anonymous classes are printed with hashcodes appended.
*/ */
@ -89,6 +92,10 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
*/ */
public TypeSymbol tsym; public TypeSymbol tsym;
/** The type annotations on this type.
*/
protected final List<Attribute.TypeCompound> annos;
/** /**
* Checks if the current type tag is equal to the given tag. * Checks if the current type tag is equal to the given tag.
* @return true if tag is equal to the current type tag. * @return true if tag is equal to the current type tag.
@ -173,10 +180,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); } public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
/** Define a type given its tag and type symbol /** Define a type given its tag, type symbol, and type annotations
*/ */
public Type(TypeSymbol tsym) { public Type(TypeSymbol tsym, List<Attribute.TypeCompound> annos) {
if(annos == null) {
Assert.error("Attempting to create type " + tsym + " with null type annotations");
}
this.tsym = tsym; this.tsym = tsym;
this.annos = annos;
} }
/** An abstract class for mappings from types to types /** An abstract class for mappings from types to types
@ -225,25 +237,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return this; return this;
} }
public Type annotatedType(List<Attribute.TypeCompound> annos) { public abstract Type annotatedType(List<Attribute.TypeCompound> annos);
return new AnnotatedType(annos, this);
}
public boolean isAnnotated() { public boolean isAnnotated() {
return false; return !annos.isEmpty();
}
/**
* If this is an annotated type, return the underlying type.
* Otherwise, return the type itself.
*/
public Type unannotatedType() {
return this;
} }
@Override @Override
public List<Attribute.TypeCompound> getAnnotationMirrors() { public List<Attribute.TypeCompound> getAnnotationMirrors() {
return List.nil(); return annos;
} }
@ -272,16 +274,35 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return ts; return ts;
} }
protected void appendAnnotationsString(StringBuilder sb,
boolean prefix) {
if (isAnnotated()) {
if (prefix) {
sb.append(" ");
}
sb.append(annos);
sb.append(" ");
}
}
protected void appendAnnotationsString(StringBuilder sb) {
appendAnnotationsString(sb, false);
}
/** The Java source which this type represents. /** The Java source which this type represents.
*/ */
public String toString() { public String toString() {
String s = (tsym == null || tsym.name == null) StringBuilder sb = new StringBuilder();
? "<none>" appendAnnotationsString(sb);
: tsym.name.toString(); if (tsym == null || tsym.name == null) {
if (moreInfo && hasTag(TYPEVAR)) { sb.append("<none>");
s = s + hashCode(); } else {
sb.append(tsym.name);
} }
return s; if (moreInfo && hasTag(TYPEVAR)) {
sb.append(hashCode());
}
return sb.toString();
} }
/** /**
@ -333,8 +354,8 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
args = args.tail; args = args.tail;
buf.append(','); buf.append(',');
} }
if (args.head.unannotatedType().hasTag(ARRAY)) { if (args.head.hasTag(ARRAY)) {
buf.append(((ArrayType)args.head.unannotatedType()).elemtype); buf.append(((ArrayType)args.head).elemtype);
if (args.head.getAnnotationMirrors().nonEmpty()) { if (args.head.getAnnotationMirrors().nonEmpty()) {
buf.append(args.head.getAnnotationMirrors()); buf.append(args.head.getAnnotationMirrors());
} }
@ -486,11 +507,21 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
TypeTag tag; TypeTag tag;
public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) { public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) {
super(tsym); this(tag, tsym, noAnnotations);
}
public JCPrimitiveType(TypeTag tag, TypeSymbol tsym,
List<Attribute.TypeCompound> annos) {
super(tsym, annos);
this.tag = tag; this.tag = tag;
Assert.check(tag.isPrimitive); Assert.check(tag.isPrimitive);
} }
@Override
public Type annotatedType(List<Attribute.TypeCompound> annos) {
return new JCPrimitiveType(tag, tsym, annos);
}
@Override @Override
public boolean isNumeric() { public boolean isNumeric() {
return tag != BOOLEAN; return tag != BOOLEAN;
@ -517,7 +548,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
@Override @Override
public Type constType(Object constValue) { public Type constType(Object constValue) {
final Object value = constValue; final Object value = constValue;
return new JCPrimitiveType(tag, tsym) { return new JCPrimitiveType(tag, tsym, annos) {
@Override @Override
public Object constValue() { public Object constValue() {
return value; return value;
@ -601,19 +632,37 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) { public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) {
super(tsym); this(type, kind, tsym, null, noAnnotations);
this.type = Assert.checkNonNull(type);
this.kind = kind;
}
public WildcardType(WildcardType t, TypeVar bound) {
this(t.type, t.kind, t.tsym, bound);
} }
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, TypeVar bound) { public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
this(type, kind, tsym); List<Attribute.TypeCompound> annos) {
this(type, kind, tsym, null, annos);
}
public WildcardType(WildcardType t, TypeVar bound,
List<Attribute.TypeCompound> annos) {
this(t.type, t.kind, t.tsym, bound, annos);
}
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
TypeVar bound) {
this(type, kind, tsym, noAnnotations);
}
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
TypeVar bound, List<Attribute.TypeCompound> annos) {
super(tsym, annos);
this.type = Assert.checkNonNull(type);
this.kind = kind;
this.bound = bound; this.bound = bound;
} }
@Override
public WildcardType annotatedType(List<Attribute.TypeCompound> annos) {
return new WildcardType(type, kind, tsym, bound, annos);
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return WILDCARD; return WILDCARD;
@ -658,6 +707,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
boolean isPrintingBound = false; boolean isPrintingBound = false;
public String toString() { public String toString() {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
appendAnnotationsString(s);
s.append(kind.toString()); s.append(kind.toString());
if (kind != UNBOUND) if (kind != UNBOUND)
s.append(type); s.append(type);
@ -679,7 +729,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
if (t == type) if (t == type)
return this; return this;
else else
return new WildcardType(t, kind, tsym, bound); return new WildcardType(t, kind, tsym, bound, annos);
} }
public Type getExtendsBound() { public Type getExtendsBound() {
@ -736,7 +786,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public List<Type> all_interfaces_field; public List<Type> all_interfaces_field;
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) { public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
super(tsym); this(outer, typarams, tsym, noAnnotations);
}
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym,
List<Attribute.TypeCompound> annos) {
super(tsym, annos);
this.outer_field = outer; this.outer_field = outer;
this.typarams_field = typarams; this.typarams_field = typarams;
this.allparams_field = null; this.allparams_field = null;
@ -753,6 +808,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
*/ */
} }
@Override
public ClassType annotatedType(List<Attribute.TypeCompound> annos) {
final ClassType out = new ClassType(outer_field, typarams_field, tsym, annos);
out.allparams_field = allparams_field;
out.supertype_field = supertype_field;
out.interfaces_field = interfaces_field;
return out;
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return CLASS; return CLASS;
@ -765,7 +829,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public Type constType(Object constValue) { public Type constType(Object constValue) {
final Object value = constValue; final Object value = constValue;
return new ClassType(getEnclosingType(), typarams_field, tsym) { return new ClassType(getEnclosingType(), typarams_field, tsym, annos) {
@Override @Override
public Object constValue() { public Object constValue() {
return value; return value;
@ -781,6 +845,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
*/ */
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
appendAnnotationsString(buf);
if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) {
buf.append(getEnclosingType().toString()); buf.append(getEnclosingType().toString());
buf.append("."); buf.append(".");
@ -806,7 +871,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return s.toString(); return s.toString();
} else if (sym.name.isEmpty()) { } else if (sym.name.isEmpty()) {
String s; String s;
ClassType norm = (ClassType) tsym.type.unannotatedType(); ClassType norm = (ClassType) tsym.type;
if (norm == null) { if (norm == null) {
s = Log.getLocalizedString("anonymous.class", (Object)null); s = Log.getLocalizedString("anonymous.class", (Object)null);
} else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
@ -858,7 +923,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return return
getEnclosingType().isErroneous() || getEnclosingType().isErroneous() ||
isErroneous(getTypeArguments()) || isErroneous(getTypeArguments()) ||
this != tsym.type.unannotatedType() && tsym.type.isErroneous(); this != tsym.type && tsym.type.isErroneous();
} }
public boolean isParameterized() { public boolean isParameterized() {
@ -897,7 +962,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
List<Type> typarams = getTypeArguments(); List<Type> typarams = getTypeArguments();
List<Type> typarams1 = map(typarams, f); List<Type> typarams1 = map(typarams, f);
if (outer1 == outer && typarams1 == typarams) return this; if (outer1 == outer && typarams1 == typarams) return this;
else return new ClassType(outer1, typarams1, tsym); else return new ClassType(outer1, typarams1, tsym, annos);
} }
public boolean contains(Type elem) { public boolean contains(Type elem) {
@ -924,7 +989,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public static class ErasedClassType extends ClassType { public static class ErasedClassType extends ClassType {
public ErasedClassType(Type outer, TypeSymbol tsym) { public ErasedClassType(Type outer, TypeSymbol tsym) {
super(outer, List.<Type>nil(), tsym); this(outer, tsym, noAnnotations);
}
public ErasedClassType(Type outer, TypeSymbol tsym,
List<Attribute.TypeCompound> annos) {
super(outer, List.<Type>nil(), tsym, annos);
} }
@Override @Override
@ -938,7 +1008,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
final List<? extends Type> alternatives_field; final List<? extends Type> alternatives_field;
public UnionClassType(ClassType ct, List<? extends Type> alternatives) { public UnionClassType(ClassType ct, List<? extends Type> alternatives) {
super(ct.outer_field, ct.typarams_field, ct.tsym); // Presently no way to refer to this type directly, so we
// cannot put annotations directly on it.
super(ct.outer_field, ct.typarams_field, ct.tsym, noAnnotations);
allparams_field = ct.allparams_field; allparams_field = ct.allparams_field;
supertype_field = ct.supertype_field; supertype_field = ct.supertype_field;
interfaces_field = ct.interfaces_field; interfaces_field = ct.interfaces_field;
@ -971,7 +1043,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public boolean allInterfaces; public boolean allInterfaces;
public IntersectionClassType(List<Type> bounds, ClassSymbol csym, boolean allInterfaces) { public IntersectionClassType(List<Type> bounds, ClassSymbol csym, boolean allInterfaces) {
super(Type.noType, List.<Type>nil(), csym); // Presently no way to refer to this type directly, so we
// cannot put annotations directly on it.
super(Type.noType, List.<Type>nil(), csym, noAnnotations);
this.allInterfaces = allInterfaces; this.allInterfaces = allInterfaces;
Assert.check((csym.flags() & COMPOUND) != 0); Assert.check((csym.flags() & COMPOUND) != 0);
supertype_field = bounds.head; supertype_field = bounds.head;
@ -1011,10 +1085,20 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public Type elemtype; public Type elemtype;
public ArrayType(Type elemtype, TypeSymbol arrayClass) { public ArrayType(Type elemtype, TypeSymbol arrayClass) {
super(arrayClass); this(elemtype, arrayClass, noAnnotations);
}
public ArrayType(Type elemtype, TypeSymbol arrayClass,
List<Attribute.TypeCompound> annos) {
super(arrayClass, annos);
this.elemtype = elemtype; this.elemtype = elemtype;
} }
@Override
public ArrayType annotatedType(List<Attribute.TypeCompound> annos) {
return new ArrayType(elemtype, tsym, annos);
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return ARRAY; return ARRAY;
@ -1025,7 +1109,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
public String toString() { public String toString() {
return elemtype + "[]"; StringBuilder sb = new StringBuilder();
sb.append(elemtype);
appendAnnotationsString(sb, true);
sb.append("[]");
return sb.toString();
} }
public boolean equals(Object obj) { public boolean equals(Object obj) {
@ -1068,7 +1156,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
public ArrayType makeVarargs() { public ArrayType makeVarargs() {
return new ArrayType(elemtype, tsym) { return new ArrayType(elemtype, tsym, annos) {
@Override @Override
public boolean isVarargs() { public boolean isVarargs() {
return true; return true;
@ -1079,7 +1167,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public Type map(Mapping f) { public Type map(Mapping f) {
Type elemtype1 = f.apply(elemtype); Type elemtype1 = f.apply(elemtype);
if (elemtype1 == elemtype) return this; if (elemtype1 == elemtype) return this;
else return new ArrayType(elemtype1, tsym); else return new ArrayType(elemtype1, tsym, annos);
} }
public boolean contains(Type elem) { public boolean contains(Type elem) {
@ -1117,12 +1205,19 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
Type restype, Type restype,
List<Type> thrown, List<Type> thrown,
TypeSymbol methodClass) { TypeSymbol methodClass) {
super(methodClass); // Presently no way to refer to a method type directly, so
// we cannot put type annotations on it.
super(methodClass, noAnnotations);
this.argtypes = argtypes; this.argtypes = argtypes;
this.restype = restype; this.restype = restype;
this.thrown = thrown; this.thrown = thrown;
} }
@Override
public MethodType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate a method type");
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return METHOD; return METHOD;
@ -1138,7 +1233,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
* should be. * should be.
*/ */
public String toString() { public String toString() {
return "(" + argtypes + ")" + restype; StringBuilder sb = new StringBuilder();
appendAnnotationsString(sb);
sb.append('(');
sb.append(argtypes);
sb.append(')');
sb.append(restype);
return sb.toString();
} }
public List<Type> getParameterTypes() { return argtypes; } public List<Type> getParameterTypes() { return argtypes; }
@ -1197,7 +1298,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public static class PackageType extends Type implements NoType { public static class PackageType extends Type implements NoType {
PackageType(TypeSymbol tsym) { PackageType(TypeSymbol tsym) {
super(tsym); // Package types cannot be annotated
super(tsym, noAnnotations);
}
@Override
public PackageType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate a package type");
} }
@Override @Override
@ -1245,17 +1352,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public Type lower; public Type lower;
public TypeVar(Name name, Symbol owner, Type lower) { public TypeVar(Name name, Symbol owner, Type lower) {
super(null); this(name, owner, lower, noAnnotations);
}
public TypeVar(Name name, Symbol owner, Type lower,
List<Attribute.TypeCompound> annos) {
super(null, annos);
tsym = new TypeVariableSymbol(0, name, this, owner); tsym = new TypeVariableSymbol(0, name, this, owner);
this.lower = lower; this.lower = lower;
} }
public TypeVar(TypeSymbol tsym, Type bound, Type lower) { public TypeVar(TypeSymbol tsym, Type bound, Type lower,
super(tsym); List<Attribute.TypeCompound> annos) {
super(tsym, annos);
this.bound = bound; this.bound = bound;
this.lower = lower; this.lower = lower;
} }
@Override
public TypeVar annotatedType(List<Attribute.TypeCompound> annos) {
return new TypeVar(tsym, bound, lower, annos);
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return TYPEVAR; return TYPEVAR;
@ -1317,13 +1435,29 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
Symbol owner, Symbol owner,
Type upper, Type upper,
Type lower, Type lower,
WildcardType wildcard) { WildcardType wildcard,
super(name, owner, lower); List<Attribute.TypeCompound> annos) {
super(name, owner, lower, annos);
this.lower = Assert.checkNonNull(lower); this.lower = Assert.checkNonNull(lower);
this.bound = upper; this.bound = upper;
this.wildcard = wildcard; this.wildcard = wildcard;
} }
public CapturedType(TypeSymbol tsym,
Type bound,
Type upper,
Type lower,
WildcardType wildcard,
List<Attribute.TypeCompound> annos) {
super(tsym, bound, lower, annos);
this.wildcard = wildcard;
}
@Override
public CapturedType annotatedType(List<Attribute.TypeCompound> annos) {
return new CapturedType(tsym, bound, bound, lower, wildcard, annos);
}
@Override @Override
public <R,S> R accept(Type.Visitor<R,S> v, S s) { public <R,S> R accept(Type.Visitor<R,S> v, S s) {
return v.visitCapturedType(this, s); return v.visitCapturedType(this, s);
@ -1336,18 +1470,22 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
@Override @Override
public String toString() { public String toString() {
return "capture#" StringBuilder sb = new StringBuilder();
+ (hashCode() & 0xFFFFFFFFL) % Printer.PRIME appendAnnotationsString(sb);
+ " of " sb.append("capture#");
+ wildcard; sb.append((hashCode() & 0xFFFFFFFFL) % Printer.PRIME);
sb.append(" of ");
sb.append(wildcard);
return sb.toString();
} }
} }
public static abstract class DelegatedType extends Type { public static abstract class DelegatedType extends Type {
public Type qtype; public Type qtype;
public TypeTag tag; public TypeTag tag;
public DelegatedType(TypeTag tag, Type qtype) { public DelegatedType(TypeTag tag, Type qtype,
super(qtype.tsym); List<Attribute.TypeCompound> annos) {
super(qtype.tsym, annos);
this.tag = tag; this.tag = tag;
this.qtype = qtype; this.qtype = qtype;
} }
@ -1373,17 +1511,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public List<Type> tvars; public List<Type> tvars;
public ForAll(List<Type> tvars, Type qtype) { public ForAll(List<Type> tvars, Type qtype) {
super(FORALL, (MethodType)qtype); super(FORALL, (MethodType)qtype, noAnnotations);
this.tvars = tvars; this.tvars = tvars;
} }
@Override
public ForAll annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate forall type");
}
@Override @Override
public <R,S> R accept(Type.Visitor<R,S> v, S s) { public <R,S> R accept(Type.Visitor<R,S> v, S s) {
return v.visitForAll(this, s); return v.visitForAll(this, s);
} }
public String toString() { public String toString() {
return "<" + tvars + ">" + qtype; StringBuilder sb = new StringBuilder();
appendAnnotationsString(sb);
sb.append('<');
sb.append(tvars);
sb.append('>');
sb.append(qtype);
return sb.toString();
} }
public List<Type> getTypeArguments() { return tvars; } public List<Type> getTypeArguments() { return tvars; }
@ -1479,7 +1628,8 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
public UndetVar(TypeVar origin, Types types) { public UndetVar(TypeVar origin, Types types) {
super(UNDETVAR, origin); // This is a synthesized internal type, so we cannot annotate it.
super(UNDETVAR, origin, noAnnotations);
bounds = new EnumMap<>(InferenceBound.class); bounds = new EnumMap<>(InferenceBound.class);
List<Type> declaredBounds = types.getBounds(origin); List<Type> declaredBounds = types.getBounds(origin);
declaredCount = declaredBounds.length(); declaredCount = declaredBounds.length();
@ -1489,7 +1639,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
public String toString() { public String toString() {
return (inst == null) ? qtype + "?" : inst.toString(); StringBuilder sb = new StringBuilder();
appendAnnotationsString(sb);
if (inst == null) {
sb.append(qtype);
sb.append('?');
} else {
sb.append(inst);
}
return sb.toString();
} }
public String debugString() { public String debugString() {
@ -1506,6 +1664,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return result; return result;
} }
@Override
public UndetVar annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate an UndetVar type");
}
@Override @Override
public boolean isPartial() { public boolean isPartial() {
return true; return true;
@ -1659,7 +1822,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
*/ */
public static class JCNoType extends Type implements NoType { public static class JCNoType extends Type implements NoType {
public JCNoType() { public JCNoType() {
super(null); // Need to use List.nil(), because JCNoType constructor
// gets called in static initializers in Type, where
// noAnnotations is also defined.
super(null, List.<Attribute.TypeCompound>nil());
}
@Override
public JCNoType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate JCNoType");
} }
@Override @Override
@ -1686,7 +1857,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public static class JCVoidType extends Type implements NoType { public static class JCVoidType extends Type implements NoType {
public JCVoidType() { public JCVoidType() {
super(null); // Void cannot be annotated
super(null, noAnnotations);
}
@Override
public JCVoidType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate void type");
} }
@Override @Override
@ -1715,7 +1892,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
static class BottomType extends Type implements NullType { static class BottomType extends Type implements NullType {
public BottomType() { public BottomType() {
super(null); // Bottom is a synthesized internal type, so it cannot be annotated
super(null, noAnnotations);
}
@Override
public BottomType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate bottom type");
} }
@Override @Override
@ -1759,7 +1942,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
private Type originalType = null; private Type originalType = null;
public ErrorType(Type originalType, TypeSymbol tsym) { public ErrorType(Type originalType, TypeSymbol tsym) {
super(noType, List.<Type>nil(), null); this(originalType, tsym, noAnnotations);
}
public ErrorType(Type originalType, TypeSymbol tsym,
List<Attribute.TypeCompound> typeAnnotations) {
super(noType, List.<Type>nil(), null, typeAnnotations);
this.tsym = tsym; this.tsym = tsym;
this.originalType = (originalType == null ? noType : originalType); this.originalType = (originalType == null ? noType : originalType);
} }
@ -1771,6 +1959,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
c.members_field = new Scope.ErrorScope(c); c.members_field = new Scope.ErrorScope(c);
} }
@Override
public ErrorType annotatedType(List<Attribute.TypeCompound> annos) {
return new ErrorType(originalType, tsym, annos);
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return ERROR; return ERROR;
@ -1827,182 +2020,17 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
} }
} }
public static class AnnotatedType extends Type
implements
javax.lang.model.type.ArrayType,
javax.lang.model.type.DeclaredType,
javax.lang.model.type.PrimitiveType,
javax.lang.model.type.TypeVariable,
javax.lang.model.type.WildcardType {
/** The type annotations on this type.
*/
private List<Attribute.TypeCompound> typeAnnotations;
/** The underlying type that is annotated.
*/
private Type underlyingType;
protected AnnotatedType(List<Attribute.TypeCompound> typeAnnotations,
Type underlyingType) {
super(underlyingType.tsym);
this.typeAnnotations = typeAnnotations;
this.underlyingType = underlyingType;
Assert.check(typeAnnotations != null && typeAnnotations.nonEmpty(),
"Can't create AnnotatedType without annotations: " + underlyingType);
Assert.check(!underlyingType.isAnnotated(),
"Can't annotate already annotated type: " + underlyingType +
"; adding: " + typeAnnotations);
}
@Override
public TypeTag getTag() {
return underlyingType.getTag();
}
@Override
public boolean isAnnotated() {
return true;
}
@Override
public List<Attribute.TypeCompound> getAnnotationMirrors() {
return typeAnnotations;
}
@Override
public TypeKind getKind() {
return underlyingType.getKind();
}
@Override
public Type unannotatedType() {
return underlyingType;
}
@Override
public <R,S> R accept(Type.Visitor<R,S> v, S s) {
return v.visitAnnotatedType(this, s);
}
@Override
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
return underlyingType.accept(v, p);
}
@Override
public Type map(Mapping f) {
underlyingType.map(f);
return this;
}
@Override
public Type constType(Object constValue) { return underlyingType.constType(constValue); }
@Override
public Type getEnclosingType() { return underlyingType.getEnclosingType(); }
@Override
public Type getReturnType() { return underlyingType.getReturnType(); }
@Override
public List<Type> getTypeArguments() { return underlyingType.getTypeArguments(); }
@Override
public List<Type> getParameterTypes() { return underlyingType.getParameterTypes(); }
@Override
public Type getReceiverType() { return underlyingType.getReceiverType(); }
@Override
public List<Type> getThrownTypes() { return underlyingType.getThrownTypes(); }
@Override
public Type getUpperBound() { return underlyingType.getUpperBound(); }
@Override
public Type getLowerBound() { return underlyingType.getLowerBound(); }
@Override
public boolean isErroneous() { return underlyingType.isErroneous(); }
@Override
public boolean isCompound() { return underlyingType.isCompound(); }
@Override
public boolean isInterface() { return underlyingType.isInterface(); }
@Override
public List<Type> allparams() { return underlyingType.allparams(); }
@Override
public boolean isPrimitive() { return underlyingType.isPrimitive(); }
@Override
public boolean isPrimitiveOrVoid() { return underlyingType.isPrimitiveOrVoid(); }
@Override
public boolean isNumeric() { return underlyingType.isNumeric(); }
@Override
public boolean isReference() { return underlyingType.isReference(); }
@Override
public boolean isNullOrReference() { return underlyingType.isNullOrReference(); }
@Override
public boolean isPartial() { return underlyingType.isPartial(); }
@Override
public boolean isParameterized() { return underlyingType.isParameterized(); }
@Override
public boolean isRaw() { return underlyingType.isRaw(); }
@Override
public boolean isFinal() { return underlyingType.isFinal(); }
@Override
public boolean isSuperBound() { return underlyingType.isSuperBound(); }
@Override
public boolean isExtendsBound() { return underlyingType.isExtendsBound(); }
@Override
public boolean isUnbound() { return underlyingType.isUnbound(); }
@Override
public String toString() {
// This method is only used for internal debugging output.
// See
// com.sun.tools.javac.code.Printer.visitAnnotatedType(AnnotatedType, Locale)
// for the user-visible logic.
if (typeAnnotations != null &&
!typeAnnotations.isEmpty()) {
return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")";
} else {
return "({} :: " + underlyingType.toString() +")";
}
}
@Override
public boolean contains(Type t) { return underlyingType.contains(t); }
@Override
public Type withTypeVar(Type t) {
// Don't create a new AnnotatedType, as 'this' will
// get its annotations set later.
underlyingType = underlyingType.withTypeVar(t);
return this;
}
// TODO: attach annotations?
@Override
public TypeSymbol asElement() { return underlyingType.asElement(); }
// TODO: attach annotations?
@Override
public MethodType asMethodType() { return underlyingType.asMethodType(); }
@Override
public void complete() { underlyingType.complete(); }
@Override
public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); }
// The result is an ArrayType, but only in the model sense, not the Type sense.
public Type makeVarargs() {
return ((ArrayType) underlyingType).makeVarargs().annotatedType(typeAnnotations);
}
@Override
public TypeMirror getExtendsBound() { return ((WildcardType)underlyingType).getExtendsBound(); }
@Override
public TypeMirror getSuperBound() { return ((WildcardType)underlyingType).getSuperBound(); }
}
public static class UnknownType extends Type { public static class UnknownType extends Type {
public UnknownType() { public UnknownType() {
super(null); // Unknown is a synthesized internal type, so it cannot be
// annotated.
super(null, noAnnotations);
}
@Override
public UnknownType annotatedType(List<Attribute.TypeCompound> annos) {
throw new AssertionError("Cannot annotate unknown type");
} }
@Override @Override
@ -2046,7 +2074,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
R visitForAll(ForAll t, S s); R visitForAll(ForAll t, S s);
R visitUndetVar(UndetVar t, S s); R visitUndetVar(UndetVar t, S s);
R visitErrorType(ErrorType t, S s); R visitErrorType(ErrorType t, S s);
R visitAnnotatedType(AnnotatedType t, S s);
R visitType(Type t, S s); R visitType(Type t, S s);
} }
} }

View file

@ -326,15 +326,21 @@ public class TypeAnnotationPosition {
public int getCatchType() { public int getCatchType() {
Assert.check(hasCatchType(), Assert.check(hasCatchType(),
"exception_index does not contain a valid catch type"); "exception_index does not contain valid catch info");
return (-this.exception_index) - 1 ; return ((-this.exception_index) - 1) & 0xff ;
} }
public void setCatchType(final int catchType) { public int getStartPos() {
Assert.check(hasCatchType(),
"exception_index does not contain valid catch info");
return ((-this.exception_index) - 1) >> 8 ;
}
public void setCatchInfo(final int catchType, final int startPos) {
Assert.check(this.exception_index < 0, Assert.check(this.exception_index < 0,
"exception_index already contains a bytecode index"); "exception_index already contains a bytecode index");
Assert.check(catchType >= 0, "Expected a valid catch type"); Assert.check(catchType >= 0, "Expected a valid catch type");
this.exception_index = -(catchType + 1); this.exception_index = -((catchType | startPos << 8) + 1);
} }
/** /**

View file

@ -32,7 +32,6 @@ import javax.lang.model.type.TypeKind;
import javax.tools.JavaFileObject; import javax.tools.JavaFileObject;
import com.sun.tools.javac.code.Attribute.TypeCompound; import com.sun.tools.javac.code.Attribute.TypeCompound;
import com.sun.tools.javac.code.Type.AnnotatedType;
import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.CapturedType; import com.sun.tools.javac.code.Type.CapturedType;
import com.sun.tools.javac.code.Type.ClassType; import com.sun.tools.javac.code.Type.ClassType;
@ -331,7 +330,6 @@ public class TypeAnnotations {
// Note that we don't use the result, the call to // Note that we don't use the result, the call to
// typeWithAnnotations side-effects the type annotation positions. // typeWithAnnotations side-effects the type annotation positions.
// This is important for constructors of nested classes. // This is important for constructors of nested classes.
sym.appendUniqueTypeAttributes(typeAnnotations); sym.appendUniqueTypeAttributes(typeAnnotations);
return; return;
} }
@ -391,14 +389,15 @@ public class TypeAnnotations {
private Type typeWithAnnotations(final JCTree typetree, final Type type, private Type typeWithAnnotations(final JCTree typetree, final Type type,
final List<Attribute.TypeCompound> annotations, final List<Attribute.TypeCompound> annotations,
final List<Attribute.TypeCompound> onlyTypeAnnotations) { final List<Attribute.TypeCompound> onlyTypeAnnotations) {
// System.out.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s, onlyTypeAnnotations: %s)%n", //System.err.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s, onlyTypeAnnotations: %s)%n",
// typetree, type, annotations, onlyTypeAnnotations); // typetree, type, annotations, onlyTypeAnnotations);
if (annotations.isEmpty()) { if (annotations.isEmpty()) {
return type; return type;
} }
if (type.hasTag(TypeTag.ARRAY)) { if (type.hasTag(TypeTag.ARRAY)) {
Type.ArrayType arType = (Type.ArrayType) type.unannotatedType(); Type.ArrayType arType = (Type.ArrayType) type;
Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym,
Type.noAnnotations);
Type toreturn; Type toreturn;
if (type.isAnnotated()) { if (type.isAnnotated()) {
toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); toreturn = tomodify.annotatedType(type.getAnnotationMirrors());
@ -413,13 +412,15 @@ public class TypeAnnotations {
while (arType.elemtype.hasTag(TypeTag.ARRAY)) { while (arType.elemtype.hasTag(TypeTag.ARRAY)) {
if (arType.elemtype.isAnnotated()) { if (arType.elemtype.isAnnotated()) {
Type aelemtype = arType.elemtype; Type aelemtype = arType.elemtype;
arType = (Type.ArrayType) aelemtype.unannotatedType(); arType = (Type.ArrayType) aelemtype;
ArrayType prevToMod = tomodify; ArrayType prevToMod = tomodify;
tomodify = new Type.ArrayType(null, arType.tsym); tomodify = new Type.ArrayType(null, arType.tsym,
Type.noAnnotations);
prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors()); prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors());
} else { } else {
arType = (Type.ArrayType) arType.elemtype; arType = (Type.ArrayType) arType.elemtype;
tomodify.elemtype = new Type.ArrayType(null, arType.tsym); tomodify.elemtype = new Type.ArrayType(null, arType.tsym,
Type.noAnnotations);
tomodify = (Type.ArrayType) tomodify.elemtype; tomodify = (Type.ArrayType) tomodify.elemtype;
} }
arTree = arrayTypeTree(arTree.elemtype); arTree = arrayTypeTree(arTree.elemtype);
@ -569,6 +570,7 @@ public class TypeAnnotations {
private Type typeWithAnnotations(final Type type, private Type typeWithAnnotations(final Type type,
final Type stopAt, final Type stopAt,
final List<Attribute.TypeCompound> annotations) { final List<Attribute.TypeCompound> annotations) {
//System.err.println("typeWithAnnotations " + type + " " + annotations + " stopAt " + stopAt);
Visitor<Type, List<TypeCompound>> visitor = Visitor<Type, List<TypeCompound>> visitor =
new Type.Visitor<Type, List<Attribute.TypeCompound>>() { new Type.Visitor<Type, List<Attribute.TypeCompound>>() {
@Override @Override
@ -579,7 +581,8 @@ public class TypeAnnotations {
return t.annotatedType(s); return t.annotatedType(s);
} else { } else {
ClassType ret = new ClassType(t.getEnclosingType().accept(this, s), ClassType ret = new ClassType(t.getEnclosingType().accept(this, s),
t.typarams_field, t.tsym); t.typarams_field, t.tsym,
t.getAnnotationMirrors());
ret.all_interfaces_field = t.all_interfaces_field; ret.all_interfaces_field = t.all_interfaces_field;
ret.allparams_field = t.allparams_field; ret.allparams_field = t.allparams_field;
ret.interfaces_field = t.interfaces_field; ret.interfaces_field = t.interfaces_field;
@ -589,11 +592,6 @@ public class TypeAnnotations {
} }
} }
@Override
public Type visitAnnotatedType(AnnotatedType t, List<TypeCompound> s) {
return t.unannotatedType().accept(this, s).annotatedType(t.getAnnotationMirrors());
}
@Override @Override
public Type visitWildcardType(WildcardType t, List<TypeCompound> s) { public Type visitWildcardType(WildcardType t, List<TypeCompound> s) {
return t.annotatedType(s); return t.annotatedType(s);
@ -601,7 +599,8 @@ public class TypeAnnotations {
@Override @Override
public Type visitArrayType(ArrayType t, List<TypeCompound> s) { public Type visitArrayType(ArrayType t, List<TypeCompound> s) {
ArrayType ret = new ArrayType(t.elemtype.accept(this, s), t.tsym); ArrayType ret = new ArrayType(t.elemtype.accept(this, s), t.tsym,
t.getAnnotationMirrors());
return ret; return ret;
} }

View file

@ -131,7 +131,7 @@ public class Types {
* @return the upper bound of the given type * @return the upper bound of the given type
*/ */
public Type upperBound(Type t) { public Type upperBound(Type t) {
return upperBound.visit(t).unannotatedType(); return upperBound.visit(t);
} }
// where // where
private final MapVisitor<Void> upperBound = new MapVisitor<Void>() { private final MapVisitor<Void> upperBound = new MapVisitor<Void>() {
@ -205,7 +205,7 @@ public class Types {
WildcardType unb = new WildcardType(syms.objectType, WildcardType unb = new WildcardType(syms.objectType,
BoundKind.UNBOUND, BoundKind.UNBOUND,
syms.boundClass, syms.boundClass,
(TypeVar)parms.head.unannotatedType()); (TypeVar)parms.head);
if (!containsType(args.head, unb)) if (!containsType(args.head, unb))
return false; return false;
parms = parms.tail; parms = parms.tail;
@ -269,7 +269,9 @@ public class Types {
List<Type> opens = openVars.toList(); List<Type> opens = openVars.toList();
ListBuffer<Type> qs = new ListBuffer<>(); ListBuffer<Type> qs = new ListBuffer<>();
for (List<Type> iter = opens; iter.nonEmpty(); iter = iter.tail) { for (List<Type> iter = opens; iter.nonEmpty(); iter = iter.tail) {
qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, (TypeVar) iter.head.unannotatedType())); qs.append(new WildcardType(syms.objectType, BoundKind.UNBOUND,
syms.boundClass, (TypeVar) iter.head,
Type.noAnnotations));
} }
res = subst(res, opens, qs.toList()); res = subst(res, opens, qs.toList());
} }
@ -599,12 +601,12 @@ public class Types {
//simply replace the wildcards with its bound //simply replace the wildcards with its bound
for (Type t : formalInterface.getTypeArguments()) { for (Type t : formalInterface.getTypeArguments()) {
if (actualTypeargs.head.hasTag(WILDCARD)) { if (actualTypeargs.head.hasTag(WILDCARD)) {
WildcardType wt = (WildcardType)actualTypeargs.head.unannotatedType(); WildcardType wt = (WildcardType)actualTypeargs.head;
Type bound; Type bound;
switch (wt.kind) { switch (wt.kind) {
case EXTENDS: case EXTENDS:
case UNBOUND: case UNBOUND:
CapturedType capVar = (CapturedType)capturedTypeargs.head.unannotatedType(); CapturedType capVar = (CapturedType)capturedTypeargs.head;
//use declared bound if it doesn't depend on formal type-args //use declared bound if it doesn't depend on formal type-args
bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ? bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ?
wt.type : capVar.bound; wt.type : capVar.bound;
@ -642,7 +644,8 @@ public class Types {
csym.members_field = new Scope(csym); csym.members_field = new Scope(csym);
MethodSymbol instDescSym = new MethodSymbol(descSym.flags(), descSym.name, descType, csym); MethodSymbol instDescSym = new MethodSymbol(descSym.flags(), descSym.name, descType, csym);
csym.members_field.enter(instDescSym); csym.members_field.enter(instDescSym);
Type.ClassType ctype = new Type.ClassType(Type.noType, List.<Type>nil(), csym); Type.ClassType ctype = new Type.ClassType(Type.noType, List.<Type>nil(), csym,
Type.noAnnotations);
ctype.supertype_field = syms.objectType; ctype.supertype_field = syms.objectType;
ctype.interfaces_field = targets; ctype.interfaces_field = targets;
csym.type = ctype; csym.type = ctype;
@ -747,8 +750,6 @@ public class Types {
//where //where
private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) { private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) {
if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) { if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) {
t = t.unannotatedType();
s = s.unannotatedType();
if (((ArrayType)t).elemtype.isPrimitive()) { if (((ArrayType)t).elemtype.isPrimitive()) {
return isSameType(elemtype(t), elemtype(s)); return isSameType(elemtype(t), elemtype(s));
} else { } else {
@ -776,8 +777,6 @@ public class Types {
if (!t.hasTag(ARRAY) || isReifiable(t)) { if (!t.hasTag(ARRAY) || isReifiable(t)) {
return; return;
} }
t = t.unannotatedType();
s = s.unannotatedType();
ArrayType from = (ArrayType)t; ArrayType from = (ArrayType)t;
boolean shouldWarn = false; boolean shouldWarn = false;
switch (s.getTag()) { switch (s.getTag()) {
@ -807,12 +806,6 @@ public class Types {
return isSubtype(t, s, false); return isSubtype(t, s, false);
} }
public boolean isSubtype(Type t, Type s, boolean capture) { public boolean isSubtype(Type t, Type s, boolean capture) {
if (t == s)
return true;
t = t.unannotatedType();
s = s.unannotatedType();
if (t == s) if (t == s)
return true; return true;
@ -828,8 +821,9 @@ public class Types {
} }
// Generally, if 's' is a type variable, recur on lower bound; but // Generally, if 's' is a type variable, recur on lower bound; but
// for alpha <: CAP, alpha should get upper bound CAP // for inference variables and intersections, we need to keep 's'
if (!t.hasTag(UNDETVAR)) { // (see JLS 4.10.2 for intersections and 18.2.3 for inference vars)
if (!t.hasTag(UNDETVAR) && !t.isCompound()) {
// TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s // TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s
Type lower = cvarLowerBound(wildLowerBound(s)); Type lower = cvarLowerBound(wildLowerBound(s));
if (s != lower) if (s != lower)
@ -899,12 +893,14 @@ public class Types {
if (s.isSuperBound() && !s.isExtendsBound()) { if (s.isSuperBound() && !s.isExtendsBound()) {
s = new WildcardType(syms.objectType, s = new WildcardType(syms.objectType,
BoundKind.UNBOUND, BoundKind.UNBOUND,
syms.boundClass); syms.boundClass,
s.getAnnotationMirrors());
changed = true; changed = true;
} else if (s != orig) { } else if (s != orig) {
s = new WildcardType(upperBound(s), s = new WildcardType(upperBound(s),
BoundKind.EXTENDS, BoundKind.EXTENDS,
syms.boundClass); syms.boundClass,
s.getAnnotationMirrors());
changed = true; changed = true;
} }
rewrite.append(s); rewrite.append(s);
@ -918,14 +914,11 @@ public class Types {
@Override @Override
public Boolean visitClassType(ClassType t, Type s) { public Boolean visitClassType(ClassType t, Type s) {
Type sup = asSuper(t, s.tsym); Type sup = asSuper(t, s.tsym);
return sup != null if (sup == null) return false;
&& sup.tsym == s.tsym // If t is an intersection, sup might not be a class type
// You're not allowed to write if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s);
// Vector<Object> vec = new Vector<String>(); return sup.tsym == s.tsym
// But with wildcards you can write // Check type variable containment
// Vector<? extends Object> vec = new Vector<String>();
// which means that subtype checking must be done
// here instead of same-type checking (via containsType).
&& (!s.isParameterized() || containsTypeRecursive(s, sup)) && (!s.isParameterized() || containsTypeRecursive(s, sup))
&& isSubtypeNoCapture(sup.getEnclosingType(), && isSubtypeNoCapture(sup.getEnclosingType(),
s.getEnclosingType()); s.getEnclosingType());
@ -1107,7 +1100,7 @@ public class Types {
if (s.hasTag(TYPEVAR)) { if (s.hasTag(TYPEVAR)) {
//type-substitution does not preserve type-var types //type-substitution does not preserve type-var types
//check that type var symbols and bounds are indeed the same //check that type var symbols and bounds are indeed the same
return sameTypeVars((TypeVar)t.unannotatedType(), (TypeVar)s.unannotatedType()); return sameTypeVars((TypeVar)t, (TypeVar)s);
} }
else { else {
//special case for s == ? super X, where upper(s) = u //special case for s == ? super X, where upper(s) = u
@ -1149,9 +1142,9 @@ public class Types {
HashSet<UniqueType> set = new HashSet<>(); HashSet<UniqueType> set = new HashSet<>();
for (Type x : interfaces(t)) for (Type x : interfaces(t))
set.add(new UniqueType(x.unannotatedType(), Types.this)); set.add(new UniqueType(x, Types.this));
for (Type x : interfaces(s)) { for (Type x : interfaces(s)) {
if (!set.remove(new UniqueType(x.unannotatedType(), Types.this))) if (!set.remove(new UniqueType(x, Types.this)))
return false; return false;
} }
return (set.isEmpty()); return (set.isEmpty());
@ -1256,30 +1249,47 @@ public class Types {
if (!s.hasTag(WILDCARD)) { if (!s.hasTag(WILDCARD)) {
return false; return false;
} else { } else {
WildcardType t2 = (WildcardType)s.unannotatedType(); WildcardType t2 = (WildcardType)s;
return t.kind == t2.kind && return t.kind == t2.kind &&
isSameType(t.type, t2.type, true); isSameType(t.type, t2.type, true);
} }
} }
}; };
/** // </editor-fold>
* A version of LooseSameTypeVisitor that takes AnnotatedTypes
* into account. TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() {
*/ private Boolean compareAnnotations(Type t1, Type t2) {
TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() { List<Attribute.TypeCompound> annos1 = t1.getAnnotationMirrors();
List<Attribute.TypeCompound> annos2 = t2.getAnnotationMirrors();
return annos1.containsAll(annos2) && annos2.containsAll(annos1);
}
@Override @Override
public Boolean visitAnnotatedType(AnnotatedType t, Type s) { public Boolean visitType(Type t, Type s) {
if (!s.isAnnotated()) return compareAnnotations(t, s) && super.visitType(t, s);
return false; }
if (!t.getAnnotationMirrors().containsAll(s.getAnnotationMirrors()))
return false; @Override
if (!s.getAnnotationMirrors().containsAll(t.getAnnotationMirrors())) public Boolean visitWildcardType(WildcardType t, Type s) {
return false; return compareAnnotations(t, s) && super.visitWildcardType(t, s);
return visit(t.unannotatedType(), s); }
@Override
public Boolean visitClassType(ClassType t, Type s) {
return compareAnnotations(t, s) && super.visitClassType(t, s);
}
@Override
public Boolean visitArrayType(ArrayType t, Type s) {
return compareAnnotations(t, s) && super.visitArrayType(t, s);
}
@Override
public Boolean visitForAll(ForAll t, Type s) {
return compareAnnotations(t, s) && super.visitForAll(t, s);
} }
}; };
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Contains Type"> // <editor-fold defaultstate="collapsed" desc="Contains Type">
public boolean containedBy(Type t, Type s) { public boolean containedBy(Type t, Type s) {
@ -1287,7 +1297,7 @@ public class Types {
case UNDETVAR: case UNDETVAR:
if (s.hasTag(WILDCARD)) { if (s.hasTag(WILDCARD)) {
UndetVar undetvar = (UndetVar)t; UndetVar undetvar = (UndetVar)t;
WildcardType wt = (WildcardType)s.unannotatedType(); WildcardType wt = (WildcardType)s;
switch(wt.kind) { switch(wt.kind) {
case UNBOUND: //similar to ? extends Object case UNBOUND: //similar to ? extends Object
case EXTENDS: { case EXTENDS: {
@ -1354,7 +1364,7 @@ public class Types {
private Type U(Type t) { private Type U(Type t) {
while (t.hasTag(WILDCARD)) { while (t.hasTag(WILDCARD)) {
WildcardType w = (WildcardType)t.unannotatedType(); WildcardType w = (WildcardType)t;
if (w.isSuperBound()) if (w.isSuperBound())
return w.bound == null ? syms.objectType : w.bound.bound; return w.bound == null ? syms.objectType : w.bound.bound;
else else
@ -1365,7 +1375,7 @@ public class Types {
private Type L(Type t) { private Type L(Type t) {
while (t.hasTag(WILDCARD)) { while (t.hasTag(WILDCARD)) {
WildcardType w = (WildcardType)t.unannotatedType(); WildcardType w = (WildcardType)t;
if (w.isExtendsBound()) if (w.isExtendsBound())
return syms.botType; return syms.botType;
else else
@ -1424,15 +1434,15 @@ public class Types {
}; };
public boolean isCaptureOf(Type s, WildcardType t) { public boolean isCaptureOf(Type s, WildcardType t) {
if (!s.hasTag(TYPEVAR) || !((TypeVar)s.unannotatedType()).isCaptured()) if (!s.hasTag(TYPEVAR) || !((TypeVar)s).isCaptured())
return false; return false;
return isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard); return isSameWildcard(t, ((CapturedType)s).wildcard);
} }
public boolean isSameWildcard(WildcardType t, Type s) { public boolean isSameWildcard(WildcardType t, Type s) {
if (!s.hasTag(WILDCARD)) if (!s.hasTag(WILDCARD))
return false; return false;
WildcardType w = (WildcardType)s.unannotatedType(); WildcardType w = (WildcardType)s;
return w.kind == t.kind && w.type == t.type; return w.kind == t.kind && w.type == t.type;
} }
@ -1541,8 +1551,8 @@ public class Types {
if (t.isCompound() || s.isCompound()) { if (t.isCompound() || s.isCompound()) {
return !t.isCompound() ? return !t.isCompound() ?
visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) : visitIntersectionType((IntersectionClassType)s, t, true) :
visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false); visitIntersectionType((IntersectionClassType)t, s, false);
} }
if (s.hasTag(CLASS) || s.hasTag(ARRAY)) { if (s.hasTag(CLASS) || s.hasTag(ARRAY)) {
@ -1873,7 +1883,6 @@ public class Types {
case WILDCARD: case WILDCARD:
return elemtype(upperBound(t)); return elemtype(upperBound(t));
case ARRAY: case ARRAY:
t = t.unannotatedType();
return ((ArrayType)t).elemtype; return ((ArrayType)t).elemtype;
case FORALL: case FORALL:
return elemtype(((ForAll)t).qtype); return elemtype(((ForAll)t).qtype);
@ -1920,7 +1929,7 @@ public class Types {
if (t.hasTag(VOID) || t.hasTag(PACKAGE)) { if (t.hasTag(VOID) || t.hasTag(PACKAGE)) {
Assert.error("Type t must not be a VOID or PACKAGE type, " + t.toString()); Assert.error("Type t must not be a VOID or PACKAGE type, " + t.toString());
} }
return new ArrayType(t, syms.arrayClass); return new ArrayType(t, syms.arrayClass, Type.noAnnotations);
} }
// </editor-fold> // </editor-fold>
@ -1959,16 +1968,18 @@ public class Types {
return t; return t;
Type st = supertype(t); Type st = supertype(t);
if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) { if (st.hasTag(CLASS) || st.hasTag(TYPEVAR)) {
Type x = asSuper(st, sym); Type x = asSuper(st, sym);
if (x != null) if (x != null)
return x; return x;
} }
if ((sym.flags() & INTERFACE) != 0) { if ((sym.flags() & INTERFACE) != 0) {
for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) { for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) {
Type x = asSuper(l.head, sym); if (!l.head.hasTag(ERROR)) {
if (x != null) Type x = asSuper(l.head, sym);
return x; if (x != null)
return x;
}
} }
} }
return null; return null;
@ -2175,56 +2186,65 @@ public class Types {
} }
private Type erasure(Type t, boolean recurse) { private Type erasure(Type t, boolean recurse) {
if (t.isPrimitive()) if (t.isPrimitive()) {
return t; /* fast special case */ return t; /* fast special case */
else } else {
return erasure.visit(t, recurse); Type out = erasure.visit(t, recurse);
return out;
}
} }
// where // where
private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() { private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() {
public Type visitType(Type t, Boolean recurse) { public Type visitType(Type t, Boolean recurse) {
if (t.isPrimitive()) if (t.isPrimitive())
return t; /*fast special case*/ return t; /*fast special case*/
else else {
return t.map(recurse ? erasureRecFun : erasureFun); final List<Attribute.TypeCompound> annos = t.getAnnotationMirrors();
Type erased = t.map(recurse ? erasureRecFun : erasureFun);
if (!annos.isEmpty()) {
erased = erased.annotatedType(annos);
}
return erased;
}
} }
@Override @Override
public Type visitWildcardType(WildcardType t, Boolean recurse) { public Type visitWildcardType(WildcardType t, Boolean recurse) {
return erasure(upperBound(t), recurse); final List<Attribute.TypeCompound> annos = t.getAnnotationMirrors();
Type erased = erasure(upperBound(t), recurse);
if (!annos.isEmpty()) {
erased = erased.annotatedType(annos);
}
return erased;
} }
@Override @Override
public Type visitClassType(ClassType t, Boolean recurse) { public Type visitClassType(ClassType t, Boolean recurse) {
Type erased = t.tsym.erasure(Types.this); Type erased = t.tsym.erasure(Types.this);
List<Attribute.TypeCompound> annos = t.getAnnotationMirrors();
if (recurse) { if (recurse) {
erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym); erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym);
} }
if (!annos.isEmpty()) {
erased = erased.annotatedType(annos);
}
return erased; return erased;
} }
@Override @Override
public Type visitTypeVar(TypeVar t, Boolean recurse) { public Type visitTypeVar(TypeVar t, Boolean recurse) {
return erasure(t.bound, recurse); final List<Attribute.TypeCompound> annos = t.getAnnotationMirrors();
Type erased = erasure(t.bound, recurse);
if (!annos.isEmpty()) {
erased = erased.annotatedType(annos);
}
return erased;
} }
@Override @Override
public Type visitErrorType(ErrorType t, Boolean recurse) { public Type visitErrorType(ErrorType t, Boolean recurse) {
return t; return t;
} }
@Override
public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) {
Type erased = erasure(t.unannotatedType(), recurse);
if (erased.isAnnotated()) {
// This can only happen when the underlying type is a
// type variable and the upper bound of it is annotated.
// The annotation on the type variable overrides the one
// on the bound.
erased = ((AnnotatedType)erased).unannotatedType();
}
return erased.annotatedType(t.getAnnotationMirrors());
}
}; };
private Mapping erasureFun = new Mapping ("erasure") { private Mapping erasureFun = new Mapping ("erasure") {
@ -2550,7 +2570,8 @@ public class Types {
public Type visitClassType(ClassType t, Void ignored) { public Type visitClassType(ClassType t, Void ignored) {
Type outer1 = classBound(t.getEnclosingType()); Type outer1 = classBound(t.getEnclosingType());
if (outer1 != t.getEnclosingType()) if (outer1 != t.getEnclosingType())
return new ClassType(outer1, t.getTypeArguments(), t.tsym); return new ClassType(outer1, t.getTypeArguments(), t.tsym,
t.getAnnotationMirrors());
else else
return t; return t;
} }
@ -2965,7 +2986,8 @@ public class Types {
if (typarams1 == typarams && outer1 == outer) if (typarams1 == typarams && outer1 == outer)
return t; return t;
else else
return new ClassType(outer1, typarams1, t.tsym); return new ClassType(outer1, typarams1, t.tsym,
t.getAnnotationMirrors());
} else { } else {
Type st = subst(supertype(t)); Type st = subst(supertype(t));
List<Type> is = upperBounds(subst(interfaces(t))); List<Type> is = upperBounds(subst(interfaces(t)));
@ -2986,7 +3008,8 @@ public class Types {
} else { } else {
if (t.isExtendsBound() && bound.isExtendsBound()) if (t.isExtendsBound() && bound.isExtendsBound())
bound = upperBound(bound); bound = upperBound(bound);
return new WildcardType(bound, t.kind, syms.boundClass, t.bound); return new WildcardType(bound, t.kind, syms.boundClass,
t.bound, t.getAnnotationMirrors());
} }
} }
@ -2996,7 +3019,7 @@ public class Types {
if (elemtype == t.elemtype) if (elemtype == t.elemtype)
return t; return t;
else else
return new ArrayType(elemtype, t.tsym); return new ArrayType(elemtype, t.tsym, t.getAnnotationMirrors());
} }
@Override @Override
@ -3006,7 +3029,7 @@ public class Types {
//if 'to' types contain variables that are free in 't' //if 'to' types contain variables that are free in 't'
List<Type> freevars = newInstances(t.tvars); List<Type> freevars = newInstances(t.tvars);
t = new ForAll(freevars, t = new ForAll(freevars,
Types.this.subst(t.qtype, t.tvars, freevars)); Types.this.subst(t.qtype, t.tvars, freevars));
} }
List<Type> tvars1 = substBounds(t.tvars, from, to); List<Type> tvars1 = substBounds(t.tvars, from, to);
Type qtype1 = subst(t.qtype); Type qtype1 = subst(t.qtype);
@ -3015,7 +3038,8 @@ public class Types {
} else if (tvars1 == t.tvars) { } else if (tvars1 == t.tvars) {
return new ForAll(tvars1, qtype1); return new ForAll(tvars1, qtype1);
} else { } else {
return new ForAll(tvars1, Types.this.subst(qtype1, t.tvars, tvars1)); return new ForAll(tvars1,
Types.this.subst(qtype1, t.tvars, tvars1));
} }
} }
@ -3045,7 +3069,8 @@ public class Types {
ListBuffer<Type> newTvars = new ListBuffer<>(); ListBuffer<Type> newTvars = new ListBuffer<>();
// create new type variables without bounds // create new type variables without bounds
for (Type t : tvars) { for (Type t : tvars) {
newTvars.append(new TypeVar(t.tsym, null, syms.botType)); newTvars.append(new TypeVar(t.tsym, null, syms.botType,
t.getAnnotationMirrors()));
} }
// the new bounds should use the new type variables in place // the new bounds should use the new type variables in place
// of the old // of the old
@ -3071,7 +3096,8 @@ public class Types {
return t; return t;
else { else {
// create new type variable without bounds // create new type variable without bounds
TypeVar tv = new TypeVar(t.tsym, null, syms.botType); TypeVar tv = new TypeVar(t.tsym, null, syms.botType,
t.getAnnotationMirrors());
// the new bound should use the new type variable in place // the new bound should use the new type variable in place
// of the old // of the old
tv.bound = subst(bound1, List.<Type>of(t), List.<Type>of(tv)); tv.bound = subst(bound1, List.<Type>of(t), List.<Type>of(tv));
@ -3112,7 +3138,7 @@ public class Types {
return tvars1; return tvars1;
} }
private static final Mapping newInstanceFun = new Mapping("newInstanceFun") { private static final Mapping newInstanceFun = new Mapping("newInstanceFun") {
public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); } public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound(), t.getAnnotationMirrors()); }
}; };
// </editor-fold> // </editor-fold>
@ -3185,7 +3211,6 @@ public class Types {
* graph. Undefined for all but reference types. * graph. Undefined for all but reference types.
*/ */
public int rank(Type t) { public int rank(Type t) {
t = t.unannotatedType();
switch(t.getTag()) { switch(t.getTag()) {
case CLASS: { case CLASS: {
ClassType cls = (ClassType)t; ClassType cls = (ClassType)t;
@ -3267,7 +3292,7 @@ public class Types {
for (Type t : tvars) { for (Type t : tvars) {
if (!first) s.append(", "); if (!first) s.append(", ");
first = false; first = false;
appendTyparamString(((TypeVar)t.unannotatedType()), s); appendTyparamString(((TypeVar)t), s);
} }
s.append('>'); s.append('>');
return s.toString(); return s.toString();
@ -3439,12 +3464,14 @@ public class Types {
m = new WildcardType(lub(upperBound(act1.head), m = new WildcardType(lub(upperBound(act1.head),
upperBound(act2.head)), upperBound(act2.head)),
BoundKind.EXTENDS, BoundKind.EXTENDS,
syms.boundClass); syms.boundClass,
Type.noAnnotations);
mergeCache.remove(pair); mergeCache.remove(pair);
} else { } else {
m = new WildcardType(syms.objectType, m = new WildcardType(syms.objectType,
BoundKind.UNBOUND, BoundKind.UNBOUND,
syms.boundClass); syms.boundClass,
Type.noAnnotations);
} }
merged.append(m.withTypeVar(typarams.head)); merged.append(m.withTypeVar(typarams.head));
} }
@ -3453,7 +3480,10 @@ public class Types {
typarams = typarams.tail; typarams = typarams.tail;
} }
Assert.check(act1.isEmpty() && act2.isEmpty() && typarams.isEmpty()); Assert.check(act1.isEmpty() && act2.isEmpty() && typarams.isEmpty());
return new ClassType(class1.getEnclosingType(), merged.toList(), class1.tsym); // There is no spec detailing how type annotations are to
// be inherited. So set it to noAnnotations for now
return new ClassType(class1.getEnclosingType(), merged.toList(),
class1.tsym, Type.noAnnotations);
} }
/** /**
@ -3571,7 +3601,8 @@ public class Types {
} }
} }
// lub(A[], B[]) is lub(A, B)[] // lub(A[], B[]) is lub(A, B)[]
return new ArrayType(lub(elements), syms.arrayClass); return new ArrayType(lub(elements), syms.arrayClass,
Type.noAnnotations);
case CLASS_BOUND: case CLASS_BOUND:
// calculate lub(A, B) // calculate lub(A, B)
@ -3932,7 +3963,6 @@ public class Types {
t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments()); t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
} }
} }
t = t.unannotatedType();
ClassType cls = (ClassType)t; ClassType cls = (ClassType)t;
if (cls.isRaw() || !cls.isParameterized()) if (cls.isRaw() || !cls.isParameterized())
return cls; return cls;
@ -3951,9 +3981,9 @@ public class Types {
!currentS.isEmpty()) { !currentS.isEmpty()) {
if (currentS.head != currentT.head) { if (currentS.head != currentT.head) {
captured = true; captured = true;
WildcardType Ti = (WildcardType)currentT.head.unannotatedType(); WildcardType Ti = (WildcardType)currentT.head;
Type Ui = currentA.head.getUpperBound(); Type Ui = currentA.head.getUpperBound();
CapturedType Si = (CapturedType)currentS.head.unannotatedType(); CapturedType Si = (CapturedType)currentS.head;
if (Ui == null) if (Ui == null)
Ui = syms.objectType; Ui = syms.objectType;
switch (Ti.kind) { switch (Ti.kind) {
@ -3986,7 +4016,8 @@ public class Types {
return erasure(t); // some "rare" type involved return erasure(t); // some "rare" type involved
if (captured) if (captured)
return new ClassType(cls.getEnclosingType(), S, cls.tsym); return new ClassType(cls.getEnclosingType(), S, cls.tsym,
cls.getAnnotationMirrors());
else else
return t; return t;
} }
@ -3995,7 +4026,6 @@ public class Types {
ListBuffer<Type> result = new ListBuffer<>(); ListBuffer<Type> result = new ListBuffer<>();
for (Type t : types) { for (Type t : types) {
if (t.hasTag(WILDCARD)) { if (t.hasTag(WILDCARD)) {
t = t.unannotatedType();
Type bound = ((WildcardType)t).getExtendsBound(); Type bound = ((WildcardType)t).getExtendsBound();
if (bound == null) if (bound == null)
bound = syms.objectType; bound = syms.objectType;
@ -4003,7 +4033,8 @@ public class Types {
syms.noSymbol, syms.noSymbol,
bound, bound,
syms.botType, syms.botType,
(WildcardType)t)); (WildcardType)t,
Type.noAnnotations));
} else { } else {
result.append(t); result.append(t);
} }
@ -4089,7 +4120,7 @@ public class Types {
private boolean giveWarning(Type from, Type to) { private boolean giveWarning(Type from, Type to) {
List<Type> bounds = to.isCompound() ? List<Type> bounds = to.isCompound() ?
((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to); ((IntersectionClassType)to).getComponents() : List.of(to);
for (Type b : bounds) { for (Type b : bounds) {
Type subFrom = asSub(from, b.tsym); Type subFrom = asSub(from, b.tsym);
if (b.isParameterized() && if (b.isParameterized() &&
@ -4354,7 +4385,7 @@ public class Types {
Type B(Type t) { Type B(Type t) {
while (t.hasTag(WILDCARD)) { while (t.hasTag(WILDCARD)) {
WildcardType w = (WildcardType)t.unannotatedType(); WildcardType w = (WildcardType)t;
t = high ? t = high ?
w.getExtendsBound() : w.getExtendsBound() :
w.getSuperBound(); w.getSuperBound();
@ -4380,12 +4411,14 @@ public class Types {
return new WildcardType(syms.objectType, return new WildcardType(syms.objectType,
BoundKind.UNBOUND, BoundKind.UNBOUND,
syms.boundClass, syms.boundClass,
formal); formal,
Type.noAnnotations);
} else { } else {
return new WildcardType(bound, return new WildcardType(bound,
BoundKind.EXTENDS, BoundKind.EXTENDS,
syms.boundClass, syms.boundClass,
formal); formal,
Type.noAnnotations);
} }
} }
@ -4402,12 +4435,14 @@ public class Types {
return new WildcardType(syms.objectType, return new WildcardType(syms.objectType,
BoundKind.UNBOUND, BoundKind.UNBOUND,
syms.boundClass, syms.boundClass,
formal); formal,
Type.noAnnotations);
} else { } else {
return new WildcardType(bound, return new WildcardType(bound,
BoundKind.SUPER, BoundKind.SUPER,
syms.boundClass, syms.boundClass,
formal); formal,
Type.noAnnotations);
} }
} }
@ -4429,7 +4464,7 @@ public class Types {
public boolean equals(Object obj) { public boolean equals(Object obj) {
return (obj instanceof UniqueType) && return (obj instanceof UniqueType) &&
types.isSameAnnotatedType(type, ((UniqueType)obj).type); types.isSameType(type, ((UniqueType)obj).type);
} }
public String toString() { public String toString() {
@ -4464,8 +4499,6 @@ public class Types {
public R visitForAll(ForAll t, S s) { return visitType(t, s); } public R visitForAll(ForAll t, S s) { return visitType(t, s); }
public R visitUndetVar(UndetVar t, S s) { return visitType(t, s); } public R visitUndetVar(UndetVar t, S s) { return visitType(t, s); }
public R visitErrorType(ErrorType t, S s) { return visitType(t, s); } public R visitErrorType(ErrorType t, S s) { return visitType(t, s); }
// Pretend annotations don't exist
public R visitAnnotatedType(AnnotatedType t, S s) { return visit(t.unannotatedType(), s); }
} }
/** /**
@ -4596,7 +4629,6 @@ public class Types {
* Assemble signature of given type in string buffer. * Assemble signature of given type in string buffer.
*/ */
public void assembleSig(Type type) { public void assembleSig(Type type) {
type = type.unannotatedType();
switch (type.getTag()) { switch (type.getTag()) {
case BYTE: case BYTE:
append('B'); append('B');
@ -4693,7 +4725,6 @@ public class Types {
} }
public void assembleClassSig(Type type) { public void assembleClassSig(Type type) {
type = type.unannotatedType();
ClassType ct = (ClassType) type; ClassType ct = (ClassType) type;
ClassSymbol c = (ClassSymbol) ct.tsym; ClassSymbol c = (ClassSymbol) ct.tsym;
classReference(c); classReference(c);

View file

@ -517,6 +517,10 @@ public class Attr extends JCTree.Visitor {
return new ResultInfo(pkind, pt, newContext); return new ResultInfo(pkind, pt, newContext);
} }
protected ResultInfo dup(Type newPt, CheckContext newContext) {
return new ResultInfo(pkind, newPt, newContext);
}
@Override @Override
public String toString() { public String toString() {
if (pt != null) { if (pt != null) {
@ -1865,8 +1869,10 @@ public class Attr extends JCTree.Visitor {
return new ClassType(restype.getEnclosingType(), return new ClassType(restype.getEnclosingType(),
List.<Type>of(new WildcardType(types.erasure(qualifierType), List.<Type>of(new WildcardType(types.erasure(qualifierType),
BoundKind.EXTENDS, BoundKind.EXTENDS,
syms.boundClass)), syms.boundClass,
restype.tsym); Type.noAnnotations)),
restype.tsym,
restype.getAnnotationMirrors());
} else { } else {
return restype; return restype;
} }
@ -2036,7 +2042,8 @@ public class Attr extends JCTree.Visitor {
} else if (TreeInfo.isDiamond(tree)) { } else if (TreeInfo.isDiamond(tree)) {
ClassType site = new ClassType(clazztype.getEnclosingType(), ClassType site = new ClassType(clazztype.getEnclosingType(),
clazztype.tsym.type.getTypeArguments(), clazztype.tsym.type.getTypeArguments(),
clazztype.tsym); clazztype.tsym,
clazztype.getAnnotationMirrors());
Env<AttrContext> diamondEnv = localEnv.dup(tree); Env<AttrContext> diamondEnv = localEnv.dup(tree);
diamondEnv.info.selectSuper = cdef != null; diamondEnv.info.selectSuper = cdef != null;
@ -2255,7 +2262,8 @@ public class Attr extends JCTree.Visitor {
owntype = elemtype; owntype = elemtype;
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) { for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
attribExpr(l.head, localEnv, syms.intType); attribExpr(l.head, localEnv, syms.intType);
owntype = new ArrayType(owntype, syms.arrayClass); owntype = new ArrayType(owntype, syms.arrayClass,
Type.noAnnotations);
} }
} else { } else {
// we are seeing an untyped aggregate { ... } // we are seeing an untyped aggregate { ... }
@ -2272,7 +2280,8 @@ public class Attr extends JCTree.Visitor {
} }
if (tree.elems != null) { if (tree.elems != null) {
attribExprs(tree.elems, localEnv, elemtype); attribExprs(tree.elems, localEnv, elemtype);
owntype = new ArrayType(elemtype, syms.arrayClass); owntype = new ArrayType(elemtype, syms.arrayClass,
Type.noAnnotations);
} }
if (!types.isReifiable(elemtype)) if (!types.isReifiable(elemtype))
log.error(tree.pos(), "generic.array.creation"); log.error(tree.pos(), "generic.array.creation");
@ -2763,7 +2772,7 @@ public class Attr extends JCTree.Visitor {
targetError = false; targetError = false;
} }
JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym.baseSymbol()).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT,
that, exprType.tsym, exprType, that.name, argtypes, typeargtypes); that, exprType.tsym, exprType, that.name, argtypes, typeargtypes);
JCDiagnostic.DiagnosticType diagKind = targetError ? JCDiagnostic.DiagnosticType diagKind = targetError ?
@ -2838,7 +2847,8 @@ public class Attr extends JCTree.Visitor {
ResultInfo checkInfo = ResultInfo checkInfo =
resultInfo.dup(newMethodTemplate( resultInfo.dup(newMethodTemplate(
desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(), desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(),
that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes)); that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes),
new FunctionalReturnContext(resultInfo.checkContext));
Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo); Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo);
@ -3244,7 +3254,7 @@ public class Attr extends JCTree.Visitor {
if (skind == TYP) { if (skind == TYP) {
Type elt = site; Type elt = site;
while (elt.hasTag(ARRAY)) while (elt.hasTag(ARRAY))
elt = ((ArrayType)elt.unannotatedType()).elemtype; elt = ((ArrayType)elt).elemtype;
if (elt.hasTag(TYPEVAR)) { if (elt.hasTag(TYPEVAR)) {
log.error(tree.pos(), "type.var.cant.be.deref"); log.error(tree.pos(), "type.var.cant.be.deref");
result = types.createErrorType(tree.type); result = types.createErrorType(tree.type);
@ -3557,7 +3567,8 @@ public class Attr extends JCTree.Visitor {
normOuter = types.erasure(ownOuter); normOuter = types.erasure(ownOuter);
if (normOuter != ownOuter) if (normOuter != ownOuter)
owntype = new ClassType( owntype = new ClassType(
normOuter, List.<Type>nil(), owntype.tsym); normOuter, List.<Type>nil(), owntype.tsym,
owntype.getAnnotationMirrors());
} }
} }
break; break;
@ -3861,7 +3872,7 @@ public class Attr extends JCTree.Visitor {
public void visitTypeArray(JCArrayTypeTree tree) { public void visitTypeArray(JCArrayTypeTree tree) {
Type etype = attribType(tree.elemtype, env); Type etype = attribType(tree.elemtype, env);
Type type = new ArrayType(etype, syms.arrayClass); Type type = new ArrayType(etype, syms.arrayClass, Type.noAnnotations);
result = check(tree, type, TYP, resultInfo); result = check(tree, type, TYP, resultInfo);
} }
@ -3909,7 +3920,8 @@ public class Attr extends JCTree.Visitor {
clazzOuter = site; clazzOuter = site;
} }
} }
owntype = new ClassType(clazzOuter, actuals, clazztype.tsym); owntype = new ClassType(clazzOuter, actuals, clazztype.tsym,
clazztype.getAnnotationMirrors());
} else { } else {
if (formals.length() != 0) { if (formals.length() != 0) {
log.error(tree.pos(), "wrong.number.type.args", log.error(tree.pos(), "wrong.number.type.args",
@ -4060,7 +4072,8 @@ public class Attr extends JCTree.Visitor {
: attribType(tree.inner, env); : attribType(tree.inner, env);
result = check(tree, new WildcardType(chk.checkRefType(tree.pos(), type), result = check(tree, new WildcardType(chk.checkRefType(tree.pos(), type),
tree.kind.kind, tree.kind.kind,
syms.boundClass), syms.boundClass,
Type.noAnnotations),
TYP, resultInfo); TYP, resultInfo);
} }
@ -4088,7 +4101,7 @@ public class Attr extends JCTree.Visitor {
public void run() { public void run() {
List<Attribute.TypeCompound> compounds = fromAnnotations(annotations); List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
Assert.check(annotations.size() == compounds.size()); Assert.check(annotations.size() == compounds.size());
tree.type = tree.type.unannotatedType().annotatedType(compounds); tree.type = tree.type.annotatedType(compounds);
} }
}); });
} }
@ -4470,6 +4483,7 @@ public class Attr extends JCTree.Visitor {
} }
} }
public void visitVarDef(final JCVariableDecl tree) { public void visitVarDef(final JCVariableDecl tree) {
//System.err.println("validateTypeAnnotations.visitVarDef " + tree);
if (tree.sym != null && tree.sym.type != null) if (tree.sym != null && tree.sym.type != null)
validateAnnotatedType(tree.vartype, tree.sym.type); validateAnnotatedType(tree.vartype, tree.sym.type);
scan(tree.mods); scan(tree.mods);
@ -4512,6 +4526,7 @@ public class Attr extends JCTree.Visitor {
super.visitNewArray(tree); super.visitNewArray(tree);
} }
public void visitClassDef(JCClassDecl tree) { public void visitClassDef(JCClassDecl tree) {
//System.err.println("validateTypeAnnotations.visitClassDef " + tree);
if (sigOnly) { if (sigOnly) {
scan(tree.mods); scan(tree.mods);
scan(tree.typarams); scan(tree.typarams);
@ -4540,7 +4555,7 @@ public class Attr extends JCTree.Visitor {
* can occur. * can occur.
*/ */
private void validateAnnotatedType(final JCTree errtree, final Type type) { private void validateAnnotatedType(final JCTree errtree, final Type type) {
// System.out.println("Attr.validateAnnotatedType: " + errtree + " type: " + type); //System.err.println("Attr.validateAnnotatedType: " + errtree + " type: " + type);
if (type.isPrimitiveOrVoid()) { if (type.isPrimitiveOrVoid()) {
return; return;
@ -4578,8 +4593,7 @@ public class Attr extends JCTree.Visitor {
} }
} else if (enclTr.hasTag(ANNOTATED_TYPE)) { } else if (enclTr.hasTag(ANNOTATED_TYPE)) {
JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr; JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
if (enclTy == null || if (enclTy == null || enclTy.hasTag(NONE)) {
enclTy.hasTag(NONE)) {
if (at.getAnnotations().size() == 1) { if (at.getAnnotations().size() == 1) {
log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute); log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
} else { } else {
@ -4598,16 +4612,16 @@ public class Attr extends JCTree.Visitor {
} else if (enclTr.hasTag(JCTree.Tag.WILDCARD)) { } else if (enclTr.hasTag(JCTree.Tag.WILDCARD)) {
JCWildcard wc = (JCWildcard) enclTr; JCWildcard wc = (JCWildcard) enclTr;
if (wc.getKind() == JCTree.Kind.EXTENDS_WILDCARD) { if (wc.getKind() == JCTree.Kind.EXTENDS_WILDCARD) {
validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy.unannotatedType()).getExtendsBound()); validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy).getExtendsBound());
} else if (wc.getKind() == JCTree.Kind.SUPER_WILDCARD) { } else if (wc.getKind() == JCTree.Kind.SUPER_WILDCARD) {
validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy.unannotatedType()).getSuperBound()); validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy).getSuperBound());
} else { } else {
// Nothing to do for UNBOUND // Nothing to do for UNBOUND
} }
repeat = false; repeat = false;
} else if (enclTr.hasTag(TYPEARRAY)) { } else if (enclTr.hasTag(TYPEARRAY)) {
JCArrayTypeTree art = (JCArrayTypeTree) enclTr; JCArrayTypeTree art = (JCArrayTypeTree) enclTr;
validateAnnotatedType(art.getType(), ((ArrayType)enclTy.unannotatedType()).getComponentType()); validateAnnotatedType(art.getType(), ((ArrayType)enclTy).getComponentType());
repeat = false; repeat = false;
} else if (enclTr.hasTag(TYPEUNION)) { } else if (enclTr.hasTag(TYPEUNION)) {
JCTypeUnion ut = (JCTypeUnion) enclTr; JCTypeUnion ut = (JCTypeUnion) enclTr;

View file

@ -2234,11 +2234,11 @@ public class Check {
if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0) if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0)
return; return;
if (seen.contains(t)) { if (seen.contains(t)) {
tv = (TypeVar)t.unannotatedType(); tv = (TypeVar)t;
tv.bound = types.createErrorType(t); tv.bound = types.createErrorType(t);
log.error(pos, "cyclic.inheritance", t); log.error(pos, "cyclic.inheritance", t);
} else if (t.hasTag(TYPEVAR)) { } else if (t.hasTag(TYPEVAR)) {
tv = (TypeVar)t.unannotatedType(); tv = (TypeVar)t;
seen = seen.prepend(tv); seen = seen.prepend(tv);
for (Type b : types.getBounds(tv)) for (Type b : types.getBounds(tv))
checkNonCyclic1(pos, b, seen); checkNonCyclic1(pos, b, seen);

View file

@ -134,12 +134,17 @@ public class DeferredAttr extends JCTree.Visitor {
SpeculativeCache speculativeCache; SpeculativeCache speculativeCache;
DeferredType(JCExpression tree, Env<AttrContext> env) { DeferredType(JCExpression tree, Env<AttrContext> env) {
super(null); super(null, noAnnotations);
this.tree = tree; this.tree = tree;
this.env = attr.copyEnv(env); this.env = attr.copyEnv(env);
this.speculativeCache = new SpeculativeCache(); this.speculativeCache = new SpeculativeCache();
} }
@Override
public DeferredType annotatedType(List<Attribute.TypeCompound> typeAnnotations) {
throw new AssertionError("Cannot annotate a deferred type");
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return DEFERRED; return DEFERRED;

View file

@ -373,7 +373,7 @@ public class Infer {
List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER);
if (Type.containsAny(upperBounds, vars)) { if (Type.containsAny(upperBounds, vars)) {
TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner);
fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), null); fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), null, Type.noAnnotations);
todo.append(uv); todo.append(uv);
uv.inst = fresh_tvar.type; uv.inst = fresh_tvar.type;
} else if (upperBounds.nonEmpty()) { } else if (upperBounds.nonEmpty()) {
@ -1505,7 +1505,9 @@ public class Infer {
LOWER.solve(uv, inferenceContext) : LOWER.solve(uv, inferenceContext) :
infer.syms.botType; infer.syms.botType;
CapturedType prevCaptured = (CapturedType)uv.qtype; CapturedType prevCaptured = (CapturedType)uv.qtype;
return new CapturedType(prevCaptured.tsym.name, prevCaptured.tsym.owner, upper, lower, prevCaptured.wildcard); return new CapturedType(prevCaptured.tsym.name, prevCaptured.tsym.owner,
upper, lower, prevCaptured.wildcard,
Type.noAnnotations);
} }
}; };

View file

@ -28,7 +28,6 @@ package com.sun.tools.javac.comp;
import java.util.*; import java.util.*;
import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.AnnotatedType;
import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.main.Option.PkgInfo; import com.sun.tools.javac.main.Option.PkgInfo;
import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.*;
@ -452,7 +451,8 @@ public class Lower extends TreeTranslator {
ClassSymbol outerCacheClass = outerCacheClass(); ClassSymbol outerCacheClass = outerCacheClass();
this.mapVar = new VarSymbol(STATIC | SYNTHETIC | FINAL, this.mapVar = new VarSymbol(STATIC | SYNTHETIC | FINAL,
varName, varName,
new ArrayType(syms.intType, syms.arrayClass), new ArrayType(syms.intType, syms.arrayClass,
Type.noAnnotations),
outerCacheClass); outerCacheClass);
enterSynthetic(pos, mapVar, outerCacheClass.members()); enterSynthetic(pos, mapVar, outerCacheClass.members());
} }
@ -493,7 +493,8 @@ public class Lower extends TreeTranslator {
syms.lengthVar); syms.lengthVar);
JCExpression mapVarInit = make JCExpression mapVarInit = make
.NewArray(make.Type(syms.intType), List.of(size), null) .NewArray(make.Type(syms.intType), List.of(size), null)
.setType(new ArrayType(syms.intType, syms.arrayClass)); .setType(new ArrayType(syms.intType, syms.arrayClass,
Type.noAnnotations));
// try { $SwitchMap$Color[red.ordinal()] = 1; } catch (java.lang.NoSuchFieldError ex) {} // try { $SwitchMap$Color[red.ordinal()] = 1; } catch (java.lang.NoSuchFieldError ex) {}
ListBuffer<JCStatement> stmts = new ListBuffer<>(); ListBuffer<JCStatement> stmts = new ListBuffer<>();
@ -1979,7 +1980,7 @@ public class Lower extends TreeTranslator {
List.<JCExpression>of(make.Literal(INT, 0).setType(syms.intType)), List.<JCExpression>of(make.Literal(INT, 0).setType(syms.intType)),
null); null);
newcache.type = new ArrayType(types.erasure(outerCacheClass.type), newcache.type = new ArrayType(types.erasure(outerCacheClass.type),
syms.arrayClass); syms.arrayClass, Type.noAnnotations);
// forNameSym := java.lang.Class.forName( // forNameSym := java.lang.Class.forName(
// String s,boolean init,ClassLoader loader) // String s,boolean init,ClassLoader loader)
@ -2568,7 +2569,8 @@ public class Lower extends TreeTranslator {
Name valuesName = names.fromString(target.syntheticNameChar() + "VALUES"); Name valuesName = names.fromString(target.syntheticNameChar() + "VALUES");
while (tree.sym.members().lookup(valuesName).scope != null) // avoid name clash while (tree.sym.members().lookup(valuesName).scope != null) // avoid name clash
valuesName = names.fromString(valuesName + "" + target.syntheticNameChar()); valuesName = names.fromString(valuesName + "" + target.syntheticNameChar());
Type arrayType = new ArrayType(types.erasure(tree.type), syms.arrayClass); Type arrayType = new ArrayType(types.erasure(tree.type),
syms.arrayClass, Type.noAnnotations);
VarSymbol valuesVar = new VarSymbol(PRIVATE|FINAL|STATIC|SYNTHETIC, VarSymbol valuesVar = new VarSymbol(PRIVATE|FINAL|STATIC|SYNTHETIC,
valuesName, valuesName,
arrayType, arrayType,
@ -2841,7 +2843,7 @@ public class Lower extends TreeTranslator {
tree.underlyingType = translate(tree.underlyingType); tree.underlyingType = translate(tree.underlyingType);
// but maintain type annotations in the type. // but maintain type annotations in the type.
if (tree.type.isAnnotated()) { if (tree.type.isAnnotated()) {
tree.type = tree.underlyingType.type.unannotatedType().annotatedType(tree.type.getAnnotationMirrors()); tree.type = tree.underlyingType.type.annotatedType(tree.type.getAnnotationMirrors());
} else if (tree.underlyingType.type.isAnnotated()) { } else if (tree.underlyingType.type.isAnnotated()) {
tree.type = tree.underlyingType.type; tree.type = tree.underlyingType.type;
} }
@ -3145,7 +3147,8 @@ public class Lower extends TreeTranslator {
JCNewArray boxedArgs = make.NewArray(make.Type(varargsElement), JCNewArray boxedArgs = make.NewArray(make.Type(varargsElement),
List.<JCExpression>nil(), List.<JCExpression>nil(),
elems.toList()); elems.toList());
boxedArgs.type = new ArrayType(varargsElement, syms.arrayClass); boxedArgs.type = new ArrayType(varargsElement, syms.arrayClass,
Type.noAnnotations);
result.append(boxedArgs); result.append(boxedArgs);
} else { } else {
if (args.length() != 1) throw new AssertionError(args); if (args.length() != 1) throw new AssertionError(args);

View file

@ -457,7 +457,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
* to the symbol table. * to the symbol table.
*/ */
private void addEnumMembers(JCClassDecl tree, Env<AttrContext> env) { private void addEnumMembers(JCClassDecl tree, Env<AttrContext> env) {
JCExpression valuesType = make.Type(new ArrayType(tree.sym.type, syms.arrayClass)); JCExpression valuesType = make.Type(new ArrayType(tree.sym.type, syms.arrayClass,
Type.noAnnotations));
// public static T[] values() { return ???; } // public static T[] values() { return ???; }
JCMethodDecl values = make. JCMethodDecl values = make.
@ -677,7 +678,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
//because varargs is represented in the tree as a //because varargs is represented in the tree as a
//modifier on the parameter declaration, and not as a //modifier on the parameter declaration, and not as a
//distinct type of array node. //distinct type of array node.
ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); ArrayType atype = (ArrayType)tree.vartype.type;
tree.vartype.type = atype.makeVarargs(); tree.vartype.type = atype.makeVarargs();
} }
Scope enclScope = enter.enterScope(env); Scope enclScope = enter.enterScope(env);
@ -1255,11 +1256,13 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
ClassType ct = (ClassType) sym.type; ClassType ct = (ClassType) sym.type;
Assert.check(ct.typarams_field.isEmpty()); Assert.check(ct.typarams_field.isEmpty());
if (n == 1) { if (n == 1) {
TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType); TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType,
Type.noAnnotations);
ct.typarams_field = ct.typarams_field.prepend(v); ct.typarams_field = ct.typarams_field.prepend(v);
} else { } else {
for (int i = n; i > 0; i--) { for (int i = n; i > 0; i--) {
TypeVar v = new TypeVar(names.fromString("T" + i), sym, syms.botType); TypeVar v = new TypeVar(names.fromString("T" + i), sym,
syms.botType, Type.noAnnotations);
ct.typarams_field = ct.typarams_field.prepend(v); ct.typarams_field = ct.typarams_field.prepend(v);
} }
} }
@ -1310,8 +1313,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
} }
Type mType = new MethodType(argtypes, null, thrown, c); Type mType = new MethodType(argtypes, null, thrown, c);
Type initType = typarams.nonEmpty() ? Type initType = typarams.nonEmpty() ?
new ForAll(typarams, mType) : new ForAll(typarams, mType) :
mType; mType;
MethodSymbol init = new MethodSymbol(flags, names.init, MethodSymbol init = new MethodSymbol(flags, names.init,
initType, c); initType, c);
init.params = createDefaultConstructorParams(make, baseInit, init, init.params = createDefaultConstructorParams(make, baseInit, init,

View file

@ -94,7 +94,7 @@ public class Resolve {
public final boolean boxingEnabled; public final boolean boxingEnabled;
public final boolean varargsEnabled; public final boolean varargsEnabled;
public final boolean allowMethodHandles; public final boolean allowMethodHandles;
public final boolean allowStructuralMostSpecific; public final boolean allowFunctionalInterfaceMostSpecific;
private final boolean debugResolve; private final boolean debugResolve;
private final boolean compactMethodDiags; private final boolean compactMethodDiags;
final EnumSet<VerboseResolutionMode> verboseResolutionMode; final EnumSet<VerboseResolutionMode> verboseResolutionMode;
@ -135,7 +135,7 @@ public class Resolve {
verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
Target target = Target.instance(context); Target target = Target.instance(context);
allowMethodHandles = target.hasMethodHandles(); allowMethodHandles = target.hasMethodHandles();
allowStructuralMostSpecific = source.allowStructuralMostSpecific(); allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific();
polymorphicSignatureScope = new Scope(syms.noSymbol); polymorphicSignatureScope = new Scope(syms.noSymbol);
inapplicableMethodException = new InapplicableMethodException(diags); inapplicableMethodException = new InapplicableMethodException(diags);
@ -1084,50 +1084,47 @@ public class Resolve {
} }
public boolean compatible(Type found, Type req, Warner warn) { public boolean compatible(Type found, Type req, Warner warn) {
if (!allowStructuralMostSpecific || actual == null) { if (allowFunctionalInterfaceMostSpecific &&
return super.compatible(found, req, warn); unrelatedFunctionalInterfaces(found, req) &&
} else { (actual != null && actual.getTag() == DEFERRED)) {
switch (actual.getTag()) { DeferredType dt = (DeferredType) actual;
case DEFERRED: DeferredType.SpeculativeCache.Entry e =
DeferredType dt = (DeferredType) actual; dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase);
DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); if (e != null && e.speculativeTree != deferredAttr.stuckTree) {
return (e == null || e.speculativeTree == deferredAttr.stuckTree) return functionalInterfaceMostSpecific(found, req, e.speculativeTree, warn);
? super.compatible(found, req, warn) :
mostSpecific(found, req, e.speculativeTree, warn);
default:
return standaloneMostSpecific(found, req, actual, warn);
} }
} }
return super.compatible(found, req, warn);
} }
private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) { /** Whether {@code t} and {@code s} are unrelated functional interface types. */
MostSpecificChecker msc = new MostSpecificChecker(t, s, warn); private boolean unrelatedFunctionalInterfaces(Type t, Type s) {
return types.isFunctionalInterface(t.tsym) &&
types.isFunctionalInterface(s.tsym) &&
types.asSuper(t, s.tsym) == null &&
types.asSuper(s, t.tsym) == null;
}
/** Parameters {@code t} and {@code s} are unrelated functional interface types. */
private boolean functionalInterfaceMostSpecific(Type t, Type s, JCTree tree, Warner warn) {
FunctionalInterfaceMostSpecificChecker msc = new FunctionalInterfaceMostSpecificChecker(t, s, warn);
msc.scan(tree); msc.scan(tree);
return msc.result; return msc.result;
} }
boolean polyMostSpecific(Type t1, Type t2, Warner warn) {
return (!t1.isPrimitive() && t2.isPrimitive())
? true : super.compatible(t1, t2, warn);
}
boolean standaloneMostSpecific(Type t1, Type t2, Type exprType, Warner warn) {
return (exprType.isPrimitive() == t1.isPrimitive()
&& exprType.isPrimitive() != t2.isPrimitive())
? true : super.compatible(t1, t2, warn);
}
/** /**
* Structural checker for most specific. * Tests whether one functional interface type can be considered more specific
* than another unrelated functional interface type for the scanned expression.
*/ */
class MostSpecificChecker extends DeferredAttr.PolyScanner { class FunctionalInterfaceMostSpecificChecker extends DeferredAttr.PolyScanner {
final Type t; final Type t;
final Type s; final Type s;
final Warner warn; final Warner warn;
boolean result; boolean result;
MostSpecificChecker(Type t, Type s, Warner warn) { /** Parameters {@code t} and {@code s} are unrelated functional interface types. */
FunctionalInterfaceMostSpecificChecker(Type t, Type s, Warner warn) {
this.t = t; this.t = t;
this.s = s; this.s = s;
this.warn = warn; this.warn = warn;
@ -1136,102 +1133,96 @@ public class Resolve {
@Override @Override
void skip(JCTree tree) { void skip(JCTree tree) {
result &= standaloneMostSpecific(t, s, tree.type, warn); result &= false;
} }
@Override @Override
public void visitConditional(JCConditional tree) { public void visitConditional(JCConditional tree) {
if (tree.polyKind == PolyKind.STANDALONE) { scan(tree.truepart);
result &= standaloneMostSpecific(t, s, tree.type, warn); scan(tree.falsepart);
} else {
super.visitConditional(tree);
}
}
@Override
public void visitApply(JCMethodInvocation tree) {
result &= (tree.polyKind == PolyKind.STANDALONE)
? standaloneMostSpecific(t, s, tree.type, warn)
: polyMostSpecific(t, s, warn);
}
@Override
public void visitNewClass(JCNewClass tree) {
result &= (tree.polyKind == PolyKind.STANDALONE)
? standaloneMostSpecific(t, s, tree.type, warn)
: polyMostSpecific(t, s, warn);
} }
@Override @Override
public void visitReference(JCMemberReference tree) { public void visitReference(JCMemberReference tree) {
if (types.isFunctionalInterface(t.tsym) && Type desc_t = types.findDescriptorType(t);
types.isFunctionalInterface(s.tsym)) { Type desc_s = types.findDescriptorType(s);
Type desc_t = types.findDescriptorType(t); // use inference variables here for more-specific inference (18.5.4)
Type desc_s = types.findDescriptorType(s); if (!types.isSameTypes(desc_t.getParameterTypes(),
if (types.isSameTypes(desc_t.getParameterTypes(), inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
if (types.asSuper(t, s.tsym) != null ||
types.asSuper(s, t.tsym) != null) {
result &= MostSpecificCheckContext.super.compatible(t, s, warn);
} else if (!desc_s.getReturnType().hasTag(VOID)) {
//perform structural comparison
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
result &= ((tree.refPolyKind == PolyKind.STANDALONE)
? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn)
: polyMostSpecific(ret_t, ret_s, warn));
} else {
return;
}
}
} else {
result &= false; result &= false;
} else {
// compare return types
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
if (ret_s.hasTag(VOID)) {
result &= true;
} else if (ret_t.hasTag(VOID)) {
result &= false;
} else if (ret_t.isPrimitive() != ret_s.isPrimitive()) {
boolean retValIsPrimitive =
tree.refPolyKind == PolyKind.STANDALONE &&
tree.sym.type.getReturnType().isPrimitive();
result &= (retValIsPrimitive == ret_t.isPrimitive()) &&
(retValIsPrimitive != ret_s.isPrimitive());
} else {
result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn);
}
} }
} }
@Override @Override
public void visitLambda(JCLambda tree) { public void visitLambda(JCLambda tree) {
if (types.isFunctionalInterface(t.tsym) && Type desc_t = types.findDescriptorType(t);
types.isFunctionalInterface(s.tsym)) { Type desc_s = types.findDescriptorType(s);
Type desc_t = types.findDescriptorType(t); // use inference variables here for more-specific inference (18.5.4)
Type desc_s = types.findDescriptorType(s); if (!types.isSameTypes(desc_t.getParameterTypes(),
if (types.isSameTypes(desc_t.getParameterTypes(), inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
if (types.asSuper(t, s.tsym) != null ||
types.asSuper(s, t.tsym) != null) {
result &= MostSpecificCheckContext.super.compatible(t, s, warn);
} else if (!desc_s.getReturnType().hasTag(VOID)) {
//perform structural comparison
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
scanLambdaBody(tree, ret_t, ret_s);
} else {
return;
}
}
} else {
result &= false; result &= false;
} else {
// compare return types
Type ret_t = desc_t.getReturnType();
Type ret_s = desc_s.getReturnType();
if (ret_s.hasTag(VOID)) {
result &= true;
} else if (ret_t.hasTag(VOID)) {
result &= false;
} else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) {
for (JCExpression expr : lambdaResults(tree)) {
result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr, warn);
}
} else if (ret_t.isPrimitive() != ret_s.isPrimitive()) {
for (JCExpression expr : lambdaResults(tree)) {
boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive();
result &= (retValIsPrimitive == ret_t.isPrimitive()) &&
(retValIsPrimitive != ret_s.isPrimitive());
}
} else {
result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn);
}
} }
} }
//where //where
void scanLambdaBody(JCLambda lambda, final Type t, final Type s) { private List<JCExpression> lambdaResults(JCLambda lambda) {
if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) { if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
result &= MostSpecificCheckContext.this.mostSpecific(t, s, lambda.body, warn); return List.of((JCExpression) lambda.body);
} else { } else {
final ListBuffer<JCExpression> buffer = new ListBuffer<>();
DeferredAttr.LambdaReturnScanner lambdaScanner = DeferredAttr.LambdaReturnScanner lambdaScanner =
new DeferredAttr.LambdaReturnScanner() { new DeferredAttr.LambdaReturnScanner() {
@Override @Override
public void visitReturn(JCReturn tree) { public void visitReturn(JCReturn tree) {
if (tree.expr != null) { if (tree.expr != null) {
result &= MostSpecificCheckContext.this.mostSpecific(t, s, tree.expr, warn); buffer.append(tree.expr);
} }
} }
}; };
lambdaScanner.scan(lambda.body); lambdaScanner.scan(lambda.body);
return buffer.toList();
} }
} }
} }
} }
public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
@ -1435,7 +1426,7 @@ public class Resolve {
return bestSoFar; return bestSoFar;
} else if (useVarargs && (sym.flags() & VARARGS) == 0) { } else if (useVarargs && (sym.flags() & VARARGS) == 0) {
return bestSoFar.kind >= ERRONEOUS ? return bestSoFar.kind >= ERRONEOUS ?
new BadVarargsMethod((ResolveError)bestSoFar) : new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) :
bestSoFar; bestSoFar;
} }
Assert.check(sym.kind < AMBIGUOUS); Assert.check(sym.kind < AMBIGUOUS);
@ -1527,14 +1518,22 @@ public class Resolve {
if (m2SignatureMoreSpecific) return m2; if (m2SignatureMoreSpecific) return m2;
return ambiguityError(m1, m2); return ambiguityError(m1, m2);
case AMBIGUOUS: case AMBIGUOUS:
//check if m1 is more specific than all ambiguous methods in m2 //compare m1 to ambiguous methods in m2
AmbiguityError e = (AmbiguityError)m2.baseSymbol(); AmbiguityError e = (AmbiguityError)m2.baseSymbol();
boolean m1MoreSpecificThanAnyAmbiguous = true;
boolean allAmbiguousMoreSpecificThanM1 = true;
for (Symbol s : e.ambiguousSyms) { for (Symbol s : e.ambiguousSyms) {
if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) { Symbol moreSpecific = mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs);
return e.addAmbiguousSymbol(m1); m1MoreSpecificThanAnyAmbiguous &= moreSpecific == m1;
} allAmbiguousMoreSpecificThanM1 &= moreSpecific == s;
} }
return m1; if (m1MoreSpecificThanAnyAmbiguous)
return m1;
//if m1 is more specific than some ambiguous methods, but other ambiguous methods are
//more specific than m1, add it as a new ambiguous method:
if (!allAmbiguousMoreSpecificThanM1)
e.addAmbiguousSymbol(m1);
return e;
default: default:
throw new AssertionError(); throw new AssertionError();
} }
@ -2195,7 +2194,7 @@ public class Resolve {
List<Type> typeargtypes, List<Type> typeargtypes,
LogResolveHelper logResolveHelper) { LogResolveHelper logResolveHelper) {
if (sym.kind >= AMBIGUOUS) { if (sym.kind >= AMBIGUOUS) {
ResolveError errSym = (ResolveError)sym; ResolveError errSym = (ResolveError)sym.baseSymbol();
sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) { if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) {
@ -2584,7 +2583,7 @@ public class Resolve {
sym = super.access(env, pos, location, sym); sym = super.access(env, pos, location, sym);
} else { } else {
final JCDiagnostic details = sym.kind == WRONG_MTH ? final JCDiagnostic details = sym.kind == WRONG_MTH ?
((InapplicableSymbolError)sym).errCandidate().snd : ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd :
null; null;
sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
@Override @Override
@ -2631,7 +2630,7 @@ public class Resolve {
((ForAll)sym.type).tvars : ((ForAll)sym.type).tvars :
List.<Type>nil(); List.<Type>nil();
Type constrType = new ForAll(site.tsym.type.getTypeArguments().appendList(oldParams), Type constrType = new ForAll(site.tsym.type.getTypeArguments().appendList(oldParams),
types.createMethodTypeWithReturn(sym.type.asMethodType(), site)); types.createMethodTypeWithReturn(sym.type.asMethodType(), site));
MethodSymbol newConstr = new MethodSymbol(sym.flags(), names.init, constrType, site.tsym) { MethodSymbol newConstr = new MethodSymbol(sym.flags(), names.init, constrType, site.tsym) {
@Override @Override
public Symbol baseSymbol() { public Symbol baseSymbol() {
@ -2992,12 +2991,12 @@ public class Resolve {
return true; return true;
case WRONG_MTH: case WRONG_MTH:
InapplicableSymbolError errSym = InapplicableSymbolError errSym =
(InapplicableSymbolError)s; (InapplicableSymbolError)s.baseSymbol();
return new Template(MethodCheckDiag.ARITY_MISMATCH.regex()) return new Template(MethodCheckDiag.ARITY_MISMATCH.regex())
.matches(errSym.errCandidate().snd); .matches(errSym.errCandidate().snd);
case WRONG_MTHS: case WRONG_MTHS:
InapplicableSymbolsError errSyms = InapplicableSymbolsError errSyms =
(InapplicableSymbolsError)s; (InapplicableSymbolsError)s.baseSymbol();
return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty();
case WRONG_STATICNESS: case WRONG_STATICNESS:
return false; return false;
@ -3272,7 +3271,7 @@ public class Resolve {
List<Type> typeargtypes, MethodResolutionPhase maxPhase) { List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase); super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase);
if (site.isRaw()) { if (site.isRaw()) {
this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym); this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym, site.getAnnotationMirrors());
needsInference = true; needsInference = true;
} }
} }

View file

@ -624,18 +624,18 @@ public class ClassReader {
case '+': { case '+': {
sigp++; sigp++;
Type t = sigToType(); Type t = sigToType();
return new WildcardType(t, BoundKind.EXTENDS, return new WildcardType(t, BoundKind.EXTENDS, syms.boundClass,
syms.boundClass); Type.noAnnotations);
} }
case '*': case '*':
sigp++; sigp++;
return new WildcardType(syms.objectType, BoundKind.UNBOUND, return new WildcardType(syms.objectType, BoundKind.UNBOUND,
syms.boundClass); syms.boundClass, Type.noAnnotations);
case '-': { case '-': {
sigp++; sigp++;
Type t = sigToType(); Type t = sigToType();
return new WildcardType(t, BoundKind.SUPER, return new WildcardType(t, BoundKind.SUPER, syms.boundClass,
syms.boundClass); Type.noAnnotations);
} }
case 'B': case 'B':
sigp++; sigp++;
@ -680,7 +680,8 @@ public class ClassReader {
return syms.booleanType; return syms.booleanType;
case '[': case '[':
sigp++; sigp++;
return new ArrayType(sigToType(), syms.arrayClass); return new ArrayType(sigToType(), syms.arrayClass,
Type.noAnnotations);
case '(': case '(':
sigp++; sigp++;
List<Type> argtypes = sigToTypes(')'); List<Type> argtypes = sigToTypes(')');
@ -735,7 +736,8 @@ public class ClassReader {
try { try {
return (outer == Type.noType) ? return (outer == Type.noType) ?
t.erasure(types) : t.erasure(types) :
new ClassType(outer, List.<Type>nil(), t); new ClassType(outer, List.<Type>nil(), t,
Type.noAnnotations);
} finally { } finally {
sbp = startSbp; sbp = startSbp;
} }
@ -745,7 +747,8 @@ public class ClassReader {
ClassSymbol t = syms.enterClass(names.fromUtf(signatureBuffer, ClassSymbol t = syms.enterClass(names.fromUtf(signatureBuffer,
startSbp, startSbp,
sbp - startSbp)); sbp - startSbp));
outer = new ClassType(outer, sigToTypes('>'), t) { outer = new ClassType(outer, sigToTypes('>'), t,
Type.noAnnotations) {
boolean completed = false; boolean completed = false;
@Override @Override
public Type getEnclosingType() { public Type getEnclosingType() {
@ -808,7 +811,8 @@ public class ClassReader {
t = syms.enterClass(names.fromUtf(signatureBuffer, t = syms.enterClass(names.fromUtf(signatureBuffer,
startSbp, startSbp,
sbp - startSbp)); sbp - startSbp));
outer = new ClassType(outer, List.<Type>nil(), t); outer = new ClassType(outer, List.<Type>nil(), t,
Type.noAnnotations);
} }
signatureBuffer[sbp++] = (byte)'$'; signatureBuffer[sbp++] = (byte)'$';
continue; continue;
@ -871,7 +875,8 @@ public class ClassReader {
Name name = names.fromUtf(signature, start, sigp - start); Name name = names.fromUtf(signature, start, sigp - start);
TypeVar tvar; TypeVar tvar;
if (sigEnterPhase) { if (sigEnterPhase) {
tvar = new TypeVar(name, currentOwner, syms.botType); tvar = new TypeVar(name, currentOwner, syms.botType,
Type.noAnnotations);
typevars.enter(tvar.tsym); typevars.enter(tvar.tsym);
} else { } else {
tvar = (TypeVar)findTypeVar(name); tvar = (TypeVar)findTypeVar(name);
@ -910,7 +915,8 @@ public class ClassReader {
// we don't know for sure if this owner is correct. It could // we don't know for sure if this owner is correct. It could
// be a method and there is no way to tell before reading the // be a method and there is no way to tell before reading the
// enclosing method attribute. // enclosing method attribute.
TypeVar t = new TypeVar(name, currentOwner, syms.botType); TypeVar t = new TypeVar(name, currentOwner, syms.botType,
Type.noAnnotations);
missingTypeVariables = missingTypeVariables.prepend(t); missingTypeVariables = missingTypeVariables.prepend(t);
// System.err.println("Missing type var " + name); // System.err.println("Missing type var " + name);
return t; return t;
@ -1534,35 +1540,41 @@ public class ClassReader {
// local variable // local variable
case LOCAL_VARIABLE: { case LOCAL_VARIABLE: {
final int table_length = nextChar(); final int table_length = nextChar();
final TypeAnnotationPosition position = final int[] newLvarOffset = new int[table_length];
TypeAnnotationPosition.localVariable(readTypePath()); final int[] newLvarLength = new int[table_length];
final int[] newLvarIndex = new int[table_length];
position.lvarOffset = new int[table_length];
position.lvarLength = new int[table_length];
position.lvarIndex = new int[table_length];
for (int i = 0; i < table_length; ++i) { for (int i = 0; i < table_length; ++i) {
position.lvarOffset[i] = nextChar(); newLvarOffset[i] = nextChar();
position.lvarLength[i] = nextChar(); newLvarLength[i] = nextChar();
position.lvarIndex[i] = nextChar(); newLvarIndex[i] = nextChar();
} }
final TypeAnnotationPosition position =
TypeAnnotationPosition.localVariable(readTypePath());
position.lvarOffset = newLvarOffset;
position.lvarLength = newLvarLength;
position.lvarIndex = newLvarIndex;
return position; return position;
} }
// resource variable // resource variable
case RESOURCE_VARIABLE: { case RESOURCE_VARIABLE: {
final int table_length = nextChar(); final int table_length = nextChar();
final TypeAnnotationPosition position = final int[] newLvarOffset = new int[table_length];
TypeAnnotationPosition.resourceVariable(readTypePath()); final int[] newLvarLength = new int[table_length];
final int[] newLvarIndex = new int[table_length];
position.lvarOffset = new int[table_length];
position.lvarLength = new int[table_length];
position.lvarIndex = new int[table_length];
for (int i = 0; i < table_length; ++i) { for (int i = 0; i < table_length; ++i) {
position.lvarOffset[i] = nextChar(); newLvarOffset[i] = nextChar();
position.lvarLength[i] = nextChar(); newLvarLength[i] = nextChar();
position.lvarIndex[i] = nextChar(); newLvarIndex[i] = nextChar();
} }
final TypeAnnotationPosition position =
TypeAnnotationPosition.resourceVariable(readTypePath());
position.lvarOffset = newLvarOffset;
position.lvarLength = newLvarLength;
position.lvarIndex = newLvarIndex;
return position; return position;
} }
// exception parameter // exception parameter

View file

@ -286,7 +286,6 @@ public class ClassWriter extends ClassFile {
*/ */
@Override @Override
public void assembleSig(Type type) { public void assembleSig(Type type) {
type = type.unannotatedType();
switch (type.getTag()) { switch (type.getTag()) {
case UNINITIALIZED_THIS: case UNINITIALIZED_THIS:
case UNINITIALIZED_OBJECT: case UNINITIALIZED_OBJECT:
@ -354,7 +353,7 @@ public class ClassWriter extends ClassFile {
} else if (t.hasTag(ARRAY)) { } else if (t.hasTag(ARRAY)) {
return typeSig(types.erasure(t)); return typeSig(types.erasure(t));
} else { } else {
throw new AssertionError("xClassName"); throw new AssertionError("xClassName expects class or array type, got " + t);
} }
} }

View file

@ -928,7 +928,7 @@ public class Code {
if (o instanceof Pool.MethodHandle) return syms.methodHandleType; if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type); if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type);
if (o instanceof Type) { if (o instanceof Type) {
Type ty = ((Type)o).unannotatedType(); Type ty = (Type) o;
if (ty instanceof Type.ArrayType) return syms.classType; if (ty instanceof Type.ArrayType) return syms.classType;
if (ty instanceof Type.MethodType) return syms.methodTypeType; if (ty instanceof Type.MethodType) return syms.methodTypeType;
@ -1579,8 +1579,8 @@ public class Code {
/** Add a catch clause to code. /** Add a catch clause to code.
*/ */
public void addCatch( public void addCatch(char startPc, char endPc,
char startPc, char endPc, char handlerPc, char catchType) { char handlerPc, char catchType) {
catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType}); catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType});
} }
@ -2149,7 +2149,7 @@ public class Code {
for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
TypeAnnotationPosition p = ta.position; TypeAnnotationPosition p = ta.position;
if (p.hasCatchType()) { if (p.hasCatchType()) {
final int idx = findExceptionIndex(p.getCatchType()); final int idx = findExceptionIndex(p);
if (idx == -1) if (idx == -1)
Assert.error("Could not find exception index for type annotation " + Assert.error("Could not find exception index for type annotation " +
ta + " on exception parameter"); ta + " on exception parameter");
@ -2159,14 +2159,17 @@ public class Code {
} }
} }
private int findExceptionIndex(int catchType) { private int findExceptionIndex(TypeAnnotationPosition p) {
final int catchType = p.getCatchType();
final int startPos = p.getStartPos();
final int len = catchInfo.length();
List<char[]> iter = catchInfo.toList(); List<char[]> iter = catchInfo.toList();
int len = catchInfo.length();
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
char[] catchEntry = iter.head; char[] catchEntry = iter.head;
iter = iter.tail; iter = iter.tail;
char ct = catchEntry[3]; int ct = catchEntry[3];
if (catchType == ct) { int sp = catchEntry[0];
if (catchType == ct && sp == startPos) {
return i; return i;
} }
} }

View file

@ -317,10 +317,6 @@ public class Gen extends JCTree.Visitor {
int makeRef(DiagnosticPosition pos, Type type) { int makeRef(DiagnosticPosition pos, Type type) {
checkDimension(pos, type); checkDimension(pos, type);
if (type.isAnnotated()) { if (type.isAnnotated()) {
// Treat annotated types separately - we don't want
// to collapse all of them - at least for annotated
// exceptions.
// TODO: review this.
return pool.put((Object)type); return pool.put((Object)type);
} else { } else {
return pool.put(type.hasTag(CLASS) ? (Object)type.tsym : (Object)type); return pool.put(type.hasTag(CLASS) ? (Object)type.tsym : (Object)type);
@ -1647,7 +1643,7 @@ public class Gen extends JCTree.Visitor {
if (subCatch.type.isAnnotated()) { if (subCatch.type.isAnnotated()) {
for (Attribute.TypeCompound tc : for (Attribute.TypeCompound tc :
subCatch.type.getAnnotationMirrors()) { subCatch.type.getAnnotationMirrors()) {
tc.position.setCatchType(catchType); tc.position.setCatchInfo(catchType, startpc);
} }
} }
} }
@ -1664,7 +1660,7 @@ public class Gen extends JCTree.Visitor {
if (subCatch.type.isAnnotated()) { if (subCatch.type.isAnnotated()) {
for (Attribute.TypeCompound tc : for (Attribute.TypeCompound tc :
subCatch.type.getAnnotationMirrors()) { subCatch.type.getAnnotationMirrors()) {
tc.position.setCatchType(catchType); tc.position.setCatchInfo(catchType, startpc);
} }
} }
} }

View file

@ -673,11 +673,6 @@ public class JNIWriter {
return defaultAction(t, p); return defaultAction(t, p);
} }
@Override
public R visitAnnotatedType(Type.AnnotatedType t, P p) {
return defaultAction(t, p);
}
@Override @Override
public R visitType(Type t, P p) { public R visitType(Type t, P p) {
return defaultAction(t, p); return defaultAction(t, p);

View file

@ -102,10 +102,11 @@ public class Pool {
*/ */
public int put(Object value) { public int put(Object value) {
value = makePoolValue(value); value = makePoolValue(value);
// assert !(value instanceof Type.TypeVar); Assert.check(!(value instanceof Type.TypeVar));
Assert.check(!(value instanceof Types.UniqueType &&
((UniqueType) value).type instanceof Type.TypeVar));
Integer index = indices.get(value); Integer index = indices.get(value);
if (index == null) { if (index == null) {
// System.err.println("put " + value + " " + value.getClass());//DEBUG
index = pp; index = pp;
indices.put(value, index); indices.put(value, index);
pool = ArrayUtils.ensureCapacity(pool, pp); pool = ArrayUtils.ensureCapacity(pool, pp);

View file

@ -26,6 +26,7 @@
package com.sun.tools.javac.jvm; package com.sun.tools.javac.jvm;
import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.*;
import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_OBJECT; import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_OBJECT;
import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS; import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS;
@ -41,19 +42,27 @@ import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS;
class UninitializedType extends Type.DelegatedType { class UninitializedType extends Type.DelegatedType {
public static UninitializedType uninitializedThis(Type qtype) { public static UninitializedType uninitializedThis(Type qtype) {
return new UninitializedType(UNINITIALIZED_THIS, qtype, -1); return new UninitializedType(UNINITIALIZED_THIS, qtype, -1,
qtype.getAnnotationMirrors());
} }
public static UninitializedType uninitializedObject(Type qtype, int offset) { public static UninitializedType uninitializedObject(Type qtype, int offset) {
return new UninitializedType(UNINITIALIZED_OBJECT, qtype, offset); return new UninitializedType(UNINITIALIZED_OBJECT, qtype, offset,
qtype.getAnnotationMirrors());
} }
public final int offset; // PC where allocation took place public final int offset; // PC where allocation took place
private UninitializedType(TypeTag tag, Type qtype, int offset) { private UninitializedType(TypeTag tag, Type qtype, int offset,
super(tag, qtype); List<Attribute.TypeCompound> typeAnnotations) {
super(tag, qtype, typeAnnotations);
this.offset = offset; this.offset = offset;
} }
@Override
public UninitializedType annotatedType(List<Attribute.TypeCompound> typeAnnotations) {
return new UninitializedType(tag, qtype, offset, typeAnnotations);
}
Type initializedType() { Type initializedType() {
return qtype; return qtype;
} }

View file

@ -35,9 +35,6 @@ import java.util.MissingResourceException;
import java.util.Queue; import java.util.Queue;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.processing.Processor; import javax.annotation.processing.Processor;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
@ -1292,11 +1289,16 @@ public class JavaCompiler {
* Perform dataflow checks on an attributed parse tree. * Perform dataflow checks on an attributed parse tree.
*/ */
protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) { protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
if (compileStates.isDone(env, CompileState.FLOW)) {
results.add(env);
return;
}
try { try {
if (shouldStop(CompileState.FLOW)) if (shouldStop(CompileState.FLOW))
return; return;
if (relax || compileStates.isDone(env, CompileState.FLOW)) { if (relax) {
results.add(env); results.add(env);
return; return;
} }

View file

@ -168,7 +168,8 @@ public class JavacTypes implements javax.lang.model.util.Types {
case PACKAGE: case PACKAGE:
throw new IllegalArgumentException(componentType.toString()); throw new IllegalArgumentException(componentType.toString());
} }
return new Type.ArrayType((Type) componentType, syms.arrayClass); return new Type.ArrayType((Type) componentType, syms.arrayClass,
Type.noAnnotations);
} }
public WildcardType getWildcardType(TypeMirror extendsBound, public WildcardType getWildcardType(TypeMirror extendsBound,
@ -193,7 +194,8 @@ public class JavacTypes implements javax.lang.model.util.Types {
case DECLARED: case DECLARED:
case ERROR: case ERROR:
case TYPEVAR: case TYPEVAR:
return new Type.WildcardType(bound, bkind, syms.boundClass); return new Type.WildcardType(bound, bkind, syms.boundClass,
Type.noAnnotations);
default: default:
throw new IllegalArgumentException(bound.toString()); throw new IllegalArgumentException(bound.toString());
} }
@ -243,7 +245,8 @@ public class JavacTypes implements javax.lang.model.util.Types {
} }
// TODO: Would like a way to check that type args match formals. // TODO: Would like a way to check that type args match formals.
return (DeclaredType) new Type.ClassType(outer, targs.toList(), sym); return (DeclaredType) new Type.ClassType(outer, targs.toList(), sym,
Type.noAnnotations);
} }
/** /**

View file

@ -1089,7 +1089,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
for (ClassSymbol cs : symtab.classes.values()) { for (ClassSymbol cs : symtab.classes.values()) {
if (cs.classfile != null || cs.kind == Kinds.ERR) { if (cs.classfile != null || cs.kind == Kinds.ERR) {
cs.reset(); cs.reset();
cs.type = new ClassType(cs.type.getEnclosingType(), null, cs); cs.type = new ClassType(cs.type.getEnclosingType(),
null, cs, Type.noAnnotations);
if (cs.completer == null) { if (cs.completer == null) {
cs.completer = initialCompleter; cs.completer = initialCompleter;
} }

View file

@ -643,6 +643,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
super.setPos(pos); super.setPos(pos);
return this; return this;
} }
public boolean isPoly() { return false; }
public boolean isStandalone() { return true; }
} }
/** /**
@ -663,6 +666,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
/** is this poly expression a 'true' poly expression? */ /** is this poly expression a 'true' poly expression? */
public PolyKind polyKind; public PolyKind polyKind;
@Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
@Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
} }
/** /**

View file

@ -65,7 +65,7 @@ public class AnnotatedTypeImpl
@Override @Override
public com.sun.javadoc.Type underlyingType() { public com.sun.javadoc.Type underlyingType() {
return TypeMaker.getType(env, type.unannotatedType(), true, false); return TypeMaker.getType(env, type, true, false);
} }
@Override @Override

View file

@ -140,9 +140,6 @@ public class TypeMaker {
*/ */
static String getTypeString(DocEnv env, Type t, boolean full) { static String getTypeString(DocEnv env, Type t, boolean full) {
// TODO: should annotations be included here? // TODO: should annotations be included here?
if (t.isAnnotated()) {
t = t.unannotatedType();
}
switch (t.getTag()) { switch (t.getTag()) {
case ARRAY: case ARRAY:
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();

View file

@ -186,6 +186,12 @@ ifdef JTREG_TIMEOUT_FACTOR
JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR)
endif endif
# Default verbosity setting for jtreg
JTREG_VERBOSE = fail,error,nopass
# Default verbosity setting for jck
JCK_VERBOSE = non-pass
# Assertions: some tests show failures when assertions are enabled. # Assertions: some tests show failures when assertions are enabled.
# Since javac is typically loaded via the bootclassloader (either via TESTJAVA # Since javac is typically loaded via the bootclassloader (either via TESTJAVA
# or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac. # or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac.
@ -256,6 +262,8 @@ jdeps: JTREG_TESTDIRS = tools/jdeps
# Version of java used to run jtreg. Should normally be the same as TESTJAVA # Version of java used to run jtreg. Should normally be the same as TESTJAVA
# TESTJAVA # TESTJAVA
# Version of java to be tested. # Version of java to be tested.
# JTREG_VERBOSE
# Verbosity setting for jtreg
# JTREG_OPTIONS # JTREG_OPTIONS
# Additional options for jtreg # Additional options for jtreg
# JTREG_TESTDIRS # JTREG_TESTDIRS
@ -273,7 +281,7 @@ jtreg-tests: check-jtreg FRC
JT_JAVA=$(JT_JAVA) $(JTREG) \ JT_JAVA=$(JT_JAVA) $(JTREG) \
-J-Xmx512m \ -J-Xmx512m \
-vmoption:-Xmx768m \ -vmoption:-Xmx768m \
-a -ignore:quiet -v:fail,error,nopass \ -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \
-r:$(JTREG_OUTPUT_DIR)/JTreport \ -r:$(JTREG_OUTPUT_DIR)/JTreport \
-w:$(JTREG_OUTPUT_DIR)/JTwork \ -w:$(JTREG_OUTPUT_DIR)/JTwork \
-jdk:$(TESTJAVA) \ -jdk:$(TESTJAVA) \
@ -312,6 +320,8 @@ check-jtreg: $(PRODUCT_HOME) $(JTREG)
# Default is JDK 7 # Default is JDK 7
# TESTJAVA # TESTJAVA
# Version of java to be tested. # Version of java to be tested.
# JCK_VERBOSE
# Verbosity setting for jtjck
# JCK_COMPILER_OPTIONS # JCK_COMPILER_OPTIONS
# Additional options for JCK-compiler # Additional options for JCK-compiler
# JCK_COMPILER_TESTDIRS # JCK_COMPILER_TESTDIRS
@ -325,9 +335,9 @@ jck-compiler-tests: check-jck FRC
@rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \ @rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \
$(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt
@mkdir -p $(JCK_COMPILER_OUTPUT_DIR) @mkdir -p $(JCK_COMPILER_OUTPUT_DIR)
$(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ $(JT_JAVA)/bin/java -Xmx512m \
-jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \ -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \
-v:non-pass \ $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \
-r:$(JCK_COMPILER_OUTPUT_DIR)/report \ -r:$(JCK_COMPILER_OUTPUT_DIR)/report \
-w:$(JCK_COMPILER_OUTPUT_DIR)/work \ -w:$(JCK_COMPILER_OUTPUT_DIR)/work \
-jdk:$(TESTJAVA) \ -jdk:$(TESTJAVA) \
@ -361,6 +371,8 @@ jck-compiler-summary: FRC
# Version of java used to run JCK. Should normally be the same as TESTJAVA # Version of java used to run JCK. Should normally be the same as TESTJAVA
# TESTJAVA # TESTJAVA
# Version of java to be tested. # Version of java to be tested.
# JCK_VERBOSE
# Verbosity setting for jtjck
# JCK_RUNTIME_OPTIONS # JCK_RUNTIME_OPTIONS
# Additional options for JCK-runtime # Additional options for JCK-runtime
# JCK_RUNTIME_TESTDIRS # JCK_RUNTIME_TESTDIRS
@ -374,9 +386,9 @@ jck-runtime-tests: check-jck FRC
@rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \ @rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \
$(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt
@mkdir -p $(JCK_RUNTIME_OUTPUT_DIR) @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR)
$(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ $(JT_JAVA)/bin/java -Xmx512m \
-jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \ -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \
-v:non-pass \ $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \
-r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \
-w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \
-jdk:$(TESTJAVA) \ -jdk:$(TESTJAVA) \

View file

@ -25,23 +25,24 @@
* @test * @test
* @bug 5093723 * @bug 5093723
* @summary REGRESSION: ClassCastException in SingleIndexWriter * @summary REGRESSION: ClassCastException in SingleIndexWriter
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build T5093723
* @run main T5093723 * @run main T5093723
*/ */
public class T5093723 extends JavadocTester { public class T5093723 extends JavadocTester {
private static final String[] ARGS = new String[] { public static void main(String... args) throws Exception {
"-d", OUTPUT_DIR + ".out", "-Xdoclint:none",
SRC_DIR + "/DocumentedClass.java",
SRC_DIR + "/UndocumentedClass.java"
};
public static void main(String... args) {
T5093723 tester = new T5093723(); T5093723 tester = new T5093723();
if (tester.runJavadoc(ARGS) != 0) tester.runTests();
throw new AssertionError("non-zero return code from javadoc"); }
@Test
void test() {
javadoc("-d", "out",
"-Xdoclint:none",
testSrc("DocumentedClass.java"),
testSrc("UndocumentedClass.java"));
checkExit(Exit.OK);
} }
} }

View file

@ -26,142 +26,31 @@
* @bug 4706779 4956908 * @bug 4706779 4956908
* @summary Add text equivalent of class tree ASCII art for accessibility * @summary Add text equivalent of class tree ASCII art for accessibility
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main AccessAsciiArt * @run main AccessAsciiArt
*/ */
public class AccessAsciiArt extends JavadocTester {
import com.sun.javadoc.*; public static void main(String... args) throws Exception {
import java.util.*; AccessAsciiArt tester = new AccessAsciiArt();
import java.io.*; tester.runTests();
/**
* Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/
public class AccessAsciiArt {
private static final String BUGID = "4706779-4956908";
private static final String BUGNAME = "AccessAsciiArt";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"-sourcepath", srcdir,
"p1", "p1.subpkg"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "-sourcepath", testSrc,
} "p1", "p1.subpkg");
} checkExit(Exit.OK);
/** checkOutput("p1/subpkg/SSC.html", true,
* Assign value for [ stringToFind, filename ] // Test the top line of the class tree
* NOTE: The standard doclet uses the same separator "\n" for all OS's "<li><a href=\"../../p1/C.html\" title=\"class in p1\">p1.C</a></li>",
*/ // Test the second line of the class tree
private static final String[][] testArray = { "<li><a href=\"../../p1/SC.html\" title=\"class in p1\">p1.SC</a></li>",
// Test the third line of the class tree
// Test the top line of the class tree "<li>p1.subpkg.SSC</li>");
{
"<li><a href=\"../../p1/C.html\" title=\"class in p1\">p1.C</a></li>",
TMPDEST_DIR1 + "p1/subpkg/SSC.html" },
// Test the second line of the class tree
{
"<li><a href=\"../../p1/SC.html\" title=\"class in p1\">p1.SC</a></li>",
TMPDEST_DIR1 + "p1/subpkg/SSC.html" },
// Test the third line of the class tree
{
"<li>p1.subpkg.SSC</li>",
TMPDEST_DIR1 + "p1/subpkg/SSC.html" },
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.indexOf(stringToFind);
} }
} }

View file

@ -26,141 +26,32 @@
* @bug 4636655 * @bug 4636655
* @summary Add title attribute to <FRAME> tags for accessibility * @summary Add title attribute to <FRAME> tags for accessibility
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main AccessFrameTitle * @run main AccessFrameTitle
*/ */
public class AccessFrameTitle extends JavadocTester {
import com.sun.javadoc.*; public static void main(String... args) throws Exception {
import java.util.*; AccessFrameTitle tester = new AccessFrameTitle();
import java.io.*; tester.runTests();
/**
* Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/
public class AccessFrameTitle {
private static final String BUGID = "4636655";
private static final String BUGNAME = "AccessFrameTitle";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"-sourcepath", srcdir,
"p1", "p2"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "-sourcepath", testSrc,
} "p1", "p2");
} checkExit(Exit.OK);
/** // Testing only for the presence of the title attributes.
* Assign value for [ stringToFind, filename ] // To make this test more robust, only
* NOTE: The standard doclet uses the same separator "\n" for all OS's // the initial part of each title string is tested for,
*/ // in case the ending part of the string later changes
private static final String[][] testArray = { checkOutput("index.html", true,
"title=\"All classes and interfaces (except non-static nested types)\"",
// Testing only for the presence of the title attributes. "title=\"All Packages\"",
// To make this test more robust, only "title=\"Package, class and interface descriptions\"");
// the initial part of each title string is tested for,
// in case the ending part of the string later changes
{ "title=\"All classes and interfaces (except non-static nested types)\"",
TMPDEST_DIR1 + "index.html" },
{ "title=\"All Packages\"",
TMPDEST_DIR1 + "index.html" },
{ "title=\"Package, class and interface descriptions\"",
TMPDEST_DIR1 + "index.html" },
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.indexOf(stringToFind);
} }
} }

View file

@ -26,141 +26,35 @@
* @bug 4636667 7052425 8016549 * @bug 4636667 7052425 8016549
* @summary Use <H1, <H2>, and <H3> in proper sequence for accessibility * @summary Use <H1, <H2>, and <H3> in proper sequence for accessibility
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main AccessH1 * @run main AccessH1
*/ */
import com.sun.javadoc.*; public class AccessH1 extends JavadocTester {
import java.util.*;
import java.io.*;
public static void main(String... args) throws Exception {
/** AccessH1 tester = new AccessH1();
* Runs javadoc and runs regression tests on the resulting HTML. tester.runTests();
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/
public class AccessH1 {
protected static final String NL = System.getProperty("line.separator");
private static final String BUGID = "4636667-7052425";
private static final String BUGNAME = "AccessH1";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"-doctitle", "Document Title",
"-sourcepath", srcdir,
"p1", "p2"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "-doctitle", "Document Title",
} "-sourcepath", testSrc,
} "p1", "p2");
checkExit(Exit.OK);
/**
* Assign value for [ stringToFind, filename ]
* NOTE: The standard doclet uses the same separator "\n" for all OS's
*/
private static final String[][] testArray = {
// Test the style sheet // Test the style sheet
{ checkOutput("stylesheet.css", true,
"h1 {\n" + "h1 {\n"
" font-size:20px;\n" + + " font-size:20px;\n"
"}", + "}");
TMPDEST_DIR1 + "stylesheet.css"
},
// Test the doc title in the overview page // Test the doc title in the overview page
{ checkOutput("overview-summary.html", true,
"<h1 class=\"title\">Document Title</h1>", "<h1 class=\"title\">Document Title</h1>");
TMPDEST_DIR1 + "overview-summary.html"
}
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.replace(NL, "\n").indexOf(stringToFind);
} }
} }

View file

@ -26,150 +26,40 @@
* @bug 4638136 7198273 8025633 * @bug 4638136 7198273 8025633
* @summary Add ability to skip over nav bar for accessibility * @summary Add ability to skip over nav bar for accessibility
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main AccessSkipNav * @run main AccessSkipNav
*/ */
public class AccessSkipNav extends JavadocTester {
import com.sun.javadoc.*; public static void main(String... args) throws Exception {
import java.util.*; AccessSkipNav tester = new AccessSkipNav();
import java.io.*; tester.runTests();
/**
* Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/
public class AccessSkipNav {
protected static final String NL = System.getProperty("line.separator");
private static final String BUGID = "4638136 - 7198273";
private static final String BUGNAME = "AccessSkipNav";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"-sourcepath", srcdir,
"p1", "p2"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "-sourcepath", testSrc,
} "p1", "p2");
} checkExit(Exit.OK);
/** // Testing only for the presence of the <a href> and <a name>
* Assign value for [ stringToFind, filename ] checkOutput("p1/C1.html", true,
* NOTE: The standard doclet uses the same separator "\n" for all OS's // Top navbar <a href>
*/ "<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">Skip navigation links</a>",
private static final String[][] testArray = { // Top navbar <a name>
"<a name=\"skip.navbar.top\">\n"
+ "<!-- -->\n"
+ "</a>",
// Bottom navbar <a href>
"<a href=\"#skip.navbar.bottom\" title=\"Skip navigation links\">Skip navigation links</a>",
// Bottom navbar <a name>
"<a name=\"skip.navbar.bottom\">\n"
+ "<!-- -->\n"
+ "</a>");
// Testing only for the presence of the <a href> and <a name>
// Top navbar <a href>
{ "<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">Skip navigation links</a>",
TMPDEST_DIR1 + "p1/C1.html" },
// Top navbar <a name>
{ "<a name=\"skip.navbar.top\">\n" +
"<!-- -->\n" +
"</a>",
TMPDEST_DIR1 + "p1/C1.html" },
// Bottom navbar <a href>
{ "<a href=\"#skip.navbar.bottom\" title=\"Skip navigation links\">Skip navigation links</a>",
TMPDEST_DIR1 + "p1/C1.html" },
// Bottom navbar <a name>
{ "<a name=\"skip.navbar.bottom\">\n" +
"<!-- -->\n" +
"</a>",
TMPDEST_DIR1 + "p1/C1.html" }
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.replace(NL, "\n").indexOf(stringToFind);
} }
} }

View file

@ -26,45 +26,35 @@
* @bug 4637604 4775148 * @bug 4637604 4775148
* @summary Test the tables for summary attribute * @summary Test the tables for summary attribute
* @author dkramer * @author dkramer
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build AccessSummary
* @run main AccessSummary * @run main AccessSummary
*/ */
public class AccessSummary extends JavadocTester { public class AccessSummary extends JavadocTester {
/**
* Assign value for [ fileToSearch, stringToFind ]
*/
private static final String[][] TESTARRAY1 = {
// Test that the summary attribute appears
{ "overview-summary.html",
"summary=\"Packages table, listing packages, and an explanation\"" },
// Test that the summary attribute appears
{ "p1/C1.html",
"summary=\"Constructor Summary table, listing constructors, and an explanation\"" },
// Test that the summary attribute appears
{ "constant-values.html",
"summary=\"Constant Field Values table, listing constant fields, and values\"" }
};
// First test with -header only
private static final String[] JAVADOC_ARGS = new String[] {
"-d", OUTPUT_DIR,
"-sourcepath", SRC_DIR,
"p1", "p2"};
/** /**
* The entry point of the test. * The entry point of the test.
* @param args the array of command line arguments. * @param args the array of command line arguments.
* @throws Exception if the test fails
*/ */
public static void main(String[] args) { public static void main(String... args) throws Exception {
JavadocTester tester = new AccessSummary(); AccessSummary tester = new AccessSummary();
tester.run(JAVADOC_ARGS, TESTARRAY1, new String[][] {}); tester.runTests();
tester.printSummary(); // Necessary for string search }
@Test
void testAccessSummary() {
javadoc("-d", "out", "-sourcepath", testSrc, "p1", "p2");
checkExit(Exit.OK);
checkOutput("overview-summary.html", true,
"summary=\"Packages table, listing packages, and an explanation\"");
// Test that the summary attribute appears
checkOutput("p1/C1.html", true,
"summary=\"Constructor Summary table, listing constructors, and an explanation\"");
// Test that the summary attribute appears
checkOutput("constant-values.html", true,
"summary=\"Constant Field Values table, listing constant fields, and values\"");
} }
} }

View file

@ -26,143 +26,37 @@
* @bug 4651598 8026567 * @bug 4651598 8026567
* @summary Javadoc wrongly inserts </DD> tags when using multiple @author tags * @summary Javadoc wrongly inserts </DD> tags when using multiple @author tags
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main AuthorDD * @run main AuthorDD
*/ */
import com.sun.javadoc.*;
import java.util.*;
import java.io.*;
/** /**
* Runs javadoc and runs regression tests on the resulting HTML. * Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/ */
public class AuthorDD public class AuthorDD extends JavadocTester {
{
protected static final String NL = System.getProperty("line.separator"); public static void main(String... args) throws Exception {
AuthorDD tester = new AuthorDD();
private static final String BUGID = "4651598"; tester.runTests();
private static final String BUGNAME = "AuthorDD"; }
// Subtest number. Needed because runResultsOnHTML is run twice, and subtestNum
// should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
@Test
void test() {
// Test for all cases except the split index page // Test for all cases except the split index page
runJavadoc(new String[] {"-d", BUGID, javadoc("-d", "out",
"-author", "-author",
"-version", "-version",
"-sourcepath", srcdir, "-sourcepath", testSrc,
"p1"}); "p1");
runTestsOnHTML(testArray); checkExit(Exit.OK);
printSummary(); checkOutput("p1/C1.html", true,
} // Test single @since tag:
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
/** Run javadoc */ + "<dd>JDK 1.0</dd>",
public static void runJavadoc(String[] javadocArgs) { // Test multiple @author tags:
if (com.sun.tools.javadoc.Main.execute(AuthorDD.class.getClassLoader(), "<dt><span class=\"simpleTagLabel\">Author:</span></dt>\n"
javadocArgs) != 0) { + "<dd>Doug Kramer, Jamie, Neal</dd>");
throw new Error("Javadoc failed to execute");
}
}
/**
* Assign value for [ stringToFind, filename ]
* NOTE: The standard doclet uses the same separator "\n" for all OS's
*/
private static final String[][] testArray = {
// Test single @since tag:
{ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>JDK 1.0</dd>",
BUGID + "/p1/C1.html" },
// Test multiple @author tags:
{ "<dt><span class=\"simpleTagLabel\">Author:</span></dt>\n" +
"<dd>Doug Kramer, Jamie, Neal</dd>",
BUGID + "/p1/C1.html" },
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.replace(NL, "\n").indexOf(stringToFind);
} }
} }

View file

@ -26,13 +26,11 @@
* @bug 4524350 4662945 4633447 * @bug 4524350 4662945 4633447
* @summary stddoclet: {@docRoot} inserts an extra trailing "/" * @summary stddoclet: {@docRoot} inserts an extra trailing "/"
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main DocRootSlash * @run main DocRootSlash
*/ */
import com.sun.javadoc.*;
import java.util.*;
import java.io.*;
import java.nio.*;
import java.util.regex.*; import java.util.regex.*;
/** /**
@ -40,149 +38,55 @@ import java.util.regex.*;
* It reads each file, complete with newlines, into a string to easily * It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines. * find strings that contain newlines.
*/ */
public class DocRootSlash public class DocRootSlash extends JavadocTester {
{
private static final String BUGID = "4524350, 4662945, or 4633447";
private static final String BUGNAME = "DocRootSlash";
private static final String TMPDIR_STRING1 = "./docs1/";
// Test number. Needed because runResultsOnHTMLFile is run twice, and subtestNum public static void main(String... args) throws Exception {
// should increment across test runs. DocRootSlash tester = new DocRootSlash();
public static int subtestNum = 0; tester.runTests();
public static int numOfSubtestsPassed = 0; }
// Entry point
public static void main(String[] args) {
@Test
void test() {
// Directory that contains source files that javadoc runs on // Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", "."); String srcdir = System.getProperty("test.src", ".");
runJavadoc(new String[] {"-d", TMPDIR_STRING1, javadoc("-d", "out",
"-Xdoclint:none", "-Xdoclint:none",
"-overview", (srcdir + "/overview.html"), "-overview", (srcdir + "/overview.html"),
"-header", "<A HREF=\"{@docroot}/package-list\">{&#064;docroot}</A> <A HREF=\"{@docRoot}/help-doc\">{&#064;docRoot}</A>", "-header", "<A HREF=\"{@docroot}/package-list\">{&#064;docroot}</A> <A HREF=\"{@docRoot}/help-doc\">{&#064;docRoot}</A>",
"-sourcepath", srcdir, "-sourcepath", srcdir,
"p1", "p2"}); "p1", "p2");
runTestsOnHTMLFiles(filenameArray);
printSummary(); checkFiles(
} "p1/C1.html" ,
"p1/package-summary.html",
/** Run javadoc */ "overview-summary.html");
public static void runJavadoc(String[] javadocArgs) {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
throw new Error("Javadoc failed to execute");
}
}
/** The array of filenames to test */
private static final String[] filenameArray = {
TMPDIR_STRING1 + "p1/C1.html" ,
TMPDIR_STRING1 + "p1/package-summary.html",
TMPDIR_STRING1 + "overview-summary.html"
};
public static void runTestsOnHTMLFiles(String[] filenameArray) {
String fileString;
// Bugs 4524350 4662945
for (int i = 0; i < filenameArray.length; i++ ) {
// Read contents of file (whose filename is in filenames) into a string
fileString = readFileToString(filenameArray[i]);
System.out.println("\nSub-tests for file: " + filenameArray[i]
+ " --------------");
// Loop over all tests in a single file
for ( int j = 0; j < 11; j++ ) {
subtestNum += 1;
// Compare actual to expected string for a single subtest
compareActualToExpected(fileString);
}
}
// Bug 4633447: Special test for overview-frame.html // Bug 4633447: Special test for overview-frame.html
// Find two strings in file "overview-frame.html" // Find two strings in file "overview-frame.html"
String filename = TMPDIR_STRING1 + "overview-frame.html"; checkOutput("overview-frame.html", true,
fileString = readFileToString(filename); "<A HREF=\"./package-list\">",
"<A HREF=\"./help-doc\">");
// Find first string <A HREF="./package-list"> in overview-frame.html
subtestNum += 1;
String stringToFind = "<A HREF=\"./package-list\">";
String result;
if ( fileString.indexOf(stringToFind) == -1 ) {
result = "FAILED";
} else {
result = "succeeded";
numOfSubtestsPassed += 1;
}
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
+ "when searching for:\n"
+ stringToFind + "\n"
+ "in file " + filename);
// Find second string <A HREF="./help-doc"> in overview-frame.html
subtestNum += 1;
stringToFind = "<A HREF=\"./help-doc\">";
if ( fileString.indexOf(stringToFind) == -1 ) {
result = "FAILED";
} else {
result = "succeeded";
numOfSubtestsPassed += 1;
}
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
+ "when searching for:\n"
+ stringToFind + "\n"
+ "in file " + filename);
} }
public static void printSummary() { void checkFiles(String... filenameArray) {
System.out.println(""); int count = 0;
if ( numOfSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numOfSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numOfSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the contents of the file into a String for (String f : filenameArray) {
public static String readFileToString(String filename) { // Read contents of file into a string
try { String fileString = readFile(f);
File file = new File(filename); System.out.println("\nSub-tests for file: " + f + " --------------");
if ( !file.exists() ) { // Loop over all tests in a single file
System.out.println("\nFILE DOES NOT EXIST: " + filename); for ( int j = 0; j < 11; j++ ) {
// Compare actual to expected string for a single subtest
compareActualToExpected(++count, fileString);
} }
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
} }
} }
/** /**
* Regular expression pattern matching code adapted from Eric's * Regular expression pattern matching code
* /java/pubs/dev/linkfix/src/LinkFix.java
* *
* Prefix Pattern: * Prefix Pattern:
* flag (?i) (case insensitive, so "a href" == "A HREF" and all combinations) * flag (?i) (case insensitive, so "a href" == "A HREF" and all combinations)
@ -197,34 +101,33 @@ public class DocRootSlash
* group4 (.*?) (label - zero or more characters) * group4 (.*?) (label - zero or more characters)
* group5 (</a>) (end tag) * group5 (</a>) (end tag)
*/ */
static String prefix = "(?i)(<a\\s+href="; // <a href= (start group1) private static final String prefix = "(?i)(<a\\s+href="; // <a href= (start group1)
static String ref1 = "\")([^\"]*)(\".*?>)"; // doublequotes (end group1, group2, group3) private static final String ref1 = "\")([^\"]*)(\".*?>)"; // doublequotes (end group1, group2, group3)
static String ref2 = ")(\\S+?)([^<>]*>)"; // no quotes (end group1, group2, group3) private static final String ref2 = ")(\\S+?)([^<>]*>)"; // no quotes (end group1, group2, group3)
static String label = "(.*?)"; // text label (group4) private static final String label = "(.*?)"; // text label (group4)
static String end = "(</a>)"; // </a> (group5) private static final String end = "(</a>)"; // </a> (group5)
/** /**
* Compares the actual string to the expected string in the specified string * Compares the actual string to the expected string in the specified string
* str String to search through * @param str String to search through
*/ */
static void compareActualToExpected(String str) { void compareActualToExpected(int count, String str) {
// Pattern must be compiled each run because subtestNum is incremented checking("comparison for " + str);
// Pattern must be compiled each run because numTestsRun is incremented
Pattern actualLinkPattern1 = Pattern actualLinkPattern1 =
Pattern.compile("Sub-test " + subtestNum + " Actual: " + prefix + ref1, Pattern.DOTALL); Pattern.compile("Sub-test " + count + " Actual: " + prefix + ref1, Pattern.DOTALL);
Pattern expectLinkPattern1 = Pattern expectLinkPattern1 =
Pattern.compile("Sub-test " + subtestNum + " Expect: " + prefix + ref1, Pattern.DOTALL); Pattern.compile("Sub-test " + count + " Expect: " + prefix + ref1, Pattern.DOTALL);
// Pattern linkPattern2 = Pattern.compile(prefix + ref2 + label + end, Pattern.DOTALL); // Pattern linkPattern2 = Pattern.compile(prefix + ref2 + label + end, Pattern.DOTALL);
CharBuffer charBuffer = CharBuffer.wrap(str); Matcher actualLinkMatcher1 = actualLinkPattern1.matcher(str);
Matcher actualLinkMatcher1 = actualLinkPattern1.matcher(charBuffer); Matcher expectLinkMatcher1 = expectLinkPattern1.matcher(str);
Matcher expectLinkMatcher1 = expectLinkPattern1.matcher(charBuffer); if (expectLinkMatcher1.find() && actualLinkMatcher1.find()) {
String result;
if ( expectLinkMatcher1.find() && actualLinkMatcher1.find() ) {
String expectRef = expectLinkMatcher1.group(2); String expectRef = expectLinkMatcher1.group(2);
String actualRef = actualLinkMatcher1.group(2); String actualRef = actualLinkMatcher1.group(2);
if ( actualRef.equals(expectRef) ) { if (actualRef.equals(expectRef)) {
result = "succeeded"; passed(expectRef);
numOfSubtestsPassed += 1;
// System.out.println("pattern: " + actualLinkPattern1.pattern()); // System.out.println("pattern: " + actualLinkPattern1.pattern());
// System.out.println("actualRef: " + actualRef); // System.out.println("actualRef: " + actualRef);
// System.out.println("group0: " + actualLinkMatcher1.group()); // System.out.println("group0: " + actualLinkMatcher1.group());
@ -233,15 +136,13 @@ public class DocRootSlash
// System.out.println("group3: " + actualLinkMatcher1.group(3)); // System.out.println("group3: " + actualLinkMatcher1.group(3));
// System.exit(0); // System.exit(0);
} else { } else {
result = "FAILED"; failed("\n"
+ "Actual: \"" + actualRef + "\"\n"
+ "Expect: \"" + expectRef + "\"");
} }
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
+ "Actual: \"" + actualRef + "\"" + "\n"
+ "Expect: \"" + expectRef + "\"");
} else { } else {
System.out.println("Didn't find <A HREF> that fits the pattern: " failed("Didn't find <A HREF> that fits the pattern: "
+ expectLinkPattern1.pattern() ); + expectLinkPattern1.pattern());
} }
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,11 +26,11 @@
* @bug 8008768 * @bug 8008768
* @summary Using {@inheritDoc} in simple tag defined via -tag fails * @summary Using {@inheritDoc} in simple tag defined via -tag fails
* @author Mike Duigou * @author Mike Duigou
* @library ../lib
* @build JavadocTester
* @run main DocTest * @run main DocTest
*/ */
import java.io.*;
/** /**
* DocTest documentation. * DocTest documentation.
* *
@ -38,41 +38,27 @@ import java.io.*;
* @implSpec DocTest implementation spec. * @implSpec DocTest implementation spec.
* @implNote DocTest implementation note. * @implNote DocTest implementation note.
*/ */
public class DocTest { public class DocTest extends JavadocTester {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
String[] javadoc_args = { DocTest tester = new DocTest();
"-verbose", tester.runTests();
"-d", "DocTest", }
"-tag", "apiNote:optcm:<em>API Note</em>",
"-tag", "implSpec:optcm:<em>Implementation Requirements</em>:", @Test
"-tag", "implNote:optcm:<em>Implementation Note</em>:", void test() {
"-package", javadoc("-verbose",
new File(System.getProperty("test.src"), "DocTest.java").getPath() "-d", "DocTest",
}; "-tag", "apiNote:optcm:<em>API Note</em>",
"-tag", "implSpec:optcm:<em>Implementation Requirements</em>:",
"-tag", "implNote:optcm:<em>Implementation Note</em>:",
"-package",
testSrc("DocTest.java")
);
checkExit(Exit.OK);
// javadoc does not report an exit code for an internal exception (!) // javadoc does not report an exit code for an internal exception (!)
// so monitor stderr for stack dumps. // so monitor stderr for stack dumps.
PrintStream prevErr = System.err; checkOutput(Output.STDERR, false, "at com.sun");
ByteArrayOutputStream err_baos = new ByteArrayOutputStream();
PrintStream err_ps = new PrintStream(err_baos);
System.setErr(err_ps);
int rc;
try {
rc = com.sun.tools.javadoc.Main.execute(javadoc_args);
} finally {
err_ps.close();
System.setErr(prevErr);
}
String err = err_baos.toString();
System.err.println(err);
if (rc != 0)
throw new Exception("javadoc exited with rc=" + rc);
if (err.contains("at com.sun."))
throw new Exception("javadoc output contains stack trace");
} }
/** /**

View file

@ -27,172 +27,49 @@
* @summary Javascript IE load error when linked by -linkoffline * @summary Javascript IE load error when linked by -linkoffline
* Window title shouldn't change when loading left frames (javascript) * Window title shouldn't change when loading left frames (javascript)
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main JavascriptWinTitle * @run main JavascriptWinTitle
*/ */
public class JavascriptWinTitle extends JavadocTester {
import com.sun.javadoc.*; public static void main(String... args) throws Exception {
import java.util.*; JavascriptWinTitle tester = new JavascriptWinTitle();
import java.io.*; tester.runTests();
/**
* Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/
public class JavascriptWinTitle {
protected static final String NL = System.getProperty("line.separator");
private static final String BUGID = "4645058";
private static final String BUGNAME = "JavascriptWinTitle";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"-doctitle", "Document Title",
"-windowtitle", "Window Title",
"-overview", (srcdir + "/overview.html"),
"-linkoffline",
"http://java.sun.com/j2se/1.4/docs/api", srcdir,
"-sourcepath", srcdir,
"p1", "p2"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "-doctitle", "Document Title",
} "-windowtitle", "Window Title",
} "-overview", testSrc("overview.html"),
"-linkoffline", "http://java.sun.com/j2se/1.4/docs/api", testSrc,
"-sourcepath", testSrc,
"p1", "p2");
checkExit(Exit.OK);
checkOutput("overview-summary.html", true,
"<script type=\"text/javascript\">",
"<body>");
/** // Test that "onload" is not present in BODY tag:
* Assign value for [ stringToFind, filename ] checkOutput("p1/package-summary.html", true, "<body>");
* NOTE: The standard doclet uses the same separator "\n" for all OS's checkOutput("overview-frame.html", true, "<body>");
*/ checkOutput("allclasses-frame.html", true, "<body>");
private static final String[][] testArray = { checkOutput("p1/package-frame.html", true, "<body>");
// Test the javascript "type" attribute is present: // Test that win title javascript is followed by NOSCRIPT code.
{ "<script type=\"text/javascript\">", checkOutput("p1/C.html", true,
TMPDEST_DIR1 + "overview-summary.html" }, "<script type=\"text/javascript\"><!--\n"
+ " try {\n"
// Test onload is absent: + " if (location.href.indexOf('is-external=true') == -1) {\n"
{ "<body>", + " parent.document.title=\"C (Window Title)\";\n"
TMPDEST_DIR1 + "overview-summary.html" }, + " }\n"
+ " }\n"
// Test onload is present: + " catch(err) {\n"
{ "<body>", + " }\n"
TMPDEST_DIR1 + "/p1/package-summary.html" }, + "//-->\n"
+ "</script>");
// Test that "onload" is not present in BODY tag:
{ "<body>",
TMPDEST_DIR1 + "overview-frame.html" },
// Test that "onload" is not present in BODY tag:
{ "<body>",
TMPDEST_DIR1 + "allclasses-frame.html" },
// Test that "onload" is not present in BODY tag:
{ "<body>",
TMPDEST_DIR1 + "/p1/package-frame.html" },
// Test that win title javascript is followed by NOSCRIPT code.
{"<script type=\"text/javascript\"><!--\n" +
" try {\n" +
" if (location.href.indexOf('is-external=true') == -1) {\n" +
" parent.document.title=\"C (Window Title)\";\n" +
" }\n" +
" }\n" +
" catch(err) {\n" +
" }\n" +
"//-->\n" +
"</script>",
TMPDEST_DIR1 + "/p1/C.html"
}
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.replace(NL, "\n").indexOf(stringToFind);
} }
} }

View file

@ -21,114 +21,94 @@
* questions. * questions.
*/ */
import java.text.SimpleDateFormat;
import java.util.Date;
/* /*
* @test * @test
* @bug 4034096 4764726 6235799 * @bug 4034096 4764726 6235799
* @summary Add support for HTML keywords via META tag for * @summary Add support for HTML keywords via META tag for
* class and member names to improve API search * class and member names to improve API search
* @author dkramer * @author dkramer
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build MetaTag
* @run main MetaTag * @run main MetaTag
*/ */
import java.text.SimpleDateFormat;
import java.util.Date;
public class MetaTag extends JavadocTester { public class MetaTag extends JavadocTester {
//Test information.
private static final SimpleDateFormat m_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR,
"-sourcepath", SRC_DIR,
"-keywords",
"-doctitle", "Sample Packages",
"p1", "p2"
};
private static final String[] ARGS_NO_TIMESTAMP_NO_KEYWORDS = new String[] {
"-d", OUTPUT_DIR + "-2",
"-sourcepath", SRC_DIR,
"-notimestamp",
"-doctitle", "Sample Packages",
"p1", "p2"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "p1/C1.html",
"<meta name=\"keywords\" content=\"p1.C1 class\">" },
{ "p1/C1.html",
"<meta name=\"keywords\" content=\"field1\">" },
{ "p1/C1.html",
"<meta name=\"keywords\" content=\"field2\">" },
{ "p1/C1.html",
"<meta name=\"keywords\" content=\"method1()\">" },
{ "p1/C1.html",
"<meta name=\"keywords\" content=\"method2()\">" },
{ "p1/package-summary.html",
"<meta name=\"keywords\" content=\"p1 package\">" },
{ "overview-summary.html",
"<meta name=\"keywords\" content=\"Overview, Sample Packages\">" },
//NOTE: Hopefully, this regression test is not run at midnight. If the output
//was generated yesterday and this test is run today, the test will fail.
{ "overview-summary.html",
"<meta name=\"date\" "
+ "content=\"" + m_dateFormat.format(new Date()) + "\">"},
};
private static final String[][] NEGATED_TEST2 = {
//No keywords when -keywords is not used.
{ "p1/C1.html",
"<META NAME=\"keywords\" CONTENT=\"p1.C1 class\">" },
{ "p1/C1.html",
"<META NAME=\"keywords\" CONTENT=\"field1\">" },
{ "p1/C1.html",
"<META NAME=\"keywords\" CONTENT=\"field2\">" },
{ "p1/C1.html",
"<META NAME=\"keywords\" CONTENT=\"method1()\">" },
{ "p1/C1.html",
"<META NAME=\"keywords\" CONTENT=\"method2()\">" },
{ "p1/package-summary.html",
"<META NAME=\"keywords\" CONTENT=\"p1 package\">" },
{ "overview-summary.html",
"<META NAME=\"keywords\" CONTENT=\"Overview Summary, Sample Packages\">" },
//The date metatag should not show up when -notimestamp is used.
//NOTE: Hopefully, this regression test is not run at midnight. If the output
//was generated yesterday and this test is run today, the test will fail.
{ "overview-summary.html",
"<META NAME=\"date\" "
+ "CONTENT=\"" + m_dateFormat.format(new Date()) + "\">"},
};
/** /**
* The entry point of the test. * The entry point of the test.
* @param args the array of command line arguments. * @param args the array of command line arguments
* @throws Exception if the test fails
*/ */
public static void main(String[] args) { public static void main(String... args) throws Exception {
MetaTag tester = new MetaTag(); MetaTag tester = new MetaTag();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.run(ARGS_NO_TIMESTAMP_NO_KEYWORDS, NO_TEST, NEGATED_TEST2); }
tester.printSummary();
@Test
void testStandard() {
javadoc("-d", "out-1",
"-sourcepath", testSrc,
"-keywords",
"-doctitle", "Sample Packages",
"p1", "p2");
checkExit(Exit.OK);
checkOutput("p1/C1.html", true,
"<meta name=\"keywords\" content=\"p1.C1 class\">",
"<meta name=\"keywords\" content=\"field1\">",
"<meta name=\"keywords\" content=\"field2\">",
"<meta name=\"keywords\" content=\"method1()\">",
"<meta name=\"keywords\" content=\"method2()\">");
checkOutput("p1/package-summary.html", true,
"<meta name=\"keywords\" content=\"p1 package\">");
checkOutput("overview-summary.html", true,
"<meta name=\"keywords\" content=\"Overview, Sample Packages\">");
// NOTE: Hopefully, this regression test is not run at midnight. If the output
// was generated yesterday and this test is run today, the test will fail.
checkOutput("overview-summary.html", true,
"<meta name=\"date\" content=\"" + date() + "\">");
}
@Test
void testNoTimestamp() {
javadoc("-d", "out-2",
"-sourcepath", testSrc,
"-notimestamp",
"-doctitle", "Sample Packages",
"p1", "p2");
checkExit(Exit.OK);
// No keywords when -keywords is not used.
checkOutput("p1/C1.html", false,
"<META NAME=\"keywords\" CONTENT=\"p1.C1 class\">",
"<META NAME=\"keywords\" CONTENT=\"field1\">",
"<META NAME=\"keywords\" CONTENT=\"field2\">",
"<META NAME=\"keywords\" CONTENT=\"method1()\">",
"<META NAME=\"keywords\" CONTENT=\"method2()\">");
checkOutput("p1/package-summary.html", false,
"<META NAME=\"keywords\" CONTENT=\"p1 package\">");
checkOutput("overview-summary.html", false,
"<META NAME=\"keywords\" CONTENT=\"Overview Summary, Sample Packages\">");
// The date metatag should not show up when -notimestamp is used.
// NOTE: Hopefully, this regression test is not run at midnight. If the output
// was generated yesterday and this test is run today, the test will fail.
checkOutput("overview-summary.html", false,
"<META NAME=\"date\" CONTENT=\"" + date() + "\">");
}
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String date() {
return dateFormat.format(new Date());
} }
} }

View file

@ -28,83 +28,62 @@
* is present for three sets of options: (1) -header, * is present for three sets of options: (1) -header,
* (2) -packagesheader, and (3) -header -packagesheader * (2) -packagesheader, and (3) -header -packagesheader
* @author dkramer * @author dkramer
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build PackagesHeader
* @run main PackagesHeader * @run main PackagesHeader
*/ */
public class PackagesHeader extends JavadocTester { public class PackagesHeader extends JavadocTester {
//Test information. public static void main(String... args) throws Exception {
private static final String OUTPUT_DIR1 = OUTPUT_DIR + "-1/"; JavadocTester tester = new PackagesHeader();
private static final String OUTPUT_DIR2 = OUTPUT_DIR + "-2/"; tester.runTests();
private static final String OUTPUT_DIR3 = OUTPUT_DIR + "-3/"; }
/** @Test
* Assign value for [ fileToSearch, stringToFind ] void testHeader() {
*/ // First test with -header only
private static final String[][] TESTARRAY1 = { javadoc("-d", "out-header",
"-header", "Main Frame Header",
"-sourcepath", testSrc,
"p1", "p2");
checkExit(Exit.OK);
// Test that the -header shows up in the packages frame // Test that the -header shows up in the packages frame
{ "overview-frame.html", checkOutput("overview-frame.html", true,
"Main Frame Header" } "Main Frame Header");
}; }
private static final String[][] TESTARRAY2 = { @Test
void testPackagesHeader() {
// Second test with -packagesheader only
javadoc("-d", "out-packages-header",
"-packagesheader", "Packages Frame Header",
"-sourcepath", testSrc,
"p1", "p2");
checkExit(Exit.OK);
// Test that the -packagesheader string shows // Test that the -packagesheader string shows
// up in the packages frame // up in the packages frame
checkOutput("overview-frame.html", true,
"Packages Frame Header");
}
{ "overview-frame.html", @Test
"Packages Frame Header" } void testBothHeaders() {
}; // Third test with both -packagesheader and -header
javadoc("-d", "out-both",
private static final String[][] TESTARRAY3 = { "-packagesheader", "Packages Frame Header",
"-header", "Main Frame Header",
"-sourcepath", testSrc,
"p1", "p2");
checkExit(Exit.OK);
// Test that the both headers show up and are different // Test that the both headers show up and are different
checkOutput("overview-frame.html", true,
"Packages Frame Header");
{ "overview-frame.html", checkOutput("overview-summary.html", true,
"Packages Frame Header" }, "Main Frame Header");
{ "overview-summary.html",
"Main Frame Header" }
};
// First test with -header only
private static final String[] JAVADOC_ARGS1 = new String[] {
"-d", OUTPUT_DIR1,
"-header", "Main Frame Header",
"-sourcepath", SRC_DIR,
"p1", "p2"};
// Second test with -packagesheader only
private static final String[] JAVADOC_ARGS2 = new String[] {
"-d", OUTPUT_DIR2,
"-packagesheader", "Packages Frame Header",
"-sourcepath", SRC_DIR,
"p1", "p2"};
// Third test with both -packagesheader and -header
private static final String[] JAVADOC_ARGS3 = new String[] {
"-d", OUTPUT_DIR3,
"-packagesheader", "Packages Frame Header",
"-header", "Main Frame Header",
"-sourcepath", SRC_DIR,
"p1", "p2"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
JavadocTester tester = new PackagesHeader();
tester.run(JAVADOC_ARGS1, TESTARRAY1, NO_TEST);
tester.run(JAVADOC_ARGS2, TESTARRAY2, NO_TEST);
tester.run(JAVADOC_ARGS3, TESTARRAY3, NO_TEST);
tester.printSummary();
} }
} }

View file

@ -25,24 +25,24 @@
* @test * @test
* @bug 6735320 * @bug 6735320
* @summary javadoc throws exception if serialField value is missing * @summary javadoc throws exception if serialField value is missing
* @library ../lib/ * @library ../lib
* @build JavadocTester T6735320 * @build JavadocTester
* @run main T6735320 * @run main T6735320
*/ */
public class T6735320 extends JavadocTester { public class T6735320 extends JavadocTester {
private static final String[] ARGS = new String[]{ public static void main(String... args) throws Exception {
"-d", OUTPUT_DIR + ".out",
SRC_DIR + "/SerialFieldTest.java"
};
public static void main(String... args) {
T6735320 tester = new T6735320(); T6735320 tester = new T6735320();
if (tester.runJavadoc(ARGS) == 0) { tester.runTests();
throw new AssertionError("zero return code from javadoc"); }
}
if (tester.getErrorOutput().contains("StringIndexOutOfBoundsException")) { @Test
throw new AssertionError("javadoc threw StringIndexOutOfBoundsException"); void test() {
} javadoc("-d", "out",
testSrc("SerialFieldTest.java"));
checkExit(Exit.FAILED);
checkOutput(Output.STDERR, false,
"StringIndexOutOfBoundsException");
} }
} }

View file

@ -30,174 +30,52 @@
* <NOFRAMES> not allowed outside <FRAMESET> element * <NOFRAMES> not allowed outside <FRAMESET> element
* HTML table tags inserted in wrong place in pakcage use page * HTML table tags inserted in wrong place in pakcage use page
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main ValidHtml * @run main ValidHtml
*/ */
import com.sun.javadoc.*; public class ValidHtml extends JavadocTester {
import java.util.*;
import java.io.*;
/** public static void main(String... args) throws Exception {
* Runs javadoc and runs regression tests on the resulting HTML. ValidHtml tester = new ValidHtml();
* It reads each file, complete with newlines, into a string to easily tester.runTests();
* find strings that contain newlines. }
*/
public class ValidHtml {
protected static final String NL = System.getProperty("line.separator");
private static final String BUGID = "4275630";
private static final String BUGNAME = "ValidHtml";
private static final String TMPDEST_DIR1 = "./docs1/";
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
@Test
void test() {
// Test for all cases except the split index page // Test for all cases except the split index page
runJavadoc(new String[]{"-d", TMPDEST_DIR1, javadoc("-d", "out",
"-doctitle", "Document Title", "-doctitle", "Document Title",
"-windowtitle", "Window Title", "-windowtitle", "Window Title",
"-use", "-use",
"-overview", (srcdir + "/overview.html"), "-overview", testSrc("overview.html"),
"-sourcepath", srcdir, "-sourcepath", testSrc,
"p1", "p2" "p1", "p2");
}); checkExit(Exit.OK);
runTestsOnHTML(testArray);
printSummary(); // Test the proper DOCTYPE element are present:
} checkOutput("index.html", true, FRAMESET);
checkOutput("overview-summary.html", true, LOOSE);
checkOutput("p1/package-summary.html", true, LOOSE);
checkOutput("p1/C.html", true, LOOSE);
checkOutput("overview-frame.html", true, LOOSE);
checkOutput("allclasses-frame.html", true, LOOSE);
checkOutput("p1/package-frame.html", true, LOOSE);
/** Run javadoc */
public static void runJavadoc(String[] javadocArgs) {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
throw new Error("Javadoc failed to execute");
}
}
/**
* Assign value for [ stringToFind, filename ]
* NOTE: The standard doclet uses the same separator "\n" for all OS's
*/
private static final String[][] testArray = {
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
TMPDEST_DIR1 + "index.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "overview-summary.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "p1/package-summary.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "p1/C.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "overview-frame.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "allclasses-frame.html"
},
// Test the proper DOCTYPE element is present:
{
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
TMPDEST_DIR1 + "p1/package-frame.html"
},
// Test that <NOFRAMES> is inside <FRAMESET> element: // Test that <NOFRAMES> is inside <FRAMESET> element:
{ checkOutput("index.html", true,
"</noframes>\n" + "</noframes>\n"
"</frameset>", + "</frameset>");
TMPDEST_DIR1 + "index.html"
},
// Test the table elements are in the correct order: // Test the table elements are in the correct order:
{ checkOutput("p1/package-use.html", true,
"</td>\n" + "</td>\n"
"</tr>", + "</tr>");
TMPDEST_DIR1 + "/p1/package-use.html"
}
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum) + " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n" + "when searching for:\n" + stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
} }
public static void printSummary() { private static final String FRAMESET =
if (numSubtestsPassed == subtestNum) { "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">";
System.out.println("\nAll " + numSubtestsPassed + " subtests passed"); private static final String LOOSE =
} else { "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum) + " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if (!file.exists()) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int) file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int) file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.replace(NL, "\n").indexOf(stringToFind);
}
} }

View file

@ -26,131 +26,31 @@
* @bug 4720849 * @bug 4720849
* @summary com.sun.tools.doclets.standard.Standard contains hard-coded version number * @summary com.sun.tools.doclets.standard.Standard contains hard-coded version number
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main VersionNumber * @run main VersionNumber
*/ */
import com.sun.javadoc.*;
import java.util.*;
import java.io.*;
/** /**
* Runs javadoc and runs regression tests on the resulting HTML. * Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/ */
public class VersionNumber { public class VersionNumber extends JavadocTester {
private static final String BUGID = "4720849"; public static void main(String... args) throws Exception {
private static final String BUGNAME = "VersionNumber"; VersionNumber tester = new VersionNumber();
private static final String TMPDEST_DIR1 = "./docs1/"; tester.runTests();
private static final String TMPDEST_DIR2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice,
// and subtestNum should increment across subtest runs.
public static int subtestNum = 0;
public static int numSubtestsPassed = 0;
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
// Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDEST_DIR1,
"p1"});
runTestsOnHTML(testArray);
printSummary();
} }
/** Run javadoc */ @Test
public static void runJavadoc(String[] javadocArgs) { void test() {
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { javadoc("-d", "out",
throw new Error("Javadoc failed to execute"); "p1");
} checkExit(Exit.OK);
// Test the proper DOCTYPE element is present:
checkOutput("p1/C.html", true,
"<!-- Generated by javadoc (");
} }
/**
* Assign value for [ stringToFind, filename ]
* NOTE: The standard doclet uses the same separator "\n" for all OS's
*/
private static final String[][] testArray = {
// Test the proper DOCTYPE element is present:
{
"<!-- Generated by javadoc (",
TMPDEST_DIR1 + "p1/C.html" },
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.indexOf(stringToFind);
}
} }

View file

@ -26,193 +26,62 @@
* @bug 4530730 * @bug 4530730
* @summary stddoclet: With frames off, window titles have "()" appended * @summary stddoclet: With frames off, window titles have "()" appended
* @author dkramer * @author dkramer
* @library ../lib
* @build JavadocTester
* @run main WindowTitles * @run main WindowTitles
*/ */
import com.sun.javadoc.*;
import java.util.*;
import java.io.*;
// If needing regular expression pattern matching,
// see /java/pubs/dev/linkfix/src/LinkFix.java
/** /**
* Runs javadoc and runs regression tests on the resulting HTML. * Runs javadoc and runs regression tests on the resulting HTML.
* It reads each file, complete with newlines, into a string to easily
* find strings that contain newlines.
*/ */
public class WindowTitles public class WindowTitles extends JavadocTester {
{
private static final String BUGID = "4530730";
private static final String BUGNAME = "WindowTitles";
private static final String TMPDIR_STRING1 = "./docs1/";
private static final String TMPDIR_STRING2 = "./docs2/";
// Subtest number. Needed because runResultsOnHTML is run twice, and subtestNum public static void main(String... args) throws Exception {
// should increment across subtest runs. WindowTitles tester = new WindowTitles();
public static int subtestNum = 0; tester.runTests();
public static int numSubtestsPassed = 0; }
// Entry point
public static void main(String[] args) {
// Directory that contains source files that javadoc runs on
String srcdir = System.getProperty("test.src", ".");
@Test
void test() {
// Test for all cases except the split index page // Test for all cases except the split index page
runJavadoc(new String[] {"-d", TMPDIR_STRING1, javadoc("-d", "out-1",
"-use", "-use",
"-sourcepath", srcdir, "-sourcepath", testSrc,
"p1", "p2"}); "p1", "p2");
runTestsOnHTML(testArray); checkExit(Exit.OK);
checkTitle("overview-summary.html", "Overview");
checkTitle("overview-tree.html", "Class Hierarchy");
checkTitle("overview-frame.html", "Overview List");
checkTitle("p1/package-summary.html", "p1");
checkTitle("p1/package-frame.html", "p1");
checkTitle("p1/package-tree.html", "p1 Class Hierarchy");
checkTitle("p1/package-use.html", "Uses of Package p1");
checkTitle("p1/C1.html", "C1");
checkTitle("allclasses-frame.html", "All Classes");
checkTitle("allclasses-noframe.html", "All Classes");
checkTitle("constant-values.html", "Constant Field Values");
checkTitle("deprecated-list.html", "Deprecated List");
checkTitle("serialized-form.html", "Serialized Form");
checkTitle("help-doc.html", "API Help");
checkTitle("index-all.html", "Index");
checkTitle("p1/class-use/C1.html", "Uses of Class p1.C1");
}
@Test
void test2() {
// Test only for the split-index case (and run on only one package) // Test only for the split-index case (and run on only one package)
System.out.println(""); // blank line javadoc("-d", "out-2",
runJavadoc(new String[] {"-d", TMPDIR_STRING2, "-splitindex",
"-splitindex", "-sourcepath", testSrc,
"-sourcepath", System.getProperty("test.src", "."), "p1");
"p1"}); checkExit(Exit.OK);
runTestsOnHTML(testSplitIndexArray);
printSummary(); checkTitle("index-files/index-1.html", "C-Index");
} }
/** Run javadoc */ void checkTitle(String file, String title) {
public static void runJavadoc(String[] javadocArgs) { checkOutput(file, true, "<title>" + title + "</title>");
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
throw new Error("Javadoc failed to execute");
}
} }
/**
* Assign value for [ stringToFind, filename ]
* NOTE: The standard doclet uses platform-specific line separators ("\n")
*/
private static final String[][] testArray = {
{ "<title>Overview</title>",
TMPDIR_STRING1 + "overview-summary.html" },
{ "<title>Class Hierarchy</title>",
TMPDIR_STRING1 + "overview-tree.html" },
{ "<title>Overview List</title>",
TMPDIR_STRING1 + "overview-frame.html" },
{ "<title>p1</title>",
TMPDIR_STRING1 + "p1/package-summary.html" },
{ "<title>p1</title>",
TMPDIR_STRING1 + "p1/package-frame.html" },
{ "<title>p1 Class Hierarchy</title>",
TMPDIR_STRING1 + "p1/package-tree.html" },
{ "<title>Uses of Package p1</title>",
TMPDIR_STRING1 + "p1/package-use.html" },
{ "<title>C1</title>",
TMPDIR_STRING1 + "p1/C1.html" },
{ "<title>All Classes</title>",
TMPDIR_STRING1 + "allclasses-frame.html" },
{ "<title>All Classes</title>",
TMPDIR_STRING1 + "allclasses-noframe.html" },
{ "<title>Constant Field Values</title>",
TMPDIR_STRING1 + "constant-values.html" },
{ "<title>Deprecated List</title>",
TMPDIR_STRING1 + "deprecated-list.html" },
{ "<title>Serialized Form</title>",
TMPDIR_STRING1 + "serialized-form.html" },
{ "<title>API Help</title>",
TMPDIR_STRING1 + "help-doc.html" },
{ "<title>Index</title>",
TMPDIR_STRING1 + "index-all.html" },
{ "<title>Uses of Class p1.C1</title>",
TMPDIR_STRING1 + "p1/class-use/C1.html" },
};
/**
* Assign value for [ stringToFind, filename ] for split index page
*/
private static final String[][] testSplitIndexArray = {
{ "<title>C-Index</title>",
TMPDIR_STRING2 + "index-files/index-1.html" },
};
public static void runTestsOnHTML(String[][] testArray) {
for (int i = 0; i < testArray.length; i++) {
subtestNum += 1;
// Read contents of file into a string
String fileString = readFileToString(testArray[i][1]);
// Get string to find
String stringToFind = testArray[i][0];
// Find string in file's contents
if (findString(fileString, stringToFind) == -1) {
System.out.println("\nSub-test " + (subtestNum)
+ " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+ "when searching for:\n"
+ stringToFind);
} else {
numSubtestsPassed += 1;
System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
}
}
}
public static void printSummary() {
if ( numSubtestsPassed == subtestNum ) {
System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
} else {
throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+ " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
}
}
// Read the file into a String
public static String readFileToString(String filename) {
try {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
// Create an array of characters the size of the file
char[] allChars = new char[(int)file.length()];
// Read the characters into the allChars array
in.read(allChars, 0, (int)file.length());
in.close();
// Convert to a string
String allCharsString = new String(allChars);
return allCharsString;
} catch (FileNotFoundException e) {
System.err.println(e);
return "";
} catch (IOException e) {
System.err.println(e);
return "";
}
}
public static int findString(String fileString, String stringToFind) {
return fileString.indexOf(stringToFind);
}
} }

View file

@ -26,42 +26,30 @@
* @bug 4504730 4526070 5077317 * @bug 4504730 4526070 5077317
* @summary Test the generation of constant-values.html. * @summary Test the generation of constant-values.html.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestConstantValuesDriver
* @run main TestConstantValuesDriver * @run main TestConstantValuesDriver
*/ */
public class TestConstantValuesDriver extends JavadocTester { public class TestConstantValuesDriver extends JavadocTester {
private static final String[] ARGS = new String[] { public static void main(String... args) throws Exception {
"-d", OUTPUT_DIR, SRC_DIR + "/TestConstantValues.java",
SRC_DIR + "/TestConstantValues2.java",
SRC_DIR + "/A.java"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
String[][] tests = new String[5][2];
for (int i = 0; i < tests.length-1; i++) {
tests[i][0] = "constant-values.html";
tests[i][1] = "TEST"+(i+1)+"PASSES";
}
tests[tests.length-1][0] = "constant-values.html";
tests[tests.length-1][1] = "<code>\"&lt;Hello World&gt;\"</code>";
TestConstantValuesDriver tester = new TestConstantValuesDriver(); TestConstantValuesDriver tester = new TestConstantValuesDriver();
tester.run(ARGS, tests, NO_TEST); tester.runTests();
tester.printSummary();
} }
/** @Test
* @throws java.io.IOException Test 1 passes void test() {
* @throws java.io.IOException Test 2 passes javadoc("-d", "out",
* @throws java.lang.NullPointerException comment three testSrc("TestConstantValues.java"),
* @throws java.io.IOException Test 3 passes testSrc("TestConstantValues2.java"),
*/ testSrc("A.java"));
public void method(){} checkExit(Exit.OK);
checkOutput("constant-values.html", true,
"TEST1PASSES",
"TEST2PASSES",
"TEST3PASSES",
"TEST4PASSES",
"<code>\"&lt;Hello World&gt;\"</code>");
}
} }

View file

@ -26,30 +26,28 @@
* @bug 4525364 * @bug 4525364
* @summary Determine if duplicate throws tags can be used. * @summary Determine if duplicate throws tags can be used.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDupThrowsTags
* @run main TestDupThrowsTags * @run main TestDupThrowsTags
*/ */
public class TestDupThrowsTags extends JavadocTester { public class TestDupThrowsTags extends JavadocTester {
private static final String[] ARGS = new String[] { public static void main(String... args) throws Exception {
"-d", OUTPUT_DIR, SRC_DIR + "/TestDupThrowsTags.java"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
String[][] tests = new String[4][2];
for (int i = 0; i < tests.length; i++) {
tests[i][0] = "TestDupThrowsTags.html";
tests[i][1] = "Test "+(i+1)+" passes";
}
TestDupThrowsTags tester = new TestDupThrowsTags(); TestDupThrowsTags tester = new TestDupThrowsTags();
tester.run(ARGS, tests, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
testSrc("TestDupThrowsTags.java"));
checkExit(Exit.FAILED);
checkOutput("TestDupThrowsTags.html", true,
"Test 1 passes",
"Test 2 passes",
"Test 3 passes",
"Test 4 passes");
} }
/** /**
@ -58,6 +56,6 @@ public class TestDupThrowsTags extends JavadocTester {
* @throws java.lang.NullPointerException Test 3 passes * @throws java.lang.NullPointerException Test 3 passes
* @throws java.io.IOException Test 4 passes * @throws java.io.IOException Test 4 passes
*/ */
public void method(){} public void method() {}
} }

File diff suppressed because it is too large Load diff

View file

@ -26,33 +26,31 @@
* @bug 4640745 * @bug 4640745
* @summary This test verifys that the -link option handles absolute paths. * @summary This test verifys that the -link option handles absolute paths.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestAbsLinkPath
* @run main TestAbsLinkPath * @run main TestAbsLinkPath
*/ */
public class TestAbsLinkPath extends JavadocTester { public class TestAbsLinkPath extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "pkg1/C1.html", "C2.html"}};
private static final String[] ARGS1 =
new String[] {
"-d", "tmp2", "-sourcepath", SRC_DIR, "pkg2"};
private static final String[] ARGS2 =
new String[] {
"-d", "tmp", "-sourcepath", SRC_DIR,
"-link", "../tmp2", "pkg1"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestAbsLinkPath tester = new TestAbsLinkPath(); TestAbsLinkPath tester = new TestAbsLinkPath();
tester.run(ARGS1, NO_TEST, NO_TEST); tester.runTests();
tester.run(ARGS2, TEST, NO_TEST); }
tester.printSummary();
@Test
void test1() {
String out1 = "out1";
javadoc("-d", out1, "-sourcepath", testSrc, "pkg2");
checkExit(Exit.OK);
javadoc("-d", "out2",
"-sourcepath", testSrc,
"-link", "../" + out1,
"pkg1");
checkExit(Exit.OK);
checkOutput("pkg1/C1.html", true,
"C2.html");
} }
} }

View file

@ -27,80 +27,72 @@
* @summary Make sure that the abstract method is identified correctly * @summary Make sure that the abstract method is identified correctly
* if the abstract modifier is present explicitly or implicitly. * if the abstract modifier is present explicitly or implicitly.
* @author bpatel * @author bpatel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestAbstractMethod * @build JavadocTester
* @run main TestAbstractMethod * @run main TestAbstractMethod
*/ */
public class TestAbstractMethod extends JavadocTester { public class TestAbstractMethod extends JavadocTester {
//Test information. public static void main(String... args) throws Exception {
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/A.html",
"<td class=\"colFirst\"><code>default void</code></td>"},
{ "pkg/A.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
"class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
"Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>" +
"</span><span id=\"t5\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{ "pkg/B.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
"class=\"tableTab\"><span><a href=\"javascript:show(4);\">Abstract " +
"Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(8);\">Concrete Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{ "pkg/B.html",
"<td class=\"colFirst\"><code>abstract void</code></td>"},
{ "pkg/C.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t5\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{ "pkg/C.html",
"<td class=\"colFirst\"><code>default void</code></td>"}
};
private static final String[][] NEGATED_TEST = {
{ "pkg/A.html",
"<td class=\"colFirst\"><code>abstract void</code></td>"},
{ "pkg/B.html",
"<span><a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span>"},
{ "pkg/B.html",
"<td class=\"colFirst\"><code>default void</code></td>"},
{ "pkg/C.html",
"<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span>"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestAbstractMethod tester = new TestAbstractMethod(); TestAbstractMethod tester = new TestAbstractMethod();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/A.html", true,
"<td class=\"colFirst\"><code>default void</code></td>",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>"
+ "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t2\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(2);\">Instance Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" "
+ "class=\"tableTab\"><span><a href=\"javascript:show(4);\">"
+ "Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>"
+ "</span><span id=\"t5\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(16);\">Default Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span></caption>");
checkOutput("pkg/B.html", true,
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>"
+ "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t2\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(2);\">Instance Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" "
+ "class=\"tableTab\"><span><a href=\"javascript:show(4);\">Abstract "
+ "Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t4\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(8);\">Concrete Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span></caption>",
"<td class=\"colFirst\"><code>abstract void</code></td>");
checkOutput("pkg/C.html", true,
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>"
+ "All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t2\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(2);\">Instance Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t5\" class=\"tableTab\"><span>"
+ "<a href=\"javascript:show(16);\">Default Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></span></caption>",
"<td class=\"colFirst\"><code>default void</code></td>");
checkOutput("pkg/A.html", false,
"<td class=\"colFirst\"><code>abstract void</code></td>");
checkOutput("pkg/B.html", false,
"<span><a href=\"javascript:show(16);\">Default Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span>",
"<td class=\"colFirst\"><code>default void</code></td>");
checkOutput("pkg/C.html", false,
"<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span>");
} }
} }

View file

@ -26,250 +26,136 @@
* @bug 8025633 8025524 * @bug 8025633 8025524
* @summary Test for valid name attribute in HTML anchors. * @summary Test for valid name attribute in HTML anchors.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestAnchorNames * @build JavadocTester
* @run main TestAnchorNames * @run main TestAnchorNames
*/ */
public class TestAnchorNames extends JavadocTester { public class TestAnchorNames extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
//Test some section markers and links to these markers
{ "pkg1/RegClass.html",
"<a name=\"skip.navbar.top\">"
},
{ "pkg1/RegClass.html",
"<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">"
},
{ "pkg1/RegClass.html",
"<a name=\"nested.class.summary\">"
},
{ "pkg1/RegClass.html",
"<a href=\"#nested.class.summary\">"
},
{ "pkg1/RegClass.html",
"<a name=\"method.summary\">"
},
{ "pkg1/RegClass.html",
"<a href=\"#method.summary\">"
},
{ "pkg1/RegClass.html",
"<a name=\"field.detail\">"
},
{ "pkg1/RegClass.html",
"<a href=\"#field.detail\">"
},
{ "pkg1/RegClass.html",
"<a name=\"constructor.detail\">"
},
{ "pkg1/RegClass.html",
"<a href=\"#constructor.detail\">"
},
//Test some members and link to these members
//The marker for this appears in the serialized-form.html which we will
//test below
{ "pkg1/RegClass.html",
"<a href=\"../serialized-form.html#pkg1.RegClass\">"
},
//Test some fields
{ "pkg1/RegClass.html",
"<a name=\"Z:Z_\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z_\">"
},
{ "pkg1/RegClass.html",
"<a name=\"Z:Z_:D\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z_:D\">"
},
{ "pkg1/RegClass.html",
"<a name=\"Z:Z:D_\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z:D_\">"
},
{ "pkg1/RegClass.html",
"<a name=\"Z:Z:Dfield\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z:Dfield\">"
},
{ "pkg1/RegClass.html",
"<a name=\"fieldInCla:D:D\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#fieldInCla:D:D\">"
},
{ "pkg1/RegClass.html",
"<a name=\"S_:D:D:D:D:DINT\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#S_:D:D:D:D:DINT\">"
},
{ "pkg1/RegClass.html",
"<a name=\"method:D:D\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#method:D:D\">"
},
{ "pkg1/DeprMemClass.html",
"<a name=\"Z:Z_field_In_Class\">"
},
{ "pkg1/DeprMemClass.html",
"<a href=\"../pkg1/DeprMemClass.html#Z:Z_field_In_Class\">"
},
//Test constructor
{ "pkg1/RegClass.html",
"<a name=\"RegClass-java.lang.String-int-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#RegClass-java.lang.String-int-\">"
},
//Test some methods
{ "pkg1/RegClass.html",
"<a name=\"Z:Z_methodInClass-java.lang.String-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClass-java.lang.String-\">"
},
{ "pkg1/RegClass.html",
"<a name=\"method--\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#method--\">"
},
{ "pkg1/RegClass.html",
"<a name=\"foo-java.util.Map-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#foo-java.util.Map-\">"
},
{ "pkg1/RegClass.html",
"<a name=\"methodInCla:Ds-java.lang.String:A-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#methodInCla:Ds-java.lang.String:A-\">"
},
{ "pkg1/RegClass.html",
"<a name=\"Z:Z_methodInClas:D-java.lang.String-int-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClas:D-java.lang.String-int-\">"
},
{ "pkg1/RegClass.html",
"<a name=\"methodD-pkg1.RegClass.:DA-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.:DA-\">"
},
{ "pkg1/RegClass.html",
"<a name=\"methodD-pkg1.RegClass.D:A-\">"
},
{ "pkg1/RegClass.html",
"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.D:A-\">"
},
{ "pkg1/DeprMemClass.html",
"<a name=\"Z:Z:Dmethod_In_Class--\">"
},
{ "pkg1/DeprMemClass.html",
"<a href=\"../pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">"
},
//Test enum
{ "pkg1/RegClass.Te$t_Enum.html",
"<a name=\"Z:Z:DFLD2\">"
},
{ "pkg1/RegClass.Te$t_Enum.html",
"<a href=\"../pkg1/RegClass.Te$t_Enum.html#Z:Z:DFLD2\">"
},
//Test nested class
{ "pkg1/RegClass._NestedClas$.html",
"<a name=\"Z:Z_NestedClas:D--\">"
},
{ "pkg1/RegClass._NestedClas$.html",
"<a href=\"../pkg1/RegClass._NestedClas$.html#Z:Z_NestedClas:D--\">"
},
//Test class use page
{ "pkg1/class-use/DeprMemClass.html",
"<a href=\"../../pkg1/RegClass.html#d____mc\">"
},
//Test deprecated list page
{ "deprecated-list.html",
"<a href=\"pkg1/DeprMemClass.html#Z:Z_field_In_Class\">"
},
{ "deprecated-list.html",
"<a href=\"pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">"
},
//Test constant values page
{ "constant-values.html",
"<a href=\"pkg1/RegClass.html#S_:D:D:D:D:DINT\">"
},
//Test serialized form page
//This is the marker for the link that appears in the pkg1.RegClass.html page
{ "serialized-form.html",
"<a name=\"pkg1.RegClass\">"
},
//Test member name index page
{ "index-all.html",
"<a name=\"I:Z:Z:D\">"
},
{ "index-all.html",
"<a href=\"#I:Z:Z:D\">$"
},
{ "index-all.html",
"<a href=\"#I:Z:Z_\">_"
}
};
private static final String[][] NEGATED_TEST = {
//The marker name conversion should only affect HTML anchors. It should not
//affect the lables.
{ "pkg1/RegClass.html",
" Z:Z_"
},
{ "pkg1/RegClass.html",
" Z:Z:Dfield"
},
{ "pkg1/RegClass.html",
" Z:Z_field_In_Class"
},
{ "pkg1/RegClass.html",
" S_:D:D:D:D:DINT"
},
};
private static final String[] ARGS = new String[] { private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", "pkg1"
}; };
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
TestAnchorNames tester = new TestAnchorNames(); TestAnchorNames tester = new TestAnchorNames();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-use",
"pkg1");
checkExit(Exit.OK);
// Test some section markers and links to these markers
checkOutput("pkg1/RegClass.html", true,
"<a name=\"skip.navbar.top\">",
"<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">",
"<a name=\"nested.class.summary\">",
"<a href=\"#nested.class.summary\">",
"<a name=\"method.summary\">",
"<a href=\"#method.summary\">",
"<a name=\"field.detail\">",
"<a href=\"#field.detail\">",
"<a name=\"constructor.detail\">",
"<a href=\"#constructor.detail\">");
// Test some members and link to these members
checkOutput("pkg1/RegClass.html", true,
//The marker for this appears in the serialized-form.html which we will
//test below
"<a href=\"../serialized-form.html#pkg1.RegClass\">");
// Test some fields
checkOutput("pkg1/RegClass.html", true,
"<a name=\"Z:Z_\">",
"<a href=\"../pkg1/RegClass.html#Z:Z_\">",
"<a name=\"Z:Z_:D\">",
"<a href=\"../pkg1/RegClass.html#Z:Z_:D\">",
"<a name=\"Z:Z:D_\">",
"<a href=\"../pkg1/RegClass.html#Z:Z:D_\">",
"<a name=\"Z:Z:Dfield\">",
"<a href=\"../pkg1/RegClass.html#Z:Z:Dfield\">",
"<a name=\"fieldInCla:D:D\">",
"<a href=\"../pkg1/RegClass.html#fieldInCla:D:D\">",
"<a name=\"S_:D:D:D:D:DINT\">",
"<a href=\"../pkg1/RegClass.html#S_:D:D:D:D:DINT\">",
"<a name=\"method:D:D\">",
"<a href=\"../pkg1/RegClass.html#method:D:D\">");
checkOutput("pkg1/DeprMemClass.html", true,
"<a name=\"Z:Z_field_In_Class\">",
"<a href=\"../pkg1/DeprMemClass.html#Z:Z_field_In_Class\">");
// Test constructor
checkOutput("pkg1/RegClass.html", true,
"<a name=\"RegClass-java.lang.String-int-\">",
"<a href=\"../pkg1/RegClass.html#RegClass-java.lang.String-int-\">");
// Test some methods
checkOutput("pkg1/RegClass.html", true,
"<a name=\"Z:Z_methodInClass-java.lang.String-\">",
"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClass-java.lang.String-\">",
"<a name=\"method--\">",
"<a href=\"../pkg1/RegClass.html#method--\">",
"<a name=\"foo-java.util.Map-\">",
"<a href=\"../pkg1/RegClass.html#foo-java.util.Map-\">",
"<a name=\"methodInCla:Ds-java.lang.String:A-\">",
"<a href=\"../pkg1/RegClass.html#methodInCla:Ds-java.lang.String:A-\">",
"<a name=\"Z:Z_methodInClas:D-java.lang.String-int-\">",
"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClas:D-java.lang.String-int-\">",
"<a name=\"methodD-pkg1.RegClass.:DA-\">",
"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.:DA-\">",
"<a name=\"methodD-pkg1.RegClass.D:A-\">",
"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.D:A-\">");
checkOutput("pkg1/DeprMemClass.html", true,
"<a name=\"Z:Z:Dmethod_In_Class--\">",
"<a href=\"../pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">");
// Test enum
checkOutput("pkg1/RegClass.Te$t_Enum.html", true,
"<a name=\"Z:Z:DFLD2\">",
"<a href=\"../pkg1/RegClass.Te$t_Enum.html#Z:Z:DFLD2\">");
// Test nested class
checkOutput("pkg1/RegClass._NestedClas$.html", true,
"<a name=\"Z:Z_NestedClas:D--\">",
"<a href=\"../pkg1/RegClass._NestedClas$.html#Z:Z_NestedClas:D--\">");
// Test class use page
checkOutput("pkg1/class-use/DeprMemClass.html", true,
"<a href=\"../../pkg1/RegClass.html#d____mc\">");
// Test deprecated list page
checkOutput("deprecated-list.html", true,
"<a href=\"pkg1/DeprMemClass.html#Z:Z_field_In_Class\">",
"<a href=\"pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">");
// Test constant values page
checkOutput("constant-values.html", true,
"<a href=\"pkg1/RegClass.html#S_:D:D:D:D:DINT\">");
// Test serialized form page
checkOutput("serialized-form.html", true,
//This is the marker for the link that appears in the pkg1.RegClass.html page
"<a name=\"pkg1.RegClass\">");
// Test member name index page
checkOutput("index-all.html", true,
"<a name=\"I:Z:Z:D\">",
"<a href=\"#I:Z:Z:D\">$",
"<a href=\"#I:Z:Z_\">_");
// The marker name conversion should only affect HTML anchors. It should not
// affect the lables.
checkOutput("pkg1/RegClass.html", false,
" Z:Z_",
" Z:Z:Dfield",
" Z:Z_field_In_Class",
" S_:D:D:D:D:DINT");
} }
} }

View file

@ -27,32 +27,26 @@
* @summary Make sure that annotations types with optional elements have * @summary Make sure that annotations types with optional elements have
* element headers * element headers
* @author Mahmood Ali * @author Mahmood Ali
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestAnnotationOptional
* @run main TestAnnotationOptional * @run main TestAnnotationOptional
*/ */
public class TestAnnotationOptional extends JavadocTester { public class TestAnnotationOptional extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/AnnotationOptional.html",
"<a name=\"annotation.type.element.detail\">"
}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestAnnotationOptional tester = new TestAnnotationOptional(); TestAnnotationOptional tester = new TestAnnotationOptional();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/AnnotationOptional.html", true,
"<a name=\"annotation.type.element.detail\">");
} }
} }

View file

@ -27,64 +27,52 @@
* @summary Make sure that annotation types with 0 members does not have * @summary Make sure that annotation types with 0 members does not have
* extra HR tags. * extra HR tags.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester TestAnnotationTypes * @build JavadocTester
* @run main TestAnnotationTypes * @run main TestAnnotationTypes
*/ */
public class TestAnnotationTypes extends JavadocTester { public class TestAnnotationTypes extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/AnnotationTypeField.html",
"<li>Summary:&nbsp;</li>\n" +
"<li><a href=\"#annotation.type." +
"field.summary\">Field</a>&nbsp;|&nbsp;</li>"},
{ "pkg/AnnotationTypeField.html",
"<li>Detail:&nbsp;</li>\n" +
"<li><a href=\"#annotation.type." +
"field.detail\">Field</a>&nbsp;|&nbsp;</li>"},
{ "pkg/AnnotationTypeField.html",
"<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== -->"},
{ "pkg/AnnotationTypeField.html",
"<h3>Field Summary</h3>"},
{ "pkg/AnnotationTypeField.html",
"<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href=\"../" +
"pkg/AnnotationTypeField.html#DEFAULT_NAME\">DEFAULT_NAME</a></span>" +
"</code>&nbsp;</td>"},
{ "pkg/AnnotationTypeField.html",
"<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->"},
{ "pkg/AnnotationTypeField.html",
"<h4>DEFAULT_NAME</h4>\n" +
"<pre>public static final&nbsp;java." +
"lang.String&nbsp;DEFAULT_NAME</pre>"},
{ "pkg/AnnotationType.html",
"<li>Summary:&nbsp;</li>\n" +
"<li>Field&nbsp;|&nbsp;</li>"},
{ "pkg/AnnotationType.html",
"<li>Detail:&nbsp;</li>\n" +
"<li>Field&nbsp;|&nbsp;</li>"},
};
private static final String[][] NEGATED_TEST = {
{ "pkg/AnnotationType.html",
"<HR>\n\n" +
"<P>\n\n" +
"<P>" +
"<!-- ========= END OF CLASS DATA ========= -->" + "<HR>"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestAnnotationTypes tester = new TestAnnotationTypes(); TestAnnotationTypes tester = new TestAnnotationTypes();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/AnnotationTypeField.html", true,
"<li>Summary:&nbsp;</li>\n"
+ "<li><a href=\"#annotation.type."
+ "field.summary\">Field</a>&nbsp;|&nbsp;</li>",
"<li>Detail:&nbsp;</li>\n"
+ "<li><a href=\"#annotation.type."
+ "field.detail\">Field</a>&nbsp;|&nbsp;</li>",
"<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== -->",
"<h3>Field Summary</h3>",
"<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href=\"../"
+ "pkg/AnnotationTypeField.html#DEFAULT_NAME\">DEFAULT_NAME</a></span>"
+ "</code>&nbsp;</td>",
"<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->",
"<h4>DEFAULT_NAME</h4>\n"
+ "<pre>public static final&nbsp;java."
+ "lang.String&nbsp;DEFAULT_NAME</pre>");
checkOutput("pkg/AnnotationType.html", true,
"<li>Summary:&nbsp;</li>\n"
+ "<li>Field&nbsp;|&nbsp;</li>",
"<li>Detail:&nbsp;</li>\n"
+ "<li>Field&nbsp;|&nbsp;</li>");
checkOutput("pkg/AnnotationType.html", false,
"<HR>\n\n"
+ "<P>\n\n"
+ "<P>"
+ "<!-- ========= END OF CLASS DATA ========= -->" + "<HR>");
} }
} }

View file

@ -27,28 +27,27 @@
* @summary Test to make sure that the link to source documentation * @summary Test to make sure that the link to source documentation
* has a forward slash. It would be wrong to use a back slash. * has a forward slash. It would be wrong to use a back slash.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestBackSlashInLink
* @run main TestBackSlashInLink * @run main TestBackSlashInLink
*/ */
public class TestBackSlashInLink extends JavadocTester { public class TestBackSlashInLink extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "C.html", "src-html/C.html#line.7"}};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-linksource", SRC_DIR + "/C.java"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestBackSlashInLink tester = new TestBackSlashInLink(); TestBackSlashInLink tester = new TestBackSlashInLink();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-linksource",
testSrc("C.java"));
checkExit(Exit.OK);
checkOutput("C.html", true,
"src-html/C.html#line.7");
} }
} }

View file

@ -27,33 +27,27 @@
* @summary Test to make sure that Javadoc emits a useful warning * @summary Test to make sure that Javadoc emits a useful warning
* when a bad package.html file is in the JAR. * when a bad package.html file is in the JAR.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestBadPackageFileInJar
* @run main TestBadPackageFileInJar * @run main TestBadPackageFileInJar
*/ */
public class TestBadPackageFileInJar extends JavadocTester { public class TestBadPackageFileInJar extends JavadocTester {
private static final String[][] TEST = public static void main(String... args) throws Exception {
new String[][] {
{ERROR_OUTPUT,
"badPackageFileInJar.jar" + FS + "pkg/package.html: error - Body tag missing from HTML"}
};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-classpath",
SRC_DIR + "/badPackageFileInJar.jar", "pkg"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestBadPackageFileInJar tester = new TestBadPackageFileInJar(); TestBadPackageFileInJar tester = new TestBadPackageFileInJar();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-classpath", testSrc("badPackageFileInJar.jar"),
"pkg");
checkExit(Exit.FAILED);
checkOutput(Output.ERROR, true,
"badPackageFileInJar.jar" + FS + "pkg/package.html: error - Body tag missing from HTML");
} }
} }

View file

@ -27,27 +27,28 @@
* @summary Make sure exception is not thrown if there is a bad source * @summary Make sure exception is not thrown if there is a bad source
* file in the same directory as the file being documented. * file in the same directory as the file being documented.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestBadSourceFile
* @run main TestBadSourceFile * @run main TestBadSourceFile
*/ */
public class TestBadSourceFile extends JavadocTester { public class TestBadSourceFile extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR, SRC_DIR + "/C2.java"
};
/** /**
* The entry point of the test. * The entry point of the test.
* @param args the array of command line arguments. * @param args the array of command line arguments
* @throws Exception if the test fails
*/ */
public static void main(String[] args) { public static void main(String... args) throws Exception {
TestBadSourceFile tester = new TestBadSourceFile(); TestBadSourceFile tester = new TestBadSourceFile();
int exitCode = tester.run(ARGS, NO_TEST, NO_TEST); tester.runTests();
tester.checkExitCode(0, exitCode); }
tester.printSummary();
@Test
void test() {
javadoc("-Xdoclint:none",
"-d", "out",
testSrc("C2.java"));
checkExit(Exit.OK);
} }
} }

View file

@ -26,29 +26,25 @@
* @bug 4197513 * @bug 4197513
* @summary Javadoc does not process base class. * @summary Javadoc does not process base class.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build BaseClass * @build BaseClass
* @build JavadocTester * @build JavadocTester
* @build TestBaseClass
* @run main TestBaseClass * @run main TestBaseClass
*/ */
public class TestBaseClass extends JavadocTester { public class TestBaseClass extends JavadocTester {
private static final String[] ARGS = public static void main(String... args) throws Exception {
new String[] {
"-sourcepath", SRC_DIR,
"-docletpath", SRC_DIR, "-doclet", "BaseClass",
SRC_DIR + "/Bar.java", "baz"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestBaseClass tester = new TestBaseClass(); TestBaseClass tester = new TestBaseClass();
if (tester.run(ARGS, NO_TEST, NO_TEST) != 0) { tester.runTests();
throw new Error("Javadoc failed to execute."); }
}
@Test
void test() {
javadoc("-sourcepath", testSrc,
"-docletpath", testSrc,
"-doclet", "BaseClass",
testSrc("Bar.java"), "baz");
checkExit(Exit.OK);
} }
} }

View file

@ -29,29 +29,27 @@
* Correct Answer: "The class is empty (i.e. it has no members)." * Correct Answer: "The class is empty (i.e. it has no members)."
* Wrong Answer: "The class is empty (i.e." * Wrong Answer: "The class is empty (i.e."
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestBreakIterator
* @run main TestBreakIterator * @run main TestBreakIterator
*/ */
public class TestBreakIterator extends JavadocTester { public class TestBreakIterator extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "pkg/BreakIteratorTest.html",
"The class is empty (i.e. it has no members)."}};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-breakiterator", "pkg"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestBreakIterator tester = new TestBreakIterator(); TestBreakIterator tester = new TestBreakIterator();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-breakiterator",
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/BreakIteratorTest.html", true,
"The class is empty (i.e. it has no members).");
} }
} }

View file

@ -26,9 +26,8 @@
* @bug 4979486 * @bug 4979486
* @summary Make sure tool parses CR line separators properly. * @summary Make sure tool parses CR line separators properly.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestCRLineSeparator
* @run main TestCRLineSeparator * @run main TestCRLineSeparator
*/ */
@ -37,32 +36,27 @@ import java.util.*;
public class TestCRLineSeparator extends JavadocTester { public class TestCRLineSeparator extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", ".", "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/MyClass.html", "Line 1\n" +
" Line 2"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception {
initFiles(new File(SRC_DIR), new File("."), "pkg");
TestCRLineSeparator tester = new TestCRLineSeparator(); TestCRLineSeparator tester = new TestCRLineSeparator();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() throws IOException {
initFiles(new File(testSrc), new File("src"), "pkg");
javadoc("-d", "out",
"-sourcepath", "src",
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/MyClass.html", true,
"Line 1\n"
+ " Line 2");
} }
// recursively copy files from fromDir to toDir, replacing newlines // recursively copy files from fromDir to toDir, replacing newlines
// with \r // with \r
static void initFiles(File fromDir, File toDir, String f) throws IOException { void initFiles(File fromDir, File toDir, String f) throws IOException {
File from_f = new File(fromDir, f); File from_f = new File(fromDir, f);
File to_f = new File(toDir, f); File to_f = new File(toDir, f);
if (from_f.isDirectory()) { if (from_f.isDirectory()) {
@ -71,23 +65,17 @@ public class TestCRLineSeparator extends JavadocTester {
initFiles(from_f, to_f, child); initFiles(from_f, to_f, child);
} }
} else { } else {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
BufferedReader in = new BufferedReader(new FileReader(from_f)); try (BufferedReader in = new BufferedReader(new FileReader(from_f))) {
try {
String line; String line;
while ((line = in.readLine()) != null) while ((line = in.readLine()) != null)
lines.add(line); lines.add(line);
} finally {
in.close();
} }
BufferedWriter out = new BufferedWriter(new FileWriter(to_f)); try (BufferedWriter out = new BufferedWriter(new FileWriter(to_f))) {
try {
for (String line: lines) { for (String line: lines) {
out.write(line); out.write(line);
out.write("\r"); out.write("\r");
} }
} finally {
out.close();
} }
} }
} }

View file

@ -27,39 +27,34 @@
* @summary Run a test on -charset to make sure the charset gets generated as a * @summary Run a test on -charset to make sure the charset gets generated as a
* part of the meta tag. * part of the meta tag.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestCharset * @build JavadocTester
* @run main TestCharset * @run main TestCharset
*/ */
public class TestCharset extends JavadocTester { public class TestCharset extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-charset", "UTF-8", "-sourcepath", SRC_DIR, "pkg"
};
private static final String[][] TEST = {
{ "index.html",
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"},
{ "pkg/Foo.html",
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"}
};
private static final String[][] NEGATED_TEST = {
{ "index.html",
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"},
{ "pkg/Foo.html",
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestCharset tester = new TestCharset(); TestCharset tester = new TestCharset();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-charset", "UTF-8",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("index.html", true,
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
checkOutput("pkg/Foo.html", true,
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
checkOutput("index.html", false,
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">");
checkOutput("pkg/Foo.html", false,
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">");
} }
} }

View file

@ -26,7 +26,7 @@
* @bug 4652655 4857717 8025633 8026567 * @bug 4652655 4857717 8025633 8026567
* @summary This test verifies that class cross references work properly. * @summary This test verifies that class cross references work properly.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestClassCrossReferences * @build TestClassCrossReferences
* @run main TestClassCrossReferences * @run main TestClassCrossReferences
@ -34,37 +34,34 @@
public class TestClassCrossReferences extends JavadocTester { public class TestClassCrossReferences extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "C.html",
"<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/package-summary.html?is-external=true\"><code>Link to math package</code></a>"},
{ "C.html",
"<a href=\"http://java.sun.com/j2se/1.4/docs/api/javax/swing/text/AbstractDocument.AttributeContext.html?is-external=true\" " +
"title=\"class or interface in javax.swing.text\"><code>Link to AttributeContext innerclass</code></a>"},
{ "C.html",
"<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigDecimal.html?is-external=true\" " +
"title=\"class or interface in java.math\"><code>Link to external class BigDecimal</code></a>"},
{ "C.html",
"<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigInteger.html?is-external=true#gcd-java.math.BigInteger-\" " +
"title=\"class or interface in java.math\"><code>Link to external member gcd</code></a>"},
{ "C.html",
"<dl>\n" +
"<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n" +
"<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>\n" +
"</dl>"}
};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/",
SRC_DIR, SRC_DIR + "/C.java"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestClassCrossReferences tester = new TestClassCrossReferences(); TestClassCrossReferences tester = new TestClassCrossReferences();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary();
} }
@Test
void test() {
final String uri = "http://java.sun.com/j2se/1.4/docs/api/";
javadoc("-d", "out",
"-sourcepath", testSrc,
"-linkoffline", uri, testSrc,
testSrc("C.java"));
checkExit(Exit.OK);
checkOutput("C.html", true,
"<a href=\"" + uri + "java/math/package-summary.html?is-external=true\">"
+ "<code>Link to math package</code></a>",
"<a href=\"" + uri + "javax/swing/text/AbstractDocument.AttributeContext.html?is-external=true\" "
+ "title=\"class or interface in javax.swing.text\"><code>Link to AttributeContext innerclass</code></a>",
"<a href=\"" + uri + "java/math/BigDecimal.html?is-external=true\" "
+ "title=\"class or interface in java.math\"><code>Link to external class BigDecimal</code></a>",
"<a href=\"" + uri + "java/math/BigInteger.html?is-external=true#gcd-java.math.BigInteger-\" "
+ "title=\"class or interface in java.math\"><code>Link to external member gcd</code></a>",
"<dl>\n"
+ "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
+ "<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>\n"
+ "</dl>");
}
} }

View file

@ -29,64 +29,52 @@
* Make sure class tree includes heirarchy for enums and annotation * Make sure class tree includes heirarchy for enums and annotation
* types. * types.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestClassTree
* @run main TestClassTree * @run main TestClassTree
*/ */
public class TestClassTree extends JavadocTester { public class TestClassTree extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/package-tree.html",
"<ul>\n" +
"<li type=\"circle\">pkg.<a href=\"../pkg/ParentClass.html\" " +
"title=\"class in pkg\"><span class=\"typeNameLink\">ParentClass</span></a>"},
{ "pkg/package-tree.html",
"<h2 title=\"Annotation Type Hierarchy\">Annotation Type Hierarchy</h2>\n" +
"<ul>\n" +
"<li type=\"circle\">pkg.<a href=\"../pkg/AnnotationType.html\" " +
"title=\"annotation in pkg\"><span class=\"typeNameLink\">AnnotationType</span></a> " +
"(implements java.lang.annotation.Annotation)</li>\n" +
"</ul>"},
{ "pkg/package-tree.html",
"<h2 title=\"Enum Hierarchy\">Enum Hierarchy</h2>\n" +
"<ul>\n" +
"<li type=\"circle\">java.lang.Object\n" +
"<ul>\n" +
"<li type=\"circle\">java.lang.Enum&lt;E&gt; (implements java.lang." +
"Comparable&lt;T&gt;, java.io.Serializable)\n" +
"<ul>\n" +
"<li type=\"circle\">pkg.<a href=\"../pkg/Coin.html\" " +
"title=\"enum in pkg\"><span class=\"typeNameLink\">Coin</span></a></li>\n" +
"</ul>\n" +
"</li>\n" +
"</ul>\n" +
"</li>\n" +
"</ul>"
},
};
private static final String[][] NEGATED_TEST = {
{ "pkg/package-tree.html",
"<li type=\"circle\">class pkg.<a href=\"../pkg/ParentClass.html\" " +
"title=\"class in pkg\"><span class=\"typeNameLink\">ParentClass</span></a></li>"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestClassTree tester = new TestClassTree(); TestClassTree tester = new TestClassTree();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/package-tree.html", true,
"<ul>\n"
+ "<li type=\"circle\">pkg.<a href=\"../pkg/ParentClass.html\" "
+ "title=\"class in pkg\"><span class=\"typeNameLink\">ParentClass</span></a>",
"<h2 title=\"Annotation Type Hierarchy\">Annotation Type Hierarchy</h2>\n"
+ "<ul>\n"
+ "<li type=\"circle\">pkg.<a href=\"../pkg/AnnotationType.html\" "
+ "title=\"annotation in pkg\"><span class=\"typeNameLink\">AnnotationType</span></a> "
+ "(implements java.lang.annotation.Annotation)</li>\n"
+ "</ul>",
"<h2 title=\"Enum Hierarchy\">Enum Hierarchy</h2>\n"
+ "<ul>\n"
+ "<li type=\"circle\">java.lang.Object\n"
+ "<ul>\n"
+ "<li type=\"circle\">java.lang.Enum&lt;E&gt; (implements java.lang."
+ "Comparable&lt;T&gt;, java.io.Serializable)\n"
+ "<ul>\n"
+ "<li type=\"circle\">pkg.<a href=\"../pkg/Coin.html\" "
+ "title=\"enum in pkg\"><span class=\"typeNameLink\">Coin</span></a></li>\n"
+ "</ul>\n"
+ "</li>\n"
+ "</ul>\n"
+ "</li>\n"
+ "</ul>");
checkOutput("pkg/package-tree.html", false,
"<li type=\"circle\">class pkg.<a href=\"../pkg/ParentClass.html\" "
+ "title=\"class in pkg\"><span class=\"typeNameLink\">ParentClass</span></a></li>");
} }
} }

View file

@ -28,47 +28,44 @@
* when specifying packages on the command line and specifying individual * when specifying packages on the command line and specifying individual
* classes. * classes.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestCmndLineClass
* @run main TestCmndLineClass * @run main TestCmndLineClass
*/ */
public class TestCmndLineClass extends JavadocTester { public class TestCmndLineClass extends JavadocTester {
private static final String OUTPUT_DIR1 = "4506980-tmp1"; public static void main(String... args) throws Exception {
private static final String OUTPUT_DIR2 = "4506980-tmp2";
private static final String[] ARGS1 =
new String[] {
"-d", OUTPUT_DIR1, "-sourcepath", SRC_DIR,
"-notimestamp", SRC_DIR + "/C5.java", "pkg1", "pkg2"
};
private static final String[] ARGS2 =
new String[] {
"-d", OUTPUT_DIR2, "-sourcepath", SRC_DIR,
"-notimestamp", SRC_DIR + "/C5.java",
SRC_DIR + "/pkg1/C1.java",
SRC_DIR + "/pkg1/C2.java",
SRC_DIR + "/pkg2/C3.java",
SRC_DIR + "/pkg2/C4.java"
};
private static final String[] FILES_TO_DIFF = {
"C5.html",
"pkg1/C1.html",
"pkg1/C2.html",
"pkg2/C3.html",
"pkg2/C4.html"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestCmndLineClass tester = new TestCmndLineClass(); TestCmndLineClass tester = new TestCmndLineClass();
tester.run(ARGS1, NO_TEST, NO_TEST); tester.runTests();
tester.run(ARGS2, NO_TEST, NO_TEST); }
tester.runDiffs(OUTPUT_DIR1, OUTPUT_DIR2, FILES_TO_DIFF);
@Test
void test() {
String outdir1 = "out-1";
String outdir2 = "out-2";
javadoc("-d", outdir1,
"-sourcepath", testSrc,
"-notimestamp",
testSrc("C5.java"), "pkg1", "pkg2");
checkExit(Exit.OK);
javadoc("-d", outdir2,
"-sourcepath", testSrc,
"-notimestamp",
testSrc("C5.java"),
testSrc("pkg1/C1.java"),
testSrc("pkg1/C2.java"),
testSrc("pkg2/C3.java"),
testSrc("pkg2/C4.java"));
checkExit(Exit.OK);
diff(outdir1, outdir2,
"C5.html",
"pkg1/C1.html",
"pkg1/C2.html",
"pkg2/C3.html",
"pkg2/C4.html");
} }
} }

View file

@ -26,32 +26,28 @@
* @bug 8027977 * @bug 8027977
* @summary Test to verify javadoc executes without CompletionFailure exception. * @summary Test to verify javadoc executes without CompletionFailure exception.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestCompletionFailure * @build JavadocTester
* @run main TestCompletionFailure * @run main TestCompletionFailure
*/ */
public class TestCompletionFailure extends JavadocTester { public class TestCompletionFailure extends JavadocTester {
//Input for string search tests. public static void main(String... args) throws Exception {
private static final String[][] NEGATED_TEST = {
{ERROR_OUTPUT, "TestCompletionFailure: error - " +
"com.sun.tools.javac.code.Symbol$CompletionFailure: class file for " +
"sun.util.locale.provider.LocaleProviderAdapter not found"
}
};
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception {
TestCompletionFailure tester = new TestCompletionFailure(); TestCompletionFailure tester = new TestCompletionFailure();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkOutput(Output.STDERR, false,
"TestCompletionFailure: error - "
+ "com.sun.tools.javac.code.Symbol$CompletionFailure: class file for "
+ "sun.util.locale.provider.LocaleProviderAdapter not found");
} }
} }

View file

@ -27,28 +27,26 @@
* @summary Test to make sure that constant values page does not get * @summary Test to make sure that constant values page does not get
* generated when doclet has nothing to document. * generated when doclet has nothing to document.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestConstantValuesPage
* @run main TestConstantValuesPage * @run main TestConstantValuesPage
*/ */
public class TestConstantValuesPage extends JavadocTester { public class TestConstantValuesPage extends JavadocTester {
private static final String[][] NEGATED_TEST = { public static void main(String... args) throws Exception {
{NOTICE_OUTPUT, "constant-values.html..."}
};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "foo"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestConstantValuesPage tester = new TestConstantValuesPage(); TestConstantValuesPage tester = new TestConstantValuesPage();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"foo");
checkExit(Exit.FAILED);
checkOutput(Output.NOTICE, false,
"constant-values.html...");
} }
} }

View file

@ -27,37 +27,31 @@
* @summary The constructor comments should be surrounded by * @summary The constructor comments should be surrounded by
* <dl></dl>. Check for this in the output. * <dl></dl>. Check for this in the output.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestConstructorIndent
* @run main TestConstructorIndent * @run main TestConstructorIndent
*/ */
public class TestConstructorIndent extends JavadocTester { public class TestConstructorIndent extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, SRC_DIR + "/C.java"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "C.html", "<div class=\"block\">" +
"This is just a simple constructor.</div>\n" +
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:</span></dt>\n" +
"<dd><code>i</code> - a param.</dd>\n" +
"</dl>"
}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestConstructorIndent tester = new TestConstructorIndent(); TestConstructorIndent tester = new TestConstructorIndent();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
testSrc("C.java"));
checkExit(Exit.OK);
checkOutput("C.html", true,
"<div class=\"block\">"
+ "This is just a simple constructor.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"paramLabel\">Parameters:</span></dt>\n"
+ "<dd><code>i</code> - a param.</dd>\n"
+ "</dl>");
} }
} }

View file

@ -26,106 +26,66 @@
* @bug 8025524 8031625 * @bug 8025524 8031625
* @summary Test for constructor name which should be a non-qualified name. * @summary Test for constructor name which should be a non-qualified name.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestConstructors * @build JavadocTester
* @run main TestConstructors * @run main TestConstructors
*/ */
public class TestConstructors extends JavadocTester { public class TestConstructors extends JavadocTester {
//Input for string search tests. public static void main(String... args) throws Exception {
private static final String[][] TEST = {
{ "pkg1/Outer.html",
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd><a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, \n" +
"<a href=\"../pkg1/Outer.Inner.html#Inner-int-\"><code>Inner(int)</code></a>, \n" +
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\"><code>NestedInner()</code></a>, \n" +
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>NestedInner(int)</code></a>, \n" +
"<a href=\"../pkg1/Outer.html#Outer--\"><code>Outer()</code></a>, \n" +
"<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>"
},
{ "pkg1/Outer.html",
"Link: <a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, " +
"<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>, " +
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>" +
"NestedInner(int)</code></a>"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.html#Outer--\">Outer</a></span>()"
},
{ "pkg1/Outer.html",
"<a name=\"Outer--\">"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.html#Outer-int-\">Outer</a></span>(int&nbsp;i)"
},
{ "pkg1/Outer.html",
"<a name=\"Outer-int-\">"
},
{ "pkg1/Outer.Inner.html",
"<a href=\"../pkg1/Outer.Inner.html#Inner--\">Inner</a></span>()"
},
{ "pkg1/Outer.Inner.html",
"<a name=\"Inner--\">"
},
{ "pkg1/Outer.Inner.html",
"<a href=\"../pkg1/Outer.Inner.html#Inner-int-\">Inner</a></span>(int&nbsp;i)"
},
{ "pkg1/Outer.Inner.html",
"<a name=\"Inner-int-\">"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\">NestedInner</a></span>()"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"<a name=\"NestedInner--\">"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\">NestedInner</a></span>(int&nbsp;i)"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"<a name=\"NestedInner-int-\">"
}
};
private static final String[][] NEGATED_TEST = {
{ "pkg1/Outer.Inner.html",
"Outer.Inner--"
},
{ "pkg1/Outer.Inner.html",
"Outer.Inner-int-"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"Outer.Inner.NestedInner--"
},
{ "pkg1/Outer.Inner.NestedInner.html",
"Outer.Inner.NestedInner-int-"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.Inner.html#Outer.Inner--\"><code>Outer.Inner()</code></a>"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.Inner.html#Outer.Inner-int-\"><code>Outer.Inner(int)</code></a>"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner--\"><code>Outer.Inner.NestedInner()</code></a>"
},
{ "pkg1/Outer.html",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner-int-\"><code>Outer.Inner.NestedInner(int)</code></a>"
}
};
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception {
TestConstructors tester = new TestConstructors(); TestConstructors tester = new TestConstructors();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkOutput("pkg1/Outer.html", true,
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, \n"
+ "<a href=\"../pkg1/Outer.Inner.html#Inner-int-\"><code>Inner(int)</code></a>, \n"
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\"><code>NestedInner()</code></a>, \n"
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>NestedInner(int)</code></a>, \n"
+ "<a href=\"../pkg1/Outer.html#Outer--\"><code>Outer()</code></a>, \n"
+ "<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>",
"Link: <a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, "
+ "<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>, "
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>"
+ "NestedInner(int)</code></a>",
"<a href=\"../pkg1/Outer.html#Outer--\">Outer</a></span>()",
"<a name=\"Outer--\">",
"<a href=\"../pkg1/Outer.html#Outer-int-\">Outer</a></span>(int&nbsp;i)",
"<a name=\"Outer-int-\">");
checkOutput("pkg1/Outer.Inner.html", true,
"<a href=\"../pkg1/Outer.Inner.html#Inner--\">Inner</a></span>()",
"<a name=\"Inner--\">",
"<a href=\"../pkg1/Outer.Inner.html#Inner-int-\">Inner</a></span>(int&nbsp;i)",
"<a name=\"Inner-int-\">");
checkOutput("pkg1/Outer.Inner.NestedInner.html", true,
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\">NestedInner</a></span>()",
"<a name=\"NestedInner--\">",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\">NestedInner</a></span>(int&nbsp;i)",
"<a name=\"NestedInner-int-\">");
checkOutput("pkg1/Outer.Inner.html", false,
"Outer.Inner--",
"Outer.Inner-int-");
checkOutput("pkg1/Outer.Inner.NestedInner.html", false,
"Outer.Inner.NestedInner--",
"Outer.Inner.NestedInner-int-");
checkOutput("pkg1/Outer.html", false,
"<a href=\"../pkg1/Outer.Inner.html#Outer.Inner--\"><code>Outer.Inner()</code></a>",
"<a href=\"../pkg1/Outer.Inner.html#Outer.Inner-int-\"><code>Outer.Inner(int)</code></a>",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner--\"><code>Outer.Inner.NestedInner()</code></a>",
"<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner-int-\"><code>Outer.Inner.NestedInner(int)</code></a>");
} }
} }

View file

@ -26,69 +26,67 @@
* @bug 8006248 * @bug 8006248
* @summary Test custom tag. Verify that an unknown tag generates appropriate warnings. * @summary Test custom tag. Verify that an unknown tag generates appropriate warnings.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester taglets.CustomTag TestCustomTag * @build JavadocTester taglets.CustomTag
* @run main TestCustomTag * @run main TestCustomTag
*/ */
public class TestCustomTag extends JavadocTester { public class TestCustomTag extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR, "-tagletpath", SRC_DIR,
"-taglet", "taglets.CustomTag", "-sourcepath",
SRC_DIR, SRC_DIR + "/TagTestClass.java"
};
private static final String[] ARGS1 = new String[] {
"-d", OUTPUT_DIR + "-1", "-tagletpath",
SRC_DIR, "-taglet", "taglets.CustomTag",
"-sourcepath", SRC_DIR, SRC_DIR + "/TagTestClass.java"
};
private static final String[] ARGS2 = new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR + "-2", "-sourcepath",
SRC_DIR, SRC_DIR + "/TagTestClass.java"
};
private static final String[] ARGS3 = new String[] {
"-d", OUTPUT_DIR + "-3", "-sourcepath",
SRC_DIR, SRC_DIR + "/TagTestClass.java"
};
//Input for string search tests.
private static final String[][] TEST = new String[][] {
{WARNING_OUTPUT, "warning - @unknownTag is an unknown tag."
}
};
private static final String[][] TEST1 = new String[][] {
{ERROR_OUTPUT, "error: unknown tag: unknownTag"
}
};
private static final String[][] TEST2 = new String[][] {
{WARNING_OUTPUT, "warning - @customTag is an unknown tag."
},
{WARNING_OUTPUT, "warning - @unknownTag is an unknown tag."
}
};
private static final String[][] TEST3 = new String[][] {
{ERROR_OUTPUT, "error: unknown tag: customTag"
},
{ERROR_OUTPUT, "error: unknown tag: unknownTag"
}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestCustomTag tester = new TestCustomTag(); TestCustomTag tester = new TestCustomTag();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.run(ARGS1, TEST1, NO_TEST); }
tester.run(ARGS2, TEST2, NO_TEST);
tester.run(ARGS3, TEST3, NO_TEST); @Test
tester.printSummary(); void test1() {
javadoc("-Xdoclint:none",
"-d", "out-1",
"-tagletpath", testSrc, // TODO: probably useless
"-taglet", "taglets.CustomTag",
"-sourcepath", testSrc,
testSrc("TagTestClass.java"));
checkExit(Exit.OK);
checkOutput(Output.WARNING, true,
"warning - @unknownTag is an unknown tag.");
}
@Test
void test2() {
javadoc("-d", "out-2",
"-tagletpath", testSrc, // TODO: probably useless
"-taglet", "taglets.CustomTag",
"-sourcepath", testSrc,
testSrc("TagTestClass.java"));
checkExit(Exit.FAILED);
checkOutput(Output.ERROR, true,
"error: unknown tag: unknownTag");
}
@Test
void test3() {
javadoc("-Xdoclint:none",
"-d", "out-3",
"-sourcepath", testSrc,
testSrc("TagTestClass.java"));
checkExit(Exit.OK);
checkOutput(Output.WARNING, true,
"warning - @customTag is an unknown tag.",
"warning - @unknownTag is an unknown tag.");
}
@Test
void test4() {
javadoc("-d", "out-4",
"-sourcepath", testSrc,
testSrc("TagTestClass.java"));
checkExit(Exit.FAILED);
checkOutput(Output.ERROR, true,
"error: unknown tag: customTag",
"error: unknown tag: unknownTag");
} }
} }

View file

@ -26,76 +26,65 @@
* @bug 4927552 8026567 * @bug 4927552 8026567
* @summary <DESC> * @summary <DESC>
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester TestDeprecatedDocs * @build JavadocTester
* @run main TestDeprecatedDocs * @run main TestDeprecatedDocs
*/ */
public class TestDeprecatedDocs extends JavadocTester { public class TestDeprecatedDocs extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
private static final String TARGET_FILE =
"deprecated-list.html";
private static final String TARGET_FILE2 =
"pkg/DeprecatedClassByAnnotation.html";
//Input for string search tests.
private static final String[][] TEST = {
{TARGET_FILE, "annotation_test1 passes"},
{TARGET_FILE, "annotation_test2 passes"},
{TARGET_FILE, "annotation_test3 passes"},
{TARGET_FILE, "class_test1 passes"},
{TARGET_FILE, "class_test2 passes"},
{TARGET_FILE, "class_test3 passes"},
{TARGET_FILE, "class_test4 passes"},
{TARGET_FILE, "enum_test1 passes"},
{TARGET_FILE, "enum_test2 passes"},
{TARGET_FILE, "error_test1 passes"},
{TARGET_FILE, "error_test2 passes"},
{TARGET_FILE, "error_test3 passes"},
{TARGET_FILE, "error_test4 passes"},
{TARGET_FILE, "exception_test1 passes"},
{TARGET_FILE, "exception_test2 passes"},
{TARGET_FILE, "exception_test3 passes"},
{TARGET_FILE, "exception_test4 passes"},
{TARGET_FILE, "interface_test1 passes"},
{TARGET_FILE, "interface_test2 passes"},
{TARGET_FILE, "interface_test3 passes"},
{TARGET_FILE, "interface_test4 passes"},
{TARGET_FILE, "pkg.DeprecatedClassByAnnotation"},
{TARGET_FILE, "pkg.DeprecatedClassByAnnotation()"},
{TARGET_FILE, "pkg.DeprecatedClassByAnnotation.method()"},
{TARGET_FILE, "pkg.DeprecatedClassByAnnotation.field"},
{TARGET_FILE2, "<pre>@Deprecated\n" +
"public class <span class=\"typeNameLabel\">DeprecatedClassByAnnotation</span>\n" +
"extends java.lang.Object</pre>"},
{TARGET_FILE2, "<pre>@Deprecated\n" +
"public&nbsp;int field</pre>\n" +
"<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>"},
{TARGET_FILE2, "<pre>@Deprecated\n" +
"public&nbsp;DeprecatedClassByAnnotation()</pre>\n" +
"<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>"},
{TARGET_FILE2, "<pre>@Deprecated\n" +
"public&nbsp;void&nbsp;method()</pre>\n" +
"<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>"},
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDeprecatedDocs tester = new TestDeprecatedDocs(); TestDeprecatedDocs tester = new TestDeprecatedDocs();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("deprecated-list.html", true,
"annotation_test1 passes",
"annotation_test2 passes",
"annotation_test3 passes",
"class_test1 passes",
"class_test2 passes",
"class_test3 passes",
"class_test4 passes",
"enum_test1 passes",
"enum_test2 passes",
"error_test1 passes",
"error_test2 passes",
"error_test3 passes",
"error_test4 passes",
"exception_test1 passes",
"exception_test2 passes",
"exception_test3 passes",
"exception_test4 passes",
"interface_test1 passes",
"interface_test2 passes",
"interface_test3 passes",
"interface_test4 passes",
"pkg.DeprecatedClassByAnnotation",
"pkg.DeprecatedClassByAnnotation()",
"pkg.DeprecatedClassByAnnotation.method()",
"pkg.DeprecatedClassByAnnotation.field"
);
checkOutput("pkg/DeprecatedClassByAnnotation.html", true,
"<pre>@Deprecated\n"
+ "public class <span class=\"typeNameLabel\">DeprecatedClassByAnnotation</span>\n"
+ "extends java.lang.Object</pre>",
"<pre>@Deprecated\n"
+ "public&nbsp;int field</pre>\n"
+ "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>",
"<pre>@Deprecated\n"
+ "public&nbsp;DeprecatedClassByAnnotation()</pre>\n"
+ "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>",
"<pre>@Deprecated\n"
+ "public&nbsp;void&nbsp;method()</pre>\n"
+ "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>");
} }
} }

View file

@ -31,36 +31,30 @@
* @summary Run tests on -docencoding to see if the value is * @summary Run tests on -docencoding to see if the value is
used for stylesheet as well. used for stylesheet as well.
* @author jayashree viswanathan * @author jayashree viswanathan
* @library ../lib/ * @library ../lib
* @build JavadocTester TestDocEncoding * @build JavadocTester
* @run main TestDocEncoding * @run main TestDocEncoding
*/ */
public class TestDocEncoding extends JavadocTester { public class TestDocEncoding extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR,
"-docencoding", "Cp930",
"-sourcepath", SRC_DIR,
"-notimestamp",
"pkg"
};
private static final String[][] NEGATED_TEST = {
{ "stylesheet.css",
"body {\n" +
" background-color:#ffffff;"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDocEncoding tester = new TestDocEncoding(); TestDocEncoding tester = new TestDocEncoding();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-docencoding", "Cp930",
"-sourcepath", testSrc,
"-notimestamp",
"pkg");
checkExit(Exit.OK);
checkOutput("stylesheet.css", false,
"body {\n"
+ " background-color:#ffffff;");
} }
} }

View file

@ -27,31 +27,30 @@
* @summary Make sure that option validation errors and sent to the * @summary Make sure that option validation errors and sent to the
* DocErrorReporter. * DocErrorReporter.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDocErrorReporter
* @run main TestDocErrorReporter * @run main TestDocErrorReporter
*/ */
public class TestDocErrorReporter extends JavadocTester { public class TestDocErrorReporter extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-encoding", "xyz",
SRC_DIR + "/TestDocErrorReporter.java"
};
//Input for Javadoc return code test.
private static final int EXPECTED_EXIT_CODE = 1;
/** /**
* The entry point of the test. * The entry point of the test.
* @param args the array of command line arguments. * @param args the array of command line arguments
* @throws Exception if the test fails
*/ */
public static void main(String[] args) { public static void main(String... args) throws Exception {
TestDocErrorReporter tester = new TestDocErrorReporter(); TestDocErrorReporter tester = new TestDocErrorReporter();
int actualExitCode = tester.run(ARGS, NO_TEST, NO_TEST); tester.runTests();
tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); }
tester.printSummary();
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-encoding", "xyz",
testSrc("TestDocErrorReporter.java"));
checkExit(Exit.FAILED);
} }
} }

View file

@ -21,8 +21,6 @@
* questions. * questions.
*/ */
import java.io.File;
/* /*
* @test * @test
* @bug 4258405 4973606 8024096 * @bug 4258405 4973606 8024096
@ -31,68 +29,59 @@ import java.io.File;
* directory. * directory.
* Also test that -docfilessubdirs and -excludedocfilessubdir both work. * Also test that -docfilessubdirs and -excludedocfilessubdir both work.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDocFileDir
* @run main TestDocFileDir * @run main TestDocFileDir
*/ */
public class TestDocFileDir extends JavadocTester { public class TestDocFileDir extends JavadocTester {
private static final String[][] TEST1 = { public static void main(String... args) throws Exception {
{ "pkg/doc-files/testfile.txt",
"This doc file did not get trashed."}
};
private static final String[] FILE_TEST2 = {
"pkg/doc-files/subdir-used1/testfile.txt",
"pkg/doc-files/subdir-used2/testfile.txt"
};
private static final String[] FILE_NEGATED_TEST2 = {
"pkg/doc-files/subdir-excluded1/testfile.txt",
"pkg/doc-files/subdir-excluded2/testfile.txt"
};
private static final String[][] TEST0 = {
{"pkg/doc-files/testfile.txt",
"This doc file did not get trashed."}
};
//Output dir = Input Dir
private static final String[] ARGS1 =
new String[] {
"-d", OUTPUT_DIR + "-1",
"-sourcepath",
"blah" + File.pathSeparator + OUTPUT_DIR + "-1" +
File.pathSeparator + "blah", "pkg"};
//Exercising -docfilessubdirs and -excludedocfilessubdir
private static final String[] ARGS2 =
new String[] {
"-d", OUTPUT_DIR + "-2",
"-sourcepath", SRC_DIR,
"-docfilessubdirs",
"-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",
"pkg"};
//Output dir = "", Input dir = ""
private static final String[] ARGS0 =
new String[] {"pkg/C.java"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDocFileDir tester = new TestDocFileDir(); TestDocFileDir tester = new TestDocFileDir();
tester.setCheckOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); tester.runTests();
copyDir(SRC_DIR + "/pkg", "."); }
tester.run(ARGS0, TEST0, NO_TEST);
copyDir(SRC_DIR + "/pkg", OUTPUT_DIR + "-1"); // Output dir = "", Input dir = ""
tester.run(ARGS1, TEST1, NO_TEST); @Test
tester.setCheckOutputDirectoryCheck(DirectoryCheck.NONE); void test1() {
tester.run(ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2); copyDir(testSrc("pkg"), ".");
tester.printSummary(); setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES);
javadoc("pkg/C.java");
checkExit(Exit.OK);
checkOutput("pkg/doc-files/testfile.txt", true,
"This doc file did not get trashed.");
}
// Output dir = Input Dir
@Test
void test2() {
String outdir = "out2";
copyDir(testSrc("pkg"), outdir);
setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES);
javadoc("-d", outdir,
"-sourcepath", "blah" + PS + outdir + PS + "blah",
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/doc-files/testfile.txt", true,
"This doc file did not get trashed.");
}
// Exercising -docfilessubdirs and -excludedocfilessubdir
@Test
void test3() {
String outdir = "out3";
setOutputDirectoryCheck(DirectoryCheck.NONE);
javadoc("-d", outdir,
"-sourcepath", testSrc,
"-docfilessubdirs",
"-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",
"pkg");
checkExit(Exit.OK);
checkFiles(true,
"pkg/doc-files/subdir-used1/testfile.txt",
"pkg/doc-files/subdir-used2/testfile.txt");
checkFiles(false,
"pkg/doc-files/subdir-excluded1/testfile.txt",
"pkg/doc-files/subdir-excluded2/testfile.txt");
} }
} }

View file

@ -25,28 +25,26 @@
* @test * @test
* @bug 8008949 * @bug 8008949
* @summary verify that doc-files get copied * @summary verify that doc-files get copied
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDocFiles
* @run main TestDocFiles * @run main TestDocFiles
*/ */
public class TestDocFiles extends JavadocTester { public class TestDocFiles extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "pkg/doc-files/test.txt", "test file"}};
private static final String[] ARGS =
new String[] {
"-d", "tmp", "-sourcepath", SRC_DIR, "pkg"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDocFiles tester = new TestDocFiles(); TestDocFiles tester = new TestDocFiles();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/doc-files/test.txt", true,
"test file");
} }
} }

View file

@ -28,42 +28,38 @@
* If docRoot performs as documented, the test passes. * If docRoot performs as documented, the test passes.
* Make sure that the docRoot tag works with the -bottom option. * Make sure that the docRoot tag works with the -bottom option.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDocRootInlineTag
* @run main TestDocRootInlineTag * @run main TestDocRootInlineTag
*/ */
public class TestDocRootInlineTag extends JavadocTester { public class TestDocRootInlineTag extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "TestDocRootTag.html",
"<a href=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
"title=\"class or interface in java.io\"><code>File</code></a>"},
{ "TestDocRootTag.html",
"<a href=\"./glossary.html\">glossary</a>"},
{ "TestDocRootTag.html",
"<a href=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
"title=\"class or interface in java.io\"><code>Second File Link</code></a>"},
{ "TestDocRootTag.html", "The value of @docRoot is \"./\""},
{ "index-all.html", "My package page is " +
"<a href=\"./pkg/package-summary.html\">here</a>"}
};
private static final String[] ARGS =
new String[] {
"-bottom", "The value of @docRoot is \"{@docRoot}\"",
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-linkoffline", "http://www.java.sun.com/j2se/1.4/docs/api",
SRC_DIR, SRC_DIR + "/TestDocRootTag.java", "pkg"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDocRootInlineTag tester = new TestDocRootInlineTag(); TestDocRootInlineTag tester = new TestDocRootInlineTag();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
String uri = "http://www.java.sun.com/j2se/1.4/docs/api";
javadoc("-bottom", "The value of @docRoot is \"{@docRoot}\"",
"-d", "out",
"-sourcepath", testSrc,
"-linkoffline", uri, testSrc,
testSrc("TestDocRootTag.java"), "pkg");
checkExit(Exit.OK);
checkOutput("TestDocRootTag.html", true,
"<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
+ "title=\"class or interface in java.io\"><code>File</code></a>",
"<a href=\"./glossary.html\">glossary</a>",
"<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
+ "title=\"class or interface in java.io\"><code>Second File Link</code></a>",
"The value of @docRoot is \"./\"");
checkOutput("index-all.html", true,
"My package page is <a href=\"./pkg/package-summary.html\">here</a>");
} }
} }

View file

@ -26,109 +26,78 @@
* @bug 6553182 8025416 8029504 * @bug 6553182 8025416 8029504
* @summary This test verifies the -Xdocrootparent option. * @summary This test verifies the -Xdocrootparent option.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestDocRootLink * @build JavadocTester
* @run main TestDocRootLink * @run main TestDocRootLink
*/ */
public class TestDocRootLink extends JavadocTester { public class TestDocRootLink extends JavadocTester {
private static final String[][] TEST1 = { public static void main(String... args) throws Exception {
{ "pkg1/C1.html",
"Refer <a href=\"../../technotes/guides/index.html\">Here</a>"
},
{ "pkg1/C1.html",
"This <a href=\"../pkg2/C2.html\">Here</a> should not be replaced\n" +
" with an absolute link."
},
{ "pkg1/C1.html",
"Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
" <a href=\"../pkg2/C2.html\">Link 2</a>."
},
{ "pkg1/package-summary.html",
"<a href=\"../../technotes/guides/index.html\">\n" +
" Test document 1</a>"
},
{ "pkg1/package-summary.html",
"<a href=\"../pkg2/C2.html\">\n" +
" Another Test document 1</a>"
},
{ "pkg1/package-summary.html",
"<a href=\"../technotes/guides/index.html\">\n" +
" Another Test document 2.</a>"
}
};
private static final String[][] NEGATED_TEST1 = {
{ "pkg1/C1.html",
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
},
{ "pkg1/C1.html",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"
},
{ "pkg1/package-summary.html",
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
},
{ "pkg1/package-summary.html",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">"
}
};
private static final String[][] TEST2 = {
{ "pkg2/C2.html",
"Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>"
},
{ "pkg2/C2.html",
"This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced\n" +
" with an absolute link."
},
{ "pkg2/C2.html",
"Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
" <a href=\"../pkg1/C1.html\">Link 2</a>."
},
{ "pkg2/package-summary.html",
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">\n" +
" Test document 1</a>"
},
{ "pkg2/package-summary.html",
"<a href=\"../pkg1/C1.html\">\n" +
" Another Test document 1</a>"
},
{ "pkg2/package-summary.html",
"<a href=\"../technotes/guides/index.html\">\n" +
" Another Test document 2.</a>"
}
};
private static final String[][] NEGATED_TEST2 = {
{ "pkg2/C2.html",
"<a href=\"../../technotes/guides/index.html\">"
},
{ "pkg2/C2.html",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"
},
{ "pkg2/package-summary.html",
"<a href=\"../../technotes/guides/index.html\">"
},
{ "pkg2/package-summary.html",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">"
}
};
private static final String[] ARGS1 =
new String[]{
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1", "pkg2"
};
private static final String[] ARGS2 =
new String[]{
"-d", OUTPUT_DIR + "-1", "-Xdocrootparent",
"http://download.oracle.com/javase/7/docs", "-sourcepath",
SRC_DIR, "pkg1", "pkg2"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestDocRootLink tester = new TestDocRootLink(); TestDocRootLink tester = new TestDocRootLink();
tester.run(ARGS1, TEST1, NEGATED_TEST1); tester.runTests();
tester.run(ARGS2, TEST2, NEGATED_TEST2); }
tester.printSummary();
@Test
void test1() {
javadoc("-d", "out-1",
"-sourcepath", testSrc,
"pkg1", "pkg2");
checkExit(Exit.OK);
checkOutput("pkg1/C1.html", true,
"Refer <a href=\"../../technotes/guides/index.html\">Here</a>",
"This <a href=\"../pkg2/C2.html\">Here</a> should not be replaced\n" +
" with an absolute link.",
"Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
" <a href=\"../pkg2/C2.html\">Link 2</a>.");
checkOutput("pkg1/package-summary.html", true,
"<a href=\"../../technotes/guides/index.html\">\n" +
" Test document 1</a>",
"<a href=\"../pkg2/C2.html\">\n" +
" Another Test document 1</a>",
"<a href=\"../technotes/guides/index.html\">\n" +
" Another Test document 2.</a>");
// TODO: should this check *any* reference to http://download.oracle.com/
checkOutput("pkg1/C1.html", false,
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">");
checkOutput("pkg1/package-summary.html", false,
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">");
}
@Test
void test2() {
javadoc("-d", "out-2",
"-Xdocrootparent", "http://download.oracle.com/javase/7/docs",
"-sourcepath", testSrc,
"pkg1", "pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/C2.html", true,
"Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>",
"This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced\n" +
" with an absolute link.",
"Testing <a href=\"../technotes/guides/index.html\">Link 1</a> and\n" +
" <a href=\"../pkg1/C1.html\">Link 2</a>.");
checkOutput("pkg2/package-summary.html", true,
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">\n" +
" Test document 1</a>",
"<a href=\"../pkg1/C1.html\">\n" +
" Another Test document 1</a>",
"<a href=\"../technotes/guides/index.html\">\n" +
" Another Test document 2.</a>");
checkOutput("pkg2/C2.html", false,
"<a href=\"../../technotes/guides/index.html\">",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">");
checkOutput("pkg2/package-summary.html", false,
"<a href=\"../../technotes/guides/index.html\">",
"<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">");
} }
} }

View file

@ -27,28 +27,26 @@
* @summary Test to ensure that the doclet does not print out bad * @summary Test to ensure that the doclet does not print out bad
* warning messages about duplicate param tags. * warning messages about duplicate param tags.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestDupParamWarn
* @run main TestDupParamWarn * @run main TestDupParamWarn
*/ */
public class TestDupParamWarn extends JavadocTester { public class TestDupParamWarn extends JavadocTester {
private static final String[] ARGS = public static void main(String... args) throws Exception {
new String[] {"-d", OUTPUT_DIR, "-sourcepath",
SRC_DIR + "/", "pkg"};
private static final String[][] NEGATED_TEST =
new String[][] {{WARNING_OUTPUT,
"Parameter \"a\" is documented more than once."}};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
JavadocTester tester = new TestDupParamWarn(); JavadocTester tester = new TestDupParamWarn();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput(Output.WARNING, false,
"Parameter \"a\" is documented more than once.");
} }
} }

View file

@ -27,39 +27,32 @@
* @summary Test to make sure that Javadoc behaves properly when * @summary Test to make sure that Javadoc behaves properly when
* run on a completely empty class (no comments or members). * run on a completely empty class (no comments or members).
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestEmptyClass
* @run main TestEmptyClass * @run main TestEmptyClass
*/ */
public class TestEmptyClass extends JavadocTester { public class TestEmptyClass extends JavadocTester {
private static final String[][] NEGATED_TEST = { public static void main(String... args) throws Exception {
TestEmptyClass tester = new TestEmptyClass();
tester.runTests();
}
@Test
void test() {
javadoc("-classpath", testSrc("src"),
"-d", "out",
"-sourcepath", testSrc("src"),
testSrc("src/Empty.java"));
checkExit(Exit.OK);
//The overview tree should not link to classes that were not documented //The overview tree should not link to classes that were not documented
{ "overview-tree.html", "<A HREF=\"TestEmptyClass.html\">"}, checkOutput("overview-tree.html", false,
"<A HREF=\"TestEmptyClass.html\">");
//The index page should not link to classes that were not documented //The index page should not link to classes that were not documented
{ "index-all.html", "<A HREF=\"TestEmptyClass.html\">"}, checkOutput("index-all.html", false,
}; "<A HREF=\"TestEmptyClass.html\">");
private static final String[] ARGS =
new String[] {
"-classpath", SRC_DIR + "/src",
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR + "/src",
SRC_DIR + "/src/Empty.java"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestEmptyClass tester = new TestEmptyClass();
int exitCode = tester.run(ARGS, NO_TEST, NEGATED_TEST);
tester.printSummary();
if (exitCode != 0) {
throw new Error("Error found while executing Javadoc");
}
} }
} }

View file

@ -26,31 +26,26 @@
* @bug 5008230 * @bug 5008230
* @summary Check the outer class when documenting enclosing class/interface. * @summary Check the outer class when documenting enclosing class/interface.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestEnclosingClass
* @run main TestEnclosingClass * @run main TestEnclosingClass
*/ */
public class TestEnclosingClass extends JavadocTester { public class TestEnclosingClass extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "pkg/MyClass.MyInterface.html", "Enclosing class:"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestEnclosingClass tester = new TestEnclosingClass(); TestEnclosingClass tester = new TestEnclosingClass();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/MyClass.MyInterface.html", true,
"Enclosing class:");
} }
} }

View file

@ -27,32 +27,28 @@
* @summary This test determines if the value of the -encoding option is * @summary This test determines if the value of the -encoding option is
* properly passed from Javadoc to the source file parser. * properly passed from Javadoc to the source file parser.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestEncoding
* @run main TestEncoding * @run main TestEncoding
*/ */
public class TestEncoding extends JavadocTester { public class TestEncoding extends JavadocTester {
public static void main(String... args) throws Exception {
//If ??? is found in the output, the source file was not read with the correct encoding setting.
private static final String[][] NEGATED_TEST = {
{ "EncodeTest.html", "??"}
};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-encoding", "iso-8859-1", SRC_DIR + "/EncodeTest.java"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestEncoding tester = new TestEncoding(); TestEncoding tester = new TestEncoding();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-encoding", "iso-8859-1",
testSrc("EncodeTest.java"));
checkExit(Exit.OK);
// If ??? is found in the output, the source file was not read with the correct encoding setting.
checkOutput("EncodeTest.html", false,
"??");
} }
} }

View file

@ -28,41 +28,38 @@
* are documented properly. The method should still include "implements" or * are documented properly. The method should still include "implements" or
* "overrides" documentation even though the method is external. * "overrides" documentation even though the method is external.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester TestExternalOverridenMethod * @build JavadocTester TestExternalOverridenMethod
* @run main TestExternalOverridenMethod * @run main TestExternalOverridenMethod
*/ */
public class TestExternalOverridenMethod extends JavadocTester { public class TestExternalOverridenMethod extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
{ "pkg/XReader.html",
"<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n" +
"<dd><code><a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true#read--\" " +
"title=\"class or interface in java.io\">read</a></code>&nbsp;in class&nbsp;<code>" +
"<a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true\" " +
"title=\"class or interface in java.io\">FilterReader</a></code></dd>"},
{ "pkg/XReader.html",
"<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n" +
"<dd><code><a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true#readInt--\" " +
"title=\"class or interface in java.io\">readInt</a></code>&nbsp;in interface&nbsp;<code>" +
"<a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true\" " +
"title=\"class or interface in java.io\">DataInput</a></code></dd>"}};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-linkoffline", "http://java.sun.com/j2se/1.4.1/docs/api", SRC_DIR,
"pkg"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestExternalOverridenMethod tester = new TestExternalOverridenMethod(); TestExternalOverridenMethod tester = new TestExternalOverridenMethod();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
String uri = "http://java.sun.com/j2se/1.4.1/docs/api";
javadoc("-d", "out",
"-sourcepath", testSrc,
"-linkoffline", uri, testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/XReader.html", true,
"<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
+ "<dd><code><a href=\"" + uri + "/java/io/FilterReader.html?is-external=true#read--\" "
+ "title=\"class or interface in java.io\">read</a></code>&nbsp;in class&nbsp;<code>"
+ "<a href=\"" + uri + "/java/io/FilterReader.html?is-external=true\" "
+ "title=\"class or interface in java.io\">FilterReader</a></code></dd>",
"<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
+ "<dd><code><a href=\"" + uri + "/java/io/DataInput.html?is-external=true#readInt--\" "
+ "title=\"class or interface in java.io\">readInt</a></code>&nbsp;in interface&nbsp;<code>"
+ "<a href=\"" + uri + "/java/io/DataInput.html?is-external=true\" "
+ "title=\"class or interface in java.io\">DataInput</a></code></dd>"
);
} }
} }

View file

@ -25,14 +25,41 @@
* @test * @test
* @bug 8000418 8024288 * @bug 8000418 8024288
* @summary Verify that files use a common Generated By string * @summary Verify that files use a common Generated By string
* @library ../lib/ * @library ../lib
* @build JavadocTester TestGeneratedBy * @build JavadocTester
* @run main TestGeneratedBy * @run main TestGeneratedBy
*/ */
public class TestGeneratedBy extends JavadocTester { public class TestGeneratedBy extends JavadocTester {
private static final String[] FILES = { public static void main(String... args) throws Exception {
TestGeneratedBy tester = new TestGeneratedBy();
tester.runTests();
}
@Test
void testTimestamp() {
javadoc("-d", "out-timestamp",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkTimestamps(true);
}
@Test
void testNoTimestamp() {
javadoc("-d", "out-notimestamp",
"-notimestamp",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkTimestamps(false);
}
void checkTimestamps(boolean timestamp) {
checkTimestamps(timestamp,
"pkg/MyClass.html", "pkg/MyClass.html",
"pkg/package-summary.html", "pkg/package-summary.html",
"pkg/package-frame.html", "pkg/package-frame.html",
@ -45,63 +72,25 @@ public class TestGeneratedBy extends JavadocTester {
"serialized-form.html", "serialized-form.html",
"help-doc.html", "help-doc.html",
"index-all.html", "index-all.html",
"index.html" "index.html");
};
private static final String[] STD_ARGS =
new String[] {
"-d", OUTPUT_DIR,
"-sourcepath", SRC_DIR,
"pkg"
};
private static final String[] NO_TIMESTAMP_ARGS =
new String[] {
"-notimestamp",
"-d", OUTPUT_DIR + "-1",
"-sourcepath", SRC_DIR,
"pkg"
};
private static String[][] getTests(boolean timestamp) {
String version = System.getProperty("java.version");
String[][] tests = new String[FILES.length][];
for (int i = 0; i < FILES.length; i++) {
String genBy = "Generated by javadoc";
if (timestamp) genBy += " (" + version + ") on ";
tests[i] = new String[] {
FILES[i], genBy
};
}
return tests;
} }
private static String[][] getNegatedTests(boolean timestamp) { void checkTimestamps(boolean timestamp, String... files) {
String[][] tests = new String[FILES.length][]; String version = System.getProperty("java.version");
for (int i = 0; i < FILES.length; i++) { String genBy = "Generated by javadoc";
tests[i] = new String[] { if (timestamp) genBy += " (" + version + ") on ";
FILES[i],
for (String file: files) {
// genBy is the current standard "Generated by" text
checkOutput(file, true, genBy);
// These are older versions of the "Generated by" text
checkOutput(file, false,
(timestamp (timestamp
? "Generated by javadoc (version" ? "Generated by javadoc (version"
: "Generated by javadoc ("), : "Generated by javadoc ("),
"Generated by javadoc on" "Generated by javadoc on");
};
}
return tests;
}
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestGeneratedBy tester = new TestGeneratedBy();
int ec1 = tester.run(STD_ARGS, getTests(true), getNegatedTests(true));
int ec2 = tester.run(NO_TIMESTAMP_ARGS, getTests(false), getNegatedTests(false));
tester.printSummary();
if (ec1 != 0 || ec2 != 0) {
throw new Error("Error found while executing Javadoc");
} }
} }
} }

View file

@ -27,49 +27,46 @@
* @summary Test to make sure the -group option does not cause a bad warning * @summary Test to make sure the -group option does not cause a bad warning
* to be printed. * to be printed.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestGroupOption
* @run main TestGroupOption * @run main TestGroupOption
*/ */
public class TestGroupOption extends JavadocTester { public class TestGroupOption extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS1 = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"-group", "Package One", "pkg1",
"-group", "Package Two", "pkg2",
"-group", "Package Three", "pkg3",
"pkg1", "pkg2", "pkg3"
};
private static final String[] ARGS2 = new String[] {
"-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR,
"-group", "Package One", "pkg1",
"-group", "Package One", "pkg2",
"-group", "Package One", "pkg3",
"pkg1", "pkg2", "pkg3"
};
//Input for string search tests.
private static final String[][] NEGATED_TEST1 = {{WARNING_OUTPUT, "-group"}};
private static final String[][] TEST2 = {{WARNING_OUTPUT, "-group"}};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
//Make sure the warning is not printed when -group is used correctly.
TestGroupOption tester = new TestGroupOption(); TestGroupOption tester = new TestGroupOption();
tester.run(ARGS1, NO_TEST, NEGATED_TEST1); tester.runTests();
tester.printSummary(); }
@Test
void test1() {
//Make sure the warning is not printed when -group is used correctly.
javadoc("-d", "out-1",
"-sourcepath", testSrc,
"-group", "Package One", "pkg1",
"-group", "Package Two", "pkg2",
"-group", "Package Three", "pkg3",
"pkg1", "pkg2", "pkg3");
checkExit(Exit.OK);
checkOutput(Output.WARNING, false,
"-group");
}
@Test
void test2() {
//Make sure the warning is printed when -group is not used correctly. //Make sure the warning is printed when -group is not used correctly.
tester = new TestGroupOption(); javadoc("-d", "out-2",
tester.run(ARGS2, TEST2, NO_TEST); "-sourcepath", testSrc,
tester.printSummary(); "-group", "Package One", "pkg1",
"-group", "Package One", "pkg2",
"-group", "Package One", "pkg3",
"pkg1", "pkg2", "pkg3");
checkExit(Exit.OK);
checkOutput(Output.WARNING, true,
"-group");
} }
} }

View file

@ -26,7 +26,7 @@
* @bug 4905786 6259611 * @bug 4905786 6259611
* @summary Make sure that headings use the TH tag instead of the TD tag. * @summary Make sure that headings use the TH tag instead of the TD tag.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHeadings * @build TestHeadings
* @run main TestHeadings * @run main TestHeadings
@ -34,87 +34,82 @@
public class TestHeadings extends JavadocTester { public class TestHeadings extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", "-header", "Test Files",
"pkg1", "pkg2"
};
//Input for string search tests.
private static final String[][] TEST = { private static final String[][] TEST = {
//Package summary
{ "pkg1/package-summary.html", {
"<th class=\"colFirst\" scope=\"col\">" + },
"Class</th>\n" + { "serialized-form.html"
"<th class=\"colLast\" scope=\"col\"" + },
">Description</th>" { "serialized-form.html"
}, },
// Class documentation {
{ "pkg1/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Field and Description</th>"
}, },
{ "pkg1/C1.html", { "overview-frame.html"
"<h3>Methods inherited from class&nbsp;java.lang.Object</h3>"
}, },
{
// Class use documentation
{ "pkg1/class-use/C1.html",
"<th class=\"colFirst\" scope=\"col\">Package</th>\n" +
"<th class=\"colLast\" scope=\"col\">Description</th>"
},
{ "pkg1/class-use/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Field and Description</th>"
},
// Deprecated
{ "deprecated-list.html",
"<th class=\"colOne\" scope=\"col\">Method and Description</th>"
},
// Constant values
{ "constant-values.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Modifier and Type</th>\n" +
"<th scope=\"col\">Constant Field</th>\n" +
"<th class=\"colLast\" scope=\"col\">Value</th>"
},
// Serialized Form
{ "serialized-form.html",
"<h2 title=\"Package\">Package&nbsp;pkg1</h2>"
},
{ "serialized-form.html",
"<h3>Class <a href=\"pkg1/C1.html\" title=\"class in pkg1\">" +
"pkg1.C1</a> extends java.lang.Object implements Serializable</h3>"
},
{ "serialized-form.html",
"<h3>Serialized Fields</h3>"
},
// Overview Frame
{ "overview-frame.html",
"<h1 title=\"Test Files\" class=\"bar\">Test Files</h1>"
},
{ "overview-frame.html",
"<title>Overview List</title>"
},
// Overview Summary
{ "overview-summary.html",
"<title>Overview</title>"
} }
}; };
/** public static void main(String... args) throws Exception {
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHeadings tester = new TestHeadings(); TestHeadings tester = new TestHeadings();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-use",
"-header", "Test Files",
"pkg1", "pkg2");
checkExit(Exit.OK);
//Package summary
checkOutput("pkg1/package-summary.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Class</th>\n"
+ "<th class=\"colLast\" scope=\"col\""
+ ">Description</th>");
// Class documentation
checkOutput("pkg1/C1.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
"<h3>Methods inherited from class&nbsp;java.lang.Object</h3>");
// Class use documentation
checkOutput("pkg1/class-use/C1.html", true,
"<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Field and Description</th>");
// Deprecated
checkOutput("deprecated-list.html", true,
"<th class=\"colOne\" scope=\"col\">Method and Description</th>");
// Constant values
checkOutput("constant-values.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Modifier and Type</th>\n"
+ "<th scope=\"col\">Constant Field</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Value</th>");
// Serialized Form
checkOutput("serialized-form.html", true,
"<h2 title=\"Package\">Package&nbsp;pkg1</h2>",
"<h3>Class <a href=\"pkg1/C1.html\" title=\"class in pkg1\">"
+ "pkg1.C1</a> extends java.lang.Object implements Serializable</h3>",
"<h3>Serialized Fields</h3>");
// Overview Frame
checkOutput("overview-frame.html", true,
"<h1 title=\"Test Files\" class=\"bar\">Test Files</h1>",
"<title>Overview List</title>");
// Overview Summary
checkOutput("overview-summary.html", true,
"<title>Overview</title>");
} }
} }

View file

@ -26,32 +26,26 @@
* @bug 7132631 * @bug 7132631
* @summary Make sure that the help file is generated correctly. * @summary Make sure that the help file is generated correctly.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestHelpFile * @build JavadocTester
* @run main TestHelpFile * @run main TestHelpFile
*/ */
public class TestHelpFile extends JavadocTester { public class TestHelpFile extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
SRC_DIR + "/TestHelpFile.java"
};
private static final String[][] TEST = {
{ "help-doc.html",
"<a href=\"constant-values.html\">Constant Field Values</a>"
},
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHelpFile tester = new TestHelpFile(); TestHelpFile tester = new TestHelpFile();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
testSrc("TestHelpFile.java"));
checkExit(Exit.OK);
checkOutput("help-doc.html", true,
"<a href=\"constant-values.html\">Constant Field Values</a>");
} }
} }

View file

@ -27,81 +27,79 @@
* @summary Make sure that the -help option works properly. Make sure * @summary Make sure that the -help option works properly. Make sure
* the help link appears in the documentation. * the help link appears in the documentation.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester TestHelpOption * @build JavadocTester TestHelpOption
* @run main TestHelpOption * @run main TestHelpOption
*/ */
public class TestHelpOption extends JavadocTester { public class TestHelpOption extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-help",
SRC_DIR + "/TestHelpOption.java"
};
private static final String[] ARGS2 = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
SRC_DIR + "/TestHelpOption.java"
};
private static final String[][] TEST = {
{STANDARD_OUTPUT, "-d "},
{STANDARD_OUTPUT, "-use "},
{STANDARD_OUTPUT, "-version "},
{STANDARD_OUTPUT, "-author "},
{STANDARD_OUTPUT, "-docfilessubdirs "},
{STANDARD_OUTPUT, "-splitindex "},
{STANDARD_OUTPUT, "-windowtitle "},
{STANDARD_OUTPUT, "-doctitle "},
{STANDARD_OUTPUT, "-header "},
{STANDARD_OUTPUT, "-footer "},
{STANDARD_OUTPUT, "-bottom "},
{STANDARD_OUTPUT, "-link "},
{STANDARD_OUTPUT, "-linkoffline "},
{STANDARD_OUTPUT, "-excludedocfilessubdir "},
{STANDARD_OUTPUT, "-group "},
{STANDARD_OUTPUT, "-nocomment "},
{STANDARD_OUTPUT, "-nodeprecated "},
{STANDARD_OUTPUT, "-noqualifier "},
{STANDARD_OUTPUT, "-nosince "},
{STANDARD_OUTPUT, "-notimestamp "},
{STANDARD_OUTPUT, "-nodeprecatedlist "},
{STANDARD_OUTPUT, "-notree "},
{STANDARD_OUTPUT, "-noindex "},
{STANDARD_OUTPUT, "-nohelp "},
{STANDARD_OUTPUT, "-nonavbar "},
{STANDARD_OUTPUT, "-serialwarn "},
{STANDARD_OUTPUT, "-tag "},
{STANDARD_OUTPUT, "-taglet "},
{STANDARD_OUTPUT, "-tagletpath "},
{STANDARD_OUTPUT, "-charset "},
{STANDARD_OUTPUT, "-helpfile "},
{STANDARD_OUTPUT, "-linksource "},
{STANDARD_OUTPUT, "-sourcetab "},
{STANDARD_OUTPUT, "-keywords "},
{STANDARD_OUTPUT, "-stylesheetfile "},
{STANDARD_OUTPUT, "-docencoding "},
};
private static final String[][] TEST2 = {
{ "TestHelpOption.html",
"<li><a href=\"help-doc.html\">Help</a></li>"
},
};
//The help option should not crash the doclet.
private static final int EXPECTED_EXIT_CODE = 0;
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHelpOption tester = new TestHelpOption(); TestHelpOption tester = new TestHelpOption();
int actualExitCode = tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); }
tester.run(ARGS2, TEST2, NO_TEST);
tester.printSummary(); @Test
void testWithOption() {
javadoc("-d", "out1",
"-sourcepath", testSrc,
"-help",
testSrc("TestHelpOption.java"));
checkExit(Exit.OK);
checkOutput(true);
}
@Test
void testWithoutOption() {
javadoc("-d", "out2",
"-sourcepath", testSrc,
testSrc("TestHelpOption.java"));
checkExit(Exit.OK);
checkOutput(false);
}
private void checkOutput(boolean withOption) {
checkOutput(Output.STDOUT, withOption,
"-d ",
"-use ",
"-version ",
"-author ",
"-docfilessubdirs ",
"-splitindex ",
"-windowtitle ",
"-doctitle ",
"-header ",
"-footer ",
"-bottom ",
"-link ",
"-linkoffline ",
"-excludedocfilessubdir ",
"-group ",
"-nocomment ",
"-nodeprecated ",
"-noqualifier ",
"-nosince ",
"-notimestamp ",
"-nodeprecatedlist ",
"-notree ",
"-noindex ",
"-nohelp ",
"-nonavbar ",
"-serialwarn ",
"-tag ",
"-taglet ",
"-tagletpath ",
"-charset ",
"-helpfile ",
"-linksource ",
"-sourcetab ",
"-keywords ",
"-stylesheetfile ",
"-docencoding ");
checkOutput("TestHelpOption.html", !withOption,
"<li><a href=\"help-doc.html\">Help</a></li>");
} }
} }

View file

@ -27,34 +27,37 @@
* @summary Test to make sure that hidden overriden members are not * @summary Test to make sure that hidden overriden members are not
* documented as inherited. * documented as inherited.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHiddenMembers
* @run main TestHiddenMembers * @run main TestHiddenMembers
*/ */
public class TestHiddenMembers extends JavadocTester { public class TestHiddenMembers extends JavadocTester {
//We should not inherit any members from BaseClass because they are all overriden and hidden
//(declared as private).
private static final String[][] NEGATED_TEST = { private static final String[][] NEGATED_TEST = {
{ "pkg/SubClass.html", { }
"inherited from class pkg.<A HREF=\"../pkg/BaseClass.html\">BaseClass</A>"}
}; };
private static final String[] ARGS = private static final String[] ARGS =
new String[] { new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR,
"pkg"
}; };
/** public static void main(String... args) throws Exception {
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHiddenMembers tester = new TestHiddenMembers(); TestHiddenMembers tester = new TestHiddenMembers();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
// We should not inherit any members from BaseClass because they are all overriden and hidden
// (declared as private).
// TODO: check normal case of generated tags: upper case of lower case
checkOutput("pkg/SubClass.html", false,
"inherited from class pkg.<A HREF=\"../pkg/BaseClass.html\">BaseClass</A>");
} }
} }

View file

@ -26,73 +26,57 @@
* @bug 4663254 8016328 8025633 8026567 * @bug 4663254 8016328 8025633 8026567
* @summary Verify that spaces do not appear in hrefs and anchors. * @summary Verify that spaces do not appear in hrefs and anchors.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester TestHref * @build JavadocTester
* @run main TestHref * @run main TestHref
*/ */
public class TestHref extends JavadocTester { public class TestHref extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-linkoffline",
"http://java.sun.com/j2se/1.4/docs/api/", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
//External link.
{ "pkg/C1.html",
"href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait-long-int-\""
},
//Member summary table link.
{ "pkg/C1.html",
"href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\""
},
//Anchor test.
{ "pkg/C1.html",
"<a name=\"method-int-int-java.util.ArrayList-\">\n" +
"<!-- -->\n" +
"</a>"
},
//Backward compatibility anchor test.
{ "pkg/C1.html",
"<a name=\"method-int-int-java.util.ArrayList-\">\n" +
"<!-- -->\n" +
"</a>"
},
//{@link} test.
{ "pkg/C2.html",
"Link: <a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">"
},
//@see test.
{ "pkg/C2.html",
"See Also:</span></dt>\n" +
"<dd><a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">"
},
//Header does not link to the page itself.
{ "pkg/C4.html",
"Class C4&lt;E extends C4&lt;E&gt;&gt;</h2>"
},
//Signature does not link to the page itself.
{ "pkg/C4.html",
"public abstract class <span class=\"typeNameLabel\">C4&lt;E extends C4&lt;E&gt;&gt;</span>"
},
};
private static final String[][] NEGATED_TEST =
{
{WARNING_OUTPUT, "<a> tag is malformed"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHref tester = new TestHref(); TestHref tester = new TestHref();
tester.run(ARGS, TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-Xdoclint:none",
"-d", "out",
"-sourcepath", testSrc,
"-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/C1.html", true,
//External link.
"href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait-long-int-\"",
//Member summary table link.
"href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\"",
//Anchor test.
"<a name=\"method-int-int-java.util.ArrayList-\">\n"
+ "<!-- -->\n"
+ "</a>",
//Backward compatibility anchor test."pkg/C1.html",
"<a name=\"method-int-int-java.util.ArrayList-\">\n"
+ "<!-- -->\n"
+ "</a>");
checkOutput("pkg/C2.html", true,
//{@link} test.
"Link: <a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">",
//@see test.
"See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">"
);
checkOutput("pkg/C4.html", true,
//Header does not link to the page itself.
"Class C4&lt;E extends C4&lt;E&gt;&gt;</h2>",
//Signature does not link to the page itself.
"public abstract class <span class=\"typeNameLabel\">C4&lt;E extends C4&lt;E&gt;&gt;</span>"
);
checkOutput(Output.WARNING, false,
"<a> tag is malformed");
} }
} }

View file

@ -27,26 +27,22 @@
* @summary Determine if Hrefs are processed properly when they * @summary Determine if Hrefs are processed properly when they
* appear in doc comments. * appear in doc comments.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHrefInDocComment
* @run main TestHrefInDocComment * @run main TestHrefInDocComment
*/ */
public class TestHrefInDocComment extends JavadocTester { public class TestHrefInDocComment extends JavadocTester {
private static final String[] ARGS = public static void main(String... args) throws Exception {
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHrefInDocComment tester = new TestHrefInDocComment(); TestHrefInDocComment tester = new TestHrefInDocComment();
if (tester.run(ARGS, NO_TEST, NO_TEST) != 0) { tester.runTests();
throw new Error("Javadoc failed to execute properly with given source."); }
}
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc, "pkg");
checkExit(Exit.OK);
} }
} }

View file

@ -27,32 +27,26 @@
* @summary The field detail comment should not show up in the output if there * @summary The field detail comment should not show up in the output if there
* are no fields to document. * are no fields to document.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHtmlComments
* @run main TestHtmlComments * @run main TestHtmlComments
*/ */
public class TestHtmlComments extends JavadocTester { public class TestHtmlComments extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, SRC_DIR + "/C.java"
};
//Input for string search tests.
private static final String[][] NEGATED_TEST = {
{ "C.html",
"<!-- ============ FIELD DETAIL =========== -->"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHtmlComments tester = new TestHtmlComments(); TestHtmlComments tester = new TestHtmlComments();
tester.run(ARGS, NO_TEST, NEGATED_TEST); tester.runTests();
tester.printSummary(); }
@Test
void run() {
javadoc("-d", "out",
"-sourcepath", testSrc,
testSrc("C.java"));
checkExit(Exit.OK);
checkOutput("C.html", false,
"<!-- ============ FIELD DETAIL =========== -->");
} }
} }

View file

@ -28,159 +28,250 @@
* @bug 6786690 6820360 8025633 8026567 * @bug 6786690 6820360 8025633 8026567
* @summary This test verifies the nesting of definition list tags. * @summary This test verifies the nesting of definition list tags.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestHtmlDefinitionListTag * @build JavadocTester
* @run main TestHtmlDefinitionListTag * @run main TestHtmlDefinitionListTag
*/ */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TestHtmlDefinitionListTag extends JavadocTester { public class TestHtmlDefinitionListTag extends JavadocTester {
// Test common to all runs of javadoc. The class signature should print public static void main(String... args) throws Exception {
// properly enclosed definition list tags and the Annotation Type TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag();
// Optional Element should print properly nested definition list tags tester.runTests();
// for default value. }
private static final String[][] TEST_ALL = {
{ "pkg1/C1.html", @Test
void test_Comment_Deprecated() {
// tester.run(ARGS1, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
// tester.runTestsOnHTML(TEST_CMNT_DEPR, NO_TEST);
javadoc("-Xdoclint:none",
"-d", "out-1",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkCommon(true);
checkCommentDeprecated(true);
}
@Test
void test_NoComment_Deprecated() {
// tester.run(ARGS2, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
// tester.runTestsOnHTML(NO_TEST, TEST_CMNT_DEPR);
javadoc("-Xdoclint:none",
"-d", "out-2",
"-nocomment",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkCommon(true);
checkCommentDeprecated(false); // ??
}
@Test
void test_Comment_NoDeprecated() {
// tester.run(ARGS3, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(TEST_NODEPR, TEST_NOCMNT_NODEPR);
javadoc("-Xdoclint:none",
"-d", "out-3",
"-nodeprecated",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkCommon(false);
checkNoDeprecated();
checkNoCommentNoDeprecated(false);
}
@Test
void testNoCommentNoDeprecated() {
// tester.run(ARGS4, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
javadoc("-Xdoclint:none",
"-d", "out-4",
"-nocomment",
"-nodeprecated",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkCommon(false);
checkNoCommentNoDeprecated(true);
checkCommentDeprecated(false);
}
void checkCommon(boolean checkC5) {
// Test common to all runs of javadoc. The class signature should print
// properly enclosed definition list tags and the Annotation Type
// Optional Element should print properly nested definition list tags
// for default value.
checkOutput("pkg1/C1.html", true,
"<pre>public class <span class=\"typeNameLabel\">C1</span>\n" + "<pre>public class <span class=\"typeNameLabel\">C1</span>\n" +
"extends java.lang.Object\n" + "extends java.lang.Object\n" +
"implements java.io.Serializable</pre>"}, "implements java.io.Serializable</pre>");
{ "pkg1/C4.html", checkOutput("pkg1/C4.html", true,
"<dl>\n" + "<dl>\n" +
"<dt>Default:</dt>\n" + "<dt>Default:</dt>\n" +
"<dd>true</dd>\n" + "<dd>true</dd>\n" +
"</dl>"}}; "</dl>");
// Test for normal run of javadoc in which various ClassDocs and // Test for valid HTML generation which should not comprise of empty
// serialized form should have properly nested definition list tags // definition list tags.
// enclosing comments, tags and deprecated information. List<String> files= new ArrayList<>(Arrays.asList(
private static final String[][] TEST_CMNT_DEPR = { "pkg1/package-summary.html",
{ "pkg1/package-summary.html", "pkg1/C1.html",
"<dl>\n" + "pkg1/C1.ModalExclusionType.html",
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" + "pkg1/C2.html",
"<dd>JDK1.0</dd>\n" + "pkg1/C2.ModalType.html",
"</dl>"}, "pkg1/C3.html",
{ "pkg1/C1.html", "pkg1/C4.html",
"<dl>\n" + "overview-tree.html",
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" + "serialized-form.html"
"<dd>JDK1.0</dd>\n" + ));
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\"><code>" +
"C2</code></a>, \n" +
"<a href=\"../serialized-form.html#pkg1.C1\">" +
"Serialized Form</a></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>1.4</dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:</span></dt>\n" +
"<dd><code>title</code> - the title</dd>\n" +
"<dd><code>test</code> - boolean value" +
"</dd>\n" +
"<dt><span class=\"throwsLabel\">Throws:</span></dt>\n" +
"<dd><code>java.lang.IllegalArgumentException</code> - if the " +
"<code>owner</code>'s\n" +
" <code>GraphicsConfiguration</code> is not from a screen " +
"device</dd>\n" +
"<dd><code>HeadlessException</code></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:</span></dt>\n" +
"<dd><code>undecorated" +
"</code> - <code>true</code> if no decorations are\n" +
" to be enabled;\n" +
" <code>false</code> " +
"if decorations are to be enabled.</dd>\n" +
"<dt><span class=\"simpleTagLabel\">Since:" +
"</span></dt>\n" +
"<dd>1.4</dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd>" +
"<a href=\"../pkg1/C1.html#readObject--\"><code>readObject()" +
"</code></a></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:</span></dt>\n" +
"<dd><code>java.io.IOException</code></dd>\n" +
"<dt><span class=\"seeLabel\">See Also:" +
"</span></dt>\n" +
"<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "pkg1/C2.html",
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:" +
"</span></dt>\n" +
"<dd><code>set</code> - boolean</dd>\n" +
"<dt><span class=\"simpleTagLabel\">" +
"Since:</span></dt>\n" +
"<dd>1.4</dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:</span>" +
"</dt>\n" +
"<dd><code>" +
"java.io.IOException</code></dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span>" +
"</dt>\n" +
"<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>C1.setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a>.</span></div>\n" +
"<div class=\"block\">This field indicates whether the C1 is " +
"undecorated.</div>\n" +
"&nbsp;\n" +
"<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>1.4</dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span>" +
"</dt>\n" +
"<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>C1.setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a>.</span></div>\n" +
"<div class=\"block\">Reads the object stream.</div>\n" +
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:" +
"</span></dt>\n" +
"<dd><code><code>" +
"IOException</code></code></dd>\n" +
"<dd><code>java.io.IOException</code></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;</div>\n" +
"<div class=\"block\">The name for this class.</div>"}};
// Test with -nodeprecated option. The ClassDocs should have properly nested if (checkC5)
// definition list tags enclosing comments and tags. The ClassDocs should not files.add("pkg1/C5.html");
// display definition list for deprecated information. The serialized form
// should display properly nested definition list tags for comments, tags for (String f: files) {
// and deprecated information. checkOutput(f, false,
private static final String[][] TEST_NODEPR = { "<dl></dl>",
{ "pkg1/package-summary.html", "<dl>\n</dl>");
}
}
void checkCommentDeprecated(boolean expectFound) {
// Test for normal run of javadoc in which various ClassDocs and
// serialized form should have properly nested definition list tags
// enclosing comments, tags and deprecated information.
checkOutput("pkg1/package-summary.html", expectFound,
"<dl>\n" + "<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>JDK1.0</dd>\n" + "<dd>JDK1.0</dd>\n" +
"</dl>"}, "</dl>");
{ "pkg1/C1.html",
checkOutput("pkg1/C1.html", expectFound,
"<dl>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>JDK1.0</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\"><code>"
+ "C2</code></a>, \n"
+ "<a href=\"../serialized-form.html#pkg1.C1\">"
+ "Serialized Form</a></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"paramLabel\">Parameters:</span></dt>\n"
+ "<dd><code>title</code> - the title</dd>\n"
+ "<dd><code>test</code> - boolean value"
+ "</dd>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
+ "<dd><code>java.lang.IllegalArgumentException</code> - if the "
+ "<code>owner</code>'s\n"
+ " <code>GraphicsConfiguration</code> is not from a screen "
+ "device</dd>\n"
+ "<dd><code>HeadlessException</code></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"paramLabel\">Parameters:</span></dt>\n"
+ "<dd><code>undecorated"
+ "</code> - <code>true</code> if no decorations are\n"
+ " to be enabled;\n"
+ " <code>false</code> "
+ "if decorations are to be enabled.</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:"
+ "</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd>"
+ "<a href=\"../pkg1/C1.html#readObject--\"><code>readObject()"
+ "</code></a></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span></dt>\n"
+ "<dd><code>java.io.IOException</code></dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:"
+ "</span></dt>\n"
+ "<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>");
checkOutput("pkg1/C2.html", expectFound,
"<dl>\n"
+ "<dt><span class=\"paramLabel\">Parameters:"
+ "</span></dt>\n"
+ "<dd><code>set</code> - boolean</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">"
+ "Since:</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "</dl>");
checkOutput("serialized-form.html", expectFound,
"<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span>"
+ "</dt>\n"
+ "<dd><code>"
+ "java.io.IOException</code></dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span>"
+ "</dt>\n"
+ "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>C1.setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n"
+ " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a>.</span></div>\n"
+ "<div class=\"block\">This field indicates whether the C1 is "
+ "undecorated.</div>\n"
+ "&nbsp;\n"
+ "<dl>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span>"
+ "</dt>\n"
+ "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>C1.setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n"
+ " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a>.</span></div>\n"
+ "<div class=\"block\">Reads the object stream.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:"
+ "</span></dt>\n"
+ "<dd><code><code>"
+ "IOException</code></code></dd>\n"
+ "<dd><code>java.io.IOException</code></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;</div>\n"
+ "<div class=\"block\">The name for this class.</div>");
}
void checkNoDeprecated() {
// Test with -nodeprecated option. The ClassDocs should have properly nested
// definition list tags enclosing comments and tags. The ClassDocs should not
// display definition list for deprecated information. The serialized form
// should display properly nested definition list tags for comments, tags
// and deprecated information.
checkOutput("pkg1/package-summary.html", true,
"<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>JDK1.0</dd>\n" +
"</dl>");
checkOutput("pkg1/C1.html", true,
"<dl>\n" + "<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span>" + "<dt><span class=\"simpleTagLabel\">Since:</span>" +
"</dt>\n" + "</dt>\n" +
@ -191,216 +282,124 @@ public class TestHtmlDefinitionListTag extends JavadocTester {
"<code>C2</code></a>, \n" + "<code>C2</code></a>, \n" +
"<a href=\"../serialized-form.html#pkg1.C1\">" + "<a href=\"../serialized-form.html#pkg1.C1\">" +
"Serialized Form</a></dd>\n" + "Serialized Form</a></dd>\n" +
"</dl>"}, "</dl>");
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:" +
"</span></dt>\n" +
"<dd><code>title</code> - the title</dd>\n" +
"<dd><code>" +
"test</code> - boolean value</dd>\n" +
"<dt><span class=\"throwsLabel\">Throws:" +
"</span></dt>\n" +
"<dd><code>java.lang.IllegalArgumentException" +
"</code> - if the <code>owner</code>'s\n" +
" <code>GraphicsConfiguration" +
"</code> is not from a screen device</dd>\n" +
"<dd><code>" +
"HeadlessException</code></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"paramLabel\">Parameters:" +
"</span></dt>\n" +
"<dd><code>undecorated</code> - <code>true</code>" +
" if no decorations are\n" +
" to be enabled;\n" +
" <code>false</code> if decorations are to be enabled." +
"</dd>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>1.4</dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd><a href=\"../pkg1/C1.html#readObject--\">" +
"<code>readObject()</code></a></dd>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:</span>" +
"</dt>\n" +
"<dd><code>java.io.IOException</code></dd>\n" +
"<dt>" +
"<span class=\"seeLabel\">See Also:</span></dt>\n" +
"<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:</span>" +
"</dt>\n" +
"<dd><code>" +
"java.io.IOException</code></dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span>" +
"</dt>\n" +
"<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>C1.setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a>.</span></div>\n" +
"<div class=\"block\">This field indicates whether the C1 is " +
"undecorated.</div>\n" +
"&nbsp;\n" +
"<dl>\n" +
"<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n" +
"<dd>1.4</dd>\n" +
"<dt><span class=\"seeLabel\">See Also:</span>" +
"</dt>\n" +
"<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>C1.setUndecorated(boolean)</code></a></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a>.</span></div>\n" +
"<div class=\"block\">Reads the object stream.</div>\n" +
"<dl>\n" +
"<dt><span class=\"throwsLabel\">Throws:" +
"</span></dt>\n" +
"<dd><code><code>" +
"IOException</code></code></dd>\n" +
"<dd><code>java.io.IOException</code></dd>\n" +
"</dl>"},
{ "serialized-form.html",
"<span class=\"deprecatedLabel\">Deprecated.</span>" +
"&nbsp;</div>\n" +
"<div class=\"block\">" +
"The name for this class.</div>"}};
// Test with -nocomment and -nodeprecated options. The ClassDocs whould checkOutput("pkg1/C1.html", true,
// not display definition lists for any member details. "<dl>\n"
private static final String[][] TEST_NOCMNT_NODEPR = { + "<dt><span class=\"paramLabel\">Parameters:"
{ "pkg1/C1.html", + "</span></dt>\n"
+ "<dd><code>title</code> - the title</dd>\n"
+ "<dd><code>"
+ "test</code> - boolean value</dd>\n"
+ "<dt><span class=\"throwsLabel\">Throws:"
+ "</span></dt>\n"
+ "<dd><code>java.lang.IllegalArgumentException"
+ "</code> - if the <code>owner</code>'s\n"
+ " <code>GraphicsConfiguration"
+ "</code> is not from a screen device</dd>\n"
+ "<dd><code>"
+ "HeadlessException</code></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"paramLabel\">Parameters:"
+ "</span></dt>\n"
+ "<dd><code>undecorated</code> - <code>true</code>"
+ " if no decorations are\n"
+ " to be enabled;\n"
+ " <code>false</code> if decorations are to be enabled."
+ "</dd>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg1/C1.html#readObject--\">"
+ "<code>readObject()</code></a></dd>\n"
+ "</dl>",
"<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span>"
+ "</dt>\n"
+ "<dd><code>java.io.IOException</code></dd>\n"
+ "<dt>"
+ "<span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>");
checkOutput("serialized-form.html", true,
"<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:</span>"
+ "</dt>\n"
+ "<dd><code>"
+ "java.io.IOException</code></dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span>"
+ "</dt>\n"
+ "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>C1.setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n"
+ " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a>.</span></div>\n"
+ "<div class=\"block\">This field indicates whether the C1 is "
+ "undecorated.</div>\n"
+ "&nbsp;\n"
+ "<dl>\n"
+ "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
+ "<dd>1.4</dd>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span>"
+ "</dt>\n"
+ "<dd><a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>C1.setUndecorated(boolean)</code></a></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n"
+ " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">"
+ "<code>setUndecorated(boolean)</code></a>.</span></div>\n"
+ "<div class=\"block\">Reads the object stream.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"throwsLabel\">Throws:"
+ "</span></dt>\n"
+ "<dd><code><code>"
+ "IOException</code></code></dd>\n"
+ "<dd><code>java.io.IOException</code></dd>\n"
+ "</dl>",
"<span class=\"deprecatedLabel\">Deprecated.</span>"
+ "&nbsp;</div>\n"
+ "<div class=\"block\">"
+ "The name for this class.</div>");
}
void checkNoCommentNoDeprecated(boolean expectFound) {
// Test with -nocomment and -nodeprecated options. The ClassDocs whould
// not display definition lists for any member details.
checkOutput("pkg1/C1.html", expectFound,
"<pre>public&nbsp;void&nbsp;readObject()\n" + "<pre>public&nbsp;void&nbsp;readObject()\n" +
" throws java.io.IOException</pre>\n" + " throws java.io.IOException</pre>\n" +
"</li>"}, "</li>");
{ "pkg1/C2.html", "<pre>public&nbsp;C2()</pre>\n" +
"</li>"}, checkOutput("pkg1/C2.html", expectFound,
{ "pkg1/C1.ModalExclusionType.html", "<pre>public " + "<pre>public&nbsp;C2()</pre>\n" +
"</li>");
checkOutput("pkg1/C1.ModalExclusionType.html", expectFound,
"<pre>public " +
"static final&nbsp;<a href=\"../pkg1/C1.ModalExclusionType.html\" " + "static final&nbsp;<a href=\"../pkg1/C1.ModalExclusionType.html\" " +
"title=\"enum in pkg1\">C1.ModalExclusionType</a> " + "title=\"enum in pkg1\">C1.ModalExclusionType</a> " +
"APPLICATION_EXCLUDE</pre>\n" + "APPLICATION_EXCLUDE</pre>\n" +
"</li>"}, "</li>");
{ "serialized-form.html", "<pre>boolean " +
checkOutput("serialized-form.html", expectFound,
"<pre>boolean " +
"undecorated</pre>\n" + "undecorated</pre>\n" +
"<div class=\"block\"><span class=\"deprecatedLabel\">" + "<div class=\"block\"><span class=\"deprecatedLabel\">" +
"Deprecated.</span>&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" + "Deprecated.</span>&nbsp;<span class=\"deprecationComment\">As of JDK version 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\"><code>" + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\"><code>" +
"setUndecorated(boolean)</code></a>.</span></div>\n" + "setUndecorated(boolean)</code></a>.</span></div>\n" +
"</li>"}, "</li>",
{ "serialized-form.html", "<span class=\"deprecatedLabel\">" + "<span class=\"deprecatedLabel\">" +
"Deprecated.</span>&nbsp;<span class=\"deprecationComment\">As of JDK version" + "Deprecated.</span>&nbsp;<span class=\"deprecationComment\">As of JDK version" +
" 1.5, replaced by\n" + " 1.5, replaced by\n" +
" <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" + " <a href=\"pkg1/C1.html#setUndecorated-boolean-\">" +
"<code>setUndecorated(boolean)</code></a>.</span></div>\n" + "<code>setUndecorated(boolean)</code></a>.</span></div>\n" +
"</li>"}}; "</li>");
// Test for valid HTML generation which should not comprise of empty
// definition list tags.
private static final String[][] NEGATED_TEST_NO_C5 = {
{ "pkg1/package-summary.html",
"<dl></dl>"},
{ "pkg1/package-summary.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C1.html",
"<dl></dl>"},
{ "pkg1/C1.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C1.ModalExclusionType.html",
"<dl></dl>"},
{ "pkg1/C1.ModalExclusionType.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C2.html",
"<dl></dl>"},
{ "pkg1/C2.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C2.ModalType.html",
"<dl></dl>"},
{ "pkg1/C2.ModalType.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C3.html",
"<dl></dl>"},
{ "pkg1/C3.html",
"<dl>\n" +
"</dl>"},
{ "pkg1/C4.html",
"<dl></dl>"},
{ "pkg1/C4.html",
"<dl>\n" +
"</dl>"},
{ "overview-tree.html",
"<dl></dl>"},
{ "overview-tree.html",
"<dl>\n" +
"</dl>"},
{ "serialized-form.html",
"<dl></dl>"},
{ "serialized-form.html",
"<dl>\n" +
"</dl>"}};
private static final String[][] NEGATED_TEST_C5 = {
{ "pkg1/C5.html",
"<dl></dl>"},
{ "pkg1/C5.html",
"<dl>\n" +
"</dl>"}};
private static final String[] ARGS1 =
new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS2 =
new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR + "-2", "-nocomment", "-sourcepath",
SRC_DIR, "pkg1"};
private static final String[] ARGS3 =
new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR + "-3", "-nodeprecated", "-sourcepath",
SRC_DIR, "pkg1"};
private static final String[] ARGS4 =
new String[] {
"-Xdoclint:none", "-d", OUTPUT_DIR + "-4", "-nocomment", "-nodeprecated",
"-sourcepath", SRC_DIR, "pkg1"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag();
tester.run(ARGS1, TEST_ALL, NEGATED_TEST_NO_C5);
tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
tester.runTestsOnHTML(TEST_CMNT_DEPR, NO_TEST);
tester.run(ARGS2, TEST_ALL, NEGATED_TEST_NO_C5);
tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
tester.runTestsOnHTML(NO_TEST, TEST_CMNT_DEPR);
tester.run(ARGS3, TEST_ALL, NEGATED_TEST_NO_C5);
tester.runTestsOnHTML(TEST_NODEPR, TEST_NOCMNT_NODEPR);
tester.run(ARGS4, TEST_ALL, NEGATED_TEST_NO_C5);
tester.runTestsOnHTML(TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
tester.printSummary();
} }
} }

View file

@ -27,33 +27,38 @@
* @test * @test
* @bug 6851834 * @bug 6851834
* @summary This test verifies the HTML document generation for javadoc output. * @summary This test verifies the HTML document generation for javadoc output.
* @library ../lib
* @build JavadocTester
* @author Bhavesh Patel * @author Bhavesh Patel
* @build TestHtmlDocument
* @run main TestHtmlDocument * @run main TestHtmlDocument
*/ */
import java.io.*;
import com.sun.tools.doclets.formats.html.markup.*; import com.sun.tools.doclets.formats.html.markup.*;
/** /**
* The class reads each file, complete with newlines, into a string to easily * The class reads each file, complete with newlines, into a string to easily
* compare the existing markup with the generated markup. * compare the existing markup with the generated markup.
*/ */
public class TestHtmlDocument { public class TestHtmlDocument extends JavadocTester {
protected static final String NL = System.getProperty("line.separator");
private static final String BUGID = "6851834";
private static final String BUGNAME = "TestHtmlDocument";
private static String srcdir = System.getProperty("test.src", ".");
// Entry point // Entry point
public static void main(String[] args) throws IOException { public static void main(String... args) throws Exception {
TestHtmlDocument tester = new TestHtmlDocument();
tester.runTests();
}
@Test
void test() {
checking("markup");
// Check whether the generated markup is same as the existing markup. // Check whether the generated markup is same as the existing markup.
if (generateHtmlTree().equals(readFileToString(srcdir + "/testMarkup.html"))) { String expected = readFile(testSrc, "testMarkup.html").replace("\n", NL);
System.out.println("\nTest passed for bug " + BUGID + " (" + BUGNAME + ")\n"); String actual = generateHtmlTree();
if (actual.equals(expected)) {
passed("");
} else { } else {
throw new Error("\nTest failed for bug " + BUGID + " (" + BUGNAME + ")\n"); failed("expected content in " + testSrc("testMarkup.html") + "\n"
+ "Actual output:\n"
+ actual);
} }
} }
@ -136,25 +141,4 @@ public class TestHtmlDocument {
HtmlDocument htmlDoc = new HtmlDocument(htmlDocType, html); HtmlDocument htmlDoc = new HtmlDocument(htmlDocType, html);
return htmlDoc.toString(); return htmlDoc.toString();
} }
// Read the file into a String
public static String readFileToString(String filename) throws IOException {
File file = new File(filename);
if ( !file.exists() ) {
System.out.println("\nFILE DOES NOT EXIST: " + filename);
}
BufferedReader in = new BufferedReader(new FileReader(file));
StringBuilder fileString = new StringBuilder();
// Create an array of characters the size of the file
try {
String line;
while ((line = in.readLine()) != null) {
fileString.append(line);
fileString.append(NL);
}
} finally {
in.close();
}
return fileString.toString();
}
} }

View file

@ -26,44 +26,49 @@
/* /*
* @test * @test
* @bug 6786028 8026567 * @bug 6786028 8026567
* @summary This test verifys the use of <strong> HTML tag instead of <B> by Javadoc std doclet. * @summary This test verifies the use of <strong> HTML tag instead of <B> by Javadoc std doclet.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHtmlStrongTag
* @run main TestHtmlStrongTag * @run main TestHtmlStrongTag
*/ */
public class TestHtmlStrongTag extends JavadocTester { public class TestHtmlStrongTag extends JavadocTester {
private static final String[][] TEST1 = { public static void main(String... args) throws Exception {
{ "pkg1/C1.html",
"<span class=\"seeLabel\">See Also:</span>"}};
private static final String[][] NEGATED_TEST1 = {
{ "pkg1/C1.html", "<STRONG>Method Summary</STRONG>"},
{ "pkg1/C1.html", "<B>"},
{ "pkg1/package-summary.html",
"<STRONG>Class Summary</STRONG>"}};
private static final String[][] TEST2 = {
{ "pkg2/C2.html", "<B>Comments:</B>"}};
private static final String[][] NEGATED_TEST2 = {
{ "pkg2/C2.html", "<STRONG>Method Summary</STRONG>"}};
private static final String[] ARGS1 =
new String[] {
"-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS2 =
new String[] {
"-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "pkg2"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHtmlStrongTag tester = new TestHtmlStrongTag(); TestHtmlStrongTag tester = new TestHtmlStrongTag();
tester.run(ARGS1, TEST1, NEGATED_TEST1); tester.runTests();
tester.run(ARGS2, TEST2, NEGATED_TEST2); }
tester.printSummary();
@Test
void test1() {
javadoc("-d", "out-1",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkOutput("pkg1/C1.html", true,
"<span class=\"seeLabel\">See Also:</span>");
checkOutput("pkg1/C1.html", false,
"<STRONG>Method Summary</STRONG>",
"<B>");
checkOutput("pkg1/package-summary.html", false,
"<STRONG>Class Summary</STRONG>");
}
@Test
void test2() {
javadoc("-d", "out-2",
"-sourcepath", testSrc,
"pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/C2.html", true,
"<B>Comments:</B>");
checkOutput("pkg2/C2.html", false,
"<STRONG>Method Summary</STRONG>");
} }
} }

View file

@ -26,69 +26,59 @@
* @bug 8008164 * @bug 8008164
* @summary Test styles on HTML tables generated by javadoc. * @summary Test styles on HTML tables generated by javadoc.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester TestHtmlTableStyles * @build JavadocTester
* @run main TestHtmlTableStyles * @run main TestHtmlTableStyles
*/ */
public class TestHtmlTableStyles extends JavadocTester { public class TestHtmlTableStyles extends JavadocTester {
//Input for string search tests. public static void main(String... args) throws Exception {
private static final String[][] TEST = { TestHtmlTableStyles tester = new TestHtmlTableStyles();
{ "pkg1/TestTable.html", tester.runTests();
"<table border cellpadding=3 cellspacing=1>" }
},
{ "pkg1/TestTable.html", @Test
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " + void test() {
"cellspacing=\"0\" summary=\"Field Summary table, listing fields, " + javadoc("-d", "out",
"and an explanation\">" "-sourcepath", testSrc,
}, "-use",
{ "pkg1/TestTable.html", "pkg1", "pkg2");
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " + checkExit(Exit.OK);
"cellspacing=\"0\" summary=\"Constructor Summary table, listing " +
"constructors, and an explanation\">" checkOutput("pkg1/TestTable.html", true,
}, "<table border cellpadding=3 cellspacing=1>",
{ "pkg1/TestTable.html", "<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " + + "cellspacing=\"0\" summary=\"Field Summary table, listing fields, "
"cellspacing=\"0\" summary=\"Method Summary table, listing methods, " + + "and an explanation\">",
"and an explanation\">" "<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
}, + "cellspacing=\"0\" summary=\"Constructor Summary table, listing "
{ "pkg1/package-summary.html", + "constructors, and an explanation\">",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\" " + "<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
"cellspacing=\"0\" summary=\"Class Summary table, listing classes, " + + "cellspacing=\"0\" summary=\"Method Summary table, listing methods, "
"and an explanation\">" + "and an explanation\">");
},
{ "pkg1/class-use/TestTable.html", checkOutput("pkg1/package-summary.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" " + "<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\" "
"cellspacing=\"0\" summary=\"Use table, listing fields, and an explanation\">" + "cellspacing=\"0\" summary=\"Class Summary table, listing classes, "
}, + "and an explanation\">");
{ "overview-summary.html",
"<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " + checkOutput("pkg1/class-use/TestTable.html", true,
"cellspacing=\"0\" summary=\"Packages table, listing packages, and an explanation\">" "<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" "
}, + "cellspacing=\"0\" summary=\"Use table, listing fields, and an explanation\">");
{ "deprecated-list.html",
checkOutput("overview-summary.html", true,
"<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Packages table, listing packages, and an explanation\">");
checkOutput("deprecated-list.html", true,
"<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" " + "<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Deprecated Methods table, listing " + "cellspacing=\"0\" summary=\"Deprecated Methods table, listing " +
"deprecated methods, and an explanation\">" "deprecated methods, and an explanation\">");
},
{ "constant-values.html", checkOutput("constant-values.html", true,
"<table class=\"constantsSummary\" border=\"0\" cellpadding=\"3\" " + "<table class=\"constantsSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Constant Field Values table, listing " + "cellspacing=\"0\" summary=\"Constant Field Values table, listing " +
"constant fields, and values\">" "constant fields, and values\">");
},
};
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception {
TestHtmlTableStyles tester = new TestHtmlTableStyles();
tester.run(ARGS, TEST, NO_TEST);
tester.printSummary();
} }
} }

View file

@ -26,9 +26,8 @@
* @bug 6786688 8008164 * @bug 6786688 8008164
* @summary HTML tables should have table summary, caption and table headers. * @summary HTML tables should have table summary, caption and table headers.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHtmlTableTags
* @run main TestHtmlTableTags * @run main TestHtmlTableTags
*/ */
@ -36,400 +35,350 @@ public class TestHtmlTableTags extends JavadocTester {
//Javadoc arguments. //Javadoc arguments.
private static final String[] ARGS = new String[] { private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
}; };
//Input for string tests for HTML table tags.
private static final String[][] TABLE_TAGS_TEST = {
/*
* Test for validating summary for HTML tables
*/
//Package summary public static void main(String... args) throws Exception {
{ "pkg1/package-summary.html",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\"" +
" cellspacing=\"0\" summary=\"Class Summary table, " +
"listing classes, and an explanation\">"
},
{ "pkg1/package-summary.html",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\"" +
" cellspacing=\"0\" summary=\"Interface Summary table, " +
"listing interfaces, and an explanation\">"
},
{ "pkg2/package-summary.html",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\"" +
" cellspacing=\"0\" summary=\"Enum Summary table, " +
"listing enums, and an explanation\">"
},
{ "pkg2/package-summary.html",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\"" +
" cellspacing=\"0\" summary=\"Annotation Types Summary table, " +
"listing annotation types, and an explanation\">"
},
// Class documentation
{ "pkg1/C1.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Field Summary table, listing fields, " +
"and an explanation\">"
},
{ "pkg1/C1.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Method Summary table, listing methods, " +
"and an explanation\">"
},
{ "pkg2/C2.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Nested Class Summary table, listing " +
"nested classes, and an explanation\">"
},
{ "pkg2/C2.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Constructor Summary table, listing " +
"constructors, and an explanation\">"
},
{ "pkg2/C2.ModalExclusionType.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Enum Constant Summary table, listing " +
"enum constants, and an explanation\">"
},
{ "pkg2/C3.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Required Element Summary table, " +
"listing required elements, and an explanation\">"
},
{ "pkg2/C4.html",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Optional Element Summary table, " +
"listing optional elements, and an explanation\">"
},
// Class use documentation
{ "pkg1/class-use/I1.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing packages, and an explanation\">"
},
{ "pkg1/class-use/C1.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing fields, and an explanation\">"
},
{ "pkg1/class-use/C1.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing methods, and an explanation\">"
},
{ "pkg2/class-use/C2.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing fields, and an explanation\">"
},
{ "pkg2/class-use/C2.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing methods, and an explanation\">"
},
{ "pkg2/class-use/C2.ModalExclusionType.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing packages, and an explanation\">"
},
{ "pkg2/class-use/C2.ModalExclusionType.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing methods, and an explanation\">"
},
// Package use documentation
{ "pkg1/package-use.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing packages, and an explanation\">"
},
{ "pkg1/package-use.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing classes, and an explanation\">"
},
{ "pkg2/package-use.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing packages, and an explanation\">"
},
{ "pkg2/package-use.html",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
"table, listing classes, and an explanation\">"
},
// Deprecated
{ "deprecated-list.html",
"<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
"summary=\"Deprecated Fields table, listing deprecated fields, " +
"and an explanation\">"
},
{ "deprecated-list.html",
"<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
"summary=\"Deprecated Methods table, listing deprecated methods, " +
"and an explanation\">"
},
// Constant values
{ "constant-values.html",
"<table class=\"constantsSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
"summary=\"Constant Field Values table, listing " +
"constant fields, and values\">"
},
// Overview Summary
{ "overview-summary.html",
"<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
"cellspacing=\"0\" summary=\"Packages table, " +
"listing packages, and an explanation\">"
},
/*
* Test for validating caption for HTML tables
*/
//Package summary
{ "pkg1/package-summary.html",
"<caption><span>Class Summary</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg1/package-summary.html",
"<caption><span>Interface Summary</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg2/package-summary.html",
"<caption><span>Enum Summary</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg2/package-summary.html",
"<caption><span>Annotation Types Summary</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
// Class documentation
{ "pkg1/C1.html",
"<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg1/C1.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
"Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
"Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
"Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
"Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
"</caption>"
},
{ "pkg2/C2.html",
"<caption><span>Nested Classes</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg2/C2.html",
"<caption><span>Constructors</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg2/C2.ModalExclusionType.html",
"<caption><span>Enum Constants</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg2/C3.html",
"<caption><span>Required Elements</span><span class=\"tabEnd\">&nbsp;" +
"</span></caption>"
},
{ "pkg2/C4.html",
"<caption><span>Optional Elements</span><span class=\"tabEnd\">&nbsp;" +
"</span></caption>"
},
// Class use documentation
{ "pkg1/class-use/I1.html",
"<caption><span>Packages that use <a href=\"../../pkg1/I1.html\" " +
"title=\"interface in pkg1\">I1</a></span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg1/class-use/C1.html",
"<caption><span>Fields in <a href=\"../../pkg2/package-summary.html\">" +
"pkg2</a> declared as <a href=\"../../pkg1/C1.html\" " +
"title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">&nbsp;" +
"</span></caption>"
},
{ "pkg1/class-use/C1.html",
"<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">" +
"pkg2</a> that return <a href=\"../../pkg1/C1.html\" " +
"title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg2/class-use/C2.html",
"<caption><span>Fields in <a href=\"../../pkg1/package-summary.html\">" +
"pkg1</a> declared as <a href=\"../../pkg2/C2.html\" " +
"title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg2/class-use/C2.html",
"<caption><span>Methods in <a href=\"../../pkg1/package-summary.html\">" +
"pkg1</a> that return <a href=\"../../pkg2/C2.html\" " +
"title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "pkg2/class-use/C2.ModalExclusionType.html",
"<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">" +
"pkg2</a> that return <a href=\"../../pkg2/C2.ModalExclusionType.html\" " +
"title=\"enum in pkg2\">C2.ModalExclusionType</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></caption>"
},
// Package use documentation
{ "pkg1/package-use.html",
"<caption><span>Packages that use <a href=\"../pkg1/package-summary.html\">" +
"pkg1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg1/package-use.html",
"<caption><span>Classes in <a href=\"../pkg1/package-summary.html\">" +
"pkg1</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>" +
"</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg2/package-use.html",
"<caption><span>Packages that use <a href=\"../pkg2/package-summary.html\">" +
"pkg2</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
{ "pkg2/package-use.html",
"<caption><span>Classes in <a href=\"../pkg2/package-summary.html\">" +
"pkg2</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>" +
"</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
// Deprecated
{ "deprecated-list.html",
"<caption><span>Deprecated Fields</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
{ "deprecated-list.html",
"<caption><span>Deprecated Methods</span><span class=\"tabEnd\">" +
"&nbsp;</span></caption>"
},
// Constant values
{ "constant-values.html",
"<caption><span>pkg1.<a href=\"pkg1/C1.html\" title=\"class in pkg1\">" +
"C1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
// Overview Summary
{ "overview-summary.html",
"<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>"
},
/*
* Test for validating headers for HTML tables
*/
//Package summary
{ "pkg1/package-summary.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Class</th>\n" +
"<th class=\"colLast\" scope=\"col\"" +
">Description</th>"
},
{ "pkg1/package-summary.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Interface</th>\n" +
"<th class=\"colLast\" scope=\"col\"" +
">Description</th>"
},
{ "pkg2/package-summary.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Enum</th>\n" +
"<th class=\"colLast\" scope=\"col\"" +
">Description</th>"
},
{ "pkg2/package-summary.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Annotation Type</th>\n" +
"<th class=\"colLast\"" +
" scope=\"col\">Description</th>"
},
// Class documentation
{ "pkg1/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Field and Description</th>"
},
{ "pkg1/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Method and Description</th>"
},
{ "pkg2/C2.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Class and Description</th>"
},
{ "pkg2/C2.html",
"<th class=\"colOne\" scope=\"col\">Constructor and Description</th>"
},
{ "pkg2/C2.ModalExclusionType.html",
"<th class=\"colOne\" scope=\"col\">Enum Constant and Description</th>"
},
{ "pkg2/C3.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Required Element and Description</th>"
},
{ "pkg2/C4.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Optional Element and Description</th>"
},
// Class use documentation
{ "pkg1/class-use/I1.html",
"<th class=\"colFirst\" scope=\"col\">Package</th>\n" +
"<th class=\"colLast\" scope=\"col\">Description</th>"
},
{ "pkg1/class-use/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Field and Description</th>"
},
{ "pkg1/class-use/C1.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Method and Description</th>"
},
{ "pkg2/class-use/C2.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Field and Description</th>"
},
{ "pkg2/class-use/C2.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Method and Description</th>"
},
{ "pkg2/class-use/C2.ModalExclusionType.html",
"<th class=\"colFirst\" scope=\"col\">Package</th>\n" +
"<th class=\"colLast\" scope=\"col\">Description</th>"
},
{ "pkg2/class-use/C2.ModalExclusionType.html",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" +
"<th class=\"colLast\" scope=\"col\">Method and Description</th>"
},
// Package use documentation
{ "pkg1/package-use.html",
"<th class=\"colFirst\" scope=\"col\">Package</th>\n" +
"<th class=\"colLast\" scope=\"col\">Description</th>"
},
{ "pkg1/package-use.html",
"<th class=\"colOne\" scope=\"col\">Class and Description</th>"
},
{ "pkg2/package-use.html",
"<th class=\"colFirst\" scope=\"col\">Package</th>\n" +
"<th class=\"colLast\" scope=\"col\">Description</th>"
},
{ "pkg2/package-use.html",
"<th class=\"colOne\" scope=\"col\">Class and Description</th>"
},
// Deprecated
{ "deprecated-list.html",
"<th class=\"colOne\" scope=\"col\">Field and Description</th>"
},
{ "deprecated-list.html",
"<th class=\"colOne\" scope=\"col\">Method and Description</th>"
},
// Constant values
{ "constant-values.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Modifier and Type</th>\n" +
"<th" +
" scope=\"col\">Constant Field</th>\n" +
"<th class=\"colLast\" scope=\"col\">Value</th>"
},
// Overview Summary
{ "overview-summary.html",
"<th class=\"colFirst\" scope=\"col\">" +
"Package</th>\n" +
"<th class=\"colLast\" scope=\"col\"" +
">Description</th>"
}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHtmlTableTags tester = new TestHtmlTableTags(); TestHtmlTableTags tester = new TestHtmlTableTags();
tester.run(ARGS, TABLE_TAGS_TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"-use",
"pkg1", "pkg2");
checkExit(Exit.OK);
checkHtmlTableSummaries();
checkHtmlTableCaptions();
checkHtmlTableHeaders();
}
/*
* Tests for validating summary for HTML tables
*/
void checkHtmlTableSummaries() {
//Package summary
checkOutput("pkg1/package-summary.html", true,
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\""
+ " cellspacing=\"0\" summary=\"Class Summary table, "
+ "listing classes, and an explanation\">",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\""
+ " cellspacing=\"0\" summary=\"Interface Summary table, "
+ "listing interfaces, and an explanation\">");
checkOutput("pkg2/package-summary.html", true,
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\""
+ " cellspacing=\"0\" summary=\"Enum Summary table, "
+ "listing enums, and an explanation\">",
"<table class=\"typeSummary\" border=\"0\" cellpadding=\"3\""
+ " cellspacing=\"0\" summary=\"Annotation Types Summary table, "
+ "listing annotation types, and an explanation\">");
// Class documentation
checkOutput("pkg1/C1.html", true,
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Field Summary table, listing fields, "
+ "and an explanation\">",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Method Summary table, listing methods, "
+ "and an explanation\">");
checkOutput("pkg2/C2.html", true,
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Nested Class Summary table, listing "
+ "nested classes, and an explanation\">",
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Constructor Summary table, listing "
+ "constructors, and an explanation\">");
checkOutput("pkg2/C2.ModalExclusionType.html", true,
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Enum Constant Summary table, listing "
+ "enum constants, and an explanation\">");
checkOutput("pkg2/C3.html", true,
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Required Element Summary table, "
+ "listing required elements, and an explanation\">");
checkOutput("pkg2/C4.html", true,
"<table class=\"memberSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Optional Element Summary table, "
+ "listing optional elements, and an explanation\">");
// Class use documentation
checkOutput("pkg1/class-use/I1.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing packages, and an explanation\">");
checkOutput("pkg1/class-use/C1.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing fields, and an explanation\">",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing methods, and an explanation\">");
checkOutput("pkg2/class-use/C2.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing fields, and an explanation\">",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing methods, and an explanation\">");
checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing packages, and an explanation\">");
checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing methods, and an explanation\">");
// Package use documentation
checkOutput("pkg1/package-use.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing packages, and an explanation\">",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing classes, and an explanation\">");
checkOutput("pkg2/package-use.html", true,
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing packages, and an explanation\">",
"<table class=\"useSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use "
+ "table, listing classes, and an explanation\">");
// Deprecated
checkOutput("deprecated-list.html", true,
"<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" "
+ "summary=\"Deprecated Fields table, listing deprecated fields, "
+ "and an explanation\">",
"<table class=\"deprecatedSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" "
+ "summary=\"Deprecated Methods table, listing deprecated methods, "
+ "and an explanation\">");
// Constant values
checkOutput("constant-values.html", true,
"<table class=\"constantsSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" "
+ "summary=\"Constant Field Values table, listing "
+ "constant fields, and values\">");
// Overview Summary
checkOutput("overview-summary.html", true,
"<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" "
+ "cellspacing=\"0\" summary=\"Packages table, "
+ "listing packages, and an explanation\">");
}
/*
* Tests for validating caption for HTML tables
*/
void checkHtmlTableCaptions() {
//Package summary
checkOutput("pkg1/package-summary.html", true,
"<caption><span>Class Summary</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>",
"<caption><span>Interface Summary</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
checkOutput("pkg2/package-summary.html", true,
"<caption><span>Enum Summary</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>",
"<caption><span>Annotation Types Summary</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
// Class documentation
checkOutput("pkg1/C1.html", true,
"<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>All "
+ "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">"
+ "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">"
+ "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">"
+ "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
+ "</caption>");
checkOutput("pkg2/C2.html", true,
"<caption><span>Nested Classes</span><span class=\"tabEnd\">&nbsp;</span></caption>",
"<caption><span>Constructors</span><span class=\"tabEnd\">&nbsp;</span></caption>");
checkOutput("pkg2/C2.ModalExclusionType.html", true,
"<caption><span>Enum Constants</span><span class=\"tabEnd\">&nbsp;</span></caption>");
checkOutput("pkg2/C3.html", true,
"<caption><span>Required Elements</span><span class=\"tabEnd\">&nbsp;"
+ "</span></caption>");
checkOutput("pkg2/C4.html", true,
"<caption><span>Optional Elements</span><span class=\"tabEnd\">&nbsp;"
+ "</span></caption>");
// Class use documentation
checkOutput("pkg1/class-use/I1.html", true,
"<caption><span>Packages that use <a href=\"../../pkg1/I1.html\" "
+ "title=\"interface in pkg1\">I1</a></span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
checkOutput("pkg1/class-use/C1.html", true,
"<caption><span>Fields in <a href=\"../../pkg2/package-summary.html\">"
+ "pkg2</a> declared as <a href=\"../../pkg1/C1.html\" "
+ "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">&nbsp;"
+ "</span></caption>",
"<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">"
+ "pkg2</a> that return <a href=\"../../pkg1/C1.html\" "
+ "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
checkOutput("pkg2/class-use/C2.html", true,
"<caption><span>Fields in <a href=\"../../pkg1/package-summary.html\">"
+ "pkg1</a> declared as <a href=\"../../pkg2/C2.html\" "
+ "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>",
"<caption><span>Methods in <a href=\"../../pkg1/package-summary.html\">"
+ "pkg1</a> that return <a href=\"../../pkg2/C2.html\" "
+ "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
"<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">"
+ "pkg2</a> that return <a href=\"../../pkg2/C2.ModalExclusionType.html\" "
+ "title=\"enum in pkg2\">C2.ModalExclusionType</a></span>"
+ "<span class=\"tabEnd\">&nbsp;</span></caption>");
// Package use documentation
checkOutput("pkg1/package-use.html", true,
"<caption><span>Packages that use <a href=\"../pkg1/package-summary.html\">"
+ "pkg1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>",
"<caption><span>Classes in <a href=\"../pkg1/package-summary.html\">"
+ "pkg1</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>"
+ "</span><span class=\"tabEnd\">&nbsp;</span></caption>");
checkOutput("pkg2/package-use.html", true,
"<caption><span>Packages that use <a href=\"../pkg2/package-summary.html\">"
+ "pkg2</a></span><span class=\"tabEnd\">&nbsp;</span></caption>",
"<caption><span>Classes in <a href=\"../pkg2/package-summary.html\">"
+ "pkg2</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>"
+ "</span><span class=\"tabEnd\">&nbsp;</span></caption>");
// Deprecated
checkOutput("deprecated-list.html", true,
"<caption><span>Deprecated Fields</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>",
"<caption><span>Deprecated Methods</span><span class=\"tabEnd\">"
+ "&nbsp;</span></caption>");
// Constant values
checkOutput("constant-values.html", true,
"<caption><span>pkg1.<a href=\"pkg1/C1.html\" title=\"class in pkg1\">"
+ "C1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>");
// Overview Summary
checkOutput("overview-summary.html", true,
"<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
}
/*
* Test for validating headers for HTML tables
*/
void checkHtmlTableHeaders() {
//Package summary
checkOutput("pkg1/package-summary.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Class</th>\n"
+ "<th class=\"colLast\" scope=\"col\""
+ ">Description</th>",
"<th class=\"colFirst\" scope=\"col\">"
+ "Interface</th>\n"
+ "<th class=\"colLast\" scope=\"col\""
+ ">Description</th>");
checkOutput("pkg2/package-summary.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Enum</th>\n"
+ "<th class=\"colLast\" scope=\"col\""
+ ">Description</th>",
"<th class=\"colFirst\" scope=\"col\">"
+ "Annotation Type</th>\n"
+ "<th class=\"colLast\""
+ " scope=\"col\">Description</th>");
// Class documentation
checkOutput("pkg1/C1.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
checkOutput("pkg2/C2.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Class and Description</th>",
"<th class=\"colOne\" scope=\"col\">Constructor and Description</th>");
checkOutput("pkg2/C2.ModalExclusionType.html", true,
"<th class=\"colOne\" scope=\"col\">Enum Constant and Description</th>");
checkOutput("pkg2/C3.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Required Element and Description</th>");
checkOutput("pkg2/C4.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Optional Element and Description</th>");
// Class use documentation
checkOutput("pkg1/class-use/I1.html", true,
"<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>");
checkOutput("pkg1/class-use/C1.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
checkOutput("pkg2/class-use/C2.html", true,
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
"<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>",
"<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
// Package use documentation
checkOutput("pkg1/package-use.html", true,
"<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>",
"<th class=\"colOne\" scope=\"col\">Class and Description</th>");
checkOutput("pkg2/package-use.html", true,
"<th class=\"colFirst\" scope=\"col\">Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Description</th>",
"<th class=\"colOne\" scope=\"col\">Class and Description</th>");
// Deprecated
checkOutput("deprecated-list.html", true,
"<th class=\"colOne\" scope=\"col\">Field and Description</th>",
"<th class=\"colOne\" scope=\"col\">Method and Description</th>");
// Constant values
checkOutput("constant-values.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Modifier and Type</th>\n"
+ "<th"
+ " scope=\"col\">Constant Field</th>\n"
+ "<th class=\"colLast\" scope=\"col\">Value</th>");
// Overview Summary
checkOutput("overview-summary.html", true,
"<th class=\"colFirst\" scope=\"col\">"
+ "Package</th>\n"
+ "<th class=\"colLast\" scope=\"col\""
+ ">Description</th>");
} }
} }

View file

@ -28,9 +28,8 @@
* @bug 6786682 * @bug 6786682
* @summary This test verifies the use of lang attribute by <HTML>. * @summary This test verifies the use of lang attribute by <HTML>.
* @author Bhavesh Patel * @author Bhavesh Patel
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestHtmlTag
* @run main TestHtmlTag * @run main TestHtmlTag
*/ */
@ -38,43 +37,65 @@ import java.util.Locale;
public class TestHtmlTag extends JavadocTester { public class TestHtmlTag extends JavadocTester {
private static final String[][] TEST1 = { public static void main(String... args) throws Exception {
{ "pkg1/C1.html",
"<html lang=\"" + Locale.getDefault().getLanguage() + "\">"},
{ "pkg1/package-summary.html",
"<html lang=\"" + Locale.getDefault().getLanguage() + "\">"}};
private static final String[][] NEGATED_TEST1 = {
{ "pkg1/C1.html", "<html>"}};
private static final String[][] TEST2 = {
{ "pkg2/C2.html", "<html lang=\"ja\">"},
{ "pkg2/package-summary.html", "<html lang=\"ja\">"}};
private static final String[][] NEGATED_TEST2 = {
{ "pkg2/C2.html", "<html>"}};
private static final String[][] TEST3 = {
{ "pkg1/C1.html", "<html lang=\"en\">"},
{ "pkg1/package-summary.html", "<html lang=\"en\">"}};
private static final String[][] NEGATED_TEST3 = {
{ "pkg1/C1.html", "<html>"}};
private static final String[] ARGS1 =
new String[] {
"-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS2 =
new String[] {
"-locale", "ja", "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "pkg2"};
private static final String[] ARGS3 =
new String[] {
"-locale", "en_US", "-d", OUTPUT_DIR + "-3", "-sourcepath", SRC_DIR, "pkg1"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestHtmlTag tester = new TestHtmlTag(); TestHtmlTag tester = new TestHtmlTag();
tester.run(ARGS1, TEST1, NEGATED_TEST1); tester.runTests();
tester.run(ARGS2, TEST2, NEGATED_TEST2); }
tester.run(ARGS3, TEST3, NEGATED_TEST3);
tester.printSummary(); @Test
void test_default() {
javadoc("-d", "out-default",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
String defaultLanguage = Locale.getDefault().getLanguage();
checkOutput("pkg1/C1.html", true,
"<html lang=\"" + defaultLanguage + "\">");
checkOutput("pkg1/package-summary.html", true,
"<html lang=\"" + defaultLanguage + "\">");
checkOutput("pkg1/C1.html", false,
"<html>");
}
@Test
void test_ja() {
// TODO: why does this test need/use pkg2; why can't it use pkg1
// like the other two tests, so that we can share the check methods?
javadoc("-locale", "ja",
"-d", "out-ja",
"-sourcepath", testSrc,
"pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/C2.html", true,
"<html lang=\"ja\">");
checkOutput("pkg2/package-summary.html", true,
"<html lang=\"ja\">");
checkOutput("pkg2/C2.html", false,
"<html>");
}
@Test
void test_en_US() {
javadoc("-locale", "en_US",
"-d", "out-en_US",
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.OK);
checkOutput("pkg1/C1.html", true,
"<html lang=\"en\">");
checkOutput("pkg1/package-summary.html", true,
"<html lang=\"en\">");
checkOutput("pkg1/C1.html", false,
"<html>");
} }
} }

View file

@ -25,37 +25,30 @@
* @test * @test
* @bug 8011288 * @bug 8011288
* @summary Erratic/inconsistent indentation of signatures * @summary Erratic/inconsistent indentation of signatures
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @run main TestIndentation * @run main TestIndentation
*/ */
public class TestIndentation extends JavadocTester { public class TestIndentation extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "p"
};
//Input for string search tests.
private static final String[][] TEST = {
{ "p/Indent.html",
"<pre>public&nbsp;&lt;T&gt;&nbsp;void&nbsp;m(T&nbsp;t1," },
{ "p/Indent.html",
"\n" +
" T&nbsp;t2)" },
{ "p/Indent.html",
"\n" +
" throws java.lang.Exception" }
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestIndentation tester = new TestIndentation(); TestIndentation tester = new TestIndentation();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"p");
checkExit(Exit.OK);
checkOutput("p/Indent.html", true,
"<pre>public&nbsp;&lt;T&gt;&nbsp;void&nbsp;m(T&nbsp;t1,",
"\n"
+ " T&nbsp;t2)",
"\n"
+ " throws java.lang.Exception");
} }
} }

View file

@ -28,64 +28,53 @@
* Also test that index-all.html has the appropriate output. * Also test that index-all.html has the appropriate output.
* Test for unnamed package in index. * Test for unnamed package in index.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestIndex
* @run main TestIndex * @run main TestIndex
*/ */
public class TestIndex extends JavadocTester { public class TestIndex extends JavadocTester {
//Javadoc arguments. public static void main(String... args) throws Exception {
private static final String[] ARGS = new String[] { TestIndex tester = new TestIndex();
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + "/NoPackage.java" tester.runTests();
}; }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg", testSrc("NoPackage.java"));
checkExit(Exit.OK);
//Input for string search tests.
private static final String[][] TEST = {
//Make sure the horizontal scroll bar does not appear in class frame. //Make sure the horizontal scroll bar does not appear in class frame.
{ "index.html", checkOutput("index.html", true,
"<frame src=\"overview-summary.html\" name=\"classFrame\" title=\"" + "<frame src=\"overview-summary.html\" name=\"classFrame\" title=\""
"Package, class and interface descriptions\" scrolling=\"yes\">"}, + "Package, class and interface descriptions\" scrolling=\"yes\">");
//Test index-all.html //Test index-all.html
{ "index-all.html", checkOutput("index-all.html", true,
"<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">C</span></a>" + "<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">C</span></a>"
" - Class in <a href=\"pkg/package-summary.html\">pkg</a>"}, + " - Class in <a href=\"pkg/package-summary.html\">pkg</a>",
{ "index-all.html", "<a href=\"pkg/Interface.html\" title=\"interface in pkg\">"
"<a href=\"pkg/Interface.html\" title=\"interface in pkg\">" + + "<span class=\"typeNameLink\">Interface</span></a> - Interface in "
"<span class=\"typeNameLink\">Interface</span></a> - Interface in " + + "<a href=\"pkg/package-summary.html\">pkg</a>",
"<a href=\"pkg/package-summary.html\">pkg</a>"}, "<a href=\"pkg/AnnotationType.html\" title=\"annotation in pkg\">"
{ "index-all.html", + "<span class=\"typeNameLink\">AnnotationType</span></a> - Annotation Type in "
"<a href=\"pkg/AnnotationType.html\" title=\"annotation in pkg\">" + + "<a href=\"pkg/package-summary.html\">pkg</a>",
"<span class=\"typeNameLink\">AnnotationType</span></a> - Annotation Type in " + "<a href=\"pkg/Coin.html\" title=\"enum in pkg\">"
"<a href=\"pkg/package-summary.html\">pkg</a>"}, + "<span class=\"typeNameLink\">Coin</span></a> - Enum in "
{ "index-all.html", + "<a href=\"pkg/package-summary.html\">pkg</a>",
"<a href=\"pkg/Coin.html\" title=\"enum in pkg\">" + "Class in <a href=\"package-summary.html\">&lt;Unnamed&gt;</a>",
"<span class=\"typeNameLink\">Coin</span></a> - Enum in " + "<dl>\n"
"<a href=\"pkg/package-summary.html\">pkg</a>"}, + "<dt><span class=\"memberNameLink\"><a href=\"pkg/C.html#Java\">"
{ "index-all.html", + "Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" "
"Class in <a href=\"package-summary.html\">&lt;Unnamed&gt;</a>"}, + "title=\"class in pkg\">C</a></dt>\n"
{ "index-all.html", + "<dd>&nbsp;</dd>\n"
"<dl>\n" + + "<dt><span class=\"memberNameLink\"><a href=\"pkg/C.html#JDK\">JDK</a></span> "
"<dt><span class=\"memberNameLink\"><a href=\"pkg/C.html#Java\">" + + "- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">"
"Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" " + + "C</a></dt>\n"
"title=\"class in pkg\">C</a></dt>\n" + + "<dd>&nbsp;</dd>\n"
"<dd>&nbsp;</dd>\n" + + "</dl>");
"<dt><span class=\"memberNameLink\"><a href=\"pkg/C.html#JDK\">JDK</a></span> " +
"- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">" +
"C</a></dt>\n" +
"<dd>&nbsp;</dd>\n" +
"</dl>"},
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestIndex tester = new TestIndex();
tester.run(ARGS, TEST, NO_TEST);
tester.printSummary();
} }
} }

View file

@ -26,34 +26,29 @@
* @bug 4524136 * @bug 4524136
* @summary Test to make sure label is used for inline links. * @summary Test to make sure label is used for inline links.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib
* @build JavadocTester * @build JavadocTester
* @build TestInlineLinkLabel
* @run main TestInlineLinkLabel * @run main TestInlineLinkLabel
*/ */
public class TestInlineLinkLabel extends JavadocTester { public class TestInlineLinkLabel extends JavadocTester {
private static final String[][] TEST = { public static void main(String... args) throws Exception {
//Search for the label to the package link.
{ "pkg/C1.html" ,
"<a href=\"../pkg/package-summary.html\"><code>Here is a link to a package</code></a>"},
//Search for the label to the class link
{ "pkg/C1.html" ,
"<a href=\"../pkg/C2.html\" title=\"class in pkg\"><code>Here is a link to a class</code></a>"}
};
private static final String[] ARGS =
new String[] {
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestInlineLinkLabel tester = new TestInlineLinkLabel(); TestInlineLinkLabel tester = new TestInlineLinkLabel();
tester.run(ARGS, TEST, NO_TEST); tester.runTests();
tester.printSummary(); }
@Test
void test() {
javadoc("-d", "out",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/C1.html", true,
//Search for the label to the package link.
"<a href=\"../pkg/package-summary.html\"><code>Here is a link to a package</code></a>",
//Search for the label to the class link
"<a href=\"../pkg/C2.html\" title=\"class in pkg\"><code>Here is a link to a class</code></a>");
} }
} }

Some files were not shown because too many files have changed in this diff Show more