diff --git a/langtools/make/netbeans/langtools/nbproject/project.properties b/langtools/make/netbeans/langtools/nbproject/project.properties index 31b5a412ac6..ea7ab7feb1b 100644 --- a/langtools/make/netbeans/langtools/nbproject/project.properties +++ b/langtools/make/netbeans/langtools/nbproject/project.properties @@ -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.indent-shift-width=4 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index c1da3347149..44d3275f502 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -878,8 +878,9 @@ public class Util { */ static abstract class DocComparator implements Comparator { /** - * compares two parameter arrays by first comparing the length of the arrays, and - * then each Type of the parameter in the array. + * compares two parameter arrays by comparing 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 params2 the first parameter array. * @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) { return 0; } - int result = Integer.compare(params1.length, params2.length); - if (result != 0) { - return result; - } - for (int i = 0; i < params1.length; i++) { - result = compareStrings(params1[i].typeName(), params2[i].typeName()); + // try to compare as many as possible + for (int i = 0; i < params1.length && i < params2.length; i++) { + int result = compareStrings(params1[i].typeName(), params2[i].typeName()); if (result != 0) { return result; } } - return 0; + return Integer.compare(params1.length, params2.length); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java index 14b238b2827..f2cff56cf65 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java @@ -118,7 +118,8 @@ public abstract class Attribute implements AnnotationValue { : types.erasure(type); return new Type.ClassType(types.syms.classType.getEnclosingType(), List.of(arg), - types.syms.classType.tsym); + types.syms.classType.tsym, + Type.noAnnotations); } public String toString() { return classType + ".class"; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java index 03019926c08..3309405ac5f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java @@ -28,7 +28,6 @@ package com.sun.tools.javac.code; import java.util.Locale; 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.Symbol.*; import com.sun.tools.javac.code.Type.*; @@ -150,14 +149,16 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi @Override public String visitCapturedType(CapturedType t, Locale locale) { if (seenCaptured.contains(t)) - return localize(locale, "compiler.misc.type.captureof.1", - capturedVarId(t, locale)); + return printAnnotations(t) + + localize(locale, "compiler.misc.type.captureof.1", + capturedVarId(t, locale)); else { try { seenCaptured = seenCaptured.prepend(t); - return localize(locale, "compiler.misc.type.captureof", - capturedVarId(t, locale), - visit(t.wildcard, locale)); + return printAnnotations(t) + + localize(locale, "compiler.misc.type.captureof", + capturedVarId(t, locale), + visit(t.wildcard, locale)); } finally { seenCaptured = seenCaptured.tail; @@ -167,15 +168,16 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi @Override 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 public String visitUndetVar(UndetVar t, Locale locale) { if (t.inst != null) { - return visit(t.inst, locale); + return printAnnotations(t) + visit(t.inst, locale); } else { - return visit(t.qtype, locale) + "?"; + return printAnnotations(t) + visit(t.qtype, locale) + "?"; } } @@ -187,25 +189,34 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi 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 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; while (arrel.hasTag(TypeTag.ARRAY)) { - arrel = arrel.unannotatedType(); arrel = ((ArrayType) arrel).elemtype; } 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; while (arrel.hasTag(TypeTag.ARRAY)) { - if (arrel.isAnnotated()) { - sb.append(' '); - sb.append(arrel.getAnnotationMirrors()); - sb.append(' '); - } + sb.append(printAnnotations(arrel, true)); sb.append("[]"); - arrel = arrel.unannotatedType(); arrel = ((ArrayType) arrel).elemtype; } } @@ -216,8 +227,10 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == Kinds.TYP) { buf.append(visit(t.getEnclosingType(), locale)); buf.append('.'); + buf.append(printAnnotations(t)); buf.append(className(t, false, locale)); } else { + buf.append(printAnnotations(t)); buf.append(className(t, true, locale)); } if (t.getTypeArguments().nonEmpty()) { @@ -230,7 +243,8 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi @Override 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 @@ -243,6 +257,7 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi StringBuilder s = new StringBuilder(); s.append(t.kind); if (t.kind != UNBOUND) { + s.append(printAnnotations(t)); s.append(visit(t.type, locale)); } return s.toString(); @@ -258,28 +273,6 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi 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) { String s = (t.tsym == null || t.tsym.name == null) ? localize(locale, "compiler.misc.type.none") @@ -345,8 +338,8 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi args = args.tail; buf.append(','); } - if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) { - buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); + if (args.head.hasTag(TypeTag.ARRAY)) { + buf.append(visit(((ArrayType) args.head).elemtype, locale)); if (args.head.getAnnotationMirrors().nonEmpty()) { buf.append(' '); buf.append(args.head.getAnnotationMirrors()); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index 9a07e3eaea0..35a6ea9b84a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -234,7 +234,7 @@ public enum Source { public boolean allowGraphInference() { return compareTo(JDK1_8) >= 0; } - public boolean allowStructuralMostSpecific() { + public boolean allowFunctionalInterfaceMostSpecific() { return compareTo(JDK1_8) >= 0; } public static SourceVersion toSourceVersion(Source source) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index f9980e52c6c..f76d7282c79 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -956,7 +956,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { this( flags, name, - new ClassType(Type.noType, null, null), + new ClassType(Type.noType, null, null, Type.noAnnotations), owner); this.type.tsym = this; } @@ -992,7 +992,8 @@ public abstract class Symbol extends AnnoConstruct implements Element { public Type erasure(Types types) { if (erasure_field == null) erasure_field = new ClassType(types.erasure(type.getEnclosingType()), - List.nil(), this); + List.nil(), this, + type.getAnnotationMirrors()); return erasure_field; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java index ecaeb86ff32..dba1b9cd2da 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java @@ -80,6 +80,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { /** Constant type: special type to be used for marking stuck trees. */ public static final JCNoType stuckType = new JCNoType(); + public static final List noAnnotations = + List.nil(); + /** If this switch is turned on, the names of type variables * and anonymous classes are printed with hashcodes appended. */ @@ -89,6 +92,10 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { */ public TypeSymbol tsym; + /** The type annotations on this type. + */ + protected final List annos; + /** * Checks if the current type tag is equal to the given 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 accept(Type.Visitor 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 annos) { + if(annos == null) { + Assert.error("Attempting to create type " + tsym + " with null type annotations"); + } + this.tsym = tsym; + this.annos = annos; } /** An abstract class for mappings from types to types @@ -225,25 +237,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return this; } - public Type annotatedType(List annos) { - return new AnnotatedType(annos, this); - } + public abstract Type annotatedType(List annos); public boolean isAnnotated() { - return false; - } - - /** - * If this is an annotated type, return the underlying type. - * Otherwise, return the type itself. - */ - public Type unannotatedType() { - return this; + return !annos.isEmpty(); } @Override public List getAnnotationMirrors() { - return List.nil(); + return annos; } @@ -272,16 +274,35 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { 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. */ public String toString() { - String s = (tsym == null || tsym.name == null) - ? "" - : tsym.name.toString(); - if (moreInfo && hasTag(TYPEVAR)) { - s = s + hashCode(); + StringBuilder sb = new StringBuilder(); + appendAnnotationsString(sb); + if (tsym == null || tsym.name == null) { + sb.append(""); + } 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; buf.append(','); } - if (args.head.unannotatedType().hasTag(ARRAY)) { - buf.append(((ArrayType)args.head.unannotatedType()).elemtype); + if (args.head.hasTag(ARRAY)) { + buf.append(((ArrayType)args.head).elemtype); if (args.head.getAnnotationMirrors().nonEmpty()) { buf.append(args.head.getAnnotationMirrors()); } @@ -486,11 +507,21 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { TypeTag tag; public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) { - super(tsym); + this(tag, tsym, noAnnotations); + } + + public JCPrimitiveType(TypeTag tag, TypeSymbol tsym, + List annos) { + super(tsym, annos); this.tag = tag; Assert.check(tag.isPrimitive); } + @Override + public Type annotatedType(List annos) { + return new JCPrimitiveType(tag, tsym, annos); + } + @Override public boolean isNumeric() { return tag != BOOLEAN; @@ -517,7 +548,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { @Override public Type constType(Object constValue) { final Object value = constValue; - return new JCPrimitiveType(tag, tsym) { + return new JCPrimitiveType(tag, tsym, annos) { @Override public Object constValue() { return value; @@ -601,19 +632,37 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) { - super(tsym); - this.type = Assert.checkNonNull(type); - this.kind = kind; - } - public WildcardType(WildcardType t, TypeVar bound) { - this(t.type, t.kind, t.tsym, bound); + this(type, kind, tsym, null, noAnnotations); } - public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, TypeVar bound) { - this(type, kind, tsym); + public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, + List annos) { + this(type, kind, tsym, null, annos); + } + + public WildcardType(WildcardType t, TypeVar bound, + List 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 annos) { + super(tsym, annos); + this.type = Assert.checkNonNull(type); + this.kind = kind; this.bound = bound; } + @Override + public WildcardType annotatedType(List annos) { + return new WildcardType(type, kind, tsym, bound, annos); + } + @Override public TypeTag getTag() { return WILDCARD; @@ -658,6 +707,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { boolean isPrintingBound = false; public String toString() { StringBuilder s = new StringBuilder(); + appendAnnotationsString(s); s.append(kind.toString()); if (kind != UNBOUND) s.append(type); @@ -679,7 +729,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { if (t == type) return this; else - return new WildcardType(t, kind, tsym, bound); + return new WildcardType(t, kind, tsym, bound, annos); } public Type getExtendsBound() { @@ -736,7 +786,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public List all_interfaces_field; public ClassType(Type outer, List typarams, TypeSymbol tsym) { - super(tsym); + this(outer, typarams, tsym, noAnnotations); + } + + public ClassType(Type outer, List typarams, TypeSymbol tsym, + List annos) { + super(tsym, annos); this.outer_field = outer; this.typarams_field = typarams; this.allparams_field = null; @@ -753,6 +808,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { */ } + @Override + public ClassType annotatedType(List 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 public TypeTag getTag() { return CLASS; @@ -765,7 +829,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public Type constType(Object constValue) { final Object value = constValue; - return new ClassType(getEnclosingType(), typarams_field, tsym) { + return new ClassType(getEnclosingType(), typarams_field, tsym, annos) { @Override public Object constValue() { return value; @@ -781,6 +845,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { */ public String toString() { StringBuilder buf = new StringBuilder(); + appendAnnotationsString(buf); if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { buf.append(getEnclosingType().toString()); buf.append("."); @@ -806,7 +871,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return s.toString(); } else if (sym.name.isEmpty()) { String s; - ClassType norm = (ClassType) tsym.type.unannotatedType(); + ClassType norm = (ClassType) tsym.type; if (norm == null) { s = Log.getLocalizedString("anonymous.class", (Object)null); } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { @@ -858,7 +923,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return getEnclosingType().isErroneous() || isErroneous(getTypeArguments()) || - this != tsym.type.unannotatedType() && tsym.type.isErroneous(); + this != tsym.type && tsym.type.isErroneous(); } public boolean isParameterized() { @@ -897,7 +962,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { List typarams = getTypeArguments(); List typarams1 = map(typarams, f); 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) { @@ -924,7 +989,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public static class ErasedClassType extends ClassType { public ErasedClassType(Type outer, TypeSymbol tsym) { - super(outer, List.nil(), tsym); + this(outer, tsym, noAnnotations); + } + + public ErasedClassType(Type outer, TypeSymbol tsym, + List annos) { + super(outer, List.nil(), tsym, annos); } @Override @@ -938,7 +1008,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { final List alternatives_field; public UnionClassType(ClassType ct, List 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; supertype_field = ct.supertype_field; interfaces_field = ct.interfaces_field; @@ -971,7 +1043,9 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public boolean allInterfaces; public IntersectionClassType(List bounds, ClassSymbol csym, boolean allInterfaces) { - super(Type.noType, List.nil(), csym); + // Presently no way to refer to this type directly, so we + // cannot put annotations directly on it. + super(Type.noType, List.nil(), csym, noAnnotations); this.allInterfaces = allInterfaces; Assert.check((csym.flags() & COMPOUND) != 0); supertype_field = bounds.head; @@ -1011,10 +1085,20 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public Type elemtype; public ArrayType(Type elemtype, TypeSymbol arrayClass) { - super(arrayClass); + this(elemtype, arrayClass, noAnnotations); + } + + public ArrayType(Type elemtype, TypeSymbol arrayClass, + List annos) { + super(arrayClass, annos); this.elemtype = elemtype; } + @Override + public ArrayType annotatedType(List annos) { + return new ArrayType(elemtype, tsym, annos); + } + @Override public TypeTag getTag() { return ARRAY; @@ -1025,7 +1109,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } 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) { @@ -1068,7 +1156,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } public ArrayType makeVarargs() { - return new ArrayType(elemtype, tsym) { + return new ArrayType(elemtype, tsym, annos) { @Override public boolean isVarargs() { return true; @@ -1079,7 +1167,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public Type map(Mapping f) { Type elemtype1 = f.apply(elemtype); if (elemtype1 == elemtype) return this; - else return new ArrayType(elemtype1, tsym); + else return new ArrayType(elemtype1, tsym, annos); } public boolean contains(Type elem) { @@ -1117,12 +1205,19 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { Type restype, List thrown, 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.restype = restype; this.thrown = thrown; } + @Override + public MethodType annotatedType(List annos) { + throw new AssertionError("Cannot annotate a method type"); + } + @Override public TypeTag getTag() { return METHOD; @@ -1138,7 +1233,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { * should be. */ 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 getParameterTypes() { return argtypes; } @@ -1197,7 +1298,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public static class PackageType extends Type implements NoType { PackageType(TypeSymbol tsym) { - super(tsym); + // Package types cannot be annotated + super(tsym, noAnnotations); + } + + @Override + public PackageType annotatedType(List annos) { + throw new AssertionError("Cannot annotate a package type"); } @Override @@ -1245,17 +1352,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public 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 annos) { + super(null, annos); tsym = new TypeVariableSymbol(0, name, this, owner); this.lower = lower; } - public TypeVar(TypeSymbol tsym, Type bound, Type lower) { - super(tsym); + public TypeVar(TypeSymbol tsym, Type bound, Type lower, + List annos) { + super(tsym, annos); this.bound = bound; this.lower = lower; } + @Override + public TypeVar annotatedType(List annos) { + return new TypeVar(tsym, bound, lower, annos); + } + @Override public TypeTag getTag() { return TYPEVAR; @@ -1317,13 +1435,29 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { Symbol owner, Type upper, Type lower, - WildcardType wildcard) { - super(name, owner, lower); + WildcardType wildcard, + List annos) { + super(name, owner, lower, annos); this.lower = Assert.checkNonNull(lower); this.bound = upper; this.wildcard = wildcard; } + public CapturedType(TypeSymbol tsym, + Type bound, + Type upper, + Type lower, + WildcardType wildcard, + List annos) { + super(tsym, bound, lower, annos); + this.wildcard = wildcard; + } + + @Override + public CapturedType annotatedType(List annos) { + return new CapturedType(tsym, bound, bound, lower, wildcard, annos); + } + @Override public R accept(Type.Visitor v, S s) { return v.visitCapturedType(this, s); @@ -1336,18 +1470,22 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { @Override public String toString() { - return "capture#" - + (hashCode() & 0xFFFFFFFFL) % Printer.PRIME - + " of " - + wildcard; + StringBuilder sb = new StringBuilder(); + appendAnnotationsString(sb); + sb.append("capture#"); + sb.append((hashCode() & 0xFFFFFFFFL) % Printer.PRIME); + sb.append(" of "); + sb.append(wildcard); + return sb.toString(); } } public static abstract class DelegatedType extends Type { public Type qtype; public TypeTag tag; - public DelegatedType(TypeTag tag, Type qtype) { - super(qtype.tsym); + public DelegatedType(TypeTag tag, Type qtype, + List annos) { + super(qtype.tsym, annos); this.tag = tag; this.qtype = qtype; } @@ -1373,17 +1511,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public List tvars; public ForAll(List tvars, Type qtype) { - super(FORALL, (MethodType)qtype); + super(FORALL, (MethodType)qtype, noAnnotations); this.tvars = tvars; } + @Override + public ForAll annotatedType(List annos) { + throw new AssertionError("Cannot annotate forall type"); + } + @Override public R accept(Type.Visitor v, S s) { return v.visitForAll(this, s); } 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 getTypeArguments() { return tvars; } @@ -1479,7 +1628,8 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } 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); List declaredBounds = types.getBounds(origin); declaredCount = declaredBounds.length(); @@ -1489,7 +1639,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { } 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() { @@ -1506,6 +1664,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { return result; } + @Override + public UndetVar annotatedType(List annos) { + throw new AssertionError("Cannot annotate an UndetVar type"); + } + @Override public boolean isPartial() { return true; @@ -1659,7 +1822,15 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { */ public static class JCNoType extends Type implements NoType { 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.nil()); + } + + @Override + public JCNoType annotatedType(List annos) { + throw new AssertionError("Cannot annotate JCNoType"); } @Override @@ -1686,7 +1857,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public static class JCVoidType extends Type implements NoType { public JCVoidType() { - super(null); + // Void cannot be annotated + super(null, noAnnotations); + } + + @Override + public JCVoidType annotatedType(List annos) { + throw new AssertionError("Cannot annotate void type"); } @Override @@ -1715,7 +1892,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { static class BottomType extends Type implements NullType { public BottomType() { - super(null); + // Bottom is a synthesized internal type, so it cannot be annotated + super(null, noAnnotations); + } + + @Override + public BottomType annotatedType(List annos) { + throw new AssertionError("Cannot annotate bottom type"); } @Override @@ -1759,7 +1942,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { private Type originalType = null; public ErrorType(Type originalType, TypeSymbol tsym) { - super(noType, List.nil(), null); + this(originalType, tsym, noAnnotations); + } + + public ErrorType(Type originalType, TypeSymbol tsym, + List typeAnnotations) { + super(noType, List.nil(), null, typeAnnotations); this.tsym = tsym; 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); } + @Override + public ErrorType annotatedType(List annos) { + return new ErrorType(originalType, tsym, annos); + } + @Override public TypeTag getTag() { 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 typeAnnotations; - - /** The underlying type that is annotated. - */ - private Type underlyingType; - - protected AnnotatedType(List 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 getAnnotationMirrors() { - return typeAnnotations; - } - - - @Override - public TypeKind getKind() { - return underlyingType.getKind(); - } - - @Override - public Type unannotatedType() { - return underlyingType; - } - - @Override - public R accept(Type.Visitor v, S s) { - return v.visitAnnotatedType(this, s); - } - - @Override - public R accept(TypeVisitor 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 getTypeArguments() { return underlyingType.getTypeArguments(); } - @Override - public List getParameterTypes() { return underlyingType.getParameterTypes(); } - @Override - public Type getReceiverType() { return underlyingType.getReceiverType(); } - @Override - public List 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 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 UnknownType() { - super(null); + // Unknown is a synthesized internal type, so it cannot be + // annotated. + super(null, noAnnotations); + } + + @Override + public UnknownType annotatedType(List annos) { + throw new AssertionError("Cannot annotate unknown type"); } @Override @@ -2046,7 +2074,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { R visitForAll(ForAll t, S s); R visitUndetVar(UndetVar t, S s); R visitErrorType(ErrorType t, S s); - R visitAnnotatedType(AnnotatedType t, S s); R visitType(Type t, S s); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java index 39b53f99cba..55412a2853a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java @@ -326,15 +326,21 @@ public class TypeAnnotationPosition { public int getCatchType() { Assert.check(hasCatchType(), - "exception_index does not contain a valid catch type"); - return (-this.exception_index) - 1 ; + "exception_index does not contain valid catch info"); + 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, "exception_index already contains a bytecode index"); Assert.check(catchType >= 0, "Expected a valid catch type"); - this.exception_index = -(catchType + 1); + this.exception_index = -((catchType | startPos << 8) + 1); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 88bbf4b7830..1fa63c1ae5e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -32,7 +32,6 @@ import javax.lang.model.type.TypeKind; import javax.tools.JavaFileObject; 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.CapturedType; 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 // typeWithAnnotations side-effects the type annotation positions. // This is important for constructors of nested classes. - sym.appendUniqueTypeAttributes(typeAnnotations); return; } @@ -391,14 +389,15 @@ public class TypeAnnotations { private Type typeWithAnnotations(final JCTree typetree, final Type type, final List annotations, final List 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); if (annotations.isEmpty()) { return type; } if (type.hasTag(TypeTag.ARRAY)) { - Type.ArrayType arType = (Type.ArrayType) type.unannotatedType(); - Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); + Type.ArrayType arType = (Type.ArrayType) type; + Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym, + Type.noAnnotations); Type toreturn; if (type.isAnnotated()) { toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); @@ -413,13 +412,15 @@ public class TypeAnnotations { while (arType.elemtype.hasTag(TypeTag.ARRAY)) { if (arType.elemtype.isAnnotated()) { Type aelemtype = arType.elemtype; - arType = (Type.ArrayType) aelemtype.unannotatedType(); + arType = (Type.ArrayType) aelemtype; 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()); } else { 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; } arTree = arrayTypeTree(arTree.elemtype); @@ -569,6 +570,7 @@ public class TypeAnnotations { private Type typeWithAnnotations(final Type type, final Type stopAt, final List annotations) { + //System.err.println("typeWithAnnotations " + type + " " + annotations + " stopAt " + stopAt); Visitor> visitor = new Type.Visitor>() { @Override @@ -579,7 +581,8 @@ public class TypeAnnotations { return t.annotatedType(s); } else { 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.allparams_field = t.allparams_field; ret.interfaces_field = t.interfaces_field; @@ -589,11 +592,6 @@ public class TypeAnnotations { } } - @Override - public Type visitAnnotatedType(AnnotatedType t, List s) { - return t.unannotatedType().accept(this, s).annotatedType(t.getAnnotationMirrors()); - } - @Override public Type visitWildcardType(WildcardType t, List s) { return t.annotatedType(s); @@ -601,7 +599,8 @@ public class TypeAnnotations { @Override public Type visitArrayType(ArrayType t, List 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; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index ab29deaeda1..2184d0c1490 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -131,7 +131,7 @@ public class Types { * @return the upper bound of the given type */ public Type upperBound(Type t) { - return upperBound.visit(t).unannotatedType(); + return upperBound.visit(t); } // where private final MapVisitor upperBound = new MapVisitor() { @@ -205,7 +205,7 @@ public class Types { WildcardType unb = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, - (TypeVar)parms.head.unannotatedType()); + (TypeVar)parms.head); if (!containsType(args.head, unb)) return false; parms = parms.tail; @@ -269,7 +269,9 @@ public class Types { List opens = openVars.toList(); ListBuffer qs = new ListBuffer<>(); for (List 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()); } @@ -599,12 +601,12 @@ public class Types { //simply replace the wildcards with its bound for (Type t : formalInterface.getTypeArguments()) { if (actualTypeargs.head.hasTag(WILDCARD)) { - WildcardType wt = (WildcardType)actualTypeargs.head.unannotatedType(); + WildcardType wt = (WildcardType)actualTypeargs.head; Type bound; switch (wt.kind) { case EXTENDS: 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 bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ? wt.type : capVar.bound; @@ -642,7 +644,8 @@ public class Types { csym.members_field = new Scope(csym); MethodSymbol instDescSym = new MethodSymbol(descSym.flags(), descSym.name, descType, csym); csym.members_field.enter(instDescSym); - Type.ClassType ctype = new Type.ClassType(Type.noType, List.nil(), csym); + Type.ClassType ctype = new Type.ClassType(Type.noType, List.nil(), csym, + Type.noAnnotations); ctype.supertype_field = syms.objectType; ctype.interfaces_field = targets; csym.type = ctype; @@ -747,8 +750,6 @@ public class Types { //where private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) { if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) { - t = t.unannotatedType(); - s = s.unannotatedType(); if (((ArrayType)t).elemtype.isPrimitive()) { return isSameType(elemtype(t), elemtype(s)); } else { @@ -776,8 +777,6 @@ public class Types { if (!t.hasTag(ARRAY) || isReifiable(t)) { return; } - t = t.unannotatedType(); - s = s.unannotatedType(); ArrayType from = (ArrayType)t; boolean shouldWarn = false; switch (s.getTag()) { @@ -807,12 +806,6 @@ public class Types { return isSubtype(t, s, false); } public boolean isSubtype(Type t, Type s, boolean capture) { - if (t == s) - return true; - - t = t.unannotatedType(); - s = s.unannotatedType(); - if (t == s) return true; @@ -828,8 +821,9 @@ public class Types { } // Generally, if 's' is a type variable, recur on lower bound; but - // for alpha <: CAP, alpha should get upper bound CAP - if (!t.hasTag(UNDETVAR)) { + // for inference variables and intersections, we need to keep 's' + // (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 Type lower = cvarLowerBound(wildLowerBound(s)); if (s != lower) @@ -899,12 +893,14 @@ public class Types { if (s.isSuperBound() && !s.isExtendsBound()) { s = new WildcardType(syms.objectType, BoundKind.UNBOUND, - syms.boundClass); + syms.boundClass, + s.getAnnotationMirrors()); changed = true; } else if (s != orig) { s = new WildcardType(upperBound(s), BoundKind.EXTENDS, - syms.boundClass); + syms.boundClass, + s.getAnnotationMirrors()); changed = true; } rewrite.append(s); @@ -918,14 +914,11 @@ public class Types { @Override public Boolean visitClassType(ClassType t, Type s) { Type sup = asSuper(t, s.tsym); - return sup != null - && sup.tsym == s.tsym - // You're not allowed to write - // Vector vec = new Vector(); - // But with wildcards you can write - // Vector vec = new Vector(); - // which means that subtype checking must be done - // here instead of same-type checking (via containsType). + if (sup == null) return false; + // If t is an intersection, sup might not be a class type + if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); + return sup.tsym == s.tsym + // Check type variable containment && (!s.isParameterized() || containsTypeRecursive(s, sup)) && isSubtypeNoCapture(sup.getEnclosingType(), s.getEnclosingType()); @@ -1107,7 +1100,7 @@ public class Types { if (s.hasTag(TYPEVAR)) { //type-substitution does not preserve type-var types //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 { //special case for s == ? super X, where upper(s) = u @@ -1149,9 +1142,9 @@ public class Types { HashSet set = new HashSet<>(); 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)) { - if (!set.remove(new UniqueType(x.unannotatedType(), Types.this))) + if (!set.remove(new UniqueType(x, Types.this))) return false; } return (set.isEmpty()); @@ -1256,30 +1249,47 @@ public class Types { if (!s.hasTag(WILDCARD)) { return false; } else { - WildcardType t2 = (WildcardType)s.unannotatedType(); + WildcardType t2 = (WildcardType)s; return t.kind == t2.kind && isSameType(t.type, t2.type, true); } } }; - /** - * A version of LooseSameTypeVisitor that takes AnnotatedTypes - * into account. - */ - TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() { + // + + TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() { + private Boolean compareAnnotations(Type t1, Type t2) { + List annos1 = t1.getAnnotationMirrors(); + List annos2 = t2.getAnnotationMirrors(); + return annos1.containsAll(annos2) && annos2.containsAll(annos1); + } + @Override - public Boolean visitAnnotatedType(AnnotatedType t, Type s) { - if (!s.isAnnotated()) - return false; - if (!t.getAnnotationMirrors().containsAll(s.getAnnotationMirrors())) - return false; - if (!s.getAnnotationMirrors().containsAll(t.getAnnotationMirrors())) - return false; - return visit(t.unannotatedType(), s); + public Boolean visitType(Type t, Type s) { + return compareAnnotations(t, s) && super.visitType(t, s); + } + + @Override + public Boolean visitWildcardType(WildcardType t, Type s) { + return compareAnnotations(t, s) && super.visitWildcardType(t, 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); } }; - // // public boolean containedBy(Type t, Type s) { @@ -1287,7 +1297,7 @@ public class Types { case UNDETVAR: if (s.hasTag(WILDCARD)) { UndetVar undetvar = (UndetVar)t; - WildcardType wt = (WildcardType)s.unannotatedType(); + WildcardType wt = (WildcardType)s; switch(wt.kind) { case UNBOUND: //similar to ? extends Object case EXTENDS: { @@ -1354,7 +1364,7 @@ public class Types { private Type U(Type t) { while (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType)t.unannotatedType(); + WildcardType w = (WildcardType)t; if (w.isSuperBound()) return w.bound == null ? syms.objectType : w.bound.bound; else @@ -1365,7 +1375,7 @@ public class Types { private Type L(Type t) { while (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType)t.unannotatedType(); + WildcardType w = (WildcardType)t; if (w.isExtendsBound()) return syms.botType; else @@ -1424,15 +1434,15 @@ public class Types { }; 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 isSameWildcard(t, ((CapturedType)s.unannotatedType()).wildcard); + return isSameWildcard(t, ((CapturedType)s).wildcard); } public boolean isSameWildcard(WildcardType t, Type s) { if (!s.hasTag(WILDCARD)) return false; - WildcardType w = (WildcardType)s.unannotatedType(); + WildcardType w = (WildcardType)s; return w.kind == t.kind && w.type == t.type; } @@ -1541,8 +1551,8 @@ public class Types { if (t.isCompound() || s.isCompound()) { return !t.isCompound() ? - visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) : - visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false); + visitIntersectionType((IntersectionClassType)s, t, true) : + visitIntersectionType((IntersectionClassType)t, s, false); } if (s.hasTag(CLASS) || s.hasTag(ARRAY)) { @@ -1873,7 +1883,6 @@ public class Types { case WILDCARD: return elemtype(upperBound(t)); case ARRAY: - t = t.unannotatedType(); return ((ArrayType)t).elemtype; case FORALL: return elemtype(((ForAll)t).qtype); @@ -1920,7 +1929,7 @@ public class Types { if (t.hasTag(VOID) || t.hasTag(PACKAGE)) { 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); } // @@ -1959,16 +1968,18 @@ public class Types { return 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); if (x != null) return x; } if ((sym.flags() & INTERFACE) != 0) { for (List l = interfaces(t); l.nonEmpty(); l = l.tail) { - Type x = asSuper(l.head, sym); - if (x != null) - return x; + if (!l.head.hasTag(ERROR)) { + Type x = asSuper(l.head, sym); + if (x != null) + return x; + } } } return null; @@ -2175,56 +2186,65 @@ public class Types { } private Type erasure(Type t, boolean recurse) { - if (t.isPrimitive()) + if (t.isPrimitive()) { return t; /* fast special case */ - else - return erasure.visit(t, recurse); + } else { + Type out = erasure.visit(t, recurse); + return out; + } } // where private SimpleVisitor erasure = new SimpleVisitor() { public Type visitType(Type t, Boolean recurse) { if (t.isPrimitive()) return t; /*fast special case*/ - else - return t.map(recurse ? erasureRecFun : erasureFun); + else { + final List annos = t.getAnnotationMirrors(); + Type erased = t.map(recurse ? erasureRecFun : erasureFun); + if (!annos.isEmpty()) { + erased = erased.annotatedType(annos); + } + return erased; + } } @Override public Type visitWildcardType(WildcardType t, Boolean recurse) { - return erasure(upperBound(t), recurse); + final List annos = t.getAnnotationMirrors(); + Type erased = erasure(upperBound(t), recurse); + if (!annos.isEmpty()) { + erased = erased.annotatedType(annos); + } + return erased; } @Override public Type visitClassType(ClassType t, Boolean recurse) { Type erased = t.tsym.erasure(Types.this); + List annos = t.getAnnotationMirrors(); if (recurse) { erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym); } + if (!annos.isEmpty()) { + erased = erased.annotatedType(annos); + } return erased; } @Override public Type visitTypeVar(TypeVar t, Boolean recurse) { - return erasure(t.bound, recurse); + final List annos = t.getAnnotationMirrors(); + Type erased = erasure(t.bound, recurse); + if (!annos.isEmpty()) { + erased = erased.annotatedType(annos); + } + return erased; } @Override public Type visitErrorType(ErrorType t, Boolean recurse) { 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") { @@ -2550,7 +2570,8 @@ public class Types { public Type visitClassType(ClassType t, Void ignored) { Type outer1 = classBound(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 return t; } @@ -2965,7 +2986,8 @@ public class Types { if (typarams1 == typarams && outer1 == outer) return t; else - return new ClassType(outer1, typarams1, t.tsym); + return new ClassType(outer1, typarams1, t.tsym, + t.getAnnotationMirrors()); } else { Type st = subst(supertype(t)); List is = upperBounds(subst(interfaces(t))); @@ -2986,7 +3008,8 @@ public class Types { } else { if (t.isExtendsBound() && bound.isExtendsBound()) 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) return t; else - return new ArrayType(elemtype, t.tsym); + return new ArrayType(elemtype, t.tsym, t.getAnnotationMirrors()); } @Override @@ -3006,7 +3029,7 @@ public class Types { //if 'to' types contain variables that are free in 't' List freevars = newInstances(t.tvars); t = new ForAll(freevars, - Types.this.subst(t.qtype, t.tvars, freevars)); + Types.this.subst(t.qtype, t.tvars, freevars)); } List tvars1 = substBounds(t.tvars, from, to); Type qtype1 = subst(t.qtype); @@ -3015,7 +3038,8 @@ public class Types { } else if (tvars1 == t.tvars) { return new ForAll(tvars1, qtype1); } 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 newTvars = new ListBuffer<>(); // create new type variables without bounds 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 // of the old @@ -3071,7 +3096,8 @@ public class Types { return t; else { // 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 // of the old tv.bound = subst(bound1, List.of(t), List.of(tv)); @@ -3112,7 +3138,7 @@ public class Types { return tvars1; } 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()); } }; // @@ -3185,7 +3211,6 @@ public class Types { * graph. Undefined for all but reference types. */ public int rank(Type t) { - t = t.unannotatedType(); switch(t.getTag()) { case CLASS: { ClassType cls = (ClassType)t; @@ -3267,7 +3292,7 @@ public class Types { for (Type t : tvars) { if (!first) s.append(", "); first = false; - appendTyparamString(((TypeVar)t.unannotatedType()), s); + appendTyparamString(((TypeVar)t), s); } s.append('>'); return s.toString(); @@ -3439,12 +3464,14 @@ public class Types { m = new WildcardType(lub(upperBound(act1.head), upperBound(act2.head)), BoundKind.EXTENDS, - syms.boundClass); + syms.boundClass, + Type.noAnnotations); mergeCache.remove(pair); } else { m = new WildcardType(syms.objectType, BoundKind.UNBOUND, - syms.boundClass); + syms.boundClass, + Type.noAnnotations); } merged.append(m.withTypeVar(typarams.head)); } @@ -3453,7 +3480,10 @@ public class Types { typarams = typarams.tail; } 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)[] - return new ArrayType(lub(elements), syms.arrayClass); + return new ArrayType(lub(elements), syms.arrayClass, + Type.noAnnotations); case CLASS_BOUND: // calculate lub(A, B) @@ -3932,7 +3963,6 @@ public class Types { t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments()); } } - t = t.unannotatedType(); ClassType cls = (ClassType)t; if (cls.isRaw() || !cls.isParameterized()) return cls; @@ -3951,9 +3981,9 @@ public class Types { !currentS.isEmpty()) { if (currentS.head != currentT.head) { captured = true; - WildcardType Ti = (WildcardType)currentT.head.unannotatedType(); + WildcardType Ti = (WildcardType)currentT.head; Type Ui = currentA.head.getUpperBound(); - CapturedType Si = (CapturedType)currentS.head.unannotatedType(); + CapturedType Si = (CapturedType)currentS.head; if (Ui == null) Ui = syms.objectType; switch (Ti.kind) { @@ -3986,7 +4016,8 @@ public class Types { return erasure(t); // some "rare" type involved if (captured) - return new ClassType(cls.getEnclosingType(), S, cls.tsym); + return new ClassType(cls.getEnclosingType(), S, cls.tsym, + cls.getAnnotationMirrors()); else return t; } @@ -3995,7 +4026,6 @@ public class Types { ListBuffer result = new ListBuffer<>(); for (Type t : types) { if (t.hasTag(WILDCARD)) { - t = t.unannotatedType(); Type bound = ((WildcardType)t).getExtendsBound(); if (bound == null) bound = syms.objectType; @@ -4003,7 +4033,8 @@ public class Types { syms.noSymbol, bound, syms.botType, - (WildcardType)t)); + (WildcardType)t, + Type.noAnnotations)); } else { result.append(t); } @@ -4089,7 +4120,7 @@ public class Types { private boolean giveWarning(Type from, Type to) { List bounds = to.isCompound() ? - ((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to); + ((IntersectionClassType)to).getComponents() : List.of(to); for (Type b : bounds) { Type subFrom = asSub(from, b.tsym); if (b.isParameterized() && @@ -4354,7 +4385,7 @@ public class Types { Type B(Type t) { while (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType)t.unannotatedType(); + WildcardType w = (WildcardType)t; t = high ? w.getExtendsBound() : w.getSuperBound(); @@ -4380,12 +4411,14 @@ public class Types { return new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, - formal); + formal, + Type.noAnnotations); } else { return new WildcardType(bound, BoundKind.EXTENDS, syms.boundClass, - formal); + formal, + Type.noAnnotations); } } @@ -4402,12 +4435,14 @@ public class Types { return new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass, - formal); + formal, + Type.noAnnotations); } else { return new WildcardType(bound, BoundKind.SUPER, syms.boundClass, - formal); + formal, + Type.noAnnotations); } } @@ -4429,7 +4464,7 @@ public class Types { public boolean equals(Object obj) { return (obj instanceof UniqueType) && - types.isSameAnnotatedType(type, ((UniqueType)obj).type); + types.isSameType(type, ((UniqueType)obj).type); } public String toString() { @@ -4464,8 +4499,6 @@ public class Types { public R visitForAll(ForAll 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); } - // 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. */ public void assembleSig(Type type) { - type = type.unannotatedType(); switch (type.getTag()) { case BYTE: append('B'); @@ -4693,7 +4725,6 @@ public class Types { } public void assembleClassSig(Type type) { - type = type.unannotatedType(); ClassType ct = (ClassType) type; ClassSymbol c = (ClassSymbol) ct.tsym; classReference(c); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 1b2385dba85..335704eaef4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -517,6 +517,10 @@ public class Attr extends JCTree.Visitor { return new ResultInfo(pkind, pt, newContext); } + protected ResultInfo dup(Type newPt, CheckContext newContext) { + return new ResultInfo(pkind, newPt, newContext); + } + @Override public String toString() { if (pt != null) { @@ -1865,8 +1869,10 @@ public class Attr extends JCTree.Visitor { return new ClassType(restype.getEnclosingType(), List.of(new WildcardType(types.erasure(qualifierType), BoundKind.EXTENDS, - syms.boundClass)), - restype.tsym); + syms.boundClass, + Type.noAnnotations)), + restype.tsym, + restype.getAnnotationMirrors()); } else { return restype; } @@ -2036,7 +2042,8 @@ public class Attr extends JCTree.Visitor { } else if (TreeInfo.isDiamond(tree)) { ClassType site = new ClassType(clazztype.getEnclosingType(), clazztype.tsym.type.getTypeArguments(), - clazztype.tsym); + clazztype.tsym, + clazztype.getAnnotationMirrors()); Env diamondEnv = localEnv.dup(tree); diamondEnv.info.selectSuper = cdef != null; @@ -2255,7 +2262,8 @@ public class Attr extends JCTree.Visitor { owntype = elemtype; for (List l = tree.dims; l.nonEmpty(); l = l.tail) { attribExpr(l.head, localEnv, syms.intType); - owntype = new ArrayType(owntype, syms.arrayClass); + owntype = new ArrayType(owntype, syms.arrayClass, + Type.noAnnotations); } } else { // we are seeing an untyped aggregate { ... } @@ -2272,7 +2280,8 @@ public class Attr extends JCTree.Visitor { } if (tree.elems != null) { attribExprs(tree.elems, localEnv, elemtype); - owntype = new ArrayType(elemtype, syms.arrayClass); + owntype = new ArrayType(elemtype, syms.arrayClass, + Type.noAnnotations); } if (!types.isReifiable(elemtype)) log.error(tree.pos(), "generic.array.creation"); @@ -2763,7 +2772,7 @@ public class Attr extends JCTree.Visitor { 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); JCDiagnostic.DiagnosticType diagKind = targetError ? @@ -2838,7 +2847,8 @@ public class Attr extends JCTree.Visitor { ResultInfo checkInfo = resultInfo.dup(newMethodTemplate( 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); @@ -3244,7 +3254,7 @@ public class Attr extends JCTree.Visitor { if (skind == TYP) { Type elt = site; while (elt.hasTag(ARRAY)) - elt = ((ArrayType)elt.unannotatedType()).elemtype; + elt = ((ArrayType)elt).elemtype; if (elt.hasTag(TYPEVAR)) { log.error(tree.pos(), "type.var.cant.be.deref"); result = types.createErrorType(tree.type); @@ -3557,7 +3567,8 @@ public class Attr extends JCTree.Visitor { normOuter = types.erasure(ownOuter); if (normOuter != ownOuter) owntype = new ClassType( - normOuter, List.nil(), owntype.tsym); + normOuter, List.nil(), owntype.tsym, + owntype.getAnnotationMirrors()); } } break; @@ -3861,7 +3872,7 @@ public class Attr extends JCTree.Visitor { public void visitTypeArray(JCArrayTypeTree tree) { 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); } @@ -3909,7 +3920,8 @@ public class Attr extends JCTree.Visitor { clazzOuter = site; } } - owntype = new ClassType(clazzOuter, actuals, clazztype.tsym); + owntype = new ClassType(clazzOuter, actuals, clazztype.tsym, + clazztype.getAnnotationMirrors()); } else { if (formals.length() != 0) { log.error(tree.pos(), "wrong.number.type.args", @@ -4060,7 +4072,8 @@ public class Attr extends JCTree.Visitor { : attribType(tree.inner, env); result = check(tree, new WildcardType(chk.checkRefType(tree.pos(), type), tree.kind.kind, - syms.boundClass), + syms.boundClass, + Type.noAnnotations), TYP, resultInfo); } @@ -4088,7 +4101,7 @@ public class Attr extends JCTree.Visitor { public void run() { List compounds = fromAnnotations(annotations); 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) { + //System.err.println("validateTypeAnnotations.visitVarDef " + tree); if (tree.sym != null && tree.sym.type != null) validateAnnotatedType(tree.vartype, tree.sym.type); scan(tree.mods); @@ -4512,6 +4526,7 @@ public class Attr extends JCTree.Visitor { super.visitNewArray(tree); } public void visitClassDef(JCClassDecl tree) { + //System.err.println("validateTypeAnnotations.visitClassDef " + tree); if (sigOnly) { scan(tree.mods); scan(tree.typarams); @@ -4540,7 +4555,7 @@ public class Attr extends JCTree.Visitor { * can occur. */ 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()) { return; @@ -4578,8 +4593,7 @@ public class Attr extends JCTree.Visitor { } } else if (enclTr.hasTag(ANNOTATED_TYPE)) { JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr; - if (enclTy == null || - enclTy.hasTag(NONE)) { + if (enclTy == null || enclTy.hasTag(NONE)) { if (at.getAnnotations().size() == 1) { log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute); } else { @@ -4598,16 +4612,16 @@ public class Attr extends JCTree.Visitor { } else if (enclTr.hasTag(JCTree.Tag.WILDCARD)) { JCWildcard wc = (JCWildcard) enclTr; 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) { - validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy.unannotatedType()).getSuperBound()); + validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy).getSuperBound()); } else { // Nothing to do for UNBOUND } repeat = false; } else if (enclTr.hasTag(TYPEARRAY)) { JCArrayTypeTree art = (JCArrayTypeTree) enclTr; - validateAnnotatedType(art.getType(), ((ArrayType)enclTy.unannotatedType()).getComponentType()); + validateAnnotatedType(art.getType(), ((ArrayType)enclTy).getComponentType()); repeat = false; } else if (enclTr.hasTag(TYPEUNION)) { JCTypeUnion ut = (JCTypeUnion) enclTr; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 97cee013ca4..1b412e39405 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -2234,11 +2234,11 @@ public class Check { if (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0) return; if (seen.contains(t)) { - tv = (TypeVar)t.unannotatedType(); + tv = (TypeVar)t; tv.bound = types.createErrorType(t); log.error(pos, "cyclic.inheritance", t); } else if (t.hasTag(TYPEVAR)) { - tv = (TypeVar)t.unannotatedType(); + tv = (TypeVar)t; seen = seen.prepend(tv); for (Type b : types.getBounds(tv)) checkNonCyclic1(pos, b, seen); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 5c3533eada9..6265199a8d7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -134,12 +134,17 @@ public class DeferredAttr extends JCTree.Visitor { SpeculativeCache speculativeCache; DeferredType(JCExpression tree, Env env) { - super(null); + super(null, noAnnotations); this.tree = tree; this.env = attr.copyEnv(env); this.speculativeCache = new SpeculativeCache(); } + @Override + public DeferredType annotatedType(List typeAnnotations) { + throw new AssertionError("Cannot annotate a deferred type"); + } + @Override public TypeTag getTag() { return DEFERRED; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index e451e26c147..df41f3763a8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -373,7 +373,7 @@ public class Infer { List upperBounds = uv.getBounds(InferenceBound.UPPER); if (Type.containsAny(upperBounds, vars)) { 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); uv.inst = fresh_tvar.type; } else if (upperBounds.nonEmpty()) { @@ -1505,7 +1505,9 @@ public class Infer { LOWER.solve(uv, inferenceContext) : infer.syms.botType; 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); } }; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 269fd1938ef..bf3e3c122d4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -28,7 +28,6 @@ package com.sun.tools.javac.comp; import java.util.*; 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.main.Option.PkgInfo; import com.sun.tools.javac.tree.*; @@ -452,7 +451,8 @@ public class Lower extends TreeTranslator { ClassSymbol outerCacheClass = outerCacheClass(); this.mapVar = new VarSymbol(STATIC | SYNTHETIC | FINAL, varName, - new ArrayType(syms.intType, syms.arrayClass), + new ArrayType(syms.intType, syms.arrayClass, + Type.noAnnotations), outerCacheClass); enterSynthetic(pos, mapVar, outerCacheClass.members()); } @@ -493,7 +493,8 @@ public class Lower extends TreeTranslator { syms.lengthVar); JCExpression mapVarInit = make .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) {} ListBuffer stmts = new ListBuffer<>(); @@ -1979,7 +1980,7 @@ public class Lower extends TreeTranslator { List.of(make.Literal(INT, 0).setType(syms.intType)), null); newcache.type = new ArrayType(types.erasure(outerCacheClass.type), - syms.arrayClass); + syms.arrayClass, Type.noAnnotations); // forNameSym := java.lang.Class.forName( // String s,boolean init,ClassLoader loader) @@ -2568,7 +2569,8 @@ public class Lower extends TreeTranslator { Name valuesName = names.fromString(target.syntheticNameChar() + "VALUES"); while (tree.sym.members().lookup(valuesName).scope != null) // avoid name clash 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, valuesName, arrayType, @@ -2841,7 +2843,7 @@ public class Lower extends TreeTranslator { tree.underlyingType = translate(tree.underlyingType); // but maintain type annotations in the type. 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()) { tree.type = tree.underlyingType.type; } @@ -3145,7 +3147,8 @@ public class Lower extends TreeTranslator { JCNewArray boxedArgs = make.NewArray(make.Type(varargsElement), List.nil(), elems.toList()); - boxedArgs.type = new ArrayType(varargsElement, syms.arrayClass); + boxedArgs.type = new ArrayType(varargsElement, syms.arrayClass, + Type.noAnnotations); result.append(boxedArgs); } else { if (args.length() != 1) throw new AssertionError(args); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index ffecda19573..ab6e894b739 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -457,7 +457,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer { * to the symbol table. */ private void addEnumMembers(JCClassDecl tree, Env 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 ???; } JCMethodDecl values = make. @@ -677,7 +678,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { //because varargs is represented in the tree as a //modifier on the parameter declaration, and not as a //distinct type of array node. - ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); + ArrayType atype = (ArrayType)tree.vartype.type; tree.vartype.type = atype.makeVarargs(); } Scope enclScope = enter.enterScope(env); @@ -1255,11 +1256,13 @@ public class MemberEnter extends JCTree.Visitor implements Completer { ClassType ct = (ClassType) sym.type; Assert.check(ct.typarams_field.isEmpty()); 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); } else { 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); } } @@ -1310,8 +1313,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } Type mType = new MethodType(argtypes, null, thrown, c); Type initType = typarams.nonEmpty() ? - new ForAll(typarams, mType) : - mType; + new ForAll(typarams, mType) : + mType; MethodSymbol init = new MethodSymbol(flags, names.init, initType, c); init.params = createDefaultConstructorParams(make, baseInit, init, diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index a883db73b94..dc79bfd780a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -94,7 +94,7 @@ public class Resolve { public final boolean boxingEnabled; public final boolean varargsEnabled; public final boolean allowMethodHandles; - public final boolean allowStructuralMostSpecific; + public final boolean allowFunctionalInterfaceMostSpecific; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; @@ -135,7 +135,7 @@ public class Resolve { verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); - allowStructuralMostSpecific = source.allowStructuralMostSpecific(); + allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); polymorphicSignatureScope = new Scope(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); @@ -1084,50 +1084,47 @@ public class Resolve { } public boolean compatible(Type found, Type req, Warner warn) { - if (!allowStructuralMostSpecific || actual == null) { - return super.compatible(found, req, warn); - } else { - switch (actual.getTag()) { - case DEFERRED: - DeferredType dt = (DeferredType) actual; - DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); - return (e == null || e.speculativeTree == deferredAttr.stuckTree) - ? super.compatible(found, req, warn) : - mostSpecific(found, req, e.speculativeTree, warn); - default: - return standaloneMostSpecific(found, req, actual, warn); + if (allowFunctionalInterfaceMostSpecific && + unrelatedFunctionalInterfaces(found, req) && + (actual != null && actual.getTag() == DEFERRED)) { + DeferredType dt = (DeferredType) actual; + DeferredType.SpeculativeCache.Entry e = + dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); + if (e != null && e.speculativeTree != deferredAttr.stuckTree) { + return functionalInterfaceMostSpecific(found, req, e.speculativeTree, warn); } } + return super.compatible(found, req, warn); } - private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) { - MostSpecificChecker msc = new MostSpecificChecker(t, s, warn); + /** Whether {@code t} and {@code s} are unrelated functional interface types. */ + 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); 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 s; final Warner warn; 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.s = s; this.warn = warn; @@ -1136,102 +1133,96 @@ public class Resolve { @Override void skip(JCTree tree) { - result &= standaloneMostSpecific(t, s, tree.type, warn); + result &= false; } @Override public void visitConditional(JCConditional tree) { - if (tree.polyKind == PolyKind.STANDALONE) { - result &= standaloneMostSpecific(t, s, tree.type, warn); - } 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); + scan(tree.truepart); + scan(tree.falsepart); } @Override public void visitReference(JCMemberReference tree) { - if (types.isFunctionalInterface(t.tsym) && - types.isFunctionalInterface(s.tsym)) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - if (types.isSameTypes(desc_t.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 { + Type desc_t = types.findDescriptorType(t); + Type desc_s = types.findDescriptorType(s); + // use inference variables here for more-specific inference (18.5.4) + if (!types.isSameTypes(desc_t.getParameterTypes(), + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 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 public void visitLambda(JCLambda tree) { - if (types.isFunctionalInterface(t.tsym) && - types.isFunctionalInterface(s.tsym)) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - if (types.isSameTypes(desc_t.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 { + Type desc_t = types.findDescriptorType(t); + Type desc_s = types.findDescriptorType(s); + // use inference variables here for more-specific inference (18.5.4) + if (!types.isSameTypes(desc_t.getParameterTypes(), + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 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 - void scanLambdaBody(JCLambda lambda, final Type t, final Type s) { + private List lambdaResults(JCLambda lambda) { if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) { - result &= MostSpecificCheckContext.this.mostSpecific(t, s, lambda.body, warn); + return List.of((JCExpression) lambda.body); } else { + final ListBuffer buffer = new ListBuffer<>(); DeferredAttr.LambdaReturnScanner lambdaScanner = new DeferredAttr.LambdaReturnScanner() { @Override public void visitReturn(JCReturn tree) { if (tree.expr != null) { - result &= MostSpecificCheckContext.this.mostSpecific(t, s, tree.expr, warn); + buffer.append(tree.expr); } } }; lambdaScanner.scan(lambda.body); + return buffer.toList(); } } } + } public MethodCheck mostSpecificCheck(List actuals, boolean strict) { @@ -1435,7 +1426,7 @@ public class Resolve { return bestSoFar; } else if (useVarargs && (sym.flags() & VARARGS) == 0) { return bestSoFar.kind >= ERRONEOUS ? - new BadVarargsMethod((ResolveError)bestSoFar) : + new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : bestSoFar; } Assert.check(sym.kind < AMBIGUOUS); @@ -1527,14 +1518,22 @@ public class Resolve { if (m2SignatureMoreSpecific) return m2; return ambiguityError(m1, m2); 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(); + boolean m1MoreSpecificThanAnyAmbiguous = true; + boolean allAmbiguousMoreSpecificThanM1 = true; for (Symbol s : e.ambiguousSyms) { - if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) { - return e.addAmbiguousSymbol(m1); - } + Symbol moreSpecific = mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs); + 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: throw new AssertionError(); } @@ -2195,7 +2194,7 @@ public class Resolve { List typeargtypes, LogResolveHelper logResolveHelper) { if (sym.kind >= AMBIGUOUS) { - ResolveError errSym = (ResolveError)sym; + ResolveError errSym = (ResolveError)sym.baseSymbol(); sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) { @@ -2584,7 +2583,7 @@ public class Resolve { sym = super.access(env, pos, location, sym); } else { final JCDiagnostic details = sym.kind == WRONG_MTH ? - ((InapplicableSymbolError)sym).errCandidate().snd : + ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd : null; sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { @Override @@ -2631,7 +2630,7 @@ public class Resolve { ((ForAll)sym.type).tvars : List.nil(); 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) { @Override public Symbol baseSymbol() { @@ -2992,12 +2991,12 @@ public class Resolve { return true; case WRONG_MTH: InapplicableSymbolError errSym = - (InapplicableSymbolError)s; + (InapplicableSymbolError)s.baseSymbol(); return new Template(MethodCheckDiag.ARITY_MISMATCH.regex()) .matches(errSym.errCandidate().snd); case WRONG_MTHS: InapplicableSymbolsError errSyms = - (InapplicableSymbolsError)s; + (InapplicableSymbolsError)s.baseSymbol(); return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); case WRONG_STATICNESS: return false; @@ -3272,7 +3271,7 @@ public class Resolve { List typeargtypes, MethodResolutionPhase maxPhase) { super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase); 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; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index f48d57acd84..ed560d52355 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -624,18 +624,18 @@ public class ClassReader { case '+': { sigp++; Type t = sigToType(); - return new WildcardType(t, BoundKind.EXTENDS, - syms.boundClass); + return new WildcardType(t, BoundKind.EXTENDS, syms.boundClass, + Type.noAnnotations); } case '*': sigp++; return new WildcardType(syms.objectType, BoundKind.UNBOUND, - syms.boundClass); + syms.boundClass, Type.noAnnotations); case '-': { sigp++; Type t = sigToType(); - return new WildcardType(t, BoundKind.SUPER, - syms.boundClass); + return new WildcardType(t, BoundKind.SUPER, syms.boundClass, + Type.noAnnotations); } case 'B': sigp++; @@ -680,7 +680,8 @@ public class ClassReader { return syms.booleanType; case '[': sigp++; - return new ArrayType(sigToType(), syms.arrayClass); + return new ArrayType(sigToType(), syms.arrayClass, + Type.noAnnotations); case '(': sigp++; List argtypes = sigToTypes(')'); @@ -735,7 +736,8 @@ public class ClassReader { try { return (outer == Type.noType) ? t.erasure(types) : - new ClassType(outer, List.nil(), t); + new ClassType(outer, List.nil(), t, + Type.noAnnotations); } finally { sbp = startSbp; } @@ -745,7 +747,8 @@ public class ClassReader { ClassSymbol t = syms.enterClass(names.fromUtf(signatureBuffer, startSbp, sbp - startSbp)); - outer = new ClassType(outer, sigToTypes('>'), t) { + outer = new ClassType(outer, sigToTypes('>'), t, + Type.noAnnotations) { boolean completed = false; @Override public Type getEnclosingType() { @@ -808,7 +811,8 @@ public class ClassReader { t = syms.enterClass(names.fromUtf(signatureBuffer, startSbp, sbp - startSbp)); - outer = new ClassType(outer, List.nil(), t); + outer = new ClassType(outer, List.nil(), t, + Type.noAnnotations); } signatureBuffer[sbp++] = (byte)'$'; continue; @@ -871,7 +875,8 @@ public class ClassReader { Name name = names.fromUtf(signature, start, sigp - start); TypeVar tvar; if (sigEnterPhase) { - tvar = new TypeVar(name, currentOwner, syms.botType); + tvar = new TypeVar(name, currentOwner, syms.botType, + Type.noAnnotations); typevars.enter(tvar.tsym); } else { tvar = (TypeVar)findTypeVar(name); @@ -910,7 +915,8 @@ public class ClassReader { // 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 // 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); // System.err.println("Missing type var " + name); return t; @@ -1534,35 +1540,41 @@ public class ClassReader { // local variable case LOCAL_VARIABLE: { final int table_length = nextChar(); - final TypeAnnotationPosition position = - TypeAnnotationPosition.localVariable(readTypePath()); - - position.lvarOffset = new int[table_length]; - position.lvarLength = new int[table_length]; - position.lvarIndex = new int[table_length]; + final int[] newLvarOffset = new int[table_length]; + final int[] newLvarLength = new int[table_length]; + final int[] newLvarIndex = new int[table_length]; for (int i = 0; i < table_length; ++i) { - position.lvarOffset[i] = nextChar(); - position.lvarLength[i] = nextChar(); - position.lvarIndex[i] = nextChar(); + newLvarOffset[i] = nextChar(); + newLvarLength[i] = nextChar(); + newLvarIndex[i] = nextChar(); } + + final TypeAnnotationPosition position = + TypeAnnotationPosition.localVariable(readTypePath()); + position.lvarOffset = newLvarOffset; + position.lvarLength = newLvarLength; + position.lvarIndex = newLvarIndex; return position; } // resource variable case RESOURCE_VARIABLE: { final int table_length = nextChar(); - final TypeAnnotationPosition position = - TypeAnnotationPosition.resourceVariable(readTypePath()); - - position.lvarOffset = new int[table_length]; - position.lvarLength = new int[table_length]; - position.lvarIndex = new int[table_length]; + final int[] newLvarOffset = new int[table_length]; + final int[] newLvarLength = new int[table_length]; + final int[] newLvarIndex = new int[table_length]; for (int i = 0; i < table_length; ++i) { - position.lvarOffset[i] = nextChar(); - position.lvarLength[i] = nextChar(); - position.lvarIndex[i] = nextChar(); + newLvarOffset[i] = nextChar(); + newLvarLength[i] = nextChar(); + newLvarIndex[i] = nextChar(); } + + final TypeAnnotationPosition position = + TypeAnnotationPosition.resourceVariable(readTypePath()); + position.lvarOffset = newLvarOffset; + position.lvarLength = newLvarLength; + position.lvarIndex = newLvarIndex; return position; } // exception parameter diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 9df21523c10..5580d06831f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -286,7 +286,6 @@ public class ClassWriter extends ClassFile { */ @Override public void assembleSig(Type type) { - type = type.unannotatedType(); switch (type.getTag()) { case UNINITIALIZED_THIS: case UNINITIALIZED_OBJECT: @@ -354,7 +353,7 @@ public class ClassWriter extends ClassFile { } else if (t.hasTag(ARRAY)) { return typeSig(types.erasure(t)); } else { - throw new AssertionError("xClassName"); + throw new AssertionError("xClassName expects class or array type, got " + t); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index 081146cc2c5..8f28fa0550e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -928,7 +928,7 @@ public class Code { if (o instanceof Pool.MethodHandle) return syms.methodHandleType; if (o instanceof UniqueType) return typeForPool(((UniqueType)o).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.MethodType) return syms.methodTypeType; @@ -1579,8 +1579,8 @@ public class Code { /** Add a catch clause to code. */ - public void addCatch( - char startPc, char endPc, char handlerPc, char catchType) { + public void addCatch(char startPc, char endPc, + char handlerPc, char catchType) { catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType}); } @@ -2149,7 +2149,7 @@ public class Code { for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { TypeAnnotationPosition p = ta.position; if (p.hasCatchType()) { - final int idx = findExceptionIndex(p.getCatchType()); + final int idx = findExceptionIndex(p); if (idx == -1) Assert.error("Could not find exception index for type annotation " + 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 iter = catchInfo.toList(); - int len = catchInfo.length(); for (int i = 0; i < len; ++i) { char[] catchEntry = iter.head; iter = iter.tail; - char ct = catchEntry[3]; - if (catchType == ct) { + int ct = catchEntry[3]; + int sp = catchEntry[0]; + if (catchType == ct && sp == startPos) { return i; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 45d5bda770f..943fbb58d62 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -317,10 +317,6 @@ public class Gen extends JCTree.Visitor { int makeRef(DiagnosticPosition pos, Type type) { checkDimension(pos, type); 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); } else { 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()) { for (Attribute.TypeCompound tc : 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()) { for (Attribute.TypeCompound tc : subCatch.type.getAnnotationMirrors()) { - tc.position.setCatchType(catchType); + tc.position.setCatchInfo(catchType, startpc); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java index b12adc0ab6c..f91c5c3189b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java @@ -673,11 +673,6 @@ public class JNIWriter { return defaultAction(t, p); } - @Override - public R visitAnnotatedType(Type.AnnotatedType t, P p) { - return defaultAction(t, p); - } - @Override public R visitType(Type t, P p) { return defaultAction(t, p); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java index e058a08f36a..cef21cf52e1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java @@ -102,10 +102,11 @@ public class Pool { */ public int put(Object 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); if (index == null) { -// System.err.println("put " + value + " " + value.getClass());//DEBUG index = pp; indices.put(value, index); pool = ArrayUtils.ensureCapacity(pool, pp); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java index 73614a0c022..955a7da4d23 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java @@ -26,6 +26,7 @@ package com.sun.tools.javac.jvm; 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_THIS; @@ -41,19 +42,27 @@ import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS; class UninitializedType extends Type.DelegatedType { 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) { - 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 - private UninitializedType(TypeTag tag, Type qtype, int offset) { - super(tag, qtype); + private UninitializedType(TypeTag tag, Type qtype, int offset, + List typeAnnotations) { + super(tag, qtype, typeAnnotations); this.offset = offset; } + @Override + public UninitializedType annotatedType(List typeAnnotations) { + return new UninitializedType(tag, qtype, offset, typeAnnotations); + } + Type initializedType() { return qtype; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 90883092e3a..6c7ccc11ffa 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -35,9 +35,6 @@ import java.util.MissingResourceException; import java.util.Queue; import java.util.ResourceBundle; 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.lang.model.SourceVersion; @@ -1292,11 +1289,16 @@ public class JavaCompiler { * Perform dataflow checks on an attributed parse tree. */ protected void flow(Env env, Queue> results) { + if (compileStates.isDone(env, CompileState.FLOW)) { + results.add(env); + return; + } + try { if (shouldStop(CompileState.FLOW)) return; - if (relax || compileStates.isDone(env, CompileState.FLOW)) { + if (relax) { results.add(env); return; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java index 5b780ede81d..f968a903de4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -168,7 +168,8 @@ public class JavacTypes implements javax.lang.model.util.Types { case PACKAGE: 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, @@ -193,7 +194,8 @@ public class JavacTypes implements javax.lang.model.util.Types { case DECLARED: case ERROR: case TYPEVAR: - return new Type.WildcardType(bound, bkind, syms.boundClass); + return new Type.WildcardType(bound, bkind, syms.boundClass, + Type.noAnnotations); default: 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. - return (DeclaredType) new Type.ClassType(outer, targs.toList(), sym); + return (DeclaredType) new Type.ClassType(outer, targs.toList(), sym, + Type.noAnnotations); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index a0b3fe64a21..5ffe456db60 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -1089,7 +1089,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea for (ClassSymbol cs : symtab.classes.values()) { if (cs.classfile != null || cs.kind == Kinds.ERR) { 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) { cs.completer = initialCompleter; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index 441264bccef..f68a2f061f1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -643,6 +643,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { super.setPos(pos); 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? */ public PolyKind polyKind; + + @Override public boolean isPoly() { return polyKind == PolyKind.POLY; } + @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; } } /** diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java index eb49e10f79a..3ee1c0a99c1 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java @@ -65,7 +65,7 @@ public class AnnotatedTypeImpl @Override public com.sun.javadoc.Type underlyingType() { - return TypeMaker.getType(env, type.unannotatedType(), true, false); + return TypeMaker.getType(env, type, true, false); } @Override diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java index de4d54a651d..6a74142437b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java @@ -140,9 +140,6 @@ public class TypeMaker { */ static String getTypeString(DocEnv env, Type t, boolean full) { // TODO: should annotations be included here? - if (t.isAnnotated()) { - t = t.unannotatedType(); - } switch (t.getTag()) { case ARRAY: StringBuilder s = new StringBuilder(); diff --git a/langtools/test/Makefile b/langtools/test/Makefile index ab8b2457927..11fb171ed79 100644 --- a/langtools/test/Makefile +++ b/langtools/test/Makefile @@ -186,6 +186,12 @@ ifdef JTREG_TIMEOUT_FACTOR JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) 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. # Since javac is typically loaded via the bootclassloader (either via TESTJAVA # 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 # TESTJAVA # Version of java to be tested. +# JTREG_VERBOSE +# Verbosity setting for jtreg # JTREG_OPTIONS # Additional options for jtreg # JTREG_TESTDIRS @@ -273,7 +281,7 @@ jtreg-tests: check-jtreg FRC JT_JAVA=$(JT_JAVA) $(JTREG) \ -J-Xmx512m \ -vmoption:-Xmx768m \ - -a -ignore:quiet -v:fail,error,nopass \ + -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \ -r:$(JTREG_OUTPUT_DIR)/JTreport \ -w:$(JTREG_OUTPUT_DIR)/JTwork \ -jdk:$(TESTJAVA) \ @@ -312,6 +320,8 @@ check-jtreg: $(PRODUCT_HOME) $(JTREG) # Default is JDK 7 # TESTJAVA # Version of java to be tested. +# JCK_VERBOSE +# Verbosity setting for jtjck # JCK_COMPILER_OPTIONS # Additional options for JCK-compiler # 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 \ $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt @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 \ - -v:non-pass \ + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ -r:$(JCK_COMPILER_OUTPUT_DIR)/report \ -w:$(JCK_COMPILER_OUTPUT_DIR)/work \ -jdk:$(TESTJAVA) \ @@ -361,6 +371,8 @@ jck-compiler-summary: FRC # Version of java used to run JCK. Should normally be the same as TESTJAVA # TESTJAVA # Version of java to be tested. +# JCK_VERBOSE +# Verbosity setting for jtjck # JCK_RUNTIME_OPTIONS # Additional options for JCK-runtime # 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 \ $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt @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 \ - -v:non-pass \ + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ -jdk:$(TESTJAVA) \ diff --git a/langtools/test/com/sun/javadoc/5093723/T5093723.java b/langtools/test/com/sun/javadoc/5093723/T5093723.java index 8bea133cc07..6ffa7d16945 100644 --- a/langtools/test/com/sun/javadoc/5093723/T5093723.java +++ b/langtools/test/com/sun/javadoc/5093723/T5093723.java @@ -25,23 +25,24 @@ * @test * @bug 5093723 * @summary REGRESSION: ClassCastException in SingleIndexWriter - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build T5093723 * @run main T5093723 */ public class T5093723 extends JavadocTester { - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR + ".out", "-Xdoclint:none", - SRC_DIR + "/DocumentedClass.java", - SRC_DIR + "/UndocumentedClass.java" - }; - - public static void main(String... args) { + public static void main(String... args) throws Exception { T5093723 tester = new T5093723(); - if (tester.runJavadoc(ARGS) != 0) - throw new AssertionError("non-zero return code from javadoc"); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-Xdoclint:none", + testSrc("DocumentedClass.java"), + testSrc("UndocumentedClass.java")); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java b/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java index 699be36583a..359ea876531 100644 --- a/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java +++ b/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java @@ -26,142 +26,31 @@ * @bug 4706779 4956908 * @summary Add text equivalent of class tree ASCII art for accessibility * @author dkramer + * @library ../lib + * @build JavadocTester * @run main AccessAsciiArt */ +public class AccessAsciiArt extends JavadocTester { -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - -/** - * 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(); + public static void main(String... args) throws Exception { + AccessAsciiArt tester = new AccessAsciiArt(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } - } + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "p1", "p1.subpkg"); + 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 top line of the class tree - { -"
  • p1.C
  • ", - TMPDEST_DIR1 + "p1/subpkg/SSC.html" }, - - // Test the second line of the class tree - { -"
  • p1.SC
  • ", - TMPDEST_DIR1 + "p1/subpkg/SSC.html" }, - - // Test the third line of the class tree - { -"
  • p1.subpkg.SSC
  • ", - 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); + checkOutput("p1/subpkg/SSC.html", true, + // Test the top line of the class tree + "
  • p1.C
  • ", + // Test the second line of the class tree + "
  • p1.SC
  • ", + // Test the third line of the class tree + "
  • p1.subpkg.SSC
  • "); } } diff --git a/langtools/test/com/sun/javadoc/AccessFrameTitle/AccessFrameTitle.java b/langtools/test/com/sun/javadoc/AccessFrameTitle/AccessFrameTitle.java index c871b99c382..9505e97c5fa 100644 --- a/langtools/test/com/sun/javadoc/AccessFrameTitle/AccessFrameTitle.java +++ b/langtools/test/com/sun/javadoc/AccessFrameTitle/AccessFrameTitle.java @@ -26,141 +26,32 @@ * @bug 4636655 * @summary Add title attribute to tags for accessibility * @author dkramer + * @library ../lib + * @build JavadocTester * @run main AccessFrameTitle */ +public class AccessFrameTitle extends JavadocTester { -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - -/** - * 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(); + public static void main(String... args) throws Exception { + AccessFrameTitle tester = new AccessFrameTitle(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } - } + @Test + void test() { + javadoc("-d", "out", + "-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 = { - - // Testing only for the presence of the title attributes. - // To make this test more robust, only - // 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); + // Testing only for the presence of the title attributes. + // To make this test more robust, only + // the initial part of each title string is tested for, + // in case the ending part of the string later changes + checkOutput("index.html", true, + "title=\"All classes and interfaces (except non-static nested types)\"", + "title=\"All Packages\"", + "title=\"Package, class and interface descriptions\""); } } diff --git a/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java b/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java index 0d18145632b..323ba26f0c9 100644 --- a/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java +++ b/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java @@ -26,141 +26,35 @@ * @bug 4636667 7052425 8016549 * @summary Use , and

    in proper sequence for accessibility * @author dkramer + * @library ../lib + * @build JavadocTester * @run main AccessH1 */ -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; +public class AccessH1 extends JavadocTester { - -/** - * 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 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(); + public static void main(String... args) throws Exception { + AccessH1 tester = new AccessH1(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } - } + @Test + void test() { + javadoc("-d", "out", + "-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 - { - "h1 {\n" + - " font-size:20px;\n" + - "}", - TMPDEST_DIR1 + "stylesheet.css" - }, + checkOutput("stylesheet.css", true, + "h1 {\n" + + " font-size:20px;\n" + + "}"); + // Test the doc title in the overview page - { - "

    Document Title

    ", - 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); + checkOutput("overview-summary.html", true, + "

    Document Title

    "); } } diff --git a/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java b/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java index 38d6f136297..2299193ec76 100644 --- a/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java +++ b/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java @@ -26,150 +26,40 @@ * @bug 4638136 7198273 8025633 * @summary Add ability to skip over nav bar for accessibility * @author dkramer + * @library ../lib + * @build JavadocTester * @run main AccessSkipNav */ +public class AccessSkipNav extends JavadocTester { -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - -/** - * 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(); + public static void main(String... args) throws Exception { + AccessSkipNav tester = new AccessSkipNav(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } - } + @Test + void test() { + javadoc("-d", "out", + "-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 = { + // Testing only for the presence of the and + checkOutput("p1/C1.html", true, + // Top navbar + "Skip navigation links", + // Top navbar + "\n" + + "\n" + + "", + // Bottom navbar + "Skip navigation links", + // Bottom navbar + "\n" + + "\n" + + ""); - // Testing only for the presence of the and - // Top navbar - { "Skip navigation links", - TMPDEST_DIR1 + "p1/C1.html" }, - - // Top navbar - { "\n" + - "\n" + - "", - TMPDEST_DIR1 + "p1/C1.html" }, - - // Bottom navbar - { "Skip navigation links", - TMPDEST_DIR1 + "p1/C1.html" }, - - // Bottom navbar - { "\n" + - "\n" + - "", - 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); } } diff --git a/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java b/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java index 0aa3aca9852..7bdd0a7eefd 100644 --- a/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java +++ b/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java @@ -26,45 +26,35 @@ * @bug 4637604 4775148 * @summary Test the tables for summary attribute * @author dkramer - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build AccessSummary * @run main AccessSummary */ 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. * @param args the array of command line arguments. + * @throws Exception if the test fails */ - public static void main(String[] args) { - JavadocTester tester = new AccessSummary(); - tester.run(JAVADOC_ARGS, TESTARRAY1, new String[][] {}); - tester.printSummary(); // Necessary for string search + public static void main(String... args) throws Exception { + AccessSummary tester = new AccessSummary(); + tester.runTests(); + } + + @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\""); } } diff --git a/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java index 4b108276f80..69e82f96ced 100644 --- a/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java +++ b/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java @@ -26,143 +26,37 @@ * @bug 4651598 8026567 * @summary Javadoc wrongly inserts tags when using multiple @author tags * @author dkramer + * @library ../lib + * @build JavadocTester * @run main AuthorDD */ - -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - /** * 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"); - - private static final String BUGID = "4651598"; - 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", "."); + public static void main(String... args) throws Exception { + AuthorDD tester = new AuthorDD(); + tester.runTests(); + } + @Test + void test() { // Test for all cases except the split index page - runJavadoc(new String[] {"-d", BUGID, - "-author", - "-version", - "-sourcepath", srcdir, - "p1"}); - runTestsOnHTML(testArray); + javadoc("-d", "out", + "-author", + "-version", + "-sourcepath", testSrc, + "p1"); + checkExit(Exit.OK); - printSummary(); - } - - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(AuthorDD.class.getClassLoader(), - 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 single @since tag: - - { "
    Since:
    \n" + - "
    JDK 1.0
    ", - BUGID + "/p1/C1.html" }, - - // Test multiple @author tags: - - { "
    Author:
    \n" + - "
    Doug Kramer, Jamie, Neal
    ", - 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); + checkOutput("p1/C1.html", true, + // Test single @since tag: + "
    Since:
    \n" + + "
    JDK 1.0
    ", + // Test multiple @author tags: + "
    Author:
    \n" + + "
    Doug Kramer, Jamie, Neal
    "); } } diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java b/langtools/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java index 67c0b19968b..314a8d21dbf 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java +++ b/langtools/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java @@ -26,13 +26,11 @@ * @bug 4524350 4662945 4633447 * @summary stddoclet: {@docRoot} inserts an extra trailing "/" * @author dkramer + * @library ../lib + * @build JavadocTester * @run main DocRootSlash */ -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; -import java.nio.*; import java.util.regex.*; /** @@ -40,149 +38,55 @@ import java.util.regex.*; * It reads each file, complete with newlines, into a string to easily * find strings that contain newlines. */ -public class DocRootSlash -{ - private static final String BUGID = "4524350, 4662945, or 4633447"; - private static final String BUGNAME = "DocRootSlash"; - private static final String TMPDIR_STRING1 = "./docs1/"; +public class DocRootSlash extends JavadocTester { - // Test number. Needed because runResultsOnHTMLFile is run twice, and subtestNum - // should increment across test runs. - public static int subtestNum = 0; - public static int numOfSubtestsPassed = 0; - - // Entry point - public static void main(String[] args) { + public static void main(String... args) throws Exception { + DocRootSlash tester = new DocRootSlash(); + tester.runTests(); + } + @Test + void test() { // Directory that contains source files that javadoc runs on String srcdir = System.getProperty("test.src", "."); - runJavadoc(new String[] {"-d", TMPDIR_STRING1, - "-Xdoclint:none", - "-overview", (srcdir + "/overview.html"), - "-header", "{@docroot} {@docRoot}", - "-sourcepath", srcdir, - "p1", "p2"}); - runTestsOnHTMLFiles(filenameArray); + javadoc("-d", "out", + "-Xdoclint:none", + "-overview", (srcdir + "/overview.html"), + "-header", "{@docroot} {@docRoot}", + "-sourcepath", srcdir, + "p1", "p2"); - printSummary(); - } - - /** Run javadoc */ - 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); - } - } + checkFiles( + "p1/C1.html" , + "p1/package-summary.html", + "overview-summary.html"); // Bug 4633447: Special test for overview-frame.html // Find two strings in file "overview-frame.html" - String filename = TMPDIR_STRING1 + "overview-frame.html"; - fileString = readFileToString(filename); - - // Find first string in overview-frame.html - subtestNum += 1; - String stringToFind = ""; - 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 in overview-frame.html - subtestNum += 1; - stringToFind = ""; - 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); + checkOutput("overview-frame.html", true, + "", + ""); } - public static void printSummary() { - System.out.println(""); - 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"); - } - } + void checkFiles(String... filenameArray) { + int count = 0; - // Read the contents of 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); + for (String f : filenameArray) { + // Read contents of file into a string + String fileString = readFile(f); + System.out.println("\nSub-tests for file: " + f + " --------------"); + // Loop over all tests in a single file + 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 - * /java/pubs/dev/linkfix/src/LinkFix.java + * Regular expression pattern matching code * * Prefix Pattern: * 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) * group5 () (end tag) */ - static String prefix = "(?i)()"; // doublequotes (end group1, group2, group3) - static String ref2 = ")(\\S+?)([^<>]*>)"; // no quotes (end group1, group2, group3) - static String label = "(.*?)"; // text label (group4) - static String end = "()"; // (group5) + private static final String prefix = "(?i)()"; // doublequotes (end group1, group2, group3) + private static final String ref2 = ")(\\S+?)([^<>]*>)"; // no quotes (end group1, group2, group3) + private static final String label = "(.*?)"; // text label (group4) + private static final String end = "()"; // (group5) /** * 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) { - // Pattern must be compiled each run because subtestNum is incremented + void compareActualToExpected(int count, String str) { + checking("comparison for " + str); + + // Pattern must be compiled each run because numTestsRun is incremented 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.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); - CharBuffer charBuffer = CharBuffer.wrap(str); - Matcher actualLinkMatcher1 = actualLinkPattern1.matcher(charBuffer); - Matcher expectLinkMatcher1 = expectLinkPattern1.matcher(charBuffer); - String result; - if ( expectLinkMatcher1.find() && actualLinkMatcher1.find() ) { + Matcher actualLinkMatcher1 = actualLinkPattern1.matcher(str); + Matcher expectLinkMatcher1 = expectLinkPattern1.matcher(str); + if (expectLinkMatcher1.find() && actualLinkMatcher1.find()) { String expectRef = expectLinkMatcher1.group(2); String actualRef = actualLinkMatcher1.group(2); - if ( actualRef.equals(expectRef) ) { - result = "succeeded"; - numOfSubtestsPassed += 1; + if (actualRef.equals(expectRef)) { + passed(expectRef); // System.out.println("pattern: " + actualLinkPattern1.pattern()); // System.out.println("actualRef: " + actualRef); // System.out.println("group0: " + actualLinkMatcher1.group()); @@ -233,15 +136,13 @@ public class DocRootSlash // System.out.println("group3: " + actualLinkMatcher1.group(3)); // System.exit(0); } 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 { - System.out.println("Didn't find that fits the pattern: " - + expectLinkPattern1.pattern() ); + failed("Didn't find that fits the pattern: " + + expectLinkPattern1.pattern()); } } } diff --git a/langtools/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java b/langtools/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java index 04d77e35bfa..65632e5cbd2 100644 --- a/langtools/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java +++ b/langtools/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,11 @@ * @bug 8008768 * @summary Using {@inheritDoc} in simple tag defined via -tag fails * @author Mike Duigou + * @library ../lib + * @build JavadocTester * @run main DocTest */ -import java.io.*; - /** * DocTest documentation. * @@ -38,41 +38,27 @@ import java.io.*; * @implSpec DocTest implementation spec. * @implNote DocTest implementation note. */ -public class DocTest { +public class DocTest extends JavadocTester { public static void main(String... args) throws Exception { - String[] javadoc_args = { - "-verbose", - "-d", "DocTest", - "-tag", "apiNote:optcm:API Note", - "-tag", "implSpec:optcm:Implementation Requirements:", - "-tag", "implNote:optcm:Implementation Note:", - "-package", - new File(System.getProperty("test.src"), "DocTest.java").getPath() - }; + DocTest tester = new DocTest(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-verbose", + "-d", "DocTest", + "-tag", "apiNote:optcm:API Note", + "-tag", "implSpec:optcm:Implementation Requirements:", + "-tag", "implNote:optcm:Implementation Note:", + "-package", + testSrc("DocTest.java") + ); + checkExit(Exit.OK); // javadoc does not report an exit code for an internal exception (!) // so monitor stderr for stack dumps. - PrintStream prevErr = System.err; - 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"); + checkOutput(Output.STDERR, false, "at com.sun"); } /** diff --git a/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java b/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java index 161427d7f0f..854663d1d7f 100644 --- a/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java +++ b/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java @@ -27,172 +27,49 @@ * @summary Javascript IE load error when linked by -linkoffline * Window title shouldn't change when loading left frames (javascript) * @author dkramer + * @library ../lib + * @build JavadocTester * @run main JavascriptWinTitle */ +public class JavascriptWinTitle extends JavadocTester { -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - -/** - * 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(); + public static void main(String... args) throws Exception { + JavascriptWinTitle tester = new JavascriptWinTitle(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } - } + @Test + void test() { + javadoc("-d", "out", + "-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, + "", - 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); + // Test that win title javascript is followed by NOSCRIPT code. + checkOutput("p1/C.html", true, + ""); } } diff --git a/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java b/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java index 49456b5bfa0..2a14fbd0315 100644 --- a/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java +++ b/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java @@ -21,114 +21,94 @@ * questions. */ -import java.text.SimpleDateFormat; -import java.util.Date; - /* * @test * @bug 4034096 4764726 6235799 * @summary Add support for HTML keywords via META tag for * class and member names to improve API search * @author dkramer - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build MetaTag * @run main MetaTag */ +import java.text.SimpleDateFormat; +import java.util.Date; + 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", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/package-summary.html", - "" }, - - { "overview-summary.html", - "" }, - - //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", - ""}, - }; - - private static final String[][] NEGATED_TEST2 = { - //No keywords when -keywords is not used. - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/C1.html", - "" }, - - { "p1/package-summary.html", - "" }, - - { "overview-summary.html", - "" }, - - //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", - ""}, - }; - /** * 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(); - tester.run(ARGS, TEST, NO_TEST); - tester.run(ARGS_NO_TIMESTAMP_NO_KEYWORDS, NO_TEST, NEGATED_TEST2); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testStandard() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + "-keywords", + "-doctitle", "Sample Packages", + "p1", "p2"); + + checkExit(Exit.OK); + + checkOutput("p1/C1.html", true, + "", + "", + "", + "", + ""); + + checkOutput("p1/package-summary.html", true, + ""); + + checkOutput("overview-summary.html", true, + ""); + + // 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, + ""); + } + + @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, + "", + "", + "", + "", + ""); + + checkOutput("p1/package-summary.html", false, + ""); + + checkOutput("overview-summary.html", false, + ""); + + // 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, + ""); + } + + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + String date() { + return dateFormat.format(new Date()); } } diff --git a/langtools/test/com/sun/javadoc/PackagesHeader/PackagesHeader.java b/langtools/test/com/sun/javadoc/PackagesHeader/PackagesHeader.java index aa7ba2dbb9e..ff2a98e9151 100644 --- a/langtools/test/com/sun/javadoc/PackagesHeader/PackagesHeader.java +++ b/langtools/test/com/sun/javadoc/PackagesHeader/PackagesHeader.java @@ -28,83 +28,62 @@ * is present for three sets of options: (1) -header, * (2) -packagesheader, and (3) -header -packagesheader * @author dkramer - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build PackagesHeader * @run main PackagesHeader */ public class PackagesHeader extends JavadocTester { - //Test information. - private static final String OUTPUT_DIR1 = OUTPUT_DIR + "-1/"; - private static final String OUTPUT_DIR2 = OUTPUT_DIR + "-2/"; - private static final String OUTPUT_DIR3 = OUTPUT_DIR + "-3/"; + public static void main(String... args) throws Exception { + JavadocTester tester = new PackagesHeader(); + tester.runTests(); + } - /** - * Assign value for [ fileToSearch, stringToFind ] - */ - private static final String[][] TESTARRAY1 = { + @Test + void testHeader() { + // First test with -header only + 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 - { "overview-frame.html", - "Main Frame Header" } - }; + checkOutput("overview-frame.html", true, + "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 // up in the packages frame + checkOutput("overview-frame.html", true, + "Packages Frame Header"); + } - { "overview-frame.html", - "Packages Frame Header" } - }; - - private static final String[][] TESTARRAY3 = { + @Test + void testBothHeaders() { + // Third test with both -packagesheader and -header + javadoc("-d", "out-both", + "-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 + checkOutput("overview-frame.html", true, + "Packages Frame Header"); - { "overview-frame.html", - "Packages 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(); + checkOutput("overview-summary.html", true, + "Main Frame Header"); } } diff --git a/langtools/test/com/sun/javadoc/T6735320/T6735320.java b/langtools/test/com/sun/javadoc/T6735320/T6735320.java index 531e4a64bba..2f913274893 100644 --- a/langtools/test/com/sun/javadoc/T6735320/T6735320.java +++ b/langtools/test/com/sun/javadoc/T6735320/T6735320.java @@ -25,24 +25,24 @@ * @test * @bug 6735320 * @summary javadoc throws exception if serialField value is missing - * @library ../lib/ - * @build JavadocTester T6735320 + * @library ../lib + * @build JavadocTester * @run main T6735320 */ + public class T6735320 extends JavadocTester { - private static final String[] ARGS = new String[]{ - "-d", OUTPUT_DIR + ".out", - SRC_DIR + "/SerialFieldTest.java" - }; - - public static void main(String... args) { + public static void main(String... args) throws Exception { T6735320 tester = new T6735320(); - if (tester.runJavadoc(ARGS) == 0) { - throw new AssertionError("zero return code from javadoc"); - } - if (tester.getErrorOutput().contains("StringIndexOutOfBoundsException")) { - throw new AssertionError("javadoc threw StringIndexOutOfBoundsException"); - } + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + testSrc("SerialFieldTest.java")); + checkExit(Exit.FAILED); + checkOutput(Output.STDERR, false, + "StringIndexOutOfBoundsException"); } } diff --git a/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java b/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java index 3c9a5a64a39..43da7cdae81 100644 --- a/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java +++ b/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java @@ -30,174 +30,52 @@ * not allowed outside <FRAMESET> element * HTML table tags inserted in wrong place in pakcage use page * @author dkramer + * @library ../lib + * @build JavadocTester * @run main ValidHtml */ -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; +public class ValidHtml extends JavadocTester { -/** - * 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 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", "."); + public static void main(String... args) throws Exception { + ValidHtml tester = new ValidHtml(); + tester.runTests(); + } + @Test + void test() { // Test for all cases except the split index page - runJavadoc(new String[]{"-d", TMPDEST_DIR1, + javadoc("-d", "out", "-doctitle", "Document Title", "-windowtitle", "Window Title", "-use", - "-overview", (srcdir + "/overview.html"), - "-sourcepath", srcdir, - "p1", "p2" - }); - runTestsOnHTML(testArray); + "-overview", testSrc("overview.html"), + "-sourcepath", testSrc, + "p1", "p2"); + checkExit(Exit.OK); - 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: - { - "\n" + - "", - TMPDEST_DIR1 + "index.html" - }, + checkOutput("index.html", true, + "\n" + + ""); + // Test the table elements are in the correct order: - { - "\n" + - "", - 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); - } - } + checkOutput("p1/package-use.html", true, + "\n" + + ""); } - 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); - } + private static final String FRAMESET = + ""; + private static final String LOOSE = + ""; } diff --git a/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java b/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java index 44aca3ae30a..7089e50517d 100644 --- a/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java +++ b/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java @@ -26,131 +26,31 @@ * @bug 4720849 * @summary com.sun.tools.doclets.standard.Standard contains hard-coded version number * @author dkramer + * @library ../lib + * @build JavadocTester * @run main VersionNumber */ -import com.sun.javadoc.*; -import java.util.*; -import java.io.*; - - /** * 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"; - private static final String BUGNAME = "VersionNumber"; - 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, - "p1"}); - runTestsOnHTML(testArray); - - printSummary(); + public static void main(String... args) throws Exception { + VersionNumber tester = new VersionNumber(); + tester.runTests(); } - /** Run javadoc */ - public static void runJavadoc(String[] javadocArgs) { - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { - throw new Error("Javadoc failed to execute"); - } + @Test + void test() { + javadoc("-d", "out", + "p1"); + checkExit(Exit.OK); + + // Test the proper DOCTYPE element is present: + checkOutput("p1/C.html", true, + ""}, - { "pkg/AnnotationTypeField.html", - "

    Field Summary

    "}, - { "pkg/AnnotationTypeField.html", - "
    DEFAULT_NAME" + - " "}, - { "pkg/AnnotationTypeField.html", - ""}, - { "pkg/AnnotationTypeField.html", - "

    DEFAULT_NAME

    \n" + - "
    public static final java." +
    -            "lang.String DEFAULT_NAME
    "}, - { "pkg/AnnotationType.html", - "
  • Summary: 
  • \n" + - "
  • Field | 
  • "}, - { "pkg/AnnotationType.html", - "
  • Detail: 
  • \n" + - "
  • Field | 
  • "}, - }; - private static final String[][] NEGATED_TEST = { - { "pkg/AnnotationType.html", - "
    \n\n" + - "

    \n\n" + - "

    " + - "" + "


    "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestAnnotationTypes tester = new TestAnnotationTypes(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/AnnotationTypeField.html", true, + "
  • Summary: 
  • \n" + + "
  • Field | 
  • ", + "
  • Detail: 
  • \n" + + "
  • Field | 
  • ", + "", + "

    Field Summary

    ", + "DEFAULT_NAME" + + " ", + "", + "

    DEFAULT_NAME

    \n" + + "
    public static final java."
    +                + "lang.String DEFAULT_NAME
    "); + + checkOutput("pkg/AnnotationType.html", true, + "
  • Summary: 
  • \n" + + "
  • Field | 
  • ", + "
  • Detail: 
  • \n" + + "
  • Field | 
  • "); + + checkOutput("pkg/AnnotationType.html", false, + "
    \n\n" + + "

    \n\n" + + "

    " + + "" + "


    "); } } diff --git a/langtools/test/com/sun/javadoc/testBackSlashInLink/TestBackSlashInLink.java b/langtools/test/com/sun/javadoc/testBackSlashInLink/TestBackSlashInLink.java index f7973439012..3236ce4be79 100644 --- a/langtools/test/com/sun/javadoc/testBackSlashInLink/TestBackSlashInLink.java +++ b/langtools/test/com/sun/javadoc/testBackSlashInLink/TestBackSlashInLink.java @@ -27,28 +27,27 @@ * @summary Test to make sure that the link to source documentation * has a forward slash. It would be wrong to use a back slash. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestBackSlashInLink * @run main TestBackSlashInLink */ public class TestBackSlashInLink extends JavadocTester { - private static final String[][] TEST = { - { "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) { + public static void main(String... args) throws Exception { TestBackSlashInLink tester = new TestBackSlashInLink(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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"); } } diff --git a/langtools/test/com/sun/javadoc/testBadPackageFileInJar/TestBadPackageFileInJar.java b/langtools/test/com/sun/javadoc/testBadPackageFileInJar/TestBadPackageFileInJar.java index 32bca3224a2..f3a51e1072c 100644 --- a/langtools/test/com/sun/javadoc/testBadPackageFileInJar/TestBadPackageFileInJar.java +++ b/langtools/test/com/sun/javadoc/testBadPackageFileInJar/TestBadPackageFileInJar.java @@ -27,33 +27,27 @@ * @summary Test to make sure that Javadoc emits a useful warning * when a bad package.html file is in the JAR. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestBadPackageFileInJar * @run main TestBadPackageFileInJar */ public class TestBadPackageFileInJar extends JavadocTester { - private static final String[][] TEST = - 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) { + public static void main(String... args) throws Exception { TestBadPackageFileInJar tester = new TestBadPackageFileInJar(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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"); } } diff --git a/langtools/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java b/langtools/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java index cf60a9f6edb..6ee63656c4c 100644 --- a/langtools/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java +++ b/langtools/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java @@ -27,27 +27,28 @@ * @summary Make sure exception is not thrown if there is a bad source * file in the same directory as the file being documented. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestBadSourceFile * @run main TestBadSourceFile */ 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. - * @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(); - int exitCode = tester.run(ARGS, NO_TEST, NO_TEST); - tester.checkExitCode(0, exitCode); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + testSrc("C2.java")); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/testBaseClass/TestBaseClass.java b/langtools/test/com/sun/javadoc/testBaseClass/TestBaseClass.java index d25e8e06b30..b6a71de3a1b 100644 --- a/langtools/test/com/sun/javadoc/testBaseClass/TestBaseClass.java +++ b/langtools/test/com/sun/javadoc/testBaseClass/TestBaseClass.java @@ -26,29 +26,25 @@ * @bug 4197513 * @summary Javadoc does not process base class. * @author jamieh - * @library ../lib/ + * @library ../lib * @build BaseClass * @build JavadocTester - * @build TestBaseClass * @run main TestBaseClass */ public class TestBaseClass extends JavadocTester { - private static final String[] ARGS = - 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) { + public static void main(String... args) throws Exception { TestBaseClass tester = new TestBaseClass(); - if (tester.run(ARGS, NO_TEST, NO_TEST) != 0) { - throw new Error("Javadoc failed to execute."); - } + tester.runTests(); + } + + @Test + void test() { + javadoc("-sourcepath", testSrc, + "-docletpath", testSrc, + "-doclet", "BaseClass", + testSrc("Bar.java"), "baz"); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/testBreakIterator/TestBreakIterator.java b/langtools/test/com/sun/javadoc/testBreakIterator/TestBreakIterator.java index f0dd06e3feb..161ac5d0dc6 100644 --- a/langtools/test/com/sun/javadoc/testBreakIterator/TestBreakIterator.java +++ b/langtools/test/com/sun/javadoc/testBreakIterator/TestBreakIterator.java @@ -29,29 +29,27 @@ * Correct Answer: "The class is empty (i.e. it has no members)." * Wrong Answer: "The class is empty (i.e." * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestBreakIterator * @run main TestBreakIterator */ public class TestBreakIterator extends JavadocTester { - private static final String[][] TEST = { - { "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) { + public static void main(String... args) throws Exception { TestBreakIterator tester = new TestBreakIterator(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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)."); } } diff --git a/langtools/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java b/langtools/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java index 5bac9a6f553..5c712a41023 100644 --- a/langtools/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java +++ b/langtools/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java @@ -26,9 +26,8 @@ * @bug 4979486 * @summary Make sure tool parses CR line separators properly. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestCRLineSeparator * @run main TestCRLineSeparator */ @@ -37,32 +36,27 @@ import java.util.*; public class TestCRLineSeparator extends JavadocTester { - //Javadoc arguments. - 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"); + public static void main(String... args) throws Exception { TestCRLineSeparator tester = new TestCRLineSeparator(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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 // 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 to_f = new File(toDir, f); if (from_f.isDirectory()) { @@ -71,23 +65,17 @@ public class TestCRLineSeparator extends JavadocTester { initFiles(from_f, to_f, child); } } else { - List lines = new ArrayList(); - BufferedReader in = new BufferedReader(new FileReader(from_f)); - try { + List lines = new ArrayList<>(); + try (BufferedReader in = new BufferedReader(new FileReader(from_f))) { String line; while ((line = in.readLine()) != null) lines.add(line); - } finally { - in.close(); } - BufferedWriter out = new BufferedWriter(new FileWriter(to_f)); - try { + try (BufferedWriter out = new BufferedWriter(new FileWriter(to_f))) { for (String line: lines) { out.write(line); out.write("\r"); } - } finally { - out.close(); } } } diff --git a/langtools/test/com/sun/javadoc/testCharset/TestCharset.java b/langtools/test/com/sun/javadoc/testCharset/TestCharset.java index d851a659c98..eede6110636 100644 --- a/langtools/test/com/sun/javadoc/testCharset/TestCharset.java +++ b/langtools/test/com/sun/javadoc/testCharset/TestCharset.java @@ -27,39 +27,34 @@ * @summary Run a test on -charset to make sure the charset gets generated as a * part of the meta tag. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestCharset + * @library ../lib + * @build JavadocTester * @run main TestCharset */ public class TestCharset extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-charset", "UTF-8", "-sourcepath", SRC_DIR, "pkg" - }; - - private static final String[][] TEST = { - { "index.html", - ""}, - { "pkg/Foo.html", - ""} - }; - - private static final String[][] NEGATED_TEST = { - { "index.html", - ""}, - { "pkg/Foo.html", - ""} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestCharset tester = new TestCharset(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-charset", "UTF-8", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("index.html", true, + ""); + checkOutput("pkg/Foo.html", true, + ""); + + checkOutput("index.html", false, + ""); + checkOutput("pkg/Foo.html", false, + ""); } } diff --git a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java index 6617c6e61ec..9f1d54d4527 100644 --- a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java +++ b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java @@ -26,7 +26,7 @@ * @bug 4652655 4857717 8025633 8026567 * @summary This test verifies that class cross references work properly. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester * @build TestClassCrossReferences * @run main TestClassCrossReferences @@ -34,37 +34,34 @@ public class TestClassCrossReferences extends JavadocTester { - private static final String[][] TEST = { - { "C.html", - "Link to math package"}, - { "C.html", - "Link to AttributeContext innerclass"}, - { "C.html", - "Link to external class BigDecimal"}, - { "C.html", - "Link to external member gcd"}, - { "C.html", - "
    \n" + - "
    Overrides:
    \n" + - "
    toString in class java.lang.Object
    \n" + - "
    "} - }; - 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) { + public static void main(String... args) throws Exception { TestClassCrossReferences tester = new TestClassCrossReferences(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); } + + @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, + "" + + "Link to math package", + "Link to AttributeContext innerclass", + "Link to external class BigDecimal", + "Link to external member gcd", + "
    \n" + + "
    Overrides:
    \n" + + "
    toString in class java.lang.Object
    \n" + + "
    "); + } + } diff --git a/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java b/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java index 9215c4e54fc..22070488d77 100644 --- a/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java +++ b/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java @@ -29,64 +29,52 @@ * Make sure class tree includes heirarchy for enums and annotation * types. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestClassTree * @run main TestClassTree */ public class TestClassTree extends JavadocTester { - //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/package-tree.html", - "
      \n" + - "
    • pkg.ParentClass"}, - - { "pkg/package-tree.html", - "

      Annotation Type Hierarchy

      \n" + - "
        \n" + - "
      • pkg.AnnotationType " + - "(implements java.lang.annotation.Annotation)
      • \n" + - "
      "}, - - { "pkg/package-tree.html", - "

      Enum Hierarchy

      \n" + - "
        \n" + - "
      • java.lang.Object\n" + - "
          \n" + - "
        • java.lang.Enum<E> (implements java.lang." + - "Comparable<T>, java.io.Serializable)\n" + - "
            \n" + - "
          • pkg.Coin
          • \n" + - "
          \n" + - "
        • \n" + - "
        \n" + - "
      • \n" + - "
      " - }, - }; - private static final String[][] NEGATED_TEST = { - { "pkg/package-tree.html", - "
    • class pkg.ParentClass
    • "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestClassTree tester = new TestClassTree(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/package-tree.html", true, + "
        \n" + + "
      • pkg.ParentClass", + "

        Annotation Type Hierarchy

        \n" + + "
          \n" + + "
        • pkg.AnnotationType " + + "(implements java.lang.annotation.Annotation)
        • \n" + + "
        ", + "

        Enum Hierarchy

        \n" + + "
          \n" + + "
        • java.lang.Object\n" + + "
            \n" + + "
          • java.lang.Enum<E> (implements java.lang." + + "Comparable<T>, java.io.Serializable)\n" + + "
              \n" + + "
            • pkg.Coin
            • \n" + + "
            \n" + + "
          • \n" + + "
          \n" + + "
        • \n" + + "
        "); + + checkOutput("pkg/package-tree.html", false, + "
      • class pkg.ParentClass
      • "); } } diff --git a/langtools/test/com/sun/javadoc/testCmndLineClass/TestCmndLineClass.java b/langtools/test/com/sun/javadoc/testCmndLineClass/TestCmndLineClass.java index 7daae9edef8..e21ca6b5653 100644 --- a/langtools/test/com/sun/javadoc/testCmndLineClass/TestCmndLineClass.java +++ b/langtools/test/com/sun/javadoc/testCmndLineClass/TestCmndLineClass.java @@ -28,47 +28,44 @@ * when specifying packages on the command line and specifying individual * classes. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestCmndLineClass * @run main TestCmndLineClass */ public class TestCmndLineClass extends JavadocTester { - private static final String OUTPUT_DIR1 = "4506980-tmp1"; - 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) { + public static void main(String... args) throws Exception { TestCmndLineClass tester = new TestCmndLineClass(); - tester.run(ARGS1, NO_TEST, NO_TEST); - tester.run(ARGS2, NO_TEST, NO_TEST); - tester.runDiffs(OUTPUT_DIR1, OUTPUT_DIR2, FILES_TO_DIFF); + tester.runTests(); + } + + @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"); } } diff --git a/langtools/test/com/sun/javadoc/testCompletionFailure/TestCompletionFailure.java b/langtools/test/com/sun/javadoc/testCompletionFailure/TestCompletionFailure.java index 0c708048ca7..83434c0b64e 100644 --- a/langtools/test/com/sun/javadoc/testCompletionFailure/TestCompletionFailure.java +++ b/langtools/test/com/sun/javadoc/testCompletionFailure/TestCompletionFailure.java @@ -26,32 +26,28 @@ * @bug 8027977 * @summary Test to verify javadoc executes without CompletionFailure exception. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestCompletionFailure + * @library ../lib + * @build JavadocTester * @run main TestCompletionFailure */ public class TestCompletionFailure extends JavadocTester { - //Input for string search tests. - 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 { + public static void main(String... args) throws Exception { TestCompletionFailure tester = new TestCompletionFailure(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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"); } } diff --git a/langtools/test/com/sun/javadoc/testConstantValuesPage/TestConstantValuesPage.java b/langtools/test/com/sun/javadoc/testConstantValuesPage/TestConstantValuesPage.java index b85bf6dc3d8..b0e9bd1643b 100644 --- a/langtools/test/com/sun/javadoc/testConstantValuesPage/TestConstantValuesPage.java +++ b/langtools/test/com/sun/javadoc/testConstantValuesPage/TestConstantValuesPage.java @@ -27,28 +27,26 @@ * @summary Test to make sure that constant values page does not get * generated when doclet has nothing to document. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestConstantValuesPage * @run main TestConstantValuesPage */ public class TestConstantValuesPage extends JavadocTester { - private static final String[][] NEGATED_TEST = { - {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) { + public static void main(String... args) throws Exception { TestConstantValuesPage tester = new TestConstantValuesPage(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "foo"); + checkExit(Exit.FAILED); + + checkOutput(Output.NOTICE, false, + "constant-values.html..."); } } diff --git a/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java index 40ab6a2ebbe..50efb7d8513 100644 --- a/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java +++ b/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java @@ -27,37 +27,31 @@ * @summary The constructor comments should be surrounded by *
        . Check for this in the output. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestConstructorIndent * @run main TestConstructorIndent */ public class TestConstructorIndent extends JavadocTester { - //Javadoc arguments. - 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", "
        " + - "This is just a simple constructor.
        \n" + - "
        \n" + - "
        Parameters:
        \n" + - "
        i - a param.
        \n" + - "
        " - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestConstructorIndent tester = new TestConstructorIndent(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("C.html", true, + "
        " + + "This is just a simple constructor.
        \n" + + "
        \n" + + "
        Parameters:
        \n" + + "
        i - a param.
        \n" + + "
        "); } } diff --git a/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java b/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java index 6d1585ef66b..c98501eda98 100644 --- a/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java +++ b/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java @@ -26,106 +26,66 @@ * @bug 8025524 8031625 * @summary Test for constructor name which should be a non-qualified name. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestConstructors + * @library ../lib + * @build JavadocTester * @run main TestConstructors */ public class TestConstructors extends JavadocTester { - //Input for string search tests. - private static final String[][] TEST = { - { "pkg1/Outer.html", - "
        See Also:
        \n" + - "
        Inner(), \n" + - "Inner(int), \n" + - "NestedInner(), \n" + - "NestedInner(int), \n" + - "Outer(), \n" + - "Outer(int)" - }, - { "pkg1/Outer.html", - "Link: Inner(), " + - "Outer(int), " + - "" + - "NestedInner(int)" - }, - { "pkg1/Outer.html", - "Outer()" - }, - { "pkg1/Outer.html", - "" - }, - { "pkg1/Outer.html", - "Outer(int i)" - }, - { "pkg1/Outer.html", - "" - }, - { "pkg1/Outer.Inner.html", - "Inner()" - }, - { "pkg1/Outer.Inner.html", - "" - }, - { "pkg1/Outer.Inner.html", - "Inner(int i)" - }, - { "pkg1/Outer.Inner.html", - "" - }, - { "pkg1/Outer.Inner.NestedInner.html", - "NestedInner()" - }, - { "pkg1/Outer.Inner.NestedInner.html", - "" - }, - { "pkg1/Outer.Inner.NestedInner.html", - "NestedInner(int i)" - }, - { "pkg1/Outer.Inner.NestedInner.html", - "" - } - }; - - 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", - "Outer.Inner()" - }, - { "pkg1/Outer.html", - "Outer.Inner(int)" - }, - { "pkg1/Outer.html", - "Outer.Inner.NestedInner()" - }, - { "pkg1/Outer.html", - "Outer.Inner.NestedInner(int)" - } - }; - - 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 { + public static void main(String... args) throws Exception { TestConstructors tester = new TestConstructors(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/Outer.html", true, + "
        See Also:
        \n" + + "
        Inner(), \n" + + "Inner(int), \n" + + "NestedInner(), \n" + + "NestedInner(int), \n" + + "Outer(), \n" + + "Outer(int)", + "Link: Inner(), " + + "Outer(int), " + + "" + + "NestedInner(int)", + "Outer()", + "", + "Outer(int i)", + ""); + + checkOutput("pkg1/Outer.Inner.html", true, + "Inner()", + "", + "Inner(int i)", + ""); + + checkOutput("pkg1/Outer.Inner.NestedInner.html", true, + "NestedInner()", + "", + "NestedInner(int i)", + ""); + + 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, + "Outer.Inner()", + "Outer.Inner(int)", + "Outer.Inner.NestedInner()", + "Outer.Inner.NestedInner(int)"); } } diff --git a/langtools/test/com/sun/javadoc/testCustomTag/TestCustomTag.java b/langtools/test/com/sun/javadoc/testCustomTag/TestCustomTag.java index b7fc0f2231c..0e69c20259b 100644 --- a/langtools/test/com/sun/javadoc/testCustomTag/TestCustomTag.java +++ b/langtools/test/com/sun/javadoc/testCustomTag/TestCustomTag.java @@ -26,69 +26,67 @@ * @bug 8006248 * @summary Test custom tag. Verify that an unknown tag generates appropriate warnings. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester taglets.CustomTag TestCustomTag + * @library ../lib + * @build JavadocTester taglets.CustomTag * @run main TestCustomTag */ public class TestCustomTag extends JavadocTester { - //Javadoc arguments. - 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) { + public static void main(String... args) throws Exception { TestCustomTag tester = new TestCustomTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.run(ARGS1, TEST1, NO_TEST); - tester.run(ARGS2, TEST2, NO_TEST); - tester.run(ARGS3, TEST3, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + 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"); } } diff --git a/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java b/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java index c31f7d215d8..fb1a1ab49f1 100644 --- a/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java +++ b/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java @@ -26,76 +26,65 @@ * @bug 4927552 8026567 * @summary * @author jamieh - * @library ../lib/ - * @build JavadocTester TestDeprecatedDocs + * @library ../lib + * @build JavadocTester * @run main TestDeprecatedDocs */ public class TestDeprecatedDocs extends JavadocTester { - //Javadoc arguments. - 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, "
        @Deprecated\n" +
        -                 "public class DeprecatedClassByAnnotation\n" +
        -                 "extends java.lang.Object
        "}, - - {TARGET_FILE2, "
        @Deprecated\n" +
        -                 "public int field
        \n" + - "
        Deprecated. 
        "}, - - {TARGET_FILE2, "
        @Deprecated\n" +
        -                 "public DeprecatedClassByAnnotation()
        \n" + - "
        Deprecated. 
        "}, - - {TARGET_FILE2, "
        @Deprecated\n" +
        -                 "public void method()
        \n" + - "
        Deprecated. 
        "}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestDeprecatedDocs tester = new TestDeprecatedDocs(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "
        @Deprecated\n"
        +                + "public class DeprecatedClassByAnnotation\n"
        +                + "extends java.lang.Object
        ", + "
        @Deprecated\n"
        +                + "public int field
        \n" + + "
        Deprecated. 
        ", + "
        @Deprecated\n"
        +                + "public DeprecatedClassByAnnotation()
        \n" + + "
        Deprecated. 
        ", + "
        @Deprecated\n"
        +                + "public void method()
        \n" + + "
        Deprecated. 
        "); } } diff --git a/langtools/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java b/langtools/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java index 273285b0abc..2a9eea8b8dc 100644 --- a/langtools/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java +++ b/langtools/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java @@ -31,36 +31,30 @@ * @summary Run tests on -docencoding to see if the value is used for stylesheet as well. * @author jayashree viswanathan - * @library ../lib/ - * @build JavadocTester TestDocEncoding + * @library ../lib + * @build JavadocTester * @run main TestDocEncoding */ public class TestDocEncoding extends JavadocTester { - //Javadoc arguments. - 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) { + public static void main(String... args) throws Exception { TestDocEncoding tester = new TestDocEncoding(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-docencoding", "Cp930", + "-sourcepath", testSrc, + "-notimestamp", + "pkg"); + checkExit(Exit.OK); + + checkOutput("stylesheet.css", false, + "body {\n" + + " background-color:#ffffff;"); } } diff --git a/langtools/test/com/sun/javadoc/testDocErrorReporter/TestDocErrorReporter.java b/langtools/test/com/sun/javadoc/testDocErrorReporter/TestDocErrorReporter.java index d6da8134420..6347ad2c619 100644 --- a/langtools/test/com/sun/javadoc/testDocErrorReporter/TestDocErrorReporter.java +++ b/langtools/test/com/sun/javadoc/testDocErrorReporter/TestDocErrorReporter.java @@ -27,31 +27,30 @@ * @summary Make sure that option validation errors and sent to the * DocErrorReporter. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestDocErrorReporter * @run main TestDocErrorReporter */ 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. - * @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(); - int actualExitCode = tester.run(ARGS, NO_TEST, NO_TEST); - tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-encoding", "xyz", + testSrc("TestDocErrorReporter.java")); + + checkExit(Exit.FAILED); } } diff --git a/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java b/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java index c939e49dc46..cdf81c7b149 100644 --- a/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java +++ b/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java @@ -21,8 +21,6 @@ * questions. */ -import java.io.File; - /* * @test * @bug 4258405 4973606 8024096 @@ -31,68 +29,59 @@ import java.io.File; * directory. * Also test that -docfilessubdirs and -excludedocfilessubdir both work. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestDocFileDir * @run main TestDocFileDir */ public class TestDocFileDir extends JavadocTester { - private static final String[][] TEST1 = { - { "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) { + public static void main(String... args) throws Exception { TestDocFileDir tester = new TestDocFileDir(); - tester.setCheckOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); - copyDir(SRC_DIR + "/pkg", "."); - tester.run(ARGS0, TEST0, NO_TEST); - copyDir(SRC_DIR + "/pkg", OUTPUT_DIR + "-1"); - tester.run(ARGS1, TEST1, NO_TEST); - tester.setCheckOutputDirectoryCheck(DirectoryCheck.NONE); - tester.run(ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2); - tester.printSummary(); + tester.runTests(); + } + + // Output dir = "", Input dir = "" + @Test + void test1() { + copyDir(testSrc("pkg"), "."); + 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"); } } diff --git a/langtools/test/com/sun/javadoc/testDocFiles/TestDocFiles.java b/langtools/test/com/sun/javadoc/testDocFiles/TestDocFiles.java index 7c17f1ae9d3..5d09ef9804e 100644 --- a/langtools/test/com/sun/javadoc/testDocFiles/TestDocFiles.java +++ b/langtools/test/com/sun/javadoc/testDocFiles/TestDocFiles.java @@ -25,28 +25,26 @@ * @test * @bug 8008949 * @summary verify that doc-files get copied - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestDocFiles * @run main TestDocFiles */ public class TestDocFiles extends JavadocTester { - private static final String[][] TEST = { - { "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) { + public static void main(String... args) throws Exception { TestDocFiles tester = new TestDocFiles(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/doc-files/test.txt", true, + "test file"); } } diff --git a/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java b/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java index 1b533334fc9..2adbe83343b 100644 --- a/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java +++ b/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java @@ -28,42 +28,38 @@ * If docRoot performs as documented, the test passes. * Make sure that the docRoot tag works with the -bottom option. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestDocRootInlineTag * @run main TestDocRootInlineTag */ public class TestDocRootInlineTag extends JavadocTester { - private static final String[][] TEST = { - { "TestDocRootTag.html", - "File"}, - { "TestDocRootTag.html", - "glossary"}, - { "TestDocRootTag.html", - "Second File Link"}, - { "TestDocRootTag.html", "The value of @docRoot is \"./\""}, - { "index-all.html", "My package page is " + - "here"} - }; - 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) { + public static void main(String... args) throws Exception { TestDocRootInlineTag tester = new TestDocRootInlineTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "File", + "glossary", + "Second File Link", + "The value of @docRoot is \"./\""); + + checkOutput("index-all.html", true, + "My package page is here"); } } diff --git a/langtools/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java b/langtools/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java index 972254630ff..377cdce7dbf 100644 --- a/langtools/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java +++ b/langtools/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java @@ -26,109 +26,78 @@ * @bug 6553182 8025416 8029504 * @summary This test verifies the -Xdocrootparent option. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestDocRootLink + * @library ../lib + * @build JavadocTester * @run main TestDocRootLink */ public class TestDocRootLink extends JavadocTester { - private static final String[][] TEST1 = { - { "pkg1/C1.html", - "Refer Here" - }, - { "pkg1/C1.html", - "This Here should not be replaced\n" + - " with an absolute link." - }, - { "pkg1/C1.html", - "Testing Link 1 and\n" + - " Link 2." - }, - { "pkg1/package-summary.html", - "\n" + - " Test document 1" - }, - { "pkg1/package-summary.html", - "\n" + - " Another Test document 1" - }, - { "pkg1/package-summary.html", - "\n" + - " Another Test document 2." - } - }; - private static final String[][] NEGATED_TEST1 = { - { "pkg1/C1.html", - "" - }, - { "pkg1/C1.html", - "" - }, - { "pkg1/package-summary.html", - "" - }, - { "pkg1/package-summary.html", - "" - } - }; - private static final String[][] TEST2 = { - { "pkg2/C2.html", - "Refer Here" - }, - { "pkg2/C2.html", - "This Here should not be replaced\n" + - " with an absolute link." - }, - { "pkg2/C2.html", - "Testing Link 1 and\n" + - " Link 2." - }, - { "pkg2/package-summary.html", - "\n" + - " Test document 1" - }, - { "pkg2/package-summary.html", - "\n" + - " Another Test document 1" - }, - { "pkg2/package-summary.html", - "\n" + - " Another Test document 2." - } - }; - private static final String[][] NEGATED_TEST2 = { - { "pkg2/C2.html", - "" - }, - { "pkg2/C2.html", - "" - }, - { "pkg2/package-summary.html", - "" - }, - { "pkg2/package-summary.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) { + public static void main(String... args) throws Exception { TestDocRootLink tester = new TestDocRootLink(); - tester.run(ARGS1, TEST1, NEGATED_TEST1); - tester.run(ARGS2, TEST2, NEGATED_TEST2); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test1() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg1/C1.html", true, + "Refer Here", + "This Here should not be replaced\n" + + " with an absolute link.", + "Testing Link 1 and\n" + + " Link 2."); + + checkOutput("pkg1/package-summary.html", true, + "\n" + + " Test document 1", + "\n" + + " Another Test document 1", + "\n" + + " Another Test document 2."); + + // TODO: should this check *any* reference to http://download.oracle.com/ + checkOutput("pkg1/C1.html", false, + "", + ""); + + checkOutput("pkg1/package-summary.html", false, + "", + ""); + } + + @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 Here", + "This Here should not be replaced\n" + + " with an absolute link.", + "Testing Link 1 and\n" + + " Link 2."); + + checkOutput("pkg2/package-summary.html", true, + "\n" + + " Test document 1", + "\n" + + " Another Test document 1", + "\n" + + " Another Test document 2."); + + checkOutput("pkg2/C2.html", false, + "", + ""); + + checkOutput("pkg2/package-summary.html", false, + "", + ""); } } diff --git a/langtools/test/com/sun/javadoc/testDupParamWarn/TestDupParamWarn.java b/langtools/test/com/sun/javadoc/testDupParamWarn/TestDupParamWarn.java index 94981f92c45..2d7e355e7bf 100644 --- a/langtools/test/com/sun/javadoc/testDupParamWarn/TestDupParamWarn.java +++ b/langtools/test/com/sun/javadoc/testDupParamWarn/TestDupParamWarn.java @@ -27,28 +27,26 @@ * @summary Test to ensure that the doclet does not print out bad * warning messages about duplicate param tags. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestDupParamWarn * @run main TestDupParamWarn */ public class TestDupParamWarn extends JavadocTester { - private static final String[] ARGS = - 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) { + public static void main(String... args) throws Exception { JavadocTester tester = new TestDupParamWarn(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput(Output.WARNING, false, + "Parameter \"a\" is documented more than once."); } } diff --git a/langtools/test/com/sun/javadoc/testEmptyClass/TestEmptyClass.java b/langtools/test/com/sun/javadoc/testEmptyClass/TestEmptyClass.java index 96b019202aa..48593211815 100644 --- a/langtools/test/com/sun/javadoc/testEmptyClass/TestEmptyClass.java +++ b/langtools/test/com/sun/javadoc/testEmptyClass/TestEmptyClass.java @@ -27,39 +27,32 @@ * @summary Test to make sure that Javadoc behaves properly when * run on a completely empty class (no comments or members). * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestEmptyClass * @run main TestEmptyClass */ 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 - { "overview-tree.html", ""}, + checkOutput("overview-tree.html", false, + ""); //The index page should not link to classes that were not documented - { "index-all.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"); - } + checkOutput("index-all.html", false, + ""); } } diff --git a/langtools/test/com/sun/javadoc/testEnclosingClass/TestEnclosingClass.java b/langtools/test/com/sun/javadoc/testEnclosingClass/TestEnclosingClass.java index 86affecf6c6..9e7d9681796 100644 --- a/langtools/test/com/sun/javadoc/testEnclosingClass/TestEnclosingClass.java +++ b/langtools/test/com/sun/javadoc/testEnclosingClass/TestEnclosingClass.java @@ -26,31 +26,26 @@ * @bug 5008230 * @summary Check the outer class when documenting enclosing class/interface. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestEnclosingClass * @run main TestEnclosingClass */ public class TestEnclosingClass extends JavadocTester { - //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/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) { + public static void main(String... args) throws Exception { TestEnclosingClass tester = new TestEnclosingClass(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/MyClass.MyInterface.html", true, + "Enclosing class:"); } } diff --git a/langtools/test/com/sun/javadoc/testEncoding/TestEncoding.java b/langtools/test/com/sun/javadoc/testEncoding/TestEncoding.java index 5627f4718a4..83ab93b0e08 100644 --- a/langtools/test/com/sun/javadoc/testEncoding/TestEncoding.java +++ b/langtools/test/com/sun/javadoc/testEncoding/TestEncoding.java @@ -27,32 +27,28 @@ * @summary This test determines if the value of the -encoding option is * properly passed from Javadoc to the source file parser. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestEncoding * @run main TestEncoding */ public class TestEncoding extends JavadocTester { - - //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) { + public static void main(String... args) throws Exception { TestEncoding tester = new TestEncoding(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "??"); } } diff --git a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java index 71e318c509a..0f2864891ad 100644 --- a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java +++ b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java @@ -28,41 +28,38 @@ * are documented properly. The method should still include "implements" or * "overrides" documentation even though the method is external. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester TestExternalOverridenMethod * @run main TestExternalOverridenMethod */ public class TestExternalOverridenMethod extends JavadocTester { - private static final String[][] TEST = { - { "pkg/XReader.html", - "
        Overrides:
        \n" + - "
        read in class " + - "FilterReader
        "}, - { "pkg/XReader.html", - "
        Specified by:
        \n" + - "
        readInt in interface " + - "DataInput
        "}}; - - 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) { + public static void main(String... args) throws Exception { TestExternalOverridenMethod tester = new TestExternalOverridenMethod(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "
        Overrides:
        \n" + + "
        read in class " + + "FilterReader
        ", + "
        Specified by:
        \n" + + "
        readInt in interface " + + "DataInput
        " + ); } } diff --git a/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java b/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java index 8d7b090df39..bde5bbe4ba6 100644 --- a/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java +++ b/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java @@ -25,14 +25,41 @@ * @test * @bug 8000418 8024288 * @summary Verify that files use a common Generated By string - * @library ../lib/ - * @build JavadocTester TestGeneratedBy + * @library ../lib + * @build JavadocTester * @run main TestGeneratedBy */ 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/package-summary.html", "pkg/package-frame.html", @@ -45,63 +72,25 @@ public class TestGeneratedBy extends JavadocTester { "serialized-form.html", "help-doc.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) { - String[][] tests = new String[FILES.length][]; - for (int i = 0; i < FILES.length; i++) { - tests[i] = new String[] { - FILES[i], + void checkTimestamps(boolean timestamp, String... files) { + String version = System.getProperty("java.version"); + String genBy = "Generated by javadoc"; + if (timestamp) genBy += " (" + version + ") on "; + + 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 ? "Generated by javadoc (version" : "Generated by javadoc ("), - "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"); + "Generated by javadoc on"); } } } diff --git a/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java b/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java index b1cdc9b8334..6e2234ad984 100644 --- a/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java +++ b/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java @@ -27,49 +27,46 @@ * @summary Test to make sure the -group option does not cause a bad warning * to be printed. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestGroupOption * @run main TestGroupOption */ public class TestGroupOption extends JavadocTester { - //Javadoc arguments. - 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. + public static void main(String... args) throws Exception { TestGroupOption tester = new TestGroupOption(); - tester.run(ARGS1, NO_TEST, NEGATED_TEST1); - tester.printSummary(); + tester.runTests(); + } + @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. - tester = new TestGroupOption(); - tester.run(ARGS2, TEST2, NO_TEST); - tester.printSummary(); + javadoc("-d", "out-2", + "-sourcepath", testSrc, + "-group", "Package One", "pkg1", + "-group", "Package One", "pkg2", + "-group", "Package One", "pkg3", + "pkg1", "pkg2", "pkg3"); + checkExit(Exit.OK); + + checkOutput(Output.WARNING, true, + "-group"); + } } diff --git a/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java b/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java index f3789cf5feb..a98f151edb3 100644 --- a/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java +++ b/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java @@ -26,7 +26,7 @@ * @bug 4905786 6259611 * @summary Make sure that headings use the TH tag instead of the TD tag. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester * @build TestHeadings * @run main TestHeadings @@ -34,87 +34,82 @@ 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 = { - //Package summary - { "pkg1/package-summary.html", - "" + - "Class\n" + - "Description" + + { + }, + { "serialized-form.html" + }, + { "serialized-form.html" }, - // Class documentation - { "pkg1/C1.html", - "Modifier and Type\n" + - "Field and Description" + { }, - { "pkg1/C1.html", - "

        Methods inherited from class java.lang.Object

        " + { "overview-frame.html" }, - - // Class use documentation - { "pkg1/class-use/C1.html", - "Package\n" + - "Description" - }, - { "pkg1/class-use/C1.html", - "Modifier and Type\n" + - "Field and Description" - }, - - // Deprecated - { "deprecated-list.html", - "Method and Description" - }, - - // Constant values - { "constant-values.html", - "" + - "Modifier and Type\n" + - "Constant Field\n" + - "Value" - }, - - // Serialized Form - { "serialized-form.html", - "

        Package pkg1

        " - }, - { "serialized-form.html", - "

        Class " + - "pkg1.C1 extends java.lang.Object implements Serializable

        " - }, - { "serialized-form.html", - "

        Serialized Fields

        " - }, - - // Overview Frame - { "overview-frame.html", - "

        Test Files

        " - }, - { "overview-frame.html", - "Overview List" - }, - - // Overview Summary - { "overview-summary.html", - "Overview" + { } }; - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestHeadings tester = new TestHeadings(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "" + + "Class\n" + + "Description"); + + // Class documentation + checkOutput("pkg1/C1.html", true, + "Modifier and Type\n" + + "Field and Description", + "

        Methods inherited from class java.lang.Object

        "); + + // Class use documentation + checkOutput("pkg1/class-use/C1.html", true, + "Package\n" + + "Description", + "Modifier and Type\n" + + "Field and Description"); + + // Deprecated + checkOutput("deprecated-list.html", true, + "Method and Description"); + + // Constant values + checkOutput("constant-values.html", true, + "" + + "Modifier and Type\n" + + "Constant Field\n" + + "Value"); + + // Serialized Form + checkOutput("serialized-form.html", true, + "

        Package pkg1

        ", + "

        Class " + + "pkg1.C1 extends java.lang.Object implements Serializable

        ", + "

        Serialized Fields

        "); + + // Overview Frame + checkOutput("overview-frame.html", true, + "

        Test Files

        ", + "Overview List"); + + // Overview Summary + checkOutput("overview-summary.html", true, + "Overview"); } } diff --git a/langtools/test/com/sun/javadoc/testHelpFile/TestHelpFile.java b/langtools/test/com/sun/javadoc/testHelpFile/TestHelpFile.java index ca628432e33..eaf14913b77 100644 --- a/langtools/test/com/sun/javadoc/testHelpFile/TestHelpFile.java +++ b/langtools/test/com/sun/javadoc/testHelpFile/TestHelpFile.java @@ -26,32 +26,26 @@ * @bug 7132631 * @summary Make sure that the help file is generated correctly. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestHelpFile + * @library ../lib + * @build JavadocTester * @run main TestHelpFile */ public class TestHelpFile extends JavadocTester { - //Javadoc arguments. - 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", - "Constant Field Values" - }, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestHelpFile tester = new TestHelpFile(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("TestHelpFile.java")); + checkExit(Exit.OK); + + checkOutput("help-doc.html", true, + "Constant Field Values"); } } diff --git a/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java b/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java index 44d6d322a07..9c571d63a8e 100644 --- a/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java +++ b/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java @@ -27,81 +27,79 @@ * @summary Make sure that the -help option works properly. Make sure * the help link appears in the documentation. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester TestHelpOption * @run main TestHelpOption */ public class TestHelpOption extends JavadocTester { - //Javadoc arguments. - 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", - "
      • Help
      • " - }, - }; - - //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) { + public static void main(String... args) throws Exception { TestHelpOption tester = new TestHelpOption(); - int actualExitCode = tester.run(ARGS, TEST, NO_TEST); - tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); - tester.run(ARGS2, TEST2, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "
      • Help
      • "); } } diff --git a/langtools/test/com/sun/javadoc/testHiddenMembers/TestHiddenMembers.java b/langtools/test/com/sun/javadoc/testHiddenMembers/TestHiddenMembers.java index 8d59523c6ee..6cbe9c846b1 100644 --- a/langtools/test/com/sun/javadoc/testHiddenMembers/TestHiddenMembers.java +++ b/langtools/test/com/sun/javadoc/testHiddenMembers/TestHiddenMembers.java @@ -27,34 +27,37 @@ * @summary Test to make sure that hidden overriden members are not * documented as inherited. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHiddenMembers * @run main TestHiddenMembers */ 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 = { - { "pkg/SubClass.html", - "inherited from class pkg.BaseClass"} + { } }; 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) { + public static void main(String... args) throws Exception { TestHiddenMembers tester = new TestHiddenMembers(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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.BaseClass"); } } diff --git a/langtools/test/com/sun/javadoc/testHref/TestHref.java b/langtools/test/com/sun/javadoc/testHref/TestHref.java index 09ad34e0233..f5311674695 100644 --- a/langtools/test/com/sun/javadoc/testHref/TestHref.java +++ b/langtools/test/com/sun/javadoc/testHref/TestHref.java @@ -26,73 +26,57 @@ * @bug 4663254 8016328 8025633 8026567 * @summary Verify that spaces do not appear in hrefs and anchors. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestHref + * @library ../lib + * @build JavadocTester * @run main TestHref */ public class TestHref extends JavadocTester { - //Javadoc arguments. - 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", - "\n" + - "\n" + - "" - }, - //Backward compatibility anchor test. - { "pkg/C1.html", - "\n" + - "\n" + - "" - }, - //{@link} test. - { "pkg/C2.html", - "Link: " - }, - //@see test. - { "pkg/C2.html", - "See Also:\n" + - "
        " - }, - - //Header does not link to the page itself. - { "pkg/C4.html", - "Class C4<E extends C4<E>>" - }, - - //Signature does not link to the page itself. - { "pkg/C4.html", - "public abstract class C4<E extends C4<E>>" - }, - }; - private static final String[][] NEGATED_TEST = - { - {WARNING_OUTPUT, " tag is malformed"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestHref tester = new TestHref(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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. + "\n" + + "\n" + + "", + //Backward compatibility anchor test."pkg/C1.html", + "\n" + + "\n" + + ""); + + checkOutput("pkg/C2.html", true, + //{@link} test. + "Link: ", + //@see test. + "See Also:\n" + + "
        " + ); + + checkOutput("pkg/C4.html", true, + //Header does not link to the page itself. + "Class C4<E extends C4<E>>", + //Signature does not link to the page itself. + "public abstract class C4<E extends C4<E>>" + ); + + checkOutput(Output.WARNING, false, + " tag is malformed"); } } diff --git a/langtools/test/com/sun/javadoc/testHrefInDocComment/TestHrefInDocComment.java b/langtools/test/com/sun/javadoc/testHrefInDocComment/TestHrefInDocComment.java index b37f0829127..427e471b933 100644 --- a/langtools/test/com/sun/javadoc/testHrefInDocComment/TestHrefInDocComment.java +++ b/langtools/test/com/sun/javadoc/testHrefInDocComment/TestHrefInDocComment.java @@ -27,26 +27,22 @@ * @summary Determine if Hrefs are processed properly when they * appear in doc comments. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHrefInDocComment * @run main TestHrefInDocComment */ public class TestHrefInDocComment extends JavadocTester { - 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) { + public static void main(String... args) throws Exception { TestHrefInDocComment tester = new TestHrefInDocComment(); - if (tester.run(ARGS, NO_TEST, NO_TEST) != 0) { - throw new Error("Javadoc failed to execute properly with given source."); - } + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, "pkg"); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlComments/TestHtmlComments.java b/langtools/test/com/sun/javadoc/testHtmlComments/TestHtmlComments.java index d23f599c02f..3b8379a89fe 100644 --- a/langtools/test/com/sun/javadoc/testHtmlComments/TestHtmlComments.java +++ b/langtools/test/com/sun/javadoc/testHtmlComments/TestHtmlComments.java @@ -27,32 +27,26 @@ * @summary The field detail comment should not show up in the output if there * are no fields to document. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHtmlComments * @run main TestHtmlComments */ public class TestHtmlComments extends JavadocTester { - //Javadoc arguments. - 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", - ""} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestHtmlComments tester = new TestHtmlComments(); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void run() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("C.html", false, + ""); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java index 7b3e4f685ca..3ed9594cff4 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java @@ -28,159 +28,250 @@ * @bug 6786690 6820360 8025633 8026567 * @summary This test verifies the nesting of definition list tags. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestHtmlDefinitionListTag + * @library ../lib + * @build JavadocTester * @run main TestHtmlDefinitionListTag */ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class TestHtmlDefinitionListTag extends JavadocTester { - // 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. - private static final String[][] TEST_ALL = { - { "pkg1/C1.html", + public static void main(String... args) throws Exception { + TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag(); + tester.runTests(); + } + + @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, "
        public class C1\n" +
                         "extends java.lang.Object\n" +
        -                "implements java.io.Serializable
        "}, - { "pkg1/C4.html", + "implements java.io.Serializable"); + checkOutput("pkg1/C4.html", true, "
        \n" + "
        Default:
        \n" + "
        true
        \n" + - "
        "}}; + ""); - // 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. - private static final String[][] TEST_CMNT_DEPR = { - { "pkg1/package-summary.html", - "
        \n" + - "
        Since:
        \n" + - "
        JDK1.0
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Since:
        \n" + - "
        JDK1.0
        \n" + - "
        See Also:
        \n" + - "
        " + - "C2, \n" + - "" + - "Serialized Form
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Since:
        \n" + - "
        1.4
        \n" + - "
        See Also:
        \n" + - "
        " + - "setUndecorated(boolean)
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Parameters:
        \n" + - "
        title - the title
        \n" + - "
        test - boolean value" + - "
        \n" + - "
        Throws:
        \n" + - "
        java.lang.IllegalArgumentException - if the " + - "owner's\n" + - " GraphicsConfiguration is not from a screen " + - "device
        \n" + - "
        HeadlessException
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Parameters:
        \n" + - "
        undecorated" + - " - true if no decorations are\n" + - " to be enabled;\n" + - " false " + - "if decorations are to be enabled.
        \n" + - "
        Since:" + - "
        \n" + - "
        1.4
        \n" + - "
        See Also:
        \n" + - "
        " + - "readObject()" + - "
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Throws:
        \n" + - "
        java.io.IOException
        \n" + - "
        See Also:" + - "
        \n" + - "
        " + - "setUndecorated(boolean)
        \n" + - "
        "}, - { "pkg1/C2.html", - "
        \n" + - "
        Parameters:" + - "
        \n" + - "
        set - boolean
        \n" + - "
        " + - "Since:
        \n" + - "
        1.4
        \n" + - "
        "}, - { "serialized-form.html", - "
        \n" + - "
        Throws:" + - "
        \n" + - "
        " + - "java.io.IOException
        \n" + - "
        See Also:" + - "
        \n" + - "
        " + - "C1.setUndecorated(boolean)
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).\n" + - "
        This field indicates whether the C1 is " + - "undecorated.
        \n" + - " \n" + - "
        \n" + - "
        Since:
        \n" + - "
        1.4
        \n" + - "
        See Also:" + - "
        \n" + - "
        " + - "C1.setUndecorated(boolean)
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).\n" + - "
        Reads the object stream.
        \n" + - "
        \n" + - "
        Throws:" + - "
        \n" + - "
        " + - "IOException
        \n" + - "
        java.io.IOException
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " \n" + - "
        The name for this class.
        "}}; + // Test for valid HTML generation which should not comprise of empty + // definition list tags. + List files= new ArrayList<>(Arrays.asList( + "pkg1/package-summary.html", + "pkg1/C1.html", + "pkg1/C1.ModalExclusionType.html", + "pkg1/C2.html", + "pkg1/C2.ModalType.html", + "pkg1/C3.html", + "pkg1/C4.html", + "overview-tree.html", + "serialized-form.html" + )); - // 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. - private static final String[][] TEST_NODEPR = { - { "pkg1/package-summary.html", + if (checkC5) + files.add("pkg1/C5.html"); + + for (String f: files) { + checkOutput(f, false, + "
        ", + "
        \n
        "); + } + } + + 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, "
        \n" + "
        Since:
        \n" + "
        JDK1.0
        \n" + - "
        "}, - { "pkg1/C1.html", + ""); + + checkOutput("pkg1/C1.html", expectFound, + "
        \n" + + "
        Since:
        \n" + + "
        JDK1.0
        \n" + + "
        See Also:
        \n" + + "
        " + + "C2, \n" + + "" + + "Serialized Form
        \n" + + "
        ", + "
        \n" + + "
        Since:
        \n" + + "
        1.4
        \n" + + "
        See Also:
        \n" + + "
        " + + "setUndecorated(boolean)
        \n" + + "
        ", + "
        \n" + + "
        Parameters:
        \n" + + "
        title - the title
        \n" + + "
        test - boolean value" + + "
        \n" + + "
        Throws:
        \n" + + "
        java.lang.IllegalArgumentException - if the " + + "owner's\n" + + " GraphicsConfiguration is not from a screen " + + "device
        \n" + + "
        HeadlessException
        \n" + + "
        ", + "
        \n" + + "
        Parameters:
        \n" + + "
        undecorated" + + " - true if no decorations are\n" + + " to be enabled;\n" + + " false " + + "if decorations are to be enabled.
        \n" + + "
        Since:" + + "
        \n" + + "
        1.4
        \n" + + "
        See Also:
        \n" + + "
        " + + "readObject()" + + "
        \n" + + "
        ", + "
        \n" + + "
        Throws:
        \n" + + "
        java.io.IOException
        \n" + + "
        See Also:" + + "
        \n" + + "
        " + + "setUndecorated(boolean)
        \n" + + "
        "); + + checkOutput("pkg1/C2.html", expectFound, + "
        \n" + + "
        Parameters:" + + "
        \n" + + "
        set - boolean
        \n" + + "
        " + + "Since:
        \n" + + "
        1.4
        \n" + + "
        "); + + checkOutput("serialized-form.html", expectFound, + "
        \n" + + "
        Throws:" + + "
        \n" + + "
        " + + "java.io.IOException
        \n" + + "
        See Also:" + + "
        \n" + + "
        " + + "C1.setUndecorated(boolean)
        \n" + + "
        ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
        This field indicates whether the C1 is " + + "undecorated.
        \n" + + " \n" + + "
        \n" + + "
        Since:
        \n" + + "
        1.4
        \n" + + "
        See Also:" + + "
        \n" + + "
        " + + "C1.setUndecorated(boolean)
        \n" + + "
        ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
        Reads the object stream.
        \n" + + "
        \n" + + "
        Throws:" + + "
        \n" + + "
        " + + "IOException
        \n" + + "
        java.io.IOException
        \n" + + "
        ", + "Deprecated." + + " \n" + + "
        The name for this class.
        "); + } + + 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, + "
        \n" + + "
        Since:
        \n" + + "
        JDK1.0
        \n" + + "
        "); + + checkOutput("pkg1/C1.html", true, "
        \n" + "
        Since:" + "
        \n" + @@ -191,216 +282,124 @@ public class TestHtmlDefinitionListTag extends JavadocTester { "C2, \n" + "" + "Serialized Form
        \n" + - ""}, - { "pkg1/C1.html", - "
        \n" + - "
        Parameters:" + - "
        \n" + - "
        title - the title
        \n" + - "
        " + - "test - boolean value
        \n" + - "
        Throws:" + - "
        \n" + - "
        java.lang.IllegalArgumentException" + - " - if the owner's\n" + - " GraphicsConfiguration" + - " is not from a screen device
        \n" + - "
        " + - "HeadlessException
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Parameters:" + - "
        \n" + - "
        undecorated - true" + - " if no decorations are\n" + - " to be enabled;\n" + - " false if decorations are to be enabled." + - "
        \n" + - "
        Since:
        \n" + - "
        1.4
        \n" + - "
        See Also:
        \n" + - "
        " + - "readObject()
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        Throws:" + - "
        \n" + - "
        java.io.IOException
        \n" + - "
        " + - "See Also:
        \n" + - "
        " + - "setUndecorated(boolean)
        \n" + - "
        "}, - { "serialized-form.html", - "
        \n" + - "
        Throws:" + - "
        \n" + - "
        " + - "java.io.IOException
        \n" + - "
        See Also:" + - "
        \n" + - "
        " + - "C1.setUndecorated(boolean)
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).\n" + - "
        This field indicates whether the C1 is " + - "undecorated.
        \n" + - " \n" + - "
        \n" + - "
        Since:
        \n" + - "
        1.4
        \n" + - "
        See Also:" + - "
        \n" + - "
        " + - "C1.setUndecorated(boolean)
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).\n" + - "
        Reads the object stream.
        \n" + - "
        \n" + - "
        Throws:" + - "
        \n" + - "
        " + - "IOException
        \n" + - "
        java.io.IOException
        \n" + - "
        "}, - { "serialized-form.html", - "Deprecated." + - " \n" + - "
        " + - "The name for this class.
        "}}; + ""); - // Test with -nocomment and -nodeprecated options. The ClassDocs whould - // not display definition lists for any member details. - private static final String[][] TEST_NOCMNT_NODEPR = { - { "pkg1/C1.html", + checkOutput("pkg1/C1.html", true, + "
        \n" + + "
        Parameters:" + + "
        \n" + + "
        title - the title
        \n" + + "
        " + + "test - boolean value
        \n" + + "
        Throws:" + + "
        \n" + + "
        java.lang.IllegalArgumentException" + + " - if the owner's\n" + + " GraphicsConfiguration" + + " is not from a screen device
        \n" + + "
        " + + "HeadlessException
        \n" + + "
        ", + "
        \n" + + "
        Parameters:" + + "
        \n" + + "
        undecorated - true" + + " if no decorations are\n" + + " to be enabled;\n" + + " false if decorations are to be enabled." + + "
        \n" + + "
        Since:
        \n" + + "
        1.4
        \n" + + "
        See Also:
        \n" + + "
        " + + "readObject()
        \n" + + "
        ", + "
        \n" + + "
        Throws:" + + "
        \n" + + "
        java.io.IOException
        \n" + + "
        " + + "See Also:
        \n" + + "
        " + + "setUndecorated(boolean)
        \n" + + "
        "); + + checkOutput("serialized-form.html", true, + "
        \n" + + "
        Throws:" + + "
        \n" + + "
        " + + "java.io.IOException
        \n" + + "
        See Also:" + + "
        \n" + + "
        " + + "C1.setUndecorated(boolean)
        \n" + + "
        ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
        This field indicates whether the C1 is " + + "undecorated.
        \n" + + " \n" + + "
        \n" + + "
        Since:
        \n" + + "
        1.4
        \n" + + "
        See Also:" + + "
        \n" + + "
        " + + "C1.setUndecorated(boolean)
        \n" + + "
        ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
        Reads the object stream.
        \n" + + "
        \n" + + "
        Throws:" + + "
        \n" + + "
        " + + "IOException
        \n" + + "
        java.io.IOException
        \n" + + "
        ", + "Deprecated." + + " \n" + + "
        " + + "The name for this class.
        "); + } + + 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, "
        public void readObject()\n" +
                         "                throws java.io.IOException
        \n" + - ""}, - { "pkg1/C2.html", "
        public C2()
        \n" + - ""}, - { "pkg1/C1.ModalExclusionType.html", "
        public " +
        +                "");
        +
        +        checkOutput("pkg1/C2.html", expectFound,
        +                "
        public C2()
        \n" + + ""); + + checkOutput("pkg1/C1.ModalExclusionType.html", expectFound, + "
        public " +
                         "static final C1.ModalExclusionType " +
                         "APPLICATION_EXCLUDE
        \n" + - ""}, - { "serialized-form.html", "
        boolean " +
        +                "");
        +
        +        checkOutput("serialized-form.html", expectFound,
        +                "
        boolean " +
                         "undecorated
        \n" + "
        " + "Deprecated. As of JDK version 1.5, replaced by\n" + " " + "setUndecorated(boolean).
        \n" + - ""}, - { "serialized-form.html", "" + + "", + "" + "Deprecated. As of JDK version" + " 1.5, replaced by\n" + " " + "setUndecorated(boolean).\n" + - ""}}; - - // 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", - "
        "}, - { "pkg1/package-summary.html", - "
        \n" + - "
        "}, - { "pkg1/C1.html", - "
        "}, - { "pkg1/C1.html", - "
        \n" + - "
        "}, - { "pkg1/C1.ModalExclusionType.html", - "
        "}, - { "pkg1/C1.ModalExclusionType.html", - "
        \n" + - "
        "}, - { "pkg1/C2.html", - "
        "}, - { "pkg1/C2.html", - "
        \n" + - "
        "}, - { "pkg1/C2.ModalType.html", - "
        "}, - { "pkg1/C2.ModalType.html", - "
        \n" + - "
        "}, - { "pkg1/C3.html", - "
        "}, - { "pkg1/C3.html", - "
        \n" + - "
        "}, - { "pkg1/C4.html", - "
        "}, - { "pkg1/C4.html", - "
        \n" + - "
        "}, - { "overview-tree.html", - "
        "}, - { "overview-tree.html", - "
        \n" + - "
        "}, - { "serialized-form.html", - "
        "}, - { "serialized-form.html", - "
        \n" + - "
        "}}; - private static final String[][] NEGATED_TEST_C5 = { - { "pkg1/C5.html", - "
        "}, - { "pkg1/C5.html", - "
        \n" + - "
        "}}; - - 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(); + ""); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java b/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java index b2b2d5679c4..32da20dfded 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java +++ b/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java @@ -27,33 +27,38 @@ * @test * @bug 6851834 * @summary This test verifies the HTML document generation for javadoc output. + * @library ../lib + * @build JavadocTester * @author Bhavesh Patel - * @build TestHtmlDocument * @run main TestHtmlDocument */ -import java.io.*; import com.sun.tools.doclets.formats.html.markup.*; /** * The class reads each file, complete with newlines, into a string to easily * compare the existing markup with the generated markup. */ -public class TestHtmlDocument { - - 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", "."); +public class TestHtmlDocument extends JavadocTester { // 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. - if (generateHtmlTree().equals(readFileToString(srcdir + "/testMarkup.html"))) { - System.out.println("\nTest passed for bug " + BUGID + " (" + BUGNAME + ")\n"); + String expected = readFile(testSrc, "testMarkup.html").replace("\n", NL); + String actual = generateHtmlTree(); + if (actual.equals(expected)) { + passed(""); } 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); 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(); - } } diff --git a/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java b/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java index a29bf387fc3..cba3d5961bc 100644 --- a/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java @@ -26,44 +26,49 @@ /* * @test * @bug 6786028 8026567 - * @summary This test verifys the use of HTML tag instead of by Javadoc std doclet. + * @summary This test verifies the use of HTML tag instead of by Javadoc std doclet. * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHtmlStrongTag * @run main TestHtmlStrongTag */ public class TestHtmlStrongTag extends JavadocTester { - private static final String[][] TEST1 = { - { "pkg1/C1.html", - "See Also:"}}; - private static final String[][] NEGATED_TEST1 = { - { "pkg1/C1.html", "Method Summary"}, - { "pkg1/C1.html", ""}, - { "pkg1/package-summary.html", - "Class Summary"}}; - private static final String[][] TEST2 = { - { "pkg2/C2.html", "Comments:"}}; - private static final String[][] NEGATED_TEST2 = { - { "pkg2/C2.html", "Method Summary"}}; - - 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) { + public static void main(String... args) throws Exception { TestHtmlStrongTag tester = new TestHtmlStrongTag(); - tester.run(ARGS1, TEST1, NEGATED_TEST1); - tester.run(ARGS2, TEST2, NEGATED_TEST2); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test1() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/C1.html", true, + "See Also:"); + + checkOutput("pkg1/C1.html", false, + "Method Summary", + ""); + + checkOutput("pkg1/package-summary.html", false, + "Class Summary"); + } + + @Test + void test2() { + javadoc("-d", "out-2", + "-sourcepath", testSrc, + "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg2/C2.html", true, + "Comments:"); + + checkOutput("pkg2/C2.html", false, + "Method Summary"); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java index b211b7c71e8..9f719a9d278 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java @@ -26,69 +26,59 @@ * @bug 8008164 * @summary Test styles on HTML tables generated by javadoc. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestHtmlTableStyles + * @library ../lib + * @build JavadocTester * @run main TestHtmlTableStyles */ public class TestHtmlTableStyles extends JavadocTester { - //Input for string search tests. - private static final String[][] TEST = { - { "pkg1/TestTable.html", - "" - }, - { "pkg1/TestTable.html", - "
        " - }, - { "pkg1/TestTable.html", - "
        " - }, - { "pkg1/TestTable.html", - "
        " - }, - { "pkg1/package-summary.html", - "
        " - }, - { "pkg1/class-use/TestTable.html", - "
        " - }, - { "overview-summary.html", - "
        " - }, - { "deprecated-list.html", + public static void main(String... args) throws Exception { + TestHtmlTableStyles tester = new TestHtmlTableStyles(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-use", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg1/TestTable.html", true, + "
        ", + "
        ", + "
        ", + "
        "); + + checkOutput("pkg1/package-summary.html", true, + "
        "); + + checkOutput("pkg1/class-use/TestTable.html", true, + "
        "); + + checkOutput("overview-summary.html", true, + "
        "); + + checkOutput("deprecated-list.html", true, "
        " - }, - { "constant-values.html", + "deprecated methods, and an explanation\">"); + + checkOutput("constant-values.html", true, "
        " - }, - }; - - 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(); + "constant fields, and values\">"); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java index 16c55b00f60..13c9214e4d4 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java @@ -26,9 +26,8 @@ * @bug 6786688 8008164 * @summary HTML tables should have table summary, caption and table headers. * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHtmlTableTags * @run main TestHtmlTableTags */ @@ -36,400 +35,350 @@ public class TestHtmlTableTags extends JavadocTester { //Javadoc arguments. 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 - { "pkg1/package-summary.html", - "
        " - }, - { "pkg1/package-summary.html", - "
        " - }, - { "pkg2/package-summary.html", - "
        " - }, - { "pkg2/package-summary.html", - "
        " - }, - // Class documentation - { "pkg1/C1.html", - "
        " - }, - { "pkg1/C1.html", - "
        " - }, - { "pkg2/C2.html", - "
        " - }, - { "pkg2/C2.html", - "
        " - }, - { "pkg2/C2.ModalExclusionType.html", - "
        " - }, - { "pkg2/C3.html", - "
        " - }, - { "pkg2/C4.html", - "
        " - }, - // Class use documentation - { "pkg1/class-use/I1.html", - "
        " - }, - { "pkg1/class-use/C1.html", - "
        " - }, - { "pkg1/class-use/C1.html", - "
        " - }, - { "pkg2/class-use/C2.html", - "
        " - }, - { "pkg2/class-use/C2.html", - "
        " - }, - { "pkg2/class-use/C2.ModalExclusionType.html", - "
        " - }, - { "pkg2/class-use/C2.ModalExclusionType.html", - "
        " - }, - // Package use documentation - { "pkg1/package-use.html", - "
        " - }, - { "pkg1/package-use.html", - "
        " - }, - { "pkg2/package-use.html", - "
        " - }, - { "pkg2/package-use.html", - "
        " - }, - // Deprecated - { "deprecated-list.html", - "
        " - }, - { "deprecated-list.html", - "
        " - }, - // Constant values - { "constant-values.html", - "
        " - }, - // Overview Summary - { "overview-summary.html", - "
        " - }, - - /* - * Test for validating caption for HTML tables - */ - - //Package summary - { "pkg1/package-summary.html", - "" - }, - { "pkg1/package-summary.html", - "" - }, - { "pkg2/package-summary.html", - "" - }, - { "pkg2/package-summary.html", - "" - }, - // Class documentation - { "pkg1/C1.html", - "" - }, - { "pkg1/C1.html", - "" - }, - { "pkg2/C2.html", - "" - }, - { "pkg2/C2.html", - "" - }, - { "pkg2/C2.ModalExclusionType.html", - "" - }, - { "pkg2/C3.html", - "" - }, - { "pkg2/C4.html", - "" - }, - // Class use documentation - { "pkg1/class-use/I1.html", - "" - }, - { "pkg1/class-use/C1.html", - "" - }, - { "pkg1/class-use/C1.html", - "" - }, - { "pkg2/class-use/C2.html", - "" - }, - { "pkg2/class-use/C2.html", - "" - }, - { "pkg2/class-use/C2.ModalExclusionType.html", - "" - }, - // Package use documentation - { "pkg1/package-use.html", - "" - }, - { "pkg1/package-use.html", - "" - }, - { "pkg2/package-use.html", - "" - }, - { "pkg2/package-use.html", - "" - }, - // Deprecated - { "deprecated-list.html", - "" - }, - { "deprecated-list.html", - "" - }, - // Constant values - { "constant-values.html", - "" - }, - // Overview Summary - { "overview-summary.html", - "" - }, - - /* - * Test for validating headers for HTML tables - */ - - //Package summary - { "pkg1/package-summary.html", - "\n" + - "" - }, - { "pkg1/package-summary.html", - "\n" + - "" - }, - { "pkg2/package-summary.html", - "\n" + - "" - }, - { "pkg2/package-summary.html", - "\n" + - "" - }, - // Class documentation - { "pkg1/C1.html", - "\n" + - "" - }, - { "pkg1/C1.html", - "\n" + - "" - }, - { "pkg2/C2.html", - "\n" + - "" - }, - { "pkg2/C2.html", - "" - }, - { "pkg2/C2.ModalExclusionType.html", - "" - }, - { "pkg2/C3.html", - "\n" + - "" - }, - { "pkg2/C4.html", - "\n" + - "" - }, - // Class use documentation - { "pkg1/class-use/I1.html", - "\n" + - "" - }, - { "pkg1/class-use/C1.html", - "\n" + - "" - }, - { "pkg1/class-use/C1.html", - "\n" + - "" - }, - { "pkg2/class-use/C2.html", - "\n" + - "" - }, - { "pkg2/class-use/C2.html", - "\n" + - "" - }, - { "pkg2/class-use/C2.ModalExclusionType.html", - "\n" + - "" - }, - { "pkg2/class-use/C2.ModalExclusionType.html", - "\n" + - "" - }, - // Package use documentation - { "pkg1/package-use.html", - "\n" + - "" - }, - { "pkg1/package-use.html", - "" - }, - { "pkg2/package-use.html", - "\n" + - "" - }, - { "pkg2/package-use.html", - "" - }, - // Deprecated - { "deprecated-list.html", - "" - }, - { "deprecated-list.html", - "" - }, - // Constant values - { "constant-values.html", - "\n" + - "Constant Field\n" + - "" - }, - // Overview Summary - { "overview-summary.html", - "\n" + - "" - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestHtmlTableTags tester = new TestHtmlTableTags(); - tester.run(ARGS, TABLE_TAGS_TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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, + "
        Class Summary" + - " Interface Summary" + - " Enum Summary" + - " Annotation Types Summary" + - " Fields All " + - "Methods " + - "" + - "Instance Methods " + - "" + - "Concrete Methods " + - "" + - "Deprecated Methods " + - "Nested Classes Constructors Enum Constants Required Elements " + - "Optional Elements " + - "Packages that use I1" + - " Fields in " + - "pkg2 declared as C1 " + - "Methods in " + - "pkg2 that return C1" + - " Fields in " + - "pkg1 declared as C2" + - " Methods in " + - "pkg1 that return C2" + - " Methods in " + - "pkg2 that return C2.ModalExclusionType" + - " Packages that use " + - "pkg1 Classes in " + - "pkg1 used by pkg1" + - " Packages that use " + - "pkg2 Classes in " + - "pkg2 used by pkg1" + - " Deprecated Fields" + - " Deprecated Methods" + - " pkg1." + - "C1 Packages 
        " + - "ClassDescription" + - "InterfaceDescription" + - "EnumDescription" + - "Annotation TypeDescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionModifier and TypeClass and DescriptionConstructor and DescriptionEnum Constant and DescriptionModifier and TypeRequired Element and DescriptionModifier and TypeOptional Element and DescriptionPackageDescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionPackageDescriptionModifier and TypeMethod and DescriptionPackageDescriptionClass and DescriptionPackageDescriptionClass and DescriptionField and DescriptionMethod and Description" + - "Modifier and TypeValue" + - "PackageDescription
        ", + "
        "); + + checkOutput("pkg2/package-summary.html", true, + "
        ", + "
        "); + + // Class documentation + checkOutput("pkg1/C1.html", true, + "
        ", + "
        "); + + checkOutput("pkg2/C2.html", true, + "
        ", + "
        "); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + "
        "); + + checkOutput("pkg2/C3.html", true, + "
        "); + + checkOutput("pkg2/C4.html", true, + "
        "); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + "
        "); + + checkOutput("pkg1/class-use/C1.html", true, + "
        ", + "
        "); + + checkOutput("pkg2/class-use/C2.html", true, + "
        ", + "
        "); + + checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true, + "
        "); + + checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true, + "
        "); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + "
        ", + "
        "); + + checkOutput("pkg2/package-use.html", true, + "
        ", + "
        "); + + // Deprecated + checkOutput("deprecated-list.html", true, + "
        ", + "
        "); + + // Constant values + checkOutput("constant-values.html", true, + "
        "); + + // Overview Summary + checkOutput("overview-summary.html", true, + "
        "); + } + + /* + * Tests for validating caption for HTML tables + */ + void checkHtmlTableCaptions() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + "", + ""); + + checkOutput("pkg2/package-summary.html", true, + "", + ""); + + // Class documentation + checkOutput("pkg1/C1.html", true, + "", + ""); + + checkOutput("pkg2/C2.html", true, + "", + ""); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + ""); + + checkOutput("pkg2/C3.html", true, + ""); + + checkOutput("pkg2/C4.html", true, + ""); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + ""); + + checkOutput("pkg1/class-use/C1.html", true, + "", + ""); + + checkOutput("pkg2/class-use/C2.html", true, + "", + ""); + + checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true, + ""); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + "", + ""); + + checkOutput("pkg2/package-use.html", true, + "", + ""); + + // Deprecated + checkOutput("deprecated-list.html", true, + "", + ""); + + // Constant values + checkOutput("constant-values.html", true, + ""); + + // Overview Summary + checkOutput("overview-summary.html", true, + ""); + } + + /* + * Test for validating headers for HTML tables + */ + void checkHtmlTableHeaders() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + "\n" + + "", + "\n" + + ""); + + checkOutput("pkg2/package-summary.html", true, + "\n" + + "", + "\n" + + ""); + + // Class documentation + checkOutput("pkg1/C1.html", true, + "\n" + + "", + "\n" + + ""); + + checkOutput("pkg2/C2.html", true, + "\n" + + "", + ""); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + ""); + + checkOutput("pkg2/C3.html", true, + "\n" + + ""); + + checkOutput("pkg2/C4.html", true, + "\n" + + ""); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + "\n" + + ""); + + checkOutput("pkg1/class-use/C1.html", true, + "\n" + + "", + "\n" + + ""); + + checkOutput("pkg2/class-use/C2.html", true, + "\n" + + "", + "\n" + + ""); + + checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true, + "\n" + + "", + "\n" + + ""); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + "\n" + + "", + ""); + + checkOutput("pkg2/package-use.html", true, + "\n" + + "", + ""); + + // Deprecated + checkOutput("deprecated-list.html", true, + "", + ""); + + // Constant values + checkOutput("constant-values.html", true, + "\n" + + "Constant Field\n" + + ""); + + // Overview Summary + checkOutput("overview-summary.html", true, + "\n" + + ""); } } diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java index 8990b2fc6ac..4416eabfb78 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java @@ -28,9 +28,8 @@ * @bug 6786682 * @summary This test verifies the use of lang attribute by . * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestHtmlTag * @run main TestHtmlTag */ @@ -38,43 +37,65 @@ import java.util.Locale; public class TestHtmlTag extends JavadocTester { - private static final String[][] TEST1 = { - { "pkg1/C1.html", - ""}, - { "pkg1/package-summary.html", - ""}}; - private static final String[][] NEGATED_TEST1 = { - { "pkg1/C1.html", ""}}; - private static final String[][] TEST2 = { - { "pkg2/C2.html", ""}, - { "pkg2/package-summary.html", ""}}; - private static final String[][] NEGATED_TEST2 = { - { "pkg2/C2.html", ""}}; - private static final String[][] TEST3 = { - { "pkg1/C1.html", ""}, - { "pkg1/package-summary.html", ""}}; - private static final String[][] NEGATED_TEST3 = { - { "pkg1/C1.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) { + public static void main(String... args) throws Exception { TestHtmlTag tester = new TestHtmlTag(); - tester.run(ARGS1, TEST1, NEGATED_TEST1); - tester.run(ARGS2, TEST2, NEGATED_TEST2); - tester.run(ARGS3, TEST3, NEGATED_TEST3); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test_default() { + javadoc("-d", "out-default", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + String defaultLanguage = Locale.getDefault().getLanguage(); + + checkOutput("pkg1/C1.html", true, + ""); + + checkOutput("pkg1/package-summary.html", true, + ""); + + checkOutput("pkg1/C1.html", false, + ""); + } + + @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, + ""); + + checkOutput("pkg2/package-summary.html", true, + ""); + + checkOutput("pkg2/C2.html", false, + ""); + } + + @Test + void test_en_US() { + javadoc("-locale", "en_US", + "-d", "out-en_US", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/C1.html", true, + ""); + + checkOutput("pkg1/package-summary.html", true, + ""); + + checkOutput("pkg1/C1.html", false, + ""); } } diff --git a/langtools/test/com/sun/javadoc/testIndentation/TestIndentation.java b/langtools/test/com/sun/javadoc/testIndentation/TestIndentation.java index 6b15c49922e..52c512865c4 100644 --- a/langtools/test/com/sun/javadoc/testIndentation/TestIndentation.java +++ b/langtools/test/com/sun/javadoc/testIndentation/TestIndentation.java @@ -25,37 +25,30 @@ * @test * @bug 8011288 * @summary Erratic/inconsistent indentation of signatures - * @library ../lib/ + * @library ../lib * @build JavadocTester * @run main TestIndentation */ public class TestIndentation extends JavadocTester { - //Javadoc arguments. - 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", - "
        public <T> void m(T t1," },
        -        { "p/Indent.html",
        -          "\n" +
        -          "                  T 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) {
        +    public static void main(String... args) throws Exception {
                 TestIndentation tester = new TestIndentation();
        -        tester.run(ARGS, TEST, NO_TEST);
        -        tester.printSummary();
        +        tester.runTests();
        +    }
        +
        +    @Test
        +    void test() {
        +        javadoc("-d", "out",
        +                "-sourcepath", testSrc,
        +                "p");
        +        checkExit(Exit.OK);
        +
        +        checkOutput("p/Indent.html", true,
        +                "
        public <T> void m(T t1,",
        +                "\n"
        +                + "                  T t2)",
        +                "\n"
        +                + "           throws java.lang.Exception");
             }
         }
        diff --git a/langtools/test/com/sun/javadoc/testIndex/TestIndex.java b/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
        index f4964602949..cf3dd12f853 100644
        --- a/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
        +++ b/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
        @@ -28,64 +28,53 @@
          *           Also test that index-all.html has the appropriate output.
          *           Test for unnamed package in index.
          * @author   jamieh
        - * @library  ../lib/
        + * @library  ../lib
          * @build    JavadocTester
        - * @build    TestIndex
          * @run main TestIndex
          */
         
         public class TestIndex extends JavadocTester {
         
        -    //Javadoc arguments.
        -    private static final String[] ARGS = new String[] {
        -        "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + "/NoPackage.java"
        -    };
        +    public static void main(String... args) throws Exception {
        +        TestIndex tester = new TestIndex();
        +        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.
        -        { "index.html",
        -            ""},
        +        checkOutput("index.html", true,
        +                "");
         
                 //Test index-all.html
        -        { "index-all.html",
        -            "C" +
        -            " - Class in pkg"},
        -        { "index-all.html",
        -            "" +
        -            "Interface - Interface in " +
        -            "pkg"},
        -        { "index-all.html",
        -            "" +
        -            "AnnotationType - Annotation Type in " +
        -            "pkg"},
        -        { "index-all.html",
        -            "" +
        -            "Coin - Enum in " +
        -            "pkg"},
        -        { "index-all.html",
        -            "Class in <Unnamed>"},
        -        { "index-all.html",
        -            "
        \n" + - "
        " + - "Java - Static variable in class pkg.C
        \n" + - "
         
        \n" + - "
        JDK " + - "- Static variable in class pkg." + - "C
        \n" + - "
         
        \n" + - "
        "}, - }; - - /** - * 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(); + checkOutput("index-all.html", true, + "C" + + " - Class in pkg", + "" + + "Interface - Interface in " + + "pkg", + "" + + "AnnotationType - Annotation Type in " + + "pkg", + "" + + "Coin - Enum in " + + "pkg", + "Class in <Unnamed>", + "
        \n" + + "
        " + + "Java - Static variable in class pkg.C
        \n" + + "
         
        \n" + + "
        JDK " + + "- Static variable in class pkg." + + "C
        \n" + + "
         
        \n" + + "
        "); } } diff --git a/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java b/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java index 034f93998f6..6ce373f8ac1 100644 --- a/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java +++ b/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java @@ -26,34 +26,29 @@ * @bug 4524136 * @summary Test to make sure label is used for inline links. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestInlineLinkLabel * @run main TestInlineLinkLabel */ public class TestInlineLinkLabel extends JavadocTester { - private static final String[][] TEST = { - //Search for the label to the package link. - { "pkg/C1.html" , - "Here is a link to a package"}, - - //Search for the label to the class link - { "pkg/C1.html" , - "Here is a link to a class"} - }; - 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) { + public static void main(String... args) throws Exception { TestInlineLinkLabel tester = new TestInlineLinkLabel(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @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. + "Here is a link to a package", + //Search for the label to the class link + "Here is a link to a class"); } } diff --git a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java index b02cfe00841..be11baac55f 100644 --- a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java +++ b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java @@ -29,101 +29,82 @@ * If A implements I and B extends A, B should be in the list of * implementing classes in the documentation for I. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestInterface * @run main TestInterface */ public class TestInterface extends JavadocTester { - //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/Interface.html", - "
        int method()
        "}, - { "pkg/Interface.html", - "
        static final int field
        "}, - - - // Make sure known implementing class list is correct and omits type parameters. - { "pkg/Interface.html", - "
        \n" + - "
        All Known Implementing Classes:
        \n" + - "
        Child" + - ", Parent" + - "
        \n" + - "
        "}, - - // Make sure "All Implemented Interfaces": has substituted type parameters - { "pkg/Child.html", - "
        \n" + - "
        All Implemented Interfaces:
        \n" + - "
        " + - "Interface<T>
        \n" + - "
        " - }, - //Make sure Class Tree has substituted type parameters. - { "pkg/Child.html", - "
          \n" + - "
        • java.lang.Object
        • \n" + - "
        • \n" + - "
            \n" + - "
          • " + - "pkg.Parent<T>
          • \n" + - "
          • \n" + - "
              \n" + - "
            • pkg.Child<T>
            • \n" + - "
            \n" + - "
          • \n" + - "
          \n" + - "
        • \n" + - "
        " - }, - //Make sure "Direct Know Subclasses" omits type parameters - { "pkg/Parent.html", - "
        \n" + - "
        Direct Known Subclasses:
        \n" + - "
        Child" + - "
        \n" + - "
        " - }, - //Make sure "Specified By" has substituted type parameters. - { "pkg/Child.html", - "
        Specified by:
        \n" + - "
        method" + - " in interface " + - "" + - "Interface<" + - "T>
        " - }, - //Make sure "Overrides" has substituted type parameters. - { "pkg/Child.html", - "
        Overrides:
        \n" + - "
        method" + - " in class Parent<T>
        " - }, - }; - private static final String[][] NEGATED_TEST = { - { "pkg/Interface.html", - "public int method()"}, - { "pkg/Interface.html", - "public static final int field"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestInterface tester = new TestInterface(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/Interface.html", true, + "
        int method()
        ", + "
        static final int field
        ", + // Make sure known implementing class list is correct and omits type parameters. + "
        \n" + + "
        All Known Implementing Classes:
        \n" + + "
        Child" + + ", Parent" + + "
        \n" + + "
        "); + + checkOutput("pkg/Child.html", true, + // Make sure "All Implemented Interfaces": has substituted type parameters + "
        \n" + + "
        All Implemented Interfaces:
        \n" + + "
        " + + "Interface<T>
        \n" + + "
        ", + //Make sure Class Tree has substituted type parameters. + "
          \n" + + "
        • java.lang.Object
        • \n" + + "
        • \n" + + "
            \n" + + "
          • " + + "pkg.Parent<T>
          • \n" + + "
          • \n" + + "
              \n" + + "
            • pkg.Child<T>
            • \n" + + "
            \n" + + "
          • \n" + + "
          \n" + + "
        • \n" + + "
        ", + //Make sure "Specified By" has substituted type parameters. + "
        Specified by:
        \n" + + "
        method" + + " in interface " + + "" + + "Interface<" + + "T>
        ", + //Make sure "Overrides" has substituted type parameters. + "
        Overrides:
        \n" + + "
        method" + + " in class Parent<T>
        "); + + checkOutput("pkg/Parent.html", true, + //Make sure "Direct Know Subclasses" omits type parameters + "
        \n" + + "
        Direct Known Subclasses:
        \n" + + "
        Child" + + "
        \n" + + "
        "); + + checkOutput("pkg/Interface.html", false, + "public int method()", + "public static final int field"); } } diff --git a/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java b/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java index a104b17e442..a6ced9b247d 100644 --- a/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java +++ b/langtools/test/com/sun/javadoc/testJavaFX/TestJavaFX.java @@ -26,73 +26,57 @@ * @bug 7112427 8012295 8025633 8026567 * @summary Test of the JavaFX doclet features. * @author jvalenta - * @library ../lib/ - * @build JavadocTester TestJavaFX + * @library ../lib + * @build JavadocTester * @run main TestJavaFX */ public class TestJavaFX extends JavadocTester { - private static final String[][] TEST = - new String[][] { - { "C.html", - "
        See Also:
        \n" + - "
        getRate(), \n" + - "setRate(double)
        "}, - { "C.html", - "
        public final void setRate(double value)
        \n" + - "
        Sets the value of the property rate.
        \n" + - "
        \n" + - "
        Property description:
        " }, - { "C.html", - "
        public final double getRate()
        \n" + - "
        Gets the value of the property rate.
        \n" + - "
        \n" + - "
        Property description:
        " }, - { "C.html", - "
        " }, - { "C.html", - "

        isPaused

        \n" + - "
        public final double isPaused()
        \n" + - "
        Gets the value of the property paused.
        " }, - { "D.html", - "

        Properties inherited from class C

        \n" + - "paused, rate" }, - }; - private static final String[][] NO_TEST = - new String[][] { - { "C.html", - "A()"}, - }; - - - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-javafx", - SRC_DIR + "/C.java", SRC_DIR + "/D.java" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestJavaFX tester = new TestJavaFX(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-javafx", + testSrc("C.java"), testSrc("D.java")); + checkExit(Exit.FAILED); // should be EXIT_OK -- need to fix C.java + + checkOutput("C.html", true, + "
        See Also:
        \n" + + "
        getRate(), \n" + + "setRate(double)
        ", + "
        public final void setRate(double value)
        \n" + + "
        Sets the value of the property rate.
        \n" + + "
        \n" + + "
        Property description:
        ", + "
        public final double getRate()
        \n" + + "
        Gets the value of the property rate.
        \n" + + "
        \n" + + "
        Property description:
        ", + "
        ", + "

        isPaused

        \n" + + "
        public final double isPaused()
        \n" + + "
        Gets the value of the property paused.
        "); + + checkOutput("C.html", false, + "A()"); + + checkOutput("D.html", true, + "

        Properties inherited from class C

        \n" + + "paused, rate"); + } + } diff --git a/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java b/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java index 2b9ef7e10f0..504dcb26bfc 100644 --- a/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java +++ b/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java @@ -26,98 +26,93 @@ * @bug 4665566 4855876 7025314 8012375 8015997 8016328 8024756 * @summary Verify that the output has the right javascript. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestJavascript * @run main TestJavascript */ public class TestJavascript extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + - "/TestJavascript.java" - }; + public static void main(String... args) throws Exception { + TestJavascript tester = new TestJavascript(); + tester.runTests(); + } - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/C.html", - "Frames"}, - { "TestJavascript.html", - "Frames"}, - { "index.html", - ""}, + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg", testSrc("TestJavascript.java")); + checkExit(Exit.OK); + + checkOutput("pkg/C.html", true, + "Frames"); + + checkOutput("TestJavascript.html", true, + "Frames"); + + checkOutput("index.html", true, + ""); //Make sure title javascript only runs if is-external is not true - { "pkg/C.html", - " try {\n" + - " if (location.href.indexOf('is-external=true') == -1) {\n" + - " parent.document.title=\"C\";\n" + - " }\n" + - " }\n" + - " catch(err) {\n" + - " }"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestJavascript tester = new TestJavascript(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + checkOutput("pkg/C.html", true, + " try {\n" + + " if (location.href.indexOf('is-external=true') == -1) {\n" + + " parent.document.title=\"C\";\n" + + " }\n" + + " }\n" + + " catch(err) {\n" + + " }"); } } diff --git a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java index dc6768cdfb7..84a4eeaa44e 100644 --- a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java +++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java @@ -40,79 +40,74 @@ public class TestLambdaFeature extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", "pkg1" - }; - - private static final String[] ARGS_1 = new String[] { - "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "-source", "1.7", "pkg1" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/A.html", - ""}, - { "pkg/A.html", - "
        default void defaultMethod()
        "}, - { "pkg/A.html", - ""}, - { "pkg/A.html", - "
        \n" + - "
        Functional Interface:
        \n" + - "
        This is a functional interface and can therefore be used as " + - "the assignment target for a lambda expression or method " + - "reference.
        \n" + - "
        "}, - { "pkg1/FuncInf.html", - "
        \n" + - "
        Functional Interface:
        \n" + - "
        This is a functional interface and can therefore be used as " + - "the assignment target for a lambda expression or method " + - "reference.
        \n" + - "
        "} - }; - private static final String[][] NEGATED_TEST = { - { "pkg/A.html", - ""}, - { "pkg/A.html", - "
        default default void defaultMethod()
        "}, - { "pkg/B.html", - ""}, - { "pkg1/NotAFuncInf.html", - "
        \n" + - "
        Functional Interface:
        \n" + - "
        This is a functional interface and can therefore be used as " + - "the assignment target for a lambda expression or method " + - "reference.
        \n" + - "
        "}, - { "pkg/B.html", - "
        \n" + - "
        Functional Interface:
        "} - }; - private static final String[][] NEGATED_TEST_1 = { - { "pkg1/FuncInf.html", - "
        \n" + - "
        Functional Interface:
        "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestLambdaFeature tester = new TestLambdaFeature(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.run(ARGS_1, NO_TEST, NEGATED_TEST_1); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testDefault() { + javadoc("-d", "out-default", + "-sourcepath", testSrc, + "pkg", "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg/A.html", true, + "
        ", + "
        default void defaultMethod()
        ", + "", + "
        \n" + + "
        Functional Interface:
        \n" + + "
        This is a functional interface and can therefore be used as " + + "the assignment target for a lambda expression or method " + + "reference.
        \n" + + "
        "); + + checkOutput("pkg1/FuncInf.html", true, + "
        \n" + + "
        Functional Interface:
        \n" + + "
        This is a functional interface and can therefore be used as " + + "the assignment target for a lambda expression or method " + + "reference.
        \n" + + "
        "); + + checkOutput("pkg/A.html", false, + "", + "
        default default void defaultMethod()
        "); + + checkOutput("pkg/B.html", false, + "", + "
        \n" + + "
        Functional Interface:
        "); + + checkOutput("pkg1/NotAFuncInf.html", false, + "
        \n" + + "
        Functional Interface:
        \n" + + "
        This is a functional interface and can therefore be used as " + + "the assignment target for a lambda expression or method " + + "reference.
        \n" + + "
        "); + } + + @Test + void testSource7() { + javadoc("-d", "out-7", + "-sourcepath", testSrc, + "-source", "1.7", + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/FuncInf.html", false, + "
        \n" + + "
        Functional Interface:
        "); } } diff --git a/langtools/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java b/langtools/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java index 46e2ea98f1d..6985f1b644c 100644 --- a/langtools/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java +++ b/langtools/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java @@ -29,37 +29,35 @@ * begin their comment without a leading star without leading * spaces stripped * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build LeadingSpaces * @run main LeadingSpaces */ public class LeadingSpaces extends JavadocTester { - - private static final String[][] TEST = { - { "LeadingSpaces.html", -" 1\n" + -" 2\n" + -" 3\n" + -" 4\n" + -" 5\n" + -" 6\n" + -" 7"} - }; - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - SRC_DIR + "/LeadingSpaces.java"}; - /** * The entry point of the test. * @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 { LeadingSpaces tester = new LeadingSpaces(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testLeadingSpaces() { + javadoc("-d", "out", "-sourcepath", testSrc, + testSrc("LeadingSpaces.java")); + checkExit(Exit.OK); + checkOutput("LeadingSpaces.html", true, + " 1\n" + + " 2\n" + + " 3\n" + + " 4\n" + + " 5\n" + + " 6\n" + + " 7"); } /** diff --git a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java index 16d8cbdc2e7..8cae5034bab 100644 --- a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java +++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java @@ -27,38 +27,35 @@ * @summary Test to ensure that the refactored version of the standard * doclet still works with Taglets that implement the 1.4.0 interface. * @author jamieh - * @library ../lib/ - * @compile ../lib/JavadocTester.java TestLegacyTaglet.java ToDoTaglet.java UnderlineTaglet.java Check.java + * @library ../lib + * @build JavadocTester ToDoTaglet UnderlineTaglet Check * @run main TestLegacyTaglet */ public class TestLegacyTaglet extends JavadocTester { - private static final String[] ARGS = - new String[] {"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-tagletpath", SRC_DIR, "-taglet", "ToDoTaglet", "-taglet", "Check", - "-taglet", "UnderlineTaglet", SRC_DIR + "/C.java"}; - - private static final String[][] TEST = new String[][] { - { "C.html", "This is an underline"}, - { "C.html", - "
        To Do:
        Class Summary" + + " Interface Summary" + + " Enum Summary" + + " Annotation Types Summary" + + " Fields All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "Nested Classes Constructors Enum Constants Required Elements " + + "Optional Elements " + + "Packages that use I1" + + " Fields in " + + "pkg2 declared as C1 " + + "Methods in " + + "pkg2 that return C1" + + " Fields in " + + "pkg1 declared as C2" + + " Methods in " + + "pkg1 that return C2" + + " Methods in " + + "pkg2 that return C2.ModalExclusionType" + + " Packages that use " + + "pkg1 Classes in " + + "pkg1 used by pkg1" + + " Packages that use " + + "pkg2 Classes in " + + "pkg2 used by pkg1" + + " Deprecated Fields" + + " Deprecated Methods" + + " pkg1." + + "C1 Packages 
        " + + "ClassDescription" + + "InterfaceDescription" + + "EnumDescription" + + "Annotation TypeDescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionModifier and TypeClass and DescriptionConstructor and DescriptionEnum Constant and DescriptionModifier and TypeRequired Element and DescriptionModifier and TypeOptional Element and DescriptionPackageDescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionModifier and TypeField and DescriptionModifier and TypeMethod and DescriptionPackageDescriptionModifier and TypeMethod and DescriptionPackageDescriptionClass and DescriptionPackageDescriptionClass and DescriptionField and DescriptionMethod and Description" + + "Modifier and TypeValue" + + "PackageDescriptionrate\n" + - "
        Defines the direction/speed at which the Timeline is expected to"}, - - { "C.html", - "Default value:"}, - { "C.html", - "Since:\n" + - "
        JavaFX 8.0
        " }, - { "C.html", - "

        Sets the value of the property Property"}, - { "C.html", - "

        Gets the value of the property Property"}, - { "C.html", - "Property description:"}, - { "C.html", - "

        setTestMethodProperty() rate\n" + + "
        Defines the direction/speed at which the Timeline is expected to", + "Default value:", + "Since:\n" + + "
        JavaFX 8.0
        ", + "

        Sets the value of the property Property", + "

        Gets the value of the property Property", + "Property description:", + "

        setTestMethodProperty() default void
        " + - "All Methods " + - "" + - "Instance Methods" + - " " + - "Abstract Methods " + - "" + - "Default Methods" + - " 
        default default voiddefault voiddefault void
        " + + "All Methods " + + "" + + "Instance Methods" + + " " + + "Abstract Methods " + + "" + + "Default Methods" + + " 
        default default voiddefault void
        " + - "
        Finish this class.
        "}, - { "C.html", - "
        To Do:
        " + - "
        Tag in Method.
        "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestLegacyTaglet tester = new TestLegacyTaglet(); - tester.run(ARGS, TEST, NO_TEST); - if (tester.getErrorOutput().contains("NullPointerException")) { - throw new AssertionError("javadoc threw NullPointerException"); - } - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-tagletpath", testSrc, + "-taglet", "ToDoTaglet", + "-taglet", "Check", + "-taglet", "UnderlineTaglet", + testSrc("C.java")); + checkExit(Exit.OK); + checkOutput("C.html", true, + "This is an underline", + "
        To Do:
        " + + "
        Finish this class.
        ", + "
        To Do:
        " + + "
        Tag in Method.
        "); + checkOutput(Output.STDERR, false, + "NullPointerException"); } } diff --git a/langtools/test/com/sun/javadoc/testLinkOption/TestBadLinkOption.java b/langtools/test/com/sun/javadoc/testLinkOption/TestBadLinkOption.java index 5bb1e641d52..c1a89319d44 100644 --- a/langtools/test/com/sun/javadoc/testLinkOption/TestBadLinkOption.java +++ b/langtools/test/com/sun/javadoc/testLinkOption/TestBadLinkOption.java @@ -26,34 +26,32 @@ * @bug 4625883 * @summary Make sure that bad -link arguments trigger warnings. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestBadLinkOption * @run main TestBadLinkOption */ public class TestBadLinkOption extends JavadocTester { - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-link", OUTPUT_DIR, "pkg" - }; - - private static final String[][] TEST = { - {WARNING_OUTPUT, "Error reading file:"} - }; - - private static final String[][] NEG_TEST = { - {ERROR_OUTPUT, "Error reading file:"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestBadLinkOption tester = new TestBadLinkOption(); - tester.run(ARGS, TEST, NEG_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + String out = "out"; + javadoc("-d", out, + "-sourcepath", testSrc, + "-link", out, + "pkg"); + checkExit(Exit.OK); + + // TODO: the file it is trying to read, out/out/package-list, warrants investigation + checkOutput(Output.WARNING, true, + "Error reading file:"); + + checkOutput(Output.ERROR, false, + "Error reading file:"); } } diff --git a/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java b/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java index b1ea09635c2..9e250c53edf 100644 --- a/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java +++ b/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java @@ -27,105 +27,111 @@ * @summary Test to make sure that -link and -linkoffline link to * right files, and URLs with and without trailing slash are accepted. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestLinkOption + * @library ../lib + * @build JavadocTester * @run main TestLinkOption */ import java.io.File; public class TestLinkOption extends JavadocTester { + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String... args) throws Exception { + TestLinkOption tester = new TestLinkOption(); + tester.runTests(); + } - //Generate the documentation using -linkoffline and a URL as the first parameter. - private static final String[] ARGS1 = new String[] { - "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, - "-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", - SRC_DIR, "-package", "pkg", "java.lang" - }; + // The following test runs javadoc multiple times; it is important that the + // first one is run first, since the subsequent runs refer to the output + // it generates. Therefore we run everything serially in a single @Test + // method and not in independent @Test methods. + @Test + void test() { + // Generate the documentation using -linkoffline and a URL as the first parameter. + String out1 = "out1"; + String url = "http://java.sun.com/j2se/1.4/docs/api/"; + javadoc("-d", out1, + "-sourcepath", testSrc, + "-linkoffline", url, testSrc, + "-package", + "pkg", "java.lang"); + checkExit(Exit.OK); - private static final String[][] TEST1 = { - { "pkg/C.html", - "Link to String Class" - }, - //Make sure the parameters are indented properly when the -link option is used. - { "pkg/C.html", - "(int p1,\n" + - " int p2,\n" + - " int p3)" - }, - { "pkg/C.html", - "(int p1,\n" + - " int p2,\n" + - " " + - "Object p3)" - }, - { "java/lang/StringBuilderChild.html", - "
        public abstract class StringBuilderChild\n" +
        -                "extends Object
        " - }, + checkOutput("pkg/C.html", true, + "Link to String Class", + //Make sure the parameters are indented properly when the -link option is used. + "(int p1,\n" + + " int p2,\n" + + " int p3)", + "(int p1,\n" + + " int p2,\n" + + " " + + "Object p3)"); - }; - private static final String[][] NEGATED_TEST1 = NO_TEST; + checkOutput("java/lang/StringBuilderChild.html", true, + "
        public abstract class StringBuilderChild\n"
        +                + "extends Object
        " + ); - //Generate the documentation using -linkoffline and a relative path as the first parameter. - //We will try linking to the docs generated in test 1 with a relative path. - private static final String[] ARGS2 = new String[] { - "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, - "-linkoffline", "../" + OUTPUT_DIR + "-1", - OUTPUT_DIR + "-1", "-package", "pkg2" - }; - - private static final String[][] TEST2 = { - { "pkg2/C2.html", - "This is a link to Class C." - } - }; + ); + + String out3 = "out3"; + javadoc(createArguments(out3, out1, true)); // with trailing slash + checkExit(Exit.OK); + + String out4 = "out4"; + javadoc(createArguments(out4, out1, false)); // without trailing slash + checkExit(Exit.OK); + // Note: the following test is very weak, and will fail if ever the test + // of the message is changed. We should have a separate test to verify + // this is the text that is given when there is a problem with a URL + checkOutput(Output.WARNING, false, + "warning - Error fetching URL"); + } + /* * Create the documentation using the -link option, vary the behavior with * both trailing and no trailing slash. We are only interested in ensuring * that the command executes with no errors or related warnings. */ - static String[] createArguments(boolean withTrailingSlash) { - String packagePath = new File(OUTPUT_DIR + "-1").getAbsolutePath(); - String outputDirName = OUTPUT_DIR; + static String[] createArguments(String outDir, String packageDir, boolean withTrailingSlash) { + String packagePath = new File(packageDir).getAbsolutePath(); if (withTrailingSlash) { // add the trailing slash, if it is not present! if (!packagePath.endsWith(FS)) { packagePath = packagePath + FS; } - outputDirName = outputDirName + "-3"; } else { // remove the trailing slash, if it is present! if (packagePath.endsWith(FS)) { packagePath = packagePath.substring(0, packagePath.length() - 1); } - outputDirName = outputDirName + "-4"; } String args[] = { - "-d", outputDirName, "-sourcepath", SRC_DIR, - "-link", "file:///" + packagePath, "-package", "pkg2" + "-d", outDir, + "-sourcepath", testSrc, + "-link", "file:///" + packagePath, + "-package", + "pkg2" }; System.out.println("packagePath: " + packagePath); return args; } - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestLinkOption tester = new TestLinkOption(); - tester.run(ARGS1, TEST1, NEGATED_TEST1); - tester.run(ARGS2, TEST2, NO_TEST); - tester.runJavadoc(createArguments(true)); // with trailing slash - tester.runJavadoc(createArguments(false)); // without trailing slash - tester.printSummary(); - if (tester.getWarningOutput().contains("warning - Error fetching URL")) { - throw new Error("URL rejected ?"); - } - tester.printSummary(); - } } diff --git a/langtools/test/com/sun/javadoc/testLinkOption/TestNewLineInLink.java b/langtools/test/com/sun/javadoc/testLinkOption/TestNewLineInLink.java index 628d0fd8a2e..54f95acd46b 100644 --- a/langtools/test/com/sun/javadoc/testLinkOption/TestNewLineInLink.java +++ b/langtools/test/com/sun/javadoc/testLinkOption/TestNewLineInLink.java @@ -27,32 +27,27 @@ * @summary Make sure that a new line may act as a separator between * link and label. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestNewLineInLink * @run main TestNewLineInLink */ public class TestNewLineInLink extends JavadocTester { - private static final String[][] NEGATED_TEST = - new String[][] { - {ERROR_OUTPUT, - "illegal character"} - }; - - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-linkoffline", "http://www.java.sun.com/j2se/1.4/docs/api", - SRC_DIR, "testNewLineInLink"}; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestNewLineInLink tester = new TestNewLineInLink(); - tester.run(ARGS, new String[][] {}, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-linkoffline", "http://www.java.sun.com/j2se/1.4/docs/api", testSrc, + "testNewLineInLink"); + checkExit(Exit.OK); + + checkOutput(Output.ERROR, false, + "illegal character"); } } diff --git a/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java b/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java index 98591716a74..242d0385bb6 100644 --- a/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java +++ b/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java @@ -27,53 +27,46 @@ * @summary Make sure that you can link from one member to another using * non-qualified name, furthermore, ensure the right one is linked. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestLinkTaglet * @run main TestLinkTaglet */ public class TestLinkTaglet extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + - "/checkPkg/B.java" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/C.html", - "Qualified Link: C.InnerC.
        \n" + - " Unqualified Link1: C.InnerC.
        \n" + - " Unqualified Link2: C.InnerC.
        \n" + - " Qualified Link: method(pkg.C.InnerC, pkg.C.InnerC2).
        \n" + - " Unqualified Link: method(C.InnerC, C.InnerC2).
        \n" + - " Unqualified Link: method(InnerC, InnerC2).
        " - }, - { "pkg/C.InnerC.html", - "Link to member in outer class: C.MEMBER
        \n" + - " Link to member in inner class: C.InnerC2.MEMBER2
        \n" + - " Link to another inner class: C.InnerC2" - }, - { "pkg/C.InnerC2.html", - "
        \n" + - "
        Enclosing class:
        \n" + - "
        C
        \n" + - "
        " - }, - }; - private static final String[][] NEGATED_TEST = { - {WARNING_OUTPUT, "Tag @see: reference not found: A"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestLinkTaglet tester = new TestLinkTaglet(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + "-sourcepath", testSrc, + "pkg", testSrc("checkPkg/B.java")); + checkExit(Exit.OK); + + checkOutput("pkg/C.html", true, + "Qualified Link: C.InnerC.
        \n" + + " Unqualified Link1: C.InnerC.
        \n" + + " Unqualified Link2: C.InnerC.
        \n" + + " Qualified Link: method(pkg.C.InnerC, pkg.C.InnerC2).
        \n" + + " Unqualified Link: method(C.InnerC, C.InnerC2).
        \n" + + " Unqualified Link: method(InnerC, InnerC2).
        "); + + checkOutput("pkg/C.InnerC.html", true, + "Link to member in outer class: C.MEMBER
        \n" + + " Link to member in inner class: C.InnerC2.MEMBER2
        \n" + + " Link to another inner class: C.InnerC2"); + + checkOutput("pkg/C.InnerC2.html", true, + "
        \n" + + "
        Enclosing class:
        \n" + + "
        C
        \n" + + "
        "); + + checkOutput(Output.WARNING, false, + "Tag @see: reference not found: A"); } } diff --git a/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java b/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java index 6e233a24067..e56af5233e1 100644 --- a/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java +++ b/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java @@ -27,29 +27,28 @@ * @summary Test to make sure that there is a link with a proper anchor * from a serializable class to serialized-form.html. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestLinkToSerialForm * @run main TestLinkToSerialForm */ public class TestLinkToSerialForm extends JavadocTester { - private static final String[][] TEST = { - { "serialized-form.html", ""}, - { "pkg/C.html", ""} - }; - 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) { + public static void main(String... args) throws Exception { TestLinkToSerialForm tester = new TestLinkToSerialForm(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("serialized-form.html", true, + ""); + checkOutput("pkg/C.html", true, + ""); } } diff --git a/langtools/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java b/langtools/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java index 4be736641a1..000c6594a4a 100644 --- a/langtools/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java +++ b/langtools/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java @@ -25,73 +25,61 @@ * @test * @bug 8002387 8014636 * @summary Improve rendered HTML formatting for {@code} - * @library ../lib/ - * @build JavadocTester TestLiteralCodeInPre + * @library ../lib + * @build JavadocTester * @run main TestLiteralCodeInPre */ public class TestLiteralCodeInPre extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-Xdoclint:none", "pkg" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/Test.html", - "no_pre()
        \n" + - "
        abcdefghi
        " }, - { "pkg/Test.html", - "no_pre_extra_whitespace()
        \n" + - "
        abcdef ghi
        " }, - { "pkg/Test.html", - "in_pre()\n" + - "
         abc  def  ghi
        " }, - { "pkg/Test.html", - "pre_after_text()\n" + - "
        xyz
         abc  def  ghi
        " }, - { "pkg/Test.html", - "after_pre()\n" + - "
        xyz
         pqr 
        abcdef ghi
        " }, - { "pkg/Test.html", - "back_in_pre()\n" + - "
        xyz
         pqr 
        mno
         abc  def  ghi
        " }, - { "pkg/Test.html", - "typical_usage_code()\n" + - "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + - " Example:
        \n" +
        -            "   line 1 <T> void m(T t) {\n" +
        -            "   line 2     // do something with T\n" +
        -            "   line 3 }\n" +
        -            " 
        \n" + - " and so it goes.
        " }, - { "pkg/Test.html", - "typical_usage_literal()\n" + - "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + - " Example:
        \n" +
        -            "   line 1 <T> void m(T t) {\n" +
        -            "   line 2     // do something with T\n" +
        -            "   line 3 }\n" +
        -            " 
        \n" + - " and so it goes.
        " }, - { "pkg/Test.html", - "recommended_usage_literal()\n" + - "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + - " Example:
        \n" +
        -            "   line 1 <T> void m(T t) {\n" +
        -            "   line 2     // do something with T\n" +
        -            "   line 3 } 
        \n" + - " and so it goes.
        " } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestLiteralCodeInPre tester = new TestLiteralCodeInPre(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-Xdoclint:none", + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/Test.html", true, + "no_pre()\n" + + "
        abcdefghi
        ", + "no_pre_extra_whitespace()\n" + + "
        abcdef ghi
        ", + "in_pre()\n" + + "
         abc  def  ghi
        ", + "pre_after_text()\n" + + "
        xyz
         abc  def  ghi
        ", + "after_pre()\n" + + "
        xyz
         pqr 
        abcdef ghi
        ", + "back_in_pre()\n" + + "
        xyz
         pqr 
        mno
         abc  def  ghi
        ", + "typical_usage_code()\n" + + "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + + " Example:
        \n"
        +                + "   line 1 <T> void m(T t) {\n"
        +                + "   line 2     // do something with T\n"
        +                + "   line 3 }\n"
        +                + " 
        \n" + + " and so it goes.
        ", + "typical_usage_literal()\n" + + "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + + " Example:
        \n"
        +                + "   line 1 <T> void m(T t) {\n"
        +                + "   line 2     // do something with T\n"
        +                + "   line 3 }\n"
        +                + " 
        \n" + + " and so it goes.
        ", + "recommended_usage_literal()\n" + + "
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n" + + " Example:
        \n"
        +                + "   line 1 <T> void m(T t) {\n"
        +                + "   line 2     // do something with T\n"
        +                + "   line 3 } 
        \n" + + " and so it goes.
        "); } } diff --git a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java index f3afc14512f..c174d4aa9de 100644 --- a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java +++ b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java @@ -27,83 +27,63 @@ * @summary Test to make sure that members are inherited properly in the Javadoc. * Verify that inheritence labels are correct. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestMemberInheritence * @run main TestMemberInheritence */ public class TestMemberInheritence extends JavadocTester { - private static final String[][] TEST = { - //Public field should be inherited - { "pkg/SubClass.html", - "
        "}, - - //Public method should be inherited - { "pkg/SubClass.html", - ""}, - - //Public inner class should be inherited. - { "pkg/SubClass.html", - ""}, - - //Protected field should be inherited - { "pkg/SubClass.html", - ""}, - - //Protected method should be inherited - { "pkg/SubClass.html", - ""}, - - //Protected inner class should be inherited. - { "pkg/SubClass.html", - ""}, - - // New labels as of 1.5.0 - { "pkg/SubClass.html", - "Nested classes/interfaces inherited from class pkg." + - "BaseClass"}, - { "pkg/SubClass.html", - "Nested classes/interfaces inherited from interface pkg." + - "BaseInterface"}, - - // Test overriding/implementing methods with generic parameters. - { "pkg/BaseClass.html", - "
        \n" + - "
        Specified by:
        \n" + - "
        " + - "getAnnotation in interface " + - "" + - "BaseInterface
        \n" + - "
        "}, - - // Test diamond inheritence member summary (6256068) - { "diamond/Z.html", - "aMethod"}, - - // Test that doc is inherited from closed parent (6270645) - { "inheritDist/C.html", - "
        m1-B
        "}, - - }; - - private static final String[][] NEGATED_TEST = { - { "pkg/SubClass.html", - "staticMethod"}, - }; - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", "diamond", - "inheritDist"}; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestMemberInheritence tester = new TestMemberInheritence(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg", "diamond", "inheritDist"); + checkExit(Exit.OK); + + checkOutput("pkg/SubClass.html", true, + // Public field should be inherited + "", + // Public method should be inherited + "", + // Public inner class should be inherited. + "", + // Protected field should be inherited + "", + // Protected method should be inherited + "", + // Protected inner class should be inherited. + "", + // New labels as of 1.5.0 + "Nested classes/interfaces inherited from class pkg." + + "BaseClass", + "Nested classes/interfaces inherited from interface pkg." + + "BaseInterface"); + + checkOutput("pkg/BaseClass.html", true, + // Test overriding/implementing methods with generic parameters. + "
        \n" + + "
        Specified by:
        \n" + + "
        " + + "getAnnotation in interface " + + "" + + "BaseInterface
        \n" + + "
        "); + + checkOutput("diamond/Z.html", true, + // Test diamond inheritence member summary (6256068) + "aMethod"); + + checkOutput("inheritDist/C.html", true, + // Test that doc is inherited from closed parent (6270645) + "
        m1-B
        "); + + checkOutput("pkg/SubClass.html", false, + "staticMethod"); } } diff --git a/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java b/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java index 67b26289a01..86674721970 100644 --- a/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java +++ b/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java @@ -28,50 +28,40 @@ * type than the method in the child class. Make sure the * documentation is inherited but the return type isn't. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestMemberSummary * @run main TestMemberSummary */ public class TestMemberSummary extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg","pkg2" - }; - - //Input for string search tests. - private static final String[][] TEST = { - // Check return type in member summary. - { "pkg/PublicChild.html", - "PublicChild\n" + - "" + - "returnTypeTest()" - }, - // Check return type in member detail. - { "pkg/PublicChild.html", - "
        public " +
        -            "PublicChild returnTypeTest()
        " - }, - - // Legacy anchor dimensions (6290760) - { "pkg2/A.html", - "\n" + - "\n" + - "\n" + - "\n" + - "" - }, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestMemberSummary tester = new TestMemberSummary(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg","pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg/PublicChild.html", true, + // Check return type in member summary. + "PublicChild\n" + + "" + + "returnTypeTest()", + // Check return type in member detail. + "
        public "
        +                + "PublicChild returnTypeTest()
        "); + + // Legacy anchor dimensions (6290760) + checkOutput("pkg2/A.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + ""); } } diff --git a/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java index fd287356079..293a37b93ed 100644 --- a/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java +++ b/langtools/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java @@ -26,97 +26,74 @@ * @bug 8002304 8024096 * @summary Test for various method types in the method summary table * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestMethodTypes + * @library ../lib + * @build JavadocTester * @run main TestMethodTypes */ public class TestMethodTypes extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1" - }; - - private static final String[][] TEST = { - { "pkg1/A.html", - "var methods = {" - }, - - { "pkg1/A.html", - "All " + - "Methods " + - "" + - "Static Methods " + - "" + - "Instance Methods " + - "" + - "Concrete Methods " + - "" + - "Deprecated Methods " + - "" - }, - - { "pkg1/A.html", - "" - }, - - { "pkg1/B.html", - "All " + - "Methods " + - "" + - "Instance Methods " + - "" + - "Abstract Methods " + - "" - }, - - { "pkg1/D.html", - "var methods = {" - }, - - { "pkg1/D.html", - "All " + - "Methods " + - "" + - "Instance Methods " + - "" + - "Abstract Methods " + - "" + - "Concrete Methods " + - "" + - "Deprecated Methods " + - "" - }, - - { "pkg1/D.html", - "" - }, - }; - private static final String[][] NEGATED_TEST = { - { "pkg1/A.html", - "Methods " + - "" - }, - - { "pkg1/B.html", - "Methods " + - "" - }, - - { "pkg1/D.html", - "Methods " + - "" - }, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestMethodTypes tester = new TestMethodTypes(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/A.html", true, + "var methods = {", + "All " + + "Methods " + + "" + + "Static Methods " + + "" + + "Instance Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "", + ""); + + checkOutput("pkg1/B.html", true, + "All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Abstract Methods " + + ""); + + checkOutput("pkg1/D.html", true, + "var methods = {", + "All " + + "Methods " + + "" + + "Instance Methods " + + "" + + "Abstract Methods " + + "" + + "Concrete Methods " + + "" + + "Deprecated Methods " + + "", + ""); + + checkOutput("pkg1/A.html", false, + "Methods " + + ""); + + checkOutput("pkg1/B.html", false, + "Methods " + + ""); + + checkOutput("pkg1/D.html", false, + "Methods " + + ""); } } diff --git a/langtools/test/com/sun/javadoc/testModifier/TestModifier.java b/langtools/test/com/sun/javadoc/testModifier/TestModifier.java index 2636f1825c8..0454fc205f2 100644 --- a/langtools/test/com/sun/javadoc/testModifier/TestModifier.java +++ b/langtools/test/com/sun/javadoc/testModifier/TestModifier.java @@ -26,29 +26,25 @@ * @bug 4210388 * @summary Javadoc declares interfaces to be "abstract". * @author jamieh - * @library ../lib/ + * @library ../lib * @build ModifierAbstract * @build JavadocTester - * @build TestModifier * @run main TestModifier */ public class TestModifier extends JavadocTester { - private static final String[] ARGS = - new String[] { - "-sourcepath", SRC_DIR, - "-docletpath", SRC_DIR, "-doclet", "ModifierAbstract", - SRC_DIR + "/Interface.java", SRC_DIR + "/Test.java"}; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestModifier tester = new TestModifier(); - if (tester.run(ARGS, NO_TEST, NO_TEST) != 0) { - throw new Error("Javadoc error occured during execution."); - } + tester.runTests(); + } + + @Test + void test() { + javadoc("-sourcepath", testSrc, + "-docletpath", testSrc, + "-doclet", "ModifierAbstract", + testSrc("Interface.java"), testSrc("Test.java")); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/testNavigation/TestNavigation.java b/langtools/test/com/sun/javadoc/testNavigation/TestNavigation.java index ae43a56c871..19b1db60405 100644 --- a/langtools/test/com/sun/javadoc/testNavigation/TestNavigation.java +++ b/langtools/test/com/sun/javadoc/testNavigation/TestNavigation.java @@ -27,49 +27,44 @@ * @summary Make sure the Next/Prev Class links iterate through all types. * Make sure the navagation is 2 columns, not 3. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestNavigation + * @library ../lib + * @build JavadocTester * @run main TestNavigation */ public class TestNavigation extends JavadocTester { - //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", "
      • Prev Class
      • "}, - { "pkg/A.html", - "Next Class"}, - { "pkg/C.html", - "Prev Class"}, - { "pkg/C.html", - "Next Class"}, - { "pkg/E.html", - "Prev Class"}, - { "pkg/E.html", - "Next Class"}, - { "pkg/I.html", - "Prev Class"}, - { "pkg/I.html", "
      • Next Class
      • "}, - // Test for 4664607 - { "pkg/I.html", - "\n" + - "\n" + - "\n" + - ""} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestNavigation tester = new TestNavigation(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/A.html", true, + "
      • Prev Class
      • ", + "Next Class"); + + checkOutput("pkg/C.html", true, + "Prev Class", + "Next Class"); + + checkOutput("pkg/E.html", true, + "Prev Class", + "Next Class"); + + checkOutput("pkg/I.html", true, + "Prev Class", + "
      • Next Class
      • ", + // Test for 4664607 + "\n" + + "\n" + + "\n" + + ""); } } diff --git a/langtools/test/com/sun/javadoc/testNestedGenerics/TestNestedGenerics.java b/langtools/test/com/sun/javadoc/testNestedGenerics/TestNestedGenerics.java index 9a4e41eeb89..57bd6410c89 100644 --- a/langtools/test/com/sun/javadoc/testNestedGenerics/TestNestedGenerics.java +++ b/langtools/test/com/sun/javadoc/testNestedGenerics/TestNestedGenerics.java @@ -26,35 +26,28 @@ * @bug 6758050 8025633 * @summary Test HTML output for nested generic types. * @author bpatel - * @library ../lib/ - * @build JavadocTester TestNestedGenerics + * @library ../lib + * @build JavadocTester * @run main TestNestedGenerics */ public class TestNestedGenerics extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[]{ - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "pkg" - }; + public static void main(String... args) throws Exception { + TestNestedGenerics tester = new TestNestedGenerics(); + tester.runTests(); + } - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/NestedGenerics.html", + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/NestedGenerics.html", true, "" - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestNestedGenerics tester = new TestNestedGenerics(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + "(java.util.Map<A, java.util.Map<A, A>>)"); } } diff --git a/langtools/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java b/langtools/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java index e04b5c5332b..f41ff173bd3 100644 --- a/langtools/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java +++ b/langtools/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java @@ -25,12 +25,11 @@ * @test * @summary Test for nested inline tags. * * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester * @build testtaglets.UnderlineTaglet * @build testtaglets.BoldTaglet * @build testtaglets.GreenTaglet - * @build TestNestedInlineTag * @run main TestNestedInlineTag */ @@ -38,7 +37,6 @@ * This should be green, underlined and bold (Class): {@underline {@bold {@green My test}}} . */ public class TestNestedInlineTag extends JavadocTester { - /** * This should be green, underlined and bold (Field): {@underline {@bold {@green My test}}} . */ @@ -54,44 +52,35 @@ public class TestNestedInlineTag extends JavadocTester { */ public void method(){} - private static final String[][] TEST = { - //Test nested inline tag in class description. - { "TestNestedInlineTag.html", - "This should be green, underlined and bold (Class): My test" - }, - - //Test nested inline tag in field description. - { "TestNestedInlineTag.html", - "This should be green, underlined and bold (Field): My test" - }, - - //Test nested inline tag in constructor description. - { "TestNestedInlineTag.html", - "This should be green, underlined and bold (Constructor): My test" - }, - - //Test nested inline tag in method description. - { "TestNestedInlineTag.html", - "This should be green, underlined and bold (Method): My test" - } - }; - - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-taglet", "testtaglets.UnderlineTaglet", - "-taglet", "testtaglets.BoldTaglet", - "-taglet", "testtaglets.GreenTaglet", - SRC_DIR + "/TestNestedInlineTag.java" - }; - /** * The entry point of the test. * @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 { TestNestedInlineTag tester = new TestNestedInlineTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-taglet", "testtaglets.UnderlineTaglet", + "-taglet", "testtaglets.BoldTaglet", + "-taglet", "testtaglets.GreenTaglet", + testSrc("TestNestedInlineTag.java")); + checkExit(Exit.OK); + + checkOutput("TestNestedInlineTag.html", true, + //Test nested inline tag in class description. + "This should be green, underlined and bold (Class): My test", + //Test nested inline tag in field description. + "This should be green, underlined and bold (Field): My test", + //Test nested inline tag in constructor description. + "This should be green, underlined and bold (Constructor): My test", + //Test nested inline tag in method description. + "This should be green, underlined and bold (Method): My test" + ); } } diff --git a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java index 5f8ae96a16e..44e50e702e1 100644 --- a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java +++ b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java @@ -28,738 +28,612 @@ * language features. Check the output to ensure that the new * language features are properly documented. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestNewLanguageFeatures + * @library ../lib + * @build JavadocTester * @run main TestNewLanguageFeatures */ public class TestNewLanguageFeatures extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR, "-use", "-sourcepath", SRC_DIR, - "pkg", "pkg1", "pkg2" - }; + public static void main(String... args) throws Exception { + TestNewLanguageFeatures tester = new TestNewLanguageFeatures(); + tester.runTests(); + } - //Input for string search tests. - private static final String[][] TEST = - { - //================================= - // ENUM TESTING - //================================= - //Make sure enum header is correct. - { "pkg/Coin.html", "Enum Coin"}, - //Make sure enum signature is correct. - { "pkg/Coin.html", "
        public enum " +
        -                     "Coin\n" +
        -                     "extends java.lang.Enum<Coin>
        " - }, - //Check for enum constant section - { "pkg/Coin.html", "Enum Constants" + - " "}, - //Detail for enum constant - { "pkg/Coin.html", - "Dime"}, - //Automatically insert documentation for values() and valueOf(). - { "pkg/Coin.html", - "Returns an array containing the constants of this enum type,"}, - { "pkg/Coin.html", - "Returns the enum constant of this type with the specified name"}, - { "pkg/Coin.html", "for (Coin c : Coin.values())"}, - { "pkg/Coin.html", - "Overloaded valueOf() method has correct documentation."}, - { "pkg/Coin.html", - "Overloaded values method has correct documentation."}, + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + "-use", "-sourcepath", + testSrc, + "pkg", "pkg1", "pkg2"); + checkExit(Exit.OK); - //================================= - // TYPE PARAMETER TESTING - //================================= - //Make sure the header is correct. - { "pkg/TypeParameters.html", - "Class TypeParameters<E>"}, - //Check class type parameters section. - { "pkg/TypeParameters.html", - "
        Type Parameters:
        \n" + - "
        E - " + - "the type parameter for this class."}, - //Type parameters in @see/@link - { "pkg/TypeParameters.html", - "
        \n" + - "
        See Also:
        \n" + - "
        " + - "" + - "TypeParameters
        \n" + - "
        "}, - //Method that uses class type parameter. - { "pkg/TypeParameters.html", - "(E param)"}, - //Method type parameter section. - { "pkg/TypeParameters.html", - "Type Parameters:\n" + - "
        T - This is the first " + - "type parameter.
        \n" + - "
        V - This is the second type " + - "parameter."}, - //Signature of method with type parameters - { "pkg/TypeParameters.html", - "public <T extends java.util.List,V> " + - "java.lang.String[] methodThatHasTypeParameters"}, - //Wildcard testing. - { "pkg/Wildcards.html", - "" + - "TypeParameters<? super java.lang.String> a"}, - { "pkg/Wildcards.html", - "" + - "TypeParameters<? extends java.lang.StringBuffer> b"}, - { "pkg/Wildcards.html", - "" + - "TypeParameters c"}, - //Bad type parameter warnings. - {WARNING_OUTPUT, "warning - @param argument " + - "\"\" is not a type parameter name."}, - {WARNING_OUTPUT, "warning - @param argument " + - "\"\" is not a type parameter name."}, + checkEnums(); + checkTypeParameters(); + checkVarArgs(); + checkAnnotationTypeUsage(); + } - //Signature of subclass that has type parameters. - { "pkg/TypeParameterSubClass.html", - "
        public class TypeParameterSubClass<T extends " +
        -                "java.lang.String>\n" +
        -                "extends " +
        -                "" +
        -                "TypeParameterSuperClass<T>
        "}, + //================================= + // ENUM TESTING + //================================= + void checkEnums() { + checkOutput("pkg/Coin.html", true, + // Make sure enum header is correct. + "Enum Coin", + // Make sure enum signature is correct. + "
        public enum "
        +                + "Coin\n"
        +                + "extends java.lang.Enum<Coin>
        ", + // Check for enum constant section + "Enum Constants" + + " ", + // Detail for enum constant + "Dime", + // Automatically insert documentation for values() and valueOf(). + "Returns an array containing the constants of this enum type,", + "Returns the enum constant of this type with the specified name", + "for (Coin c : Coin.values())", + "Overloaded valueOf() method has correct documentation.", + "Overloaded values method has correct documentation."); - //Interface generic parameter substitution - //Signature of subclass that has type parameters. - { "pkg/TypeParameters.html", - "
        \n" + - "
        All Implemented Interfaces:
        \n" + - "
        " + - "SubInterface<E>, SuperInterface<E>
        \n" + - "
        "}, - { "pkg/SuperInterface.html", - "
        \n" + - "
        All Known Subinterfaces:
        \n" + - "
        " + - "SubInterface<V>
        \n" + - "
        "}, - { "pkg/SubInterface.html", - "
        \n" + - "
        All Superinterfaces:
        \n" + - "
        " + - "SuperInterface<V>
        \n" + - "
        "}, + // NO constructor section + checkOutput("pkg/Coin.html", false, + "

        Constructor Summary

        "); + } - //================================= - // VAR ARG TESTING - //================================= - { "pkg/VarArgs.html", "(int... i)"}, - { "pkg/VarArgs.html", "(int[][]... i)"}, - { "pkg/VarArgs.html", "-int:A...-"}, - { "pkg/VarArgs.html", - "" + - "TypeParameters... t"}, + //================================= + // TYPE PARAMETER TESTING + //================================= - //================================= - // ANNOTATION TYPE TESTING - //================================= - //Make sure the summary links are correct. - { "pkg/AnnotationType.html", - "
      • Summary: 
      • \n" + - "
      • Field | 
      • \n" + - "
      • " + - "Required | 
      • \n" + - "
      • " + - "Optional
      • "}, - //Make sure the detail links are correct. - { "pkg/AnnotationType.html", - "
      • Detail: 
      • \n" + - "
      • Field | 
      • \n" + - "
      • Element
      • "}, - //Make sure the heading is correct. - { "pkg/AnnotationType.html", - "Annotation Type AnnotationType"}, - //Make sure the signature is correct. - { "pkg/AnnotationType.html", - "public @interface AnnotationType"}, - //Make sure member summary headings are correct. - { "pkg/AnnotationType.html", - "

        Required Element Summary

        "}, - { "pkg/AnnotationType.html", - "

        Optional Element Summary

        "}, - //Make sure element detail heading is correct - { "pkg/AnnotationType.html", - "Element Detail"}, - //Make sure default annotation type value is printed when necessary. - { "pkg/AnnotationType.html", - "
        \n" + - "
        Default:
        \n" + - "
        \"unknown\"
        \n" + - "
        "}, + void checkTypeParameters() { + checkOutput("pkg/TypeParameters.html", true, + // Make sure the header is correct. + "Class TypeParameters<E>", + // Check class type parameters section. + "
        Type Parameters:
        \n" + + "
        E - " + + "the type parameter for this class.", + // Type parameters in @see/@link + "
        \n" + + "
        See Also:
        \n" + + "
        " + + "" + + "TypeParameters
        \n" + + "
        ", + // Method that uses class type parameter. + "(E param)", + // Method type parameter section. + "Type Parameters:\n" + + "
        T - This is the first " + + "type parameter.
        \n" + + "
        V - This is the second type " + + "parameter.", + // Signature of method with type parameters + "public <T extends java.util.List,V> " + + "java.lang.String[] methodThatHasTypeParameters"); - //================================= - // ANNOTATION TYPE USAGE TESTING - //================================= + checkOutput("pkg/Wildcards.html", true, + // Wildcard testing. + "" + + "TypeParameters<? super java.lang.String> a", + "" + + "TypeParameters<? extends java.lang.StringBuffer> b", + "" + + "TypeParameters c"); - //PACKAGE - { "pkg/package-summary.html", - "@AnnotationType(optional=\"Package Annotation\",\n" + - " required=1994)"}, + checkOutput(Output.WARNING, true, + // Bad type parameter warnings. + "warning - @param argument " + + "\"\" is not a type parameter name.", + "warning - @param argument " + + "\"\" is not a type parameter name."); - //CLASS - { "pkg/AnnotationTypeUsage.html", - "
        @AnnotationType(" +
        -                "optional" +
        -                "=\"Class Annotation\",\n" +
        -                "                " +
        -                "required=1994)\n" +
        -                "public class " +
        -                "AnnotationTypeUsage\n" +
        -                "extends java.lang.Object
        "}, + // Signature of subclass that has type parameters. + checkOutput("pkg/TypeParameterSubClass.html", true, + "
        public class TypeParameterSubClass<T extends "
        +                + "java.lang.String>\n"
        +                + "extends "
        +                + ""
        +                + "TypeParameterSuperClass<T>
        "); - //FIELD - { "pkg/AnnotationTypeUsage.html", - "
        @AnnotationType(" +
        -                "optional" +
        -                "=\"Field Annotation\",\n" +
        -                "                " +
        -                "required=1994)\n" +
        -                "public int field
        "}, + // Interface generic parameter substitution + // Signature of subclass that has type parameters. + checkOutput("pkg/TypeParameters.html", true, + "
        \n" + + "
        All Implemented Interfaces:
        \n" + + "
        " + + "SubInterface<E>, SuperInterface<E>
        \n" + + "
        "); - //CONSTRUCTOR - { "pkg/AnnotationTypeUsage.html", - "
        @AnnotationType(" +
        -                "optional" +
        -                "=\"Constructor Annotation\",\n" +
        -                "                " +
        -                "required=1994)\n" +
        -                "public AnnotationTypeUsage()
        "}, + checkOutput("pkg/SuperInterface.html", true, + "
        \n" + + "
        All Known Subinterfaces:
        \n" + + "
        " + + "SubInterface<V>
        \n" + + "
        "); + checkOutput("pkg/SubInterface.html", true, + "
        \n" + + "
        All Superinterfaces:
        \n" + + "
        " + + "SuperInterface<V>
        \n" + + "
        "); - //METHOD - { "pkg/AnnotationTypeUsage.html", - "
        @AnnotationType(" +
        -                "optional" +
        -                "=\"Method Annotation\",\n" +
        -                "                " +
        -                "required=1994)\n" +
        -                "public void method()
        "}, + //============================================================== + // Handle multiple bounds. + //============================================================== + checkOutput("pkg/MultiTypeParameters.html", true, + "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"); - //METHOD PARAMS - { "pkg/AnnotationTypeUsage.html", - "
        public void methodWithParams(" +
        -                "" +
        -                "@AnnotationType(" +
        -                "optional=\"Parameter Annotation\",required=1994)\n" +
        -                "                             int documented,\n" +
        -                "                             int undocmented)
        "}, + //============================================================== + // Test Class-Use Documentation for Type Parameters. + //============================================================== + // ClassUseTest1: + checkOutput("pkg2/class-use/Foo.html", true, + "Classes in pkg2 with type parameters of " + + "type " + + "Foo ", + "ClassUseTest1<T extends " + + "Foo" + + " & " + + "Foo2> ", + "Methods in pkg2 with type parameters of " + + "type Foo ", + "ClassUseTest1." + + "method" + + "(T t) ", + "Fields in pkg2 with type parameters of " + + "type " + + "Foo ", + "td class=\"colFirst\">ParamTest" + + "<Foo>" + ); - //CONSTRUCTOR PARAMS - { "pkg/AnnotationTypeUsage.html", - "
        public AnnotationTypeUsage(" +
        -                "@AnnotationType(" +
        -                "optional=\"Constructor Param Annotation\",required=1994)\n" +
        -                "                           int documented,\n" +
        -                "                           int undocmented)
        "}, + checkOutput("pkg2/class-use/ParamTest.html", true, + "Fields in pkg2 declared as ParamTest" + + " ", + "ParamTest<Foo>" + ); - //================================= - // ANNOTATION TYPE USAGE TESTING (All Different Types). - //================================= + checkOutput("pkg2/class-use/Foo2.html", true, + "Classes in pkg2 with type parameters of " + + "type Foo2 " + + "", + "ClassUseTest1<T extends " + + "Foo" + + " & " + + "Foo2> ", + "Methods in pkg2 with type parameters of " + + "type Foo2 " + + "", + "" + + "ClassUseTest1.method" + + "(T t) " + ); - //Integer - { "pkg1/B.html", - "d=3.14,"}, + // ClassUseTest2: > + checkOutput("pkg2/class-use/ParamTest.html", true, + "Classes in pkg2 with type parameters of " + + "type ParamTest" + + " ", + "ClassUseTest2<T extends " + + "" + + "ParamTest<" + + "Foo3>> ", + "Methods in pkg2 with type parameters of " + + "type ParamTest" + + " ", + "ClassUseTest2." + + "method" + + "(T t) ", + "Fields in pkg2 declared as ParamTest" + + " ", + "ParamTest" + + "<" + + "Foo>", + "Methods in pkg2 with type parameters of " + + "type ParamTest" + + " ", + "<T extends ParamTest" + + "<Foo3>>
        ParamTest" + + "<Foo3>
        " + ); - //Double - { "pkg1/B.html", - "d=3.14,"}, + checkOutput("pkg2/class-use/Foo3.html", true, + "Classes in pkg2 with type parameters of " + + "type " + + "Foo3 ", + "ClassUseTest2<T extends " + + "" + + "ParamTest<" + + "Foo3>> ", + "Methods in pkg2 with type parameters of " + + "type Foo3 " + + "", + "ClassUseTest2." + + "method" + + "(T t) ", + "Methods in pkg2 that return types with " + + "arguments of type Foo3" + + " ", + "<T extends ParamTest<" + + "Foo3" + + ">>
        ParamTest<Foo3>
        " + ); - //Boolean - { "pkg1/B.html", - "b=true,"}, + // ClassUseTest3: >> + checkOutput("pkg2/class-use/ParamTest2.html", true, + "Classes in pkg2 with type parameters of " + + "type ParamTest2" + + " ", + "ClassUseTest3<T extends " + + "" + + "ParamTest2<java.util.List<? extends " + + "" + + "Foo4>>> ", + "Methods in pkg2 with type parameters of " + + "type ParamTest2" + + " ", + "ClassUseTest3" + + ".method(T t) ", + "<T extends " + + "ParamTest2<java.util.List<? extends Foo4>" + + ">>
        ParamTest2<java.util.List" + + "<? extends Foo4>>
        " + ); - //String - { "pkg1/B.html", - "s=\"sigh\","}, + checkOutput("pkg2/class-use/Foo4.html", true, + "Classes in pkg2 with type parameters of " + + "type Foo4 " + + "", + "ClassUseTest3<T extends " + + "" + + "ParamTest2<java.util.List<? extends " + + "" + + "Foo4>>> ", + "Methods in pkg2 with type parameters of " + + "type Foo4 ", + "ClassUseTest3." + + "method(T t)" + + " ", + "Methods in pkg2 that return types with " + + "arguments of type Foo4 ", + "<T extends " + + "ParamTest2<java.util.List<? extends Foo4>" + + ">>
        ParamTest2<java.util.List" + + "<? extends Foo4>>
        " + ); - //Class - { "pkg1/B.html", - "c=Foo.class,"}, + // Type parameters in constructor and method args + checkOutput("pkg2/class-use/Foo4.html", true, + "Method parameters in pkg2 with type arguments of " + + "type Foo4 " + + "\n" + + "\n" + + "Modifier and Type\n" + + "Method and Description\n" + + "\n" + + "\n" + + "\n" + + "void\n" + + "ClassUseTest3." + + "method(java." + + "util.Set<Foo4> p) \n" + + "\n" + + "", + "Constructor parameters in pkg2 with type arguments " + + "of type Foo4 " + + "" + ); - //Bounded Class - { "pkg1/B.html", - "w=TypeParameterSubClass.class,"}, - - //Enum - { "pkg1/B.html", - "e=Penny,"}, - - //Annotation Type - { "pkg1/B.html", - "a=@AnnotationType(optional=\"foo\",required=1994),"}, - - //String Array - { "pkg1/B.html", - "sa={\"up\",\"down\"},"}, - - //Primitive - { "pkg1/B.html", - "primitiveClassTest=boolean.class,"}, - - //XXX: Add array test case after this if fixed: - //5020899: Incorrect internal representation of class-valued annotation elements - - //Make sure that annotations are surrounded by
         and 
        - { "pkg1/B.html", - "
        @A"},
        -            { "pkg1/B.html",
        -                "public interface B
        "}, - - - //============================================================== - // Handle multiple bounds. - //============================================================== - { "pkg/MultiTypeParameters.html", - "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"}, - - //============================================================== - // Test Class-Use Documenation for Type Parameters. - //============================================================== - - //ClassUseTest1: - { "pkg2/class-use/Foo.html", - "Classes in pkg2 with type parameters of " + - "type " + - "Foo " - }, - { "pkg2/class-use/Foo.html", - "ClassUseTest1<T extends " + - "Foo" + - " & " + - "Foo2> " - }, - { "pkg2/class-use/Foo.html", - "Methods in pkg2 with type parameters of " + - "type Foo " - }, - { "pkg2/class-use/Foo.html", - "ClassUseTest1." + - "method" + - "(T t) " - }, - { "pkg2/class-use/Foo.html", - "Fields in pkg2 with type parameters of " + - "type " + - "Foo " - }, - { "pkg2/class-use/Foo.html", - "td class=\"colFirst\">ParamTest" + - "<Foo>" - }, - - { "pkg2/class-use/ParamTest.html", - "Fields in pkg2 declared as ParamTest" + - " " - }, - { "pkg2/class-use/ParamTest.html", - "ParamTest<Foo>" - }, - - { "pkg2/class-use/Foo2.html", - "Classes in pkg2 with type parameters of " + - "type Foo2 " + - "" - }, - { "pkg2/class-use/Foo2.html", - "ClassUseTest1<T extends " + - "Foo" + - " & " + - "Foo2> " - }, - { "pkg2/class-use/Foo2.html", - "Methods in pkg2 with type parameters of " + - "type Foo2 " + - "" - }, - { "pkg2/class-use/Foo2.html", - "" + - "ClassUseTest1.method" + - "(T t) " - }, - - //ClassUseTest2: > - { "pkg2/class-use/ParamTest.html", - "Classes in pkg2 with type parameters of " + - "type ParamTest" + - " " - }, - { "pkg2/class-use/ParamTest.html", - "ClassUseTest2<T extends " + - "" + - "ParamTest<" + - "Foo3>> " - }, - { "pkg2/class-use/ParamTest.html", - "Methods in pkg2 with type parameters of " + - "type ParamTest" + - " " - }, - { "pkg2/class-use/ParamTest.html", - "ClassUseTest2." + - "method" + - "(T t) " - }, - { "pkg2/class-use/ParamTest.html", - "Fields in pkg2 declared as ParamTest" + - " " - }, - { "pkg2/class-use/ParamTest.html", - "ParamTest" + - "<" + - "Foo>" - }, - { "pkg2/class-use/ParamTest.html", - "Methods in pkg2 with type parameters of " + - "type ParamTest" + - " " - }, - { "pkg2/class-use/ParamTest.html", - "<T extends ParamTest" + - "<Foo3>>
        ParamTest" + - "<Foo3>
        " - }, - - { "pkg2/class-use/Foo3.html", - "Classes in pkg2 with type parameters of " + - "type " + - "Foo3 " - }, - { "pkg2/class-use/Foo3.html", - "ClassUseTest2<T extends " + - "" + - "ParamTest<" + - "Foo3>> " - }, - { "pkg2/class-use/Foo3.html", - "Methods in pkg2 with type parameters of " + - "type Foo3 " + - "" - }, - { "pkg2/class-use/Foo3.html", - "ClassUseTest2." + - "method" + - "(T t) " - }, - { "pkg2/class-use/Foo3.html", - "Methods in pkg2 that return types with " + - "arguments of type Foo3" + - " " - }, - { "pkg2/class-use/Foo3.html", - "<T extends ParamTest<" + - "Foo3" + - ">>
        ParamTest<Foo3>
        " - }, - - //ClassUseTest3: >> - { "pkg2/class-use/ParamTest2.html", - "Classes in pkg2 with type parameters of " + - "type ParamTest2" + - " " - }, - { "pkg2/class-use/ParamTest2.html", - "ClassUseTest3<T extends " + - "" + - "ParamTest2<java.util.List<? extends " + - "" + - "Foo4>>> " - }, - { "pkg2/class-use/ParamTest2.html", - "Methods in pkg2 with type parameters of " + - "type ParamTest2" + - " " - }, - { "pkg2/class-use/ParamTest2.html", - "ClassUseTest3" + - ".method(T t) " - }, - { "pkg2/class-use/ParamTest2.html", - "<T extends " + - "ParamTest2<java.util.List<? extends Foo4>" + - ">>
        ParamTest2<java.util.List" + - "<? extends Foo4>>
        " - }, - - { "pkg2/class-use/Foo4.html", - "Classes in pkg2 with type parameters of " + - "type Foo4 " + - "" - }, - { "pkg2/class-use/Foo4.html", - "ClassUseTest3<T extends " + - "" + - "ParamTest2<java.util.List<? extends " + - "" + - "Foo4>>> " - }, - { "pkg2/class-use/Foo4.html", - "Methods in pkg2 with type parameters of " + - "type Foo4 " - }, - { "pkg2/class-use/Foo4.html", - "ClassUseTest3." + - "method(T t)" + - " " - }, - { "pkg2/class-use/Foo4.html", - "Methods in pkg2 that return types with " + - "arguments of type Foo4 " - }, - { "pkg2/class-use/Foo4.html", - "<T extends " + - "ParamTest2<java.util.List<? extends Foo4>" + - ">>
        ParamTest2<java.util.List" + - "<? extends Foo4>>
        " - }, - - //Type parameters in constructor and method args - { "pkg2/class-use/Foo4.html", - "Method parameters in pkg2 with type arguments of " + - "type Foo4 " + - "\n" + - "\n" + - "Modifier and Type\n" + - "Method and Description\n" + - "\n" + - "\n" + - "\n" + - "void\n" + - "ClassUseTest3." + - "method(java." + - "util.Set<Foo4> p) \n" + - "\n" + - "" - }, - { "pkg2/class-use/Foo4.html", - "Constructor parameters in pkg2 with type arguments " + - "of type Foo4 " + - "" - }, - - //================================= - // Annotatation Type Usage - //================================= - { "pkg/class-use/AnnotationType.html", - "Packages with annotations of type " + - "AnnotationType " + - "" - }, - - { "pkg/class-use/AnnotationType.html", - "Classes in pkg with annotations of type " + - "AnnotationType " - }, - - { "pkg/class-use/AnnotationType.html", - "Fields in pkg with annotations of type " + - "AnnotationType" + - " " - }, - - { "pkg/class-use/AnnotationType.html", - "Methods in pkg with annotations of type " + - "AnnotationType" + - " " - }, - - { "pkg/class-use/AnnotationType.html", - "Method parameters in pkg with annotations of type " + - "AnnotationType" + - " " - }, - - { "pkg/class-use/AnnotationType.html", - "Constructors in pkg with annotations of type " + - "AnnotationType" + - " " - }, - - { "pkg/class-use/AnnotationType.html", - "Constructor parameters in pkg with annotations of " + - "type AnnotationType " - }, - - //================================= - // TYPE PARAMETER IN INDEX - //================================= - { "index-all.html", - "" + - "method(Vector<Object>)" - }, - //================================= - // TYPE PARAMETER IN INDEX - //================================= - { "index-all.html", - "" + - "method(Vector<Object>)" - }, - }; - private static final String[][] NEGATED_TEST = { //================================= - // ENUM TESTING + // TYPE PARAMETER IN INDEX //================================= - //NO constructor section - { "pkg/Coin.html", "

        Constructor Summary

        "}, + checkOutput("index-all.html", true, + "" + + "method(Vector<Object>)" + ); + + // TODO: duplicate of previous case; left in delibarately for now to simplify comparison testing //================================= - // TYPE PARAMETER TESTING + // TYPE PARAMETER IN INDEX //================================= - //No type parameters in class frame. - { "allclasses-frame.html", - "" + - "TypeParameters<E>" - }, + checkOutput("index-all.html", true, + "" + + "method(Vector<Object>)" + ); + + // No type parameters in class frame. + checkOutput("allclasses-frame.html", false, + "" + + "TypeParameters<E>" + ); + + } + + //================================= + // VAR ARG TESTING + //================================= + void checkVarArgs() { + checkOutput("pkg/VarArgs.html", true, + "(int... i)", + "(int[][]... i)", + "-int:A...-", + "" + + "TypeParameters... t"); + } + + //================================= + // ANNOTATION TYPE TESTING + //================================= + void checkAnnotationTypes() { + checkOutput("pkg/AnnotationType.html", true, + // Make sure the summary links are correct. + "
      • Summary: 
      • \n" + + "
      • Field | 
      • \n" + + "
      • " + + "Required | 
      • \n" + + "
      • " + + "Optional
      • ", + // Make sure the detail links are correct. + "
      • Detail: 
      • \n" + + "
      • Field | 
      • \n" + + "
      • Element
      • ", + // Make sure the heading is correct. + "Annotation Type AnnotationType", + // Make sure the signature is correct. + "public @interface AnnotationType", + // Make sure member summary headings are correct. + "

        Required Element Summary

        ", + "

        Optional Element Summary

        ", + // Make sure element detail heading is correct + "Element Detail", + // Make sure default annotation type value is printed when necessary. + "
        \n" + + "
        Default:
        \n" + + "
        \"unknown\"
        \n" + + "
        "); + } + + //================================= + // ANNOTATION TYPE USAGE TESTING + //================================= + void checkAnnotationTypeUsage() { + checkOutput("pkg/package-summary.html", true, + // PACKAGE + "@AnnotationType(optional=\"Package Annotation\",\n" + + " required=1994)"); + + checkOutput("pkg/AnnotationTypeUsage.html", true, + // CLASS + "
        @AnnotationType("
        +                + "optional"
        +                + "=\"Class Annotation\",\n"
        +                + "                "
        +                + "required=1994)\n"
        +                + "public class "
        +                + "AnnotationTypeUsage\n"
        +                + "extends java.lang.Object
        ", + // FIELD + "
        @AnnotationType("
        +                + "optional"
        +                + "=\"Field Annotation\",\n"
        +                + "                "
        +                + "required=1994)\n"
        +                + "public int field
        ", + // CONSTRUCTOR + "
        @AnnotationType("
        +                + "optional"
        +                + "=\"Constructor Annotation\",\n"
        +                + "                "
        +                + "required=1994)\n"
        +                + "public AnnotationTypeUsage()
        ", + // METHOD + "
        @AnnotationType("
        +                + "optional"
        +                + "=\"Method Annotation\",\n"
        +                + "                "
        +                + "required=1994)\n"
        +                + "public void method()
        ", + // METHOD PARAMS + "
        public void methodWithParams("
        +                + ""
        +                + "@AnnotationType("
        +                + "optional=\"Parameter Annotation\",required=1994)\n"
        +                + "                             int documented,\n"
        +                + "                             int undocmented)
        ", + // CONSTRUCTOR PARAMS + "
        public AnnotationTypeUsage("
        +                + "@AnnotationType("
        +                + "optional=\"Constructor Param Annotation\",required=1994)\n"
        +                + "                           int documented,\n"
        +                + "                           int undocmented)
        "); + + //================================= + // Annotatation Type Usage + //================================= + checkOutput("pkg/class-use/AnnotationType.html", true, + "Packages with annotations of type " + + "AnnotationType " + + "", + "Classes in pkg with annotations of type " + + "AnnotationType ", + "Fields in pkg with annotations of type " + + "AnnotationType" + + " ", + "Methods in pkg with annotations of type " + + "AnnotationType" + + " ", + "Method parameters in pkg with annotations of type " + + "AnnotationType" + + " ", + "Constructors in pkg with annotations of type " + + "AnnotationType" + + " ", + "Constructor parameters in pkg with annotations of " + + "type AnnotationType " + ); //============================================================== // ANNOTATION TYPE USAGE TESTING (When @Documented is omitted) //=============================================================== - - //CLASS - { "pkg/AnnotationTypeUsage.html", - "@AnnotationTypeUndocumented(optional=\"Class Annotation\",\n" + - " required=1994)\n" + - "public class AnnotationTypeUsage
        extends java.lang.Object
        "}, - - //FIELD - { "pkg/AnnotationTypeUsage.html", - "@AnnotationTypeUndocumented(optional=\"Field Annotation\",\n" + - " required=1994)\n" + - "public int field"}, - - //CONSTRUCTOR - { "pkg/AnnotationTypeUsage.html", - "@AnnotationTypeUndocumented(optional=\"Constructor Annotation\",\n" + - " required=1994)\n" + - "public AnnotationTypeUsage()"}, - - //METHOD - { "pkg/AnnotationTypeUsage.html", - "@AnnotationTypeUndocumented(optional=\"Method Annotation\",\n" + - " required=1994)\n" + - "public void method()"}, + checkOutput("pkg/AnnotationTypeUsage.html", false, + // CLASS + "@AnnotationTypeUndocumented(optional=\"Class Annotation\",\n" + + " required=1994)\n" + + "public class AnnotationTypeUsage
        extends java.lang.Object
        ", + // FIELD + "@AnnotationTypeUndocumented(optional=\"Field Annotation\",\n" + + " required=1994)\n" + + "public int field", + // CONSTRUCTOR + "@AnnotationTypeUndocumented(optional=\"Constructor Annotation\",\n" + + " required=1994)\n" + + "public AnnotationTypeUsage()", + // METHOD + "@AnnotationTypeUndocumented(optional=\"Method Annotation\",\n" + + " required=1994)\n" + + "public void method()"); //================================= // Make sure annotation types do not // trigger this warning. //================================= - {WARNING_OUTPUT, - "Internal error: package sets don't match: [] with: null" - }, - }; + checkOutput(Output.WARNING, false, + "Internal error: package sets don't match: [] with: null"); + + //================================= + // ANNOTATION TYPE USAGE TESTING (All Different Types). + //================================= + checkOutput("pkg1/B.html", true, + // Integer + "d=3.14,", + // Double + "d=3.14,", + // Boolean + "b=true,", + // String + "s=\"sigh\",", + // Class + "c=Foo.class,", + // Bounded Class + "w=TypeParameterSubClass.class,", + // Enum + "e=Penny,", + // Annotation Type + "a=@AnnotationType(optional=\"foo\",required=1994),", + // String Array + "sa={\"up\",\"down\"},", + // Primitive + "primitiveClassTest=boolean.class,"); + + // XXX: Add array test case after this if fixed: + //5020899: Incorrect internal representation of class-valued annotation elements + // Make sure that annotations are surrounded by
         and 
        + checkOutput("pkg1/B.html", true, + "
        @A",
        +                "public interface B
        "); - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestNewLanguageFeatures tester = new TestNewLanguageFeatures(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); } + } diff --git a/langtools/test/com/sun/javadoc/testNoPackagesFile/TestNoPackagesFile.java b/langtools/test/com/sun/javadoc/testNoPackagesFile/TestNoPackagesFile.java index aaefc7f9383..5e0ff72730e 100644 --- a/langtools/test/com/sun/javadoc/testNoPackagesFile/TestNoPackagesFile.java +++ b/langtools/test/com/sun/javadoc/testNoPackagesFile/TestNoPackagesFile.java @@ -27,31 +27,26 @@ * @summary Verify that packages.html is no longer generated since it is no * longer used. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestNoPackagesFile * @run main TestNoPackagesFile */ public class TestNoPackagesFile extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", 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) { + public static void main(String... args) throws Exception { TestNoPackagesFile tester = new TestNoPackagesFile(); - tester.run(ARGS, NO_TEST, NO_TEST); - if ((new java.io.File(OUTPUT_DIR + "/packages.html")).exists()) { - throw new Error("Test Fails: packages file should not be " + "generated anymore."); - } else { - System.out.println("Test passes: packages.html not found."); - } + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + // packages.html file should not be generated anymore. + checkFiles(false, "packages.html"); } } diff --git a/langtools/test/com/sun/javadoc/testNonFrameWarning/TestNonFrameWarning.java b/langtools/test/com/sun/javadoc/testNonFrameWarning/TestNonFrameWarning.java index af25ad1823c..ef809e96074 100644 --- a/langtools/test/com/sun/javadoc/testNonFrameWarning/TestNonFrameWarning.java +++ b/langtools/test/com/sun/javadoc/testNonFrameWarning/TestNonFrameWarning.java @@ -26,31 +26,28 @@ * @bug 7001086 * @summary Test Non-frame warning. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestNonFrameWarning + * @library ../lib + * @build JavadocTester * @run main TestNonFrameWarning */ public class TestNonFrameWarning extends JavadocTester { - private static final String[][] TEST = { - { "index.html", - "

        This document is designed to be viewed using the frames feature. " + - "If you see this message, you are using a non-frame-capable web client. " + - "Link to Non-frame version.

        " - } - }; - 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) { + public static void main(String... args) throws Exception { TestNonFrameWarning tester = new TestNonFrameWarning(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("index.html", true, + "

        This document is designed to be viewed using the frames feature. " + + "If you see this message, you are using a non-frame-capable web client. " + + "Link to Non-frame version.

        "); } } diff --git a/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java b/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java index ab0b9a0987d..7f895d12624 100644 --- a/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java +++ b/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java @@ -28,50 +28,43 @@ * be created. * Make sure classname is not include in javadoc usage message. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestNotifications * @run main TestNotifications */ public class TestNotifications extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg" - }; - - private static final String[] ARGS2 = new String[] { - "-help" - }; - - //Input for string search tests. - private static final String[][] TEST = { - {NOTICE_OUTPUT, "Creating destination directory: \"" + OUTPUT_DIR} - }; - private static final String[][] NEGATED_TEST = { - {NOTICE_OUTPUT, "Creating destination directory: \"" + OUTPUT_DIR} - }; - - private static final String[][] NEGATED_TEST2 = { - {NOTICE_OUTPUT, "[classnames]"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestNotifications tester = new TestNotifications(); + tester.runTests(); + } + + @Test + void test1() { + String outDir = "out"; + // Notify that the destination directory must be created. - tester.run(ARGS, TEST, NO_TEST); + javadoc("-d", outDir, "-sourcepath", testSrc, "pkg"); + checkExit(Exit.OK); + checkOutput(Output.NOTICE, true, + "Creating destination directory: \"" + outDir); + // No need to notify that the destination must be created because // it already exists. - tester.setCheckOutputDirectoryCheck(DirectoryCheck.NONE); - tester.run(ARGS, NO_TEST, NEGATED_TEST); - tester.setCheckOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); + setOutputDirectoryCheck(DirectoryCheck.NONE); + javadoc("-d", outDir, "-sourcepath", testSrc, "pkg"); + checkExit(Exit.OK); + checkOutput(Output.NOTICE, false, + "Creating destination directory: \"" + outDir); + } + + @Test + void test() { //Make sure classname is not include in javadoc usage message. - tester.run(ARGS2, NO_TEST, NEGATED_TEST2); - tester.printSummary(); + setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); + javadoc("-help"); + checkOutput(Output.NOTICE, false, + "[classnames]"); } } diff --git a/langtools/test/com/sun/javadoc/testOptions/TestOptions.java b/langtools/test/com/sun/javadoc/testOptions/TestOptions.java index 3a8ecbc58d6..80c83efbdb0 100644 --- a/langtools/test/com/sun/javadoc/testOptions/TestOptions.java +++ b/langtools/test/com/sun/javadoc/testOptions/TestOptions.java @@ -26,34 +26,30 @@ * @bug 4749567 * @summary Test the output for -header and -footer options. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestOptions + * @library ../lib + * @build JavadocTester * @run main TestOptions */ public class TestOptions extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-header", "Test header", "-footer", "Test footer", - "-sourcepath", SRC_DIR, "pkg" - }; - - private static final String[][] TEST = { - { "pkg/package-summary.html", - "
        Test header
        "}, - { "pkg/package-summary.html", - "
        Test footer
        "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestOptions tester = new TestOptions(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-header", "Test header", + "-footer", "Test footer", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/package-summary.html", true, + "
        Test header
        ", + "
        Test footer
        "); } } diff --git a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java index a10d96f613c..29286329ac2 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java +++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java @@ -23,113 +23,115 @@ /* * @test - * @bug 8039410 + * @bug 8039410 8042601 * @summary test to determine if members are ordered correctly * @author ksrini * @library ../lib/ * @build JavadocTester - * @build TestOrdering * @run main TestOrdering */ -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class TestOrdering extends JavadocTester { - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ + public static void main(String[] args) throws Exception { TestOrdering tester = new TestOrdering(); - // test unnamed packages - String[] ARGS = { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", - SRC_DIR + "/C.java", SRC_DIR + "/UsedInC.java" - }; - tester.runJavadoc(ARGS); - checkExecutableMemberOrdering(tester.readFileToString("class-use/UsedInC.html")); - - // next test using packages - String[] ARGS1 = { - "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "-use", - "pkg1" - }; - tester.runJavadoc(ARGS1); - checkClassUseOrdering(tester.readFileToString("pkg1/class-use/UsedClass.html")); - checkIndexPathOrdering(tester.readFileToString("index-all.html")); + tester.runTests(); } - static void checkExecutableMemberOrdering(String usePage) { + @Test + void testUnnamedPackages() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-use", + testSrc("C.java"), testSrc("UsedInC.java")); + checkExit(Exit.OK); + checkExecutableMemberOrdering("class-use/UsedInC.html"); + } + + @Test + void testNamedPackages() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + "-use", + "pkg1"); + checkExit(Exit.OK); + checkClassUseOrdering("pkg1/class-use/UsedClass.html"); + checkIndexPathOrdering("index-all.html"); + } + + void checkExecutableMemberOrdering(String usePage) { + String contents = readFile(usePage); // check constructors - int idx1 = usePage.indexOf("C.html#C-UsedInC"); - int idx2 = usePage.indexOf("C.html#C-UsedInC-int"); - int idx3 = usePage.indexOf("C.html#C-UsedInC-java.lang.String"); + checking("constructors"); + int idx1 = contents.indexOf("C.html#C-UsedInC"); + int idx2 = contents.indexOf("C.html#C-UsedInC-int"); + int idx3 = contents.indexOf("C.html#C-UsedInC-java.lang.String"); if (idx1 == -1 || idx2 == -1 || idx3 == -1) { - throw new Error("ctor strings not found"); - } - if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) { - throw new Error("ctor strings are out of order"); - } + failed("ctor strings not found"); + } else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) { + failed("ctor strings are out of order"); + } else + passed("ctor strings are in order"); // check methods - idx1 = usePage.indexOf("C.html#ymethod-int"); - idx2 = usePage.indexOf("C.html#ymethod-java.lang.String"); + checking("methods"); + idx1 = contents.indexOf("C.html#ymethod-int"); + idx2 = contents.indexOf("C.html#ymethod-java.lang.String"); if (idx1 == -1 || idx2 == -1) { - throw new Error("#ymethod strings not found"); - } - if (idx1 > idx2) { - throw new Error("#ymethod strings are out of order"); - } - System.out.println("Executable Member Ordering: OK"); + failed("#ymethod strings not found"); + } else if (idx1 > idx2) { + failed("#ymethod strings are out of order"); + } else + passed("Executable Member Ordering: OK"); } - static void checkClassUseOrdering(String usePage) { + void checkClassUseOrdering(String usePage) { checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield"); checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#"); checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass"); checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#"); } - static void checkClassUseOrdering(String usePage, String searchString) { + void checkClassUseOrdering(String usePage, String searchString) { + String contents = readFile(usePage); int lastidx = 0; System.out.println("testing for " + searchString); for (int i = 1; i < 5; i++) { String s = searchString.replaceAll("#ITERATION#", Integer.toString(i)); - System.out.println(s); - int idx = usePage.indexOf(s); + checking(s); + int idx = contents.indexOf(s); if (idx < lastidx) { - throw new Error(s + ", member ordering error, last:" + lastidx + ", got:" + idx); + failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx); + } else { + passed("\tlast: " + lastidx + " got:" + idx); } - System.out.println("\tlast: " + lastidx + " got:" + idx); lastidx = idx; } } - static void checkIndexPathOrdering(String indexPage) { - String[] OrderedExpectedStrings = { - "pkg1/UsedClass.html#add-java.lang.Double", - "pkg1/ZZTop.html#add-double", - "pkg1/ZZTop.html#add-java.lang.Double", - "pkg1/UsedClass.html#add-float", - "pkg1/ZZTop.html#add-float", - "pkg1/UsedClass.html#add-int", - "pkg1/ZZTop.html#add-int", - "pkg1/UsedClass.html#add-java.lang.Integer", - "pkg1/ZZTop.html#add-java.lang.Integer", - "pkg1/UsedClass.html#add-double-double", - "pkg1/UsedClass.html#add-double-java.lang.Double", - "pkg1/ZZTop.html#add-double-double", - "pkg1/ZZTop.html#add-double-java.lang.Double" - }; - int lastidx = 0; - for (String x : OrderedExpectedStrings) { - int idx = indexPage.indexOf(x); - if (idx < lastidx) { - throw new Error(x + ", index is out of order, last:" + lastidx + ", got:" + idx); - } - System.out.println(x + ": OK"); - lastidx = idx; - } + void checkIndexPathOrdering(String indexPage) { + checkOrder(indexPage, + "pkg1/UsedClass.html#add--", + "pkg1/ZZTop.html#add--", + "pkg1/UsedClass.html#add-double-", + "pkg1/UsedClass.html#add-java.lang.Double-", + "pkg1/ZZTop.html#add-double-", + "pkg1/ZZTop.html#add-java.lang.Double-", + "pkg1/UsedClass.html#add-double-byte-", + "pkg1/ZZTop.html#add-double-byte-", + "pkg1/UsedClass.html#add-double-double-", + "pkg1/UsedClass.html#add-double-java.lang.Double-", + "pkg1/ZZTop.html#add-double-double-", + "pkg1/ZZTop.html#add-double-java.lang.Double-", + "pkg1/UsedClass.html#add-float-", + "pkg1/ZZTop.html#add-float-", + "pkg1/UsedClass.html#add-float-int-", + "pkg1/ZZTop.html#add-float-int-", + "pkg1/UsedClass.html#add-int-", + "pkg1/ZZTop.html#add-int-", + "pkg1/UsedClass.html#add-int-float-", + "pkg1/ZZTop.html#add-int-float-", + "pkg1/UsedClass.html#add-java.lang.Integer-", + "pkg1/ZZTop.html#add-java.lang.Integer-"); } } diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java index d8311d60979..020dd7bb031 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java @@ -26,36 +26,41 @@ package pkg1; * For index and class-use testing */ public class UsedClass { - // This is the exact order we expect to see /** - * @param i param + * just an empty param method. */ - public void add(int i){} - - /** - * @param i param - * @return double - */ - public int add(Integer i) {return 0;} + public void add(){} /** * @param d param */ public void add(double d){} + /** + * @param i param + * @param f param + */ + public void add(int i, float f){} + + /** + * @param f param + * @param i param + */ + public void add(float f, int i){} + + /** + * @param d param + * @param b param + */ + public void add(double d, byte b){} + /** * @param d param * @return Double */ public Double add(Double d) {return (double) 22/7;} - /** - * @param f param - * @return Float - */ - public Float add(float f) {return (float) 22/7;} - /** * @param d1 param * @param d2 param @@ -69,4 +74,21 @@ public class UsedClass { * @return double */ public double add(double d1, Double d2) {return d1 + d2;} + + /** + * @param f param + * @return Float + */ + public Float add(float f) {return (float) 22/7;} + + /** + * @param i param + */ + public void add(int i){} + + /** + * @param i param + * @return double + */ + public int add(Integer i) {return 0;} } diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java index 4b39384b2de..6ad1cb4aa84 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java @@ -26,35 +26,41 @@ package pkg1; * For index testing only */ public class ZZTop { - // This is the exact order we expect to see /** - * @param i param + * just an empty param method. */ - public void add(int i){} - - /** - * @param i param - * @return double - */ - public int add(Integer i) {return 0;} + public void add(){} /** * @param d param */ public void add(double d){} + /** + * @param i param + * @param f param + */ + public void add(int i, float f){} + + /** + * @param f param + * @param i param + */ + public void add(float f, int i){} + + /** + * @param d param + * @param b param + */ + public void add(double d, byte b){} + /** * @param d param * @return Double */ public Double add(Double d) {return (double) 22/7;} - /** - * @param f param - * @return Float - */ - public Float add(float f) {return (float) 22/7;} /** * @param d1 param * @param d2 param @@ -68,4 +74,21 @@ public class ZZTop { * @return double */ public double add(double d1, Double d2) {return d1 + d2;} + + /** + * @param f param + * @return Float + */ + public Float add(float f) {return (float) 22/7;} + + /** + * @param i param + */ + public void add(int i){} + + /** + * @param i param + * @return double + */ + public int add(Integer i) {return 0;} } diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java index c38c09c51d7..3bd70294602 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java @@ -27,59 +27,54 @@ * @summary Make sure that all inherited methods from multiple extended * interfaces are documented * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestMultiInheritence * @run main TestMultiInheritence */ +// TODO: should be TestMultiInheritance public class TestMultiInheritence extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg3" - }; - - //Method foo() is inherited from BOTH I2 and I3 - private static final String[][] TEST = { - { "pkg3/I1.html", - "Methods inherited from interface pkg3." + - "" + - "I2"}, - { "pkg3/I1.html", - "Methods inherited from interface pkg3." + - "" + - "I3"}, - { "pkg3/I0.html", - "Methods inherited from interface pkg3." + - "" + - "I2"}, - { "pkg3/I0.html", - "Methods inherited from interface pkg3." + - "" + - "I3"}, - }; - - //Method foo() is NOT inherited from I4 because it is overriden by - //I3. - private static final String[][] NEGATED_TEST = { - { "pkg3/I1.html", - "Methods inherited from interface pkg3." + - "" + - "I4"}, - { "pkg3/I0.html", - "Methods inherited from interface pkg3." + - "" + - "I4"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestMultiInheritence tester = new TestMultiInheritence(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg3"); + checkExit(Exit.OK); + + // Method foo() is inherited from BOTH I2 and I3 + + checkOutput("pkg3/I1.html", true, + "Methods inherited from interface pkg3." + + "" + + "I2", + "Methods inherited from interface pkg3." + + "" + + "I3"); + + checkOutput("pkg3/I0.html", true, + "Methods inherited from interface pkg3." + + "" + + "I2", + "Methods inherited from interface pkg3." + + "" + + "I3"); + + // Method foo() is NOT inherited from I4 because it is overriden by I3. + + checkOutput("pkg3/I1.html", false, + "Methods inherited from interface pkg3." + + "" + + "I4"); + + checkOutput("pkg3/I0.html", false, + "Methods inherited from interface pkg3." + + "" + + "I4"); } } diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java index cd24cfa991d..4a582a5bb79 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java @@ -27,35 +27,32 @@ * @summary Inherited comment should link directly to member, not just * class * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestOverridenMethodDocCopy * @run main TestOverridenMethodDocCopy */ public class TestOverridenMethodDocCopy extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1", "pkg2" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg1/SubClass.html", - "Description copied from class: " + - "" + - "BaseClass" - } - }; - /** * The entry point of the test. * @param args the array of command line arguments. */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestOverridenMethodDocCopy tester = new TestOverridenMethodDocCopy(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg1/SubClass.html", true, + "Description copied from class: " + + "" + + "BaseClass"); } } diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java index 71869cb1434..cc76c074c4a 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java @@ -27,61 +27,50 @@ * @summary Determine if overriden methods are properly documented when * -protected (default) visibility flag is used. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestOverridenPrivateMethods * @run main TestOverridenPrivateMethods */ public class TestOverridenPrivateMethods extends JavadocTester { - private static final String[][] TEST = { - //The public method should be overriden - { "pkg1/SubClass.html", - "
        Overrides:
        \n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + - "
        " + - "publicMethod in class " + - "BaseClass
        "}, - - //The public method in different package should be overriden - { "pkg2/SubClass.html", - "
        Overrides:
        \n" + - "
        " + - "publicMethod in class " + - "BaseClass
        "}, - - //The package private method should be overriden since the base and sub class are in the same - //package. - { "pkg1/SubClass.html", - "
        Overrides:
        \n" + - "
        " + - "packagePrivateMethod in class " + - "BaseClass
        "} - }; - - private static final String[][] NEGATED_TEST = { - - //The private method in should not be overriden - { "pkg1/SubClass.html", - "
        Overrides:
        \n" + - "
        "}, - - //The private method in different package should not be overriden - { "pkg2/SubClass.html", - "
        Overrides:
        \n" + - "
        "}, - - //The package private method should not be overriden since the base and sub class are in - //different packages. - { "pkg2/SubClass.html", - "
        Overrides:
        \n" + - "
        "}, - }; - - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-package", "pkg1", "pkg2"}; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestOverridenPrivateMethodsWithPackageFlag tester = new TestOverridenPrivateMethodsWithPackageFlag(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-package", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + // The public method should be overridden + checkOutput("pkg1/SubClass.html", true, + "
        Overrides:
        \n" + + "
        " + + "publicMethod in class " + + "BaseClass
        "); + + // The public method in different package should be overridden + checkOutput("pkg2/SubClass.html", true, + "
        Overrides:
        \n" + + "
        " + + "publicMethod in class " + + "BaseClass
        "); + + // The package private method should be overridden since the base and sub class are in the same + // package. + checkOutput("pkg1/SubClass.html", true, + "
        Overrides:
        \n" + + "
        " + + "packagePrivateMethod in class " + + "BaseClass
        "); + + // The private method in should not be overridden + checkOutput("pkg1/SubClass.html", false, + "
        Overrides:
        \n" + + "
        "); + + // The private method in different package should not be overridden + checkOutput("pkg2/SubClass.html", false, + "
        Overrides:
        \n" + + "
        "); + + // The package private method should not be overridden since the base and sub class are in + // different packages. + checkOutput("pkg2/SubClass.html", false, + "
        Overrides:
        \n" + + "
        "); } } diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java index 13739ce6b83..9fb8423e0b2 100644 --- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java +++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java @@ -24,67 +24,59 @@ /* * @test * @bug 4634891 8026567 - * @summary Determine if overriden methods are properly documented when + * @summary Determine if overridden methods are properly documented when * -protected (default) visibility flag is used. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestOverridenPrivateMethodsWithPrivateFlag * @run main TestOverridenPrivateMethodsWithPrivateFlag */ public class TestOverridenPrivateMethodsWithPrivateFlag extends JavadocTester { - private static final String[][] TEST = { - //The public method should be overriden - { "pkg1/SubClass.html", - "
        Overrides:
        \n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + - "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Overrides:\n" + + "
        Deprecated.\n" + "
        This package is Deprecated." + "
        " - }, - { "deprecated-list.html", - "
      • Deprecated Packages
      • " - } - }; - private static final String[][] NEGATED_TEST2 = { - { "overview-summary.html", "pkg1"}, - { "allclasses-frame.html", "FooDepr"} - }; + ); - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestPackageDeprecation tester = new TestPackageDeprecation(); - tester.run(ARGS1, TEST1, NO_TEST); - tester.run(ARGS2, NO_TEST, NEGATED_TEST2); - if ((new java.io.File(OUTPUT_DIR + "-2/pkg1/" + - "package-summary.html")).exists()) { - throw new Error("Test Fails: packages summary should not be" + - "generated for deprecated package."); - } else { - System.out.println("Test passes: package-summary.html not found."); - } - if ((new java.io.File(OUTPUT_DIR + "-2/FooDepr.html")).exists()) { - throw new Error("Test Fails: FooDepr should not be" + - "generated as it is deprecated."); - } else { - System.out.println("Test passes: FooDepr.html not found."); - } - tester.printSummary(); + checkOutput("deprecated-list.html", true, + "
      • Deprecated Packages
      • " + ); + } + + @Test + void testNoDeprecated() { + javadoc("-d", "out-nodepr", + "-sourcepath", testSrc, + "-use", + "-nodeprecated", + "pkg", "pkg1", testSrc("C2.java"), testSrc("FooDepr.java")); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", false, + "pkg1"); + checkOutput("allclasses-frame.html", false, + "FooDepr"); + + checkFiles(false, + "pkg1/package-summary.html", + "FooDepr.html"); } } diff --git a/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java b/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java index dae5022afa9..7941694631d 100644 --- a/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java +++ b/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java @@ -28,69 +28,58 @@ * passed to Javadoc. Also test that the proper package links are generated * when single or multiple packages are documented. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestPackagePage * @run main TestPackagePage */ public class TestPackagePage extends JavadocTester { - private static final String[][] TEST1 = { - { "com/pkg/package-summary.html", - "This is a package page." - }, - //With just one package, all general pages link to the single package page. - { "com/pkg/C.html", - "Package" - }, - { "com/pkg/package-tree.html", - "
      • Package
      • " - }, - { "deprecated-list.html", - "
      • Package
      • " - }, - { "index-all.html", - "
      • Package
      • " - }, - { "help-doc.html", - "
      • Package
      • " - }, - }; - - private static final String[][] TEST2 = { - //With multiple packages, there is no package link in general pages. - { "deprecated-list.html", - "
      • Package
      • " - }, - { "index-all.html", - "
      • Package
      • " - }, - { "help-doc.html", - "
      • Package
      • " - }, - }; - - private static final String[] ARGS1 = - new String[] { - "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, - SRC_DIR + "/com/pkg/C.java" - }; - - private static final String[] ARGS2 = - new String[] { - "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, - "com.pkg", "pkg2" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestPackagePage tester = new TestPackagePage(); - tester.run(ARGS1, TEST1, NO_TEST); - tester.run(ARGS2, TEST2, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testSinglePackage() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + testSrc("com/pkg/C.java")); + checkExit(Exit.OK); + + checkOutput("com/pkg/package-summary.html", true, + "This is a package page."); + + // With just one package, all general pages link to the single package page. + checkOutput("com/pkg/C.html", true, + "Package"); + checkOutput("com/pkg/package-tree.html", true, + "
      • Package
      • "); + checkOutput("deprecated-list.html", true, + "
      • Package
      • "); + checkOutput("index-all.html", true, + "
      • Package
      • "); + checkOutput("help-doc.html", true, + "
      • Package
      • "); + } + + private static final String[][] TEST1 = { + }; + + + @Test + void testMultiplePackages() { + javadoc("-d", "out-2", + "-sourcepath", testSrc, + "com.pkg", "pkg2"); + checkExit(Exit.OK); + + //With multiple packages, there is no package link in general pages. + checkOutput("deprecated-list.html", true, + "
      • Package
      • "); + checkOutput("index-all.html", true, + "
      • Package
      • "); + checkOutput("help-doc.html", true, + "
      • Package
      • "); } } diff --git a/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java b/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java index 91b9ef5e6ef..252d3ddbcda 100644 --- a/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java +++ b/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java @@ -28,50 +28,38 @@ * match up with a real parameters. * Make sure inheritDoc cannot be used in an invalid param tag. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestParamTaglet * @run main TestParamTaglet */ public class TestParamTaglet extends JavadocTester { - //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 = { - //Regular param tags. - { "pkg/C.html", - "Parameters:\n" + - "
        param1 - testing 1 2 3.
        \n" + - "
        param2 - testing 1 2 3." - }, - //Param tags that don't match with any real parameters. - { "pkg/C.html", - "Parameters:\n" + - "
        p1 - testing 1 2 3.
        \n" + - "
        p2 - testing 1 2 3." - }, - //{@inherit} doc misuse does not cause doclet to throw exception. - // Param is printed with nothing inherited. - //XXX: in the future when Configuration is available during doc inheritence, - //print a warning for this mistake. - { "pkg/C.html", - "inheritBug -" - }, - - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestParamTaglet tester = new TestParamTaglet(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.FAILED); + + checkOutput("pkg/C.html", true, + //Regular param tags. + "Parameters:\n" + + "
        param1 - testing 1 2 3.
        \n" + + "
        param2 - testing 1 2 3.", + //Param tags that don't match with any real parameters. + "Parameters:\n" + + "
        p1 - testing 1 2 3.
        \n" + + "
        p2 - testing 1 2 3.", + //{@inherit} doc misuse does not cause doclet to throw exception. + // Param is printed with nothing inherited. + //XXX: in the future when Configuration is available during doc inheritence, + //print a warning for this mistake. + "inheritBug -"); } } diff --git a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java index 3f50448c641..1b051b6f3df 100644 --- a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java +++ b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java @@ -37,237 +37,185 @@ * Make sure when no modifier appear in the class signature, the * signature is displayed correctly without extra space at the beginning. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestPrivateClasses + * @library ../lib + * @build JavadocTester * @run main TestPrivateClasses */ public class TestPrivateClasses extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS1 = new String[] { - "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg", "pkg2" - }; - private static final String[] ARGS2 = new String[] { - "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "-private", - "pkg", "pkg2" - }; - - // Test output when -private flag is not used. - private static final String[][] TEST1 = { - // Field inheritence from non-public superclass. - { "pkg/PublicChild.html", - "" + - "fieldInheritedFromParent" - }, - - // Method inheritence from non-public superclass. - { "pkg/PublicChild.html", - "" + - "methodInheritedFromParent" - }, - - // Field inheritence from non-public superinterface. - { "pkg/PublicInterface.html", - "" + - "fieldInheritedFromInterface" - }, - - // Method inheritence from non-public superinterface. - { "pkg/PublicInterface.html", - "" + - "methodInterface" - }, - - // private class does not show up in tree - { "pkg/PublicChild.html", - "
          \n" + - "
        • java.lang.Object
        • \n" + - "
        • \n" + - "
            \n" + - "
          • pkg.PublicChild
          • \n" + - "
          \n" + - "
        • \n" + - "
        " - }, - - // Method is documented as though it is declared in the inheriting method. - { "pkg/PublicChild.html", - "
        public void methodInheritedFromParent(int p1)"
        -        },
        -
        -        //Make sure implemented interfaces from private superclass are inherited
        -        { "pkg/PublicInterface.html",
        -            "
        \n" + - "
        All Known Implementing Classes:
        \n" + - "
        " + - "PublicChild
        \n" + - "
        "}, - - { "pkg/PublicChild.html", - "
        \n" + - "
        All Implemented Interfaces:
        \n" + - "
        " + - "PublicInterface
        \n" + - "
        "}, - - //Generic interface method test. - { "pkg2/C.html", - "This comment should get copied to the implementing class"}, - }; - private static final String[][] NEGATED_TEST1 = { - // Should not document that a method overrides method from private class. - { "pkg/PublicChild.html", - "Overrides:"}, - // Should not document that a method specified by private interface. - { "pkg/PublicChild.html", - "Specified by:"}, - { "pkg/PublicInterface.html", - "Specified by:"}, - // Should not mention that any documentation was copied. - { "pkg/PublicChild.html", - "Description copied from"}, - { "pkg/PublicInterface.html", - "Description copied from"}, - // Don't extend private classes or interfaces - { "pkg/PublicChild.html", - "PrivateParent"}, - { "pkg/PublicInterface.html", - "PrivateInterface"}, - { "pkg/PublicChild.html", - "PrivateInterface"}, - { "pkg/PublicInterface.html", - "All Superinterfaces"}, - // Make inherited constant are documented correctly. - { "constant-values.html", - "PrivateInterface"}, - - //Do not inherit private interface method with generic parameters. - //This method has been implemented. - { "pkg2/C.html", - "hello"}, - }; - - // Test output when -private flag is used. - private static final String[][] TEST2 = { - // Field inheritence from non-public superclass. - { "pkg/PublicChild.html", - "Fields inherited from class pkg." + - "" + - "PrivateParent" - }, - { "pkg/PublicChild.html", - "" + - "fieldInheritedFromParent" - }, - // Field inheritence from non-public superinterface. - { "pkg/PublicInterface.html", - "Fields inherited from interface pkg." + - "" + - "PrivateInterface" - }, - { "pkg/PublicInterface.html", - "" + - "fieldInheritedFromInterface" - }, - // Method inheritence from non-public superclass. - { "pkg/PublicChild.html", - "Methods inherited from class pkg." + - "" + - "PrivateParent" - }, - { "pkg/PublicChild.html", - "" + - "methodInheritedFromParent" - }, - // Should document that a method overrides method from private class. - { "pkg/PublicChild.html", - "
        Overrides:
        \n" + - "
        " + - "methodOverridenFromParent in class " + - "" + - "PrivateParent
        "}, - // Should document that a method is specified by private interface. - { "pkg/PublicChild.html", - "
        Specified by:
        \n" + - "
        " + - "methodInterface in interface " + - "" + - "PrivateInterface
        "}, - // Method inheritence from non-public superinterface. - { "pkg/PublicInterface.html", - "Methods inherited from interface pkg." + - "" + - "PrivateInterface" - }, - { "pkg/PrivateInterface.html", - "" + - "methodInterface" - }, - // Should mention that any documentation was copied. - { "pkg/PublicChild.html", - "Description copied from"}, - // Extend documented private classes or interfaces - { "pkg/PublicChild.html", - "extends"}, - { "pkg/PublicInterface.html", - "extends"}, - { "pkg/PublicInterface.html", - "All Superinterfaces"}, - - //Make sure implemented interfaces from private superclass are inherited - { "pkg/PublicInterface.html", - "
        \n" + - "
        All Known Implementing Classes:
        \n" + - "
        " + - "PrivateParent, " + - "PublicChild" + - "
        \n" + - "
        "}, - - { "pkg/PublicChild.html", - "
        \n" + - "
        All Implemented Interfaces:
        \n" + - "
        " + - "PrivateInterface, " + - "" + - "PublicInterface
        \n" + - "
        "}, - - //Since private flag is used, we can document that private interface method - //with generic parameters has been implemented. - { "pkg2/C.html", - "Description copied from interface: " + - "I"}, - - { "pkg2/C.html", - "
        Specified by:
        \n" + - "
        hello" + - " in interface " + - "I" + - "<java.lang.String>
        "}, - - //Make sure when no modifier appear in the class signature, the - //signature is displayed correctly without extra space at the beginning. - { "pkg/PrivateParent.html", - "
        class PrivateParent"},
        -
        -      { "pkg/PublicChild.html",
        -            "
        public class PublicChild"},
        -    };
        -    private static final String[][] NEGATED_TEST2 = {
        -        { "pkg/PrivateParent.html",
        -            "
         class PrivateParent"},
        -    };
        -
        -    /**
        -     * The entry point of the test.
        -     * @param args the array of command line arguments.
        -     */
        -    public static void main(String[] args) {
        +    public static void main(String... args) throws Exception {
                 TestPrivateClasses tester = new TestPrivateClasses();
        -        tester.run(ARGS1, TEST1, NEGATED_TEST1);
        -        tester.run(ARGS2, TEST2, NEGATED_TEST2);
        -        tester.printSummary();
        +        tester.runTests();
        +    }
        +
        +    @Test
        +    void testDefault() {
        +        javadoc("-d", "out-default",
        +                "-sourcepath", testSrc,
        +                "pkg", "pkg2");
        +        checkExit(Exit.OK);
        +
        +        checkOutput("pkg/PublicChild.html", true,
        +                // Field inheritence from non-public superclass.
        +                ""
        +                + "fieldInheritedFromParent",
        +                // Method inheritance from non-public superclass.
        +                ""
        +                + "methodInheritedFromParent",
        +                // private class does not show up in tree
        +                "
          \n" + + "
        • java.lang.Object
        • \n" + + "
        • \n" + + "
            \n" + + "
          • pkg.PublicChild
          • \n" + + "
          \n" + + "
        • \n" + + "
        ", + // Method is documented as though it is declared in the inheriting method. + "
        public void methodInheritedFromParent(int p1)",
        +                "
        \n" + + "
        All Implemented Interfaces:
        \n" + + "
        " + + "PublicInterface
        \n" + + "
        "); + + checkOutput("pkg/PublicChild.html", false, + // Should not document that a method overrides method from private class. + "Overrides:", + // Should not document that a method specified by private interface. + "Specified by:", + // Should not mention that any documentation was copied. + "Description copied from", + // Don't extend private classes or interfaces + "PrivateParent", + "PrivateInterface"); + + checkOutput("pkg/PublicInterface.html", true, + // Field inheritance from non-public superinterface. + "" + + "fieldInheritedFromInterface", + // Method inheritance from non-public superinterface. + "" + + "methodInterface", + //Make sure implemented interfaces from private superclass are inherited + "
        \n" + + "
        All Known Implementing Classes:
        \n" + + "
        " + + "PublicChild
        \n" + + "
        "); + + checkOutput("pkg/PublicInterface.html", false, + "Specified by:", + "Description copied from", + "PrivateInterface", + "All Superinterfaces"); + + checkOutput("pkg2/C.html", true, + //Generic interface method test. + "This comment should get copied to the implementing class"); + + checkOutput("pkg2/C.html", false, + //Do not inherit private interface method with generic parameters. + //This method has been implemented. + "hello"); + + checkOutput("constant-values.html", false, + // Make inherited constant are documented correctly. + "PrivateInterface"); + } + + @Test + void testPrivate() { + javadoc("-d", "out-private", + "-sourcepath", testSrc, + "-private", + "pkg", "pkg2"); + checkExit(Exit.OK); + + checkOutput("pkg/PublicChild.html", true, + // Field inheritence from non-public superclass. + "Fields inherited from class pkg." + + "" + + "PrivateParent", + "" + + "fieldInheritedFromParent", + // Method inheritence from non-public superclass. + "Methods inherited from class pkg." + + "" + + "PrivateParent", + "" + + "methodInheritedFromParent", + // Should document that a method overrides method from private class. + "
        Overrides:
        \n" + + "
        " + + "methodOverridenFromParent in class " + + "" + + "PrivateParent
        ", + // Should document that a method is specified by private interface. + "
        Specified by:
        \n" + + "
        " + + "methodInterface in interface " + + "" + + "PrivateInterface
        ", + // Should mention that any documentation was copied. + "Description copied from", + // Extend documented private classes or interfaces + "extends", + "
        \n" + + "
        All Implemented Interfaces:
        \n" + + "
        " + + "PrivateInterface, " + + "" + + "PublicInterface
        \n" + + "
        ", + "
        public class PublicChild");
        +
        +        checkOutput("pkg/PublicInterface.html", true,
        +                // Field inheritence from non-public superinterface.
        +                "Fields inherited from interface pkg."
        +                + ""
        +                + "PrivateInterface",
        +                ""
        +                + "fieldInheritedFromInterface",
        +                // Method inheritance from non-public superinterface.
        +                "Methods inherited from interface pkg."
        +                + ""
        +                + "PrivateInterface",
        +                // Extend documented private classes or interfaces
        +                "extends",
        +                "All Superinterfaces",
        +                //Make sure implemented interfaces from private superclass are inherited
        +                "
        \n" + + "
        All Known Implementing Classes:
        \n" + + "
        " + + "PrivateParent, " + + "PublicChild" + + "
        \n" + + "
        "); + + checkOutput("pkg/PrivateInterface.html", true, + "" + + "methodInterface" + ); + + checkOutput("pkg2/C.html", true, + //Since private flag is used, we can document that private interface method + //with generic parameters has been implemented. + "Description copied from interface: " + + "I", + "
        Specified by:
        \n" + + "
        hello" + + " in interface " + + "I" + + "<java.lang.String>
        "); + + checkOutput("pkg/PrivateParent.html", true, + //Make sure when no modifier appear in the class signature, the + //signature is displayed correctly without extra space at the beginning. + "
        class PrivateParent");
        +
        +        checkOutput("pkg/PrivateParent.html", false,
        +                "
         class PrivateParent");
             }
         }
        diff --git a/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java b/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java
        index ff24deb6774..741f711f88c 100644
        --- a/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java
        +++ b/langtools/test/com/sun/javadoc/testProfiles/TestProfiles.java
        @@ -26,194 +26,174 @@
          * @bug      8006124 8009684 8016921 8023700 8024096 8008164 8026567 8026770
          * @summary  Test javadoc support for profiles.
          * @author   Bhavesh Patel, Evgeniya Stepanova
        - * @library  ../lib/
        - * @build    JavadocTester TestProfiles
        + * @library ../lib
        + * @build    JavadocTester
          * @run main TestProfiles
          */
         public class TestProfiles extends JavadocTester {
         
        -    //Test information.
        -    private static final String PROFILE_OUTPUT_DIR = OUTPUT_DIR + "-1";
        -    private static final String PACKAGE_OUTPUT_DIR = OUTPUT_DIR + "-2";
        -    //Javadoc arguments.
        -    private static final String[] ARGS1 = new String[]{
        -        "-d", PROFILE_OUTPUT_DIR, "-sourcepath", SRC_DIR, "-Xprofilespath",
        -         SRC_DIR + "/profile-rtjar-includes.txt", "pkg1", "pkg2",
        -         "pkg3", "pkg4", "pkg5", "pkgDeprecated"
        -    };
        -    private static final String[] ARGS2 = new String[]{
        -        "-d", PACKAGE_OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1", "pkg2",
        -        "pkg3", "pkg4", "pkg5"
        -    };
        -    //Input for string tests for profiles.
        -    private static final String[][] PROFILES_TEST = {
        +    public static void main(String... args) throws Exception {
        +        TestProfiles tester = new TestProfiles();
        +        tester.runTests();
        +    }
        +
        +    @Test
        +    void testProfiles() {
        +        javadoc("-d", "out-profiles",
        +                "-sourcepath", testSrc,
        +                "-Xprofilespath", testSrc("profile-rtjar-includes.txt"),
        +                "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated");
        +        checkExit(Exit.OK);
        +
                 // Tests for profile-overview-frame.html listing all profiles.
        -        { "profile-overview-frame.html",
        -            "All Packages"
        -        },
        -        { "profile-overview-frame.html",
        -            "
      • " - + "compact1
      • " - }, + checkOutput("profile-overview-frame.html", true, + "All Packages", + "
      • " + + "compact1
      • "); + // Tests for profileName-frame.html listing all packages in a profile. - { "compact2-frame.html", - "" - + "All PackagesAll Profiles" - }, - { "compact2-frame.html", - "
      • pkg4
      • " - }, + checkOutput("compact2-frame.html", true, + "" + + "All PackagesAll Profiles", + "
      • pkg4
      • "); + // Test for profileName-package-frame.html listing all types in a // package of a profile. - { "pkg2/compact2-package-frame.html", - "" - + "compact2 - pkg2" - }, + checkOutput("pkg2/compact2-package-frame.html", true, + "" + + "compact2 - pkg2"); + // Tests for profileName-summary.html listing the summary for a profile. - { "compact2-summary.html", - "
      • Prev Profile
      • \n" - + "
      • Next Profile
      • " - }, - { "compact2-summary.html", - "

        Profile compact2

        " - }, - { "compact2-summary.html", - "

        pkg2

        " - }, - { "compact2-summary.html", - "
          \n" + - "
        • \n" - + "

          " - + "pkg2

          \n" + - "" - }, - { "compact2-summary.html", - "
          " - }, + checkOutput("compact2-summary.html", true, + "
        • Prev Profile
        • \n" + + "
        • Next Profile
        • ", + "

          Profile compact2

          ", + "

          pkg2

          ", + "
          ", + "
          "); + + // Tests for profileName-package-summary.html listing the summary for a // package in a profile. - { "pkg5/compact3-package-summary.html", - "
        • Prev Package" - + "
        • " - }, - { "pkg5/compact3-package-summary.html", - "
          compact3
          " - }, - { "pkg5/compact3-package-summary.html", - "
            \n" + - "
          • \n" - + "
          " - }, - //Test for "overview-frame.html" showing the "All Profiles" link. - { "overview-frame.html", - "All Profiles" - }, - //Test for "className.html" showing the profile information for the type. - { "pkg2/Class1Pkg2.html", - "
          compact1, compact2, compact3
          " - }, - { "index.html", - "" - }, - //Test for "overview-summary.html" showing the profile list. - { "overview-summary.html", - "" - }, - //Test deprecated class in profiles - { "compact1-summary.html", - "\n" - + "
          Class1Pkg2Deprecated" - }, - { "deprecated-list.html", - "pkg2.Class1Pkg2\n" - +"
          Class1Pkg2. This class is deprecated
          " - }, + checkOutput("pkg5/compact3-package-summary.html", true, + "
        • Prev Package" + + "
        • ", + "
          compact3
          ", + "
            \n" + + "
          • \n" + + ""); + + // Test for "overview-frame.html" showing the "All Profiles" link. + checkOutput("overview-frame.html", true, + "All Profiles"); + + // Test for "className.html" showing the profile information for the type. + checkOutput("pkg2/Class1Pkg2.html", true, + "
            compact1, compact2, compact3
            "); + + checkOutput("index.html", true, + ""); + + // Test for "overview-summary.html" showing the profile list. + checkOutput("overview-summary.html", true, + ""); + + // Test deprecated class in profiles + checkOutput("compact1-summary.html", true, + "\n" + + "
            Class1Pkg2Deprecated"); + + checkOutput("deprecated-list.html", true, + "pkg2.Class1Pkg2\n" + + "
            Class1Pkg2. This class is deprecated
            "); + //Test deprecated package in profile - { "deprecated-list.html", - "
            pkgDeprecated\n" - +"
            This package is Deprecated." - + " Use pkg1.
            " - }, - { "pkgDeprecated/package-summary.html", - "
            Deprecated.\n" - + "
            This package is Deprecated." - + " Use pkg1.
            " - }, - // need to add teststring when JDK-8015496 will be fixed - //Test exception in profiles - { "compact1-summary.html", - "\n" - + "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" - + "" - }, + checkOutput("deprecated-list.html", true, + "
            Exception Summary" - + " 
            Exception" - + "Description
            ClassExceptionpkgDeprecated\n" + + "
            This package is Deprecated." + + " Use pkg1.
            "); + + checkOutput("pkgDeprecated/package-summary.html", true, + "
            Deprecated.\n" + + "
            This package is Deprecated." + + " Use pkg1.
            "); + + // TODO: need to add teststring when JDK-8015496 will be fixed + // Test exception in profiles + checkOutput("compact1-summary.html", true, + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""); + //Test errors in profiles - { "compact1-summary.html", - "
            Exception Summary" + + " 
            Exception" + + "Description
            ClassException
            \n" - + "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" - + "\n" + - "" - } - }; - private static final String[][] PROFILES_NEGATED_TEST = { - { "pkg3/Class2Pkg3.html", - "
            compact1" - }, - { "pkg3/Interface1Pkg3.html", - "
            compact1" - }, - { "pkg4/compact2-package-frame.html", + checkOutput("compact1-summary.html", true, + "
            Error Summary " - + "
            ErrorDescription
            " - + "ClassError
            \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + ""); + + // negative tests + checkOutput("pkg3/Class2Pkg3.html", false, + "
            compact1"); + + checkOutput("pkg3/Interface1Pkg3.html", false, + "
            compact1"); + + checkOutput("pkg4/compact2-package-frame.html", false, "
          • Anno1Pkg4
          • " - }, - { "compact1-summary.html","
          • Use
          • " - }, - { "compact2-summary.html", + + "target=\"classFrame\">Anno1Pkg4"); + + checkOutput("compact1-summary.html", false, + "
          • Use
          • "); + + checkOutput("compact2-summary.html", false, "
            Error Summary " + + "
            ErrorDescription
            " + + "ClassError
            " - }, - { "pkg5/compact3-package-summary.html", + + "listing classes, and an explanation\">"); + + checkOutput("pkg5/compact3-package-summary.html", false, "
              \n" + "
            • \n" + "
            • \n" + "
            " - } - }; - private static final String[][] PACKAGES_TEST = { - { "overview-frame.html", - "

            Packages

            " - }, - { "pkg4/package-frame.html", - "

            pkg4

            " - }, - { "pkg4/package-summary.html", - "
            \n" + - "

            Package pkg4

            \n" + - "
            " - } - }; - private static final String[][] PACKAGES_NEGATED_TEST = { - { "overview-frame.html", - "All Profiles" - }, - { "pkg2/Class1Pkg2.html", - "
            compact1, compact2, compact3
            " - }, - { "overview-summary.html", - "" - } - }; - private static final String[] PACKAGES_NEGATED_FILE_TEST = { - "profile-overview-frame.html", - "compact2-frame.html", - "pkg2/compact2-package-frame.html", - "compact2-summary.html", - "pkg5/compact3-package-summary.html" - }; + + "interfaces, and an explanation\">"); + } - /** - * The entry point of the test. - * - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestProfiles tester = new TestProfiles(); - tester.run(ARGS1, PROFILES_TEST, PROFILES_NEGATED_TEST); - tester.run(ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST, NO_FILE_TEST, PACKAGES_NEGATED_FILE_TEST); - tester.printSummary(); + @Test + void testPackages() { + javadoc("-d", "out-packages", + "-sourcepath", testSrc, + "pkg1", "pkg2", "pkg3", "pkg4", "pkg5"); + checkExit(Exit.OK); + + checkOutput("overview-frame.html", true, + "

            Packages

            "); + + checkOutput("pkg4/package-frame.html", true, + "

            pkg4

            "); + + checkOutput("pkg4/package-summary.html", true, + "
            \n" + + "

            Package pkg4

            \n" + + "
            "); + + checkOutput("overview-frame.html", false, + "All Profiles"); + + checkOutput("pkg2/Class1Pkg2.html", false, + "
            compact1, compact2, compact3
            "); + + checkOutput("overview-summary.html", false, + ""); + + checkFiles(false, + "profile-overview-frame.html", + "compact2-frame.html", + "pkg2/compact2-package-frame.html", + "compact2-summary.html", + "pkg5/compact3-package-summary.html"); } } diff --git a/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java b/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java index 965b8e149c4..d4c2fd80b41 100644 --- a/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java +++ b/langtools/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java @@ -26,97 +26,98 @@ * @bug 8006124 8009684 8015663 8015496 8026567 * @summary Test javadoc options support for profiles. * @author Evgeniya Stepanova - * @library ../lib/ - * @build JavadocTester TestProfilesConfiguration + * @library ../lib + * @build JavadocTester * @run main TestProfilesConfiguration */ public class TestProfilesConfiguration extends JavadocTester { - //Test information. - private static final String PROFILE_CONFIGURATION_OUTPUT_DIR = OUTPUT_DIR + "-3"; - private static final String NODEPR_NOPKGS_OUTPUT_DIR = OUTPUT_DIR + "-4"; - //Javadoc arguments. - private static final String[] ARGS3 = new String[]{ - "-d", PROFILE_CONFIGURATION_OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-nocomment", "-keywords", "-Xprofilespath", SRC_DIR + - "/profile-rtjar-includes.txt", "-doctitle", "Simple doctitle", - "-use", "pkg3", "pkg1", "pkg2", "pkg4", - "pkg5", "-packagesheader", "Simple packages header","pkgDeprecated" - }; - private static final String[] ARGS4 = new String[]{ - "-d", NODEPR_NOPKGS_OUTPUT_DIR, "-sourcepath", SRC_DIR, "-nocomment", - "-nodeprecated", "-keywords", "-Xprofilespath", SRC_DIR + - "/profile-rtjar-includes-nopkgs.txt", "-doctitle", "Simple doctitle", - "-use", "-packagesheader", "Simple packages header", - "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated" - }; - private static final String[][] NODEPR_NOPKGS_TEST = { - { "overview-summary.html", - "" - }, - { "profile-overview-frame.html", - "" - } - }; - private static final String[][] NODEPR_NOPKGS_NEGATED_TEST = { - { "overview-summary.html", - "compact1" - } - }; - - private static final String[][] PROFILES_CONFIGURATION_TEST = { - //-use option test string fo profile view page - { "compact1-summary.html","
          • Use
          • " - }, - //-doctitle option test string - { "overview-summary.html", - "
            \n" + - "

            Simple doctitle

            " - }, - //-packagesheader option test string fo profiles - { "profile-overview-frame.html", - "

            Simple packages header

            " - }, - //-keywords option test string for profiles - { "compact1-summary.html", - "" - }, - //Deprecated information on a package - { "compact1-summary.html", - "

            pkgDeprecated

            \n" + - "
            " + - "Deprecated.
            " - } - }; - private static final String[][] PROFILES_CONFIGURATION_NEGATED_TEST = { - //-nocomments option test string - { "compact1-summary.html", - "
            Class1Pkg2.
            " - } - }; - - /** - * The entry point of the test. - * - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestProfilesConfiguration tester = new TestProfilesConfiguration(); - tester.run(ARGS3, PROFILES_CONFIGURATION_TEST, - PROFILES_CONFIGURATION_NEGATED_TEST); - tester.run(ARGS4, NODEPR_NOPKGS_TEST, - NODEPR_NOPKGS_NEGATED_TEST); - tester.printSummary(); + tester.runTests(); +// tester.run(ARGS3, PROFILES_CONFIGURATION_TEST, PROFILES_CONFIGURATION_NEGATED_TEST); +// tester.run(ARGS4, NODEPR_NOPKGS_TEST, NODEPR_NOPKGS_NEGATED_TEST); +// tester.printSummary(); + } + + @Test + void testProfiles() { + javadoc("-d", "out-profiles", + "-sourcepath", testSrc, + "-nocomment", + "-keywords", + "-Xprofilespath", testSrc("profile-rtjar-includes.txt"), + "-doctitle", "Simple doctitle", + "-use", + "-packagesheader", "Simple packages header", + "pkg3", "pkg1", "pkg2", "pkg4", "pkg5", "pkgDeprecated"); + checkExit(Exit.OK); + + checkOutput("compact1-summary.html", true, + //-use option test string fo profile view page + "
          • Use
          • ", + // -keywords option test string for profiles + "", + // Deprecated information on a package + "

            pkgDeprecated

            \n" + + "
            " + + "Deprecated.
            " + ); + + //-nocomments option test string + checkOutput("compact1-summary.html", false, + "
            Class1Pkg2.
            " + ); + + // -doctitle option test string + checkOutput("overview-summary.html", true, + "
            \n" + + "

            Simple doctitle

            " + ); + + // -packagesheader option test string fo profiles + checkOutput("profile-overview-frame.html", true, + "

            Simple packages header

            " + ); + } + + + @Test + void testNoDeprNoPackages() { + javadoc("-d", "out-noDeprNoPackages", + "-sourcepath", testSrc, + "-nocomment", + "-nodeprecated", + "-keywords", + "-Xprofilespath", testSrc("profile-rtjar-includes-nopkgs.txt"), + "-doctitle", "Simple doctitle", + "-use", + "-packagesheader", "Simple packages header", + "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", true, + "" + ); + + checkOutput("profile-overview-frame.html", true, + "" + ); + + checkOutput("overview-summary.html", false, + "compact1" + ); + } } diff --git a/langtools/test/com/sun/javadoc/testRecurseSubPackages/TestRecurseSubPackages.java b/langtools/test/com/sun/javadoc/testRecurseSubPackages/TestRecurseSubPackages.java index d1957358a83..615c64bba6e 100644 --- a/langtools/test/com/sun/javadoc/testRecurseSubPackages/TestRecurseSubPackages.java +++ b/langtools/test/com/sun/javadoc/testRecurseSubPackages/TestRecurseSubPackages.java @@ -26,35 +26,33 @@ * @bug 4074234 * @summary Make Javadoc capable of traversing/recursing all of given subpackages. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestRecurseSubPackages * @run main TestRecurseSubPackages */ public class TestRecurseSubPackages extends JavadocTester { - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-subpackages", "pkg1", "-exclude", "pkg1.pkg2.packageToExclude" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - String[][] tests = new String[6][2]; - for (int i = 0; i < tests.length; i++) { - tests[i][0] = "allclasses-frame.html"; - tests[i][1] = "C" + (i+1) + ".html"; - } - String[][] negatedTests = new String[][] { - { "allclasses-frame.html", "DummyClass.html"} - }; + public static void main(String... args) throws Exception { TestRecurseSubPackages tester = new TestRecurseSubPackages(); - tester.run(ARGS, tests, negatedTests); - tester.printSummary(); + tester.runTests(); } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-subpackages", "pkg1", + "-exclude", "pkg1.pkg2.packageToExclude"); + checkExit(Exit.OK); + + for (int i = 1; i <= 6; i++) { + checkOutput("allclasses-frame.html", true, + "C" + i + ".html"); + } + + checkOutput("allclasses-frame.html", false, + "DummyClass.html"); + } + } diff --git a/langtools/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java b/langtools/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java index d4bd107c1a5..8d53c8dc014 100644 --- a/langtools/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java +++ b/langtools/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java @@ -27,81 +27,64 @@ * @summary Test to make sure that relative paths are redirected in the * output so that they are not broken. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestRelativeLinks * @run main TestRelativeLinks */ public class TestRelativeLinks extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-use", "-sourcepath", SRC_DIR, "pkg", "pkg2" - }; - - //Input for string search tests. - private static final String[][] TEST = { - //These relative paths should stay relative because they appear - //in the right places. - { "pkg/C.html", - "relative class link"}, - { "pkg/C.html", - "relative field link"}, - { "pkg/C.html", - "relative method link"}, - { "pkg/package-summary.html", - "relative package link"}, - { "pkg/C.html", - " relative-multi-line-link."}, - - //These relative paths should be redirected because they are in different - //places. - - //INDEX PAGE - { "index-all.html", - "relative class link"}, - { "index-all.html", - "relative field link"}, - { "index-all.html", - "relative method link"}, - { "index-all.html", - "relative package link"}, - { "index-all.html", - " relative-multi-line-link."}, - - - //PACKAGE USE - { "pkg/package-use.html", - "relative package link."}, - { "pkg/package-use.html", - "relative class link"}, - - //CLASS_USE - { "pkg/class-use/C.html", - "relative field link"}, - { "pkg/class-use/C.html", - "relative method link"}, - { "pkg/class-use/C.html", - "relative package link"}, - { "pkg/class-use/C.html", - " relative-multi-line-link."}, - - //PACKAGE OVERVIEW - { "overview-summary.html", - "relative package link"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestRelativeLinks tester = new TestRelativeLinks(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-use", + "-sourcepath", testSrc, + "pkg", "pkg2"); + checkExit(Exit.OK); + + // These relative paths should stay relative because they appear + // in the right places. + checkOutput("pkg/C.html", true, + "relative class link", + "relative field link", + "relative method link", + " relative-multi-line-link."); + checkOutput("pkg/package-summary.html", true, + "relative package link"); + + // These relative paths should be redirected because they are in different + // places. + + // INDEX PAGE + checkOutput("index-all.html", true, + "relative class link", + "relative field link", + "relative method link", + "relative package link", + " relative-multi-line-link."); + + // PACKAGE USE + checkOutput("pkg/package-use.html", true, + "relative package link.", + "relative class link"); + + // CLASS_USE + checkOutput("pkg/class-use/C.html", true, + "relative field link", + "relative method link", + "relative package link", + " relative-multi-line-link."); + + // PACKAGE OVERVIEW + checkOutput("overview-summary.html", true, + "relative package link"); } } diff --git a/langtools/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java b/langtools/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java index 661e1f75f5b..22370f6e14b 100644 --- a/langtools/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java +++ b/langtools/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java @@ -26,147 +26,125 @@ * @bug 8005092 * @summary Test repeated annotations output. * @author bpatel - * @library ../lib/ - * @build JavadocTester TestRepeatedAnnotations + * @library ../lib + * @build JavadocTester * @run main TestRepeatedAnnotations */ public class TestRepeatedAnnotations extends JavadocTester { - //Test information. - - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", "pkg1" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/C.html", - "@ContaineeSynthDoc " + - "@ContaineeSynthDoc"}, - { "pkg/C.html", - "@ContaineeRegDoc " + - "@ContaineeRegDoc"}, - { "pkg/C.html", - "@RegContainerDoc" + - "(value={" + - "@RegContaineeNotDoc," + - "@RegContaineeNotDoc})"}, - { "pkg/C.html", - "@ContaineeSynthDoc " + - "@ContaineeSynthDoc " + - "@ContaineeSynthDoc"}, - { "pkg/C.html", - "@ContainerSynthDoc(" + - "value=" + - "@ContaineeSynthDoc)"}, - { "pkg/C.html", - "@ContaineeSynthDoc " + - "@ContaineeSynthDoc"}, - - { "pkg/D.html", - "@RegDoc" + - "(x=1)"}, - { "pkg/D.html", - "@RegArryDoc" + - "(y=1)"}, - { "pkg/D.html", - "@RegArryDoc" + - "(y={1,2})"}, - { "pkg/D.html", - "@NonSynthDocContainer" + - "(value=" + - "@RegArryDoc)"}, - - { "pkg1/C.html", - "@RegContainerValDoc" + - "(value={" + - "@RegContaineeNotDoc," + - "@RegContaineeNotDoc}," + - "y=3)"}, - { "pkg1/C.html", - "@ContainerValDoc" + - "(value={" + - "@ContaineeNotDoc," + - "@ContaineeNotDoc}," + - "x=1)"} - }; - - private static final String[][] NEGATED_TEST = { - { "pkg/C.html", - "@RegContaineeDoc " + - "@RegContaineeDoc"}, - { "pkg/C.html", - "@RegContainerNotDoc" + - "(value={" + - "@RegContaineeNotDoc," + - "@RegContaineeNotDoc})"}, - - { "pkg1/C.html", - "@ContaineeSynthDoc " + - "@ContaineeSynthDoc"}, - { "pkg1/C.html", - "@RegContainerValNotDoc" + - "(value={" + - "@RegContaineeDoc," + - "@RegContaineeDoc}," + - "y=4)"}, - { "pkg1/C.html", - "@ContainerValNotDoc" + - "(value={" + - "@ContaineeNotDoc," + - "@ContaineeNotDoc}," + - "x=2)"}, - { "pkg1/C.html", - "@ContainerSynthNotDoc(" + - "value=" + - "@ContaineeSynthDoc)"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestRepeatedAnnotations tester = new TestRepeatedAnnotations(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg", "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg/C.html", true, + "@ContaineeSynthDoc " + + "@ContaineeSynthDoc", + "@ContaineeRegDoc " + + "@ContaineeRegDoc", + "@RegContainerDoc" + + "(value={" + + "@RegContaineeNotDoc," + + "@RegContaineeNotDoc})", + "@ContaineeSynthDoc " + + "@ContaineeSynthDoc " + + "@ContaineeSynthDoc", + "@ContainerSynthDoc(" + + "value=" + + "@ContaineeSynthDoc)", + "@ContaineeSynthDoc " + + "@ContaineeSynthDoc"); + + checkOutput("pkg/D.html", true, + "@RegDoc" + + "(x=1)", + "@RegArryDoc" + + "(y=1)", + "@RegArryDoc" + + "(y={1,2})", + "@NonSynthDocContainer" + + "(value=" + + "@RegArryDoc)"); + + checkOutput("pkg1/C.html", true, + "@RegContainerValDoc" + + "(value={" + + "@RegContaineeNotDoc," + + "@RegContaineeNotDoc}," + + "y=3)", + "@ContainerValDoc" + + "(value={" + + "@ContaineeNotDoc," + + "@ContaineeNotDoc}," + + "x=1)"); + + checkOutput("pkg/C.html", false, + "@RegContaineeDoc " + + "@RegContaineeDoc", + "@RegContainerNotDoc" + + "(value={" + + "@RegContaineeNotDoc," + + "@RegContaineeNotDoc})"); + + checkOutput("pkg1/C.html", false, + "@ContaineeSynthDoc " + + "@ContaineeSynthDoc", + "@RegContainerValNotDoc" + + "(value={" + + "@RegContaineeDoc," + + "@RegContaineeDoc}," + + "y=4)", + "@ContainerValNotDoc" + + "(value={" + + "@ContaineeNotDoc," + + "@ContaineeNotDoc}," + + "x=2)", + "@ContainerSynthNotDoc(" + + "value=" + + "@ContaineeSynthDoc)"); } } diff --git a/langtools/test/com/sun/javadoc/testReturnTag/TestReturnTag.java b/langtools/test/com/sun/javadoc/testReturnTag/TestReturnTag.java index cef982bbba0..35278f60e69 100644 --- a/langtools/test/com/sun/javadoc/testReturnTag/TestReturnTag.java +++ b/langtools/test/com/sun/javadoc/testReturnTag/TestReturnTag.java @@ -26,26 +26,13 @@ * @bug 4490068 * @summary Warn when a return tag is used on a method without a return type. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestReturnTag * @run main TestReturnTag */ public class TestReturnTag extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, SRC_DIR + - "/TestReturnTag.java" - }; - - //Input for string search tests. - private static final String[][] TEST = { - {WARNING_OUTPUT, - "warning - @return tag cannot be used in method with void return type."} - }; - /** * Trigger warning message when return tag is used on a void method. * @@ -53,13 +40,20 @@ public class TestReturnTag extends JavadocTester { */ public void method() {} - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestReturnTag tester = new TestReturnTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void tests() { + javadoc("-Xdoclint:none", + "-d", "out", + "-sourcepath", testSrc, + testSrc("TestReturnTag.java")); + checkExit(Exit.OK); + + checkOutput(Output.WARNING, true, + "warning - @return tag cannot be used in method with void return type."); } } diff --git a/langtools/test/com/sun/javadoc/testSeeTag/TestSeeTag.java b/langtools/test/com/sun/javadoc/testSeeTag/TestSeeTag.java index cf5b3ef8b76..8ce6945de84 100644 --- a/langtools/test/com/sun/javadoc/testSeeTag/TestSeeTag.java +++ b/langtools/test/com/sun/javadoc/testSeeTag/TestSeeTag.java @@ -26,37 +26,29 @@ * @bug 8017191 * @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages * @author jjg - * @library ../lib/ - * @build JavadocTester TestSeeTag + * @library ../lib + * @build JavadocTester * @run main TestSeeTag */ public class TestSeeTag extends JavadocTester { - //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/Test.html", - "List" - } - }; - private static final String[][] NEGATED_TEST = { - { "pkg/Test.html", - "<code>List</code>" - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSeeTag tester = new TestSeeTag(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/Test.html", true, + "List"); + + checkOutput("pkg/Test.html", false, + "<code>List</code>"); } } diff --git a/langtools/test/com/sun/javadoc/testSerialVersionUID/TestSerialVersionUID.java b/langtools/test/com/sun/javadoc/testSerialVersionUID/TestSerialVersionUID.java index abffdc97069..23bbdf6c1e7 100644 --- a/langtools/test/com/sun/javadoc/testSerialVersionUID/TestSerialVersionUID.java +++ b/langtools/test/com/sun/javadoc/testSerialVersionUID/TestSerialVersionUID.java @@ -27,32 +27,25 @@ * @summary Test to make sure that the serialVersionUID is properly * documented in the serialized form. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSerialVersionUID * @run main TestSerialVersionUID */ public class TestSerialVersionUID extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, - SRC_DIR + "/C.java" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "serialized-form.html", "-111111111111111L"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSerialVersionUID tester = new TestSerialVersionUID(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("serialized-form.html", true, + "-111111111111111L"); } } diff --git a/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java b/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java index 6108f9141b1..209f7d73a4c 100644 --- a/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java +++ b/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java @@ -38,85 +38,76 @@ * @run main TestSerializedForm */ -import java.lang.*; import java.io.*; public class TestSerializedForm extends JavadocTester implements Serializable { + public static void main(String... args) throws Exception { + TestSerializedForm tester = new TestSerializedForm(); + tester.runTests(); +// tester.run(ARGS, TEST, NEGATED_TEST); +// tester.run(ARGS_PRIVATE, TEST_PRIVATE, NEGATED_TEST_PRIVATE); +// tester.printSummary(); + } - private static final String[][] TEST = { - { "serialized-form.html", - "protected java.lang.Object readResolve()"}, - { "serialized-form.html", - "protected java.lang.Object writeReplace()"}, - { "serialized-form.html", - "protected java.lang.Object readObjectNoData()"}, - { "serialized-form.html", - "See Also"}, - { "serialized-form.html", - "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + - "extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends " + - "java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.ProtectedInnerClass.ProInnerClass extends " + - "java.lang.Object implements Serializable

            "} - }; + @Test + void testDefault() { + javadoc("-d", "out-default", + "-sourcepath", testSrc, + testSrc("TestSerializedForm.java"), "pkg1"); + checkExit(Exit.OK); - private static final String[][] TEST_PRIVATE = { - { "serialized-form.html", - "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + - "extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class " + - "pkg1.PrivateIncludeInnerClass.PriInnerClass extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class " + - "pkg1.ProtectedInnerClass.ProInnerClass extends java.lang.Object implements Serializable

            "} - }; + checkOutput("serialized-form.html", true, + "protected java.lang.Object readResolve()", + "protected java.lang.Object writeReplace()", + "protected java.lang.Object readObjectNoData()", + "See Also", + "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + + "extends java.lang.Object implements Serializable

            ", + "

            Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends " + + "java.lang.Object implements Serializable

            ", + "

            Class pkg1.ProtectedInnerClass.ProInnerClass extends " + + "java.lang.Object implements Serializable

            "); - private static final String[][] NEGATED_TEST = { - { "serialized-form.html", - "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + - "extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class " + - "pkg1.PrivateInnerClass.PriInnerClass extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class " + - "pkg1.ProtectedInnerClass.ProInnerClass extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements " + - "Serializable

            "} - }; + checkOutput("serialized-form.html", false, + "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + + "extends java.lang.Object implements Serializable

            ", + "

            Class " + + "pkg1.PrivateInnerClass.PriInnerClass extends java.lang.Object implements Serializable

            ", + "

            Class " + + "pkg1.ProtectedInnerClass.ProInnerClass extends java.lang.Object implements Serializable

            ", + "

            Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements " + + "Serializable

            "); + } - private static final String[][] NEGATED_TEST_PRIVATE = { - { "serialized-form.html", - "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + - "extends java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.PrivateInnerClass.PriInnerClass extends " + - "java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.ProtectedInnerClass.ProInnerClass extends " + - "java.lang.Object implements Serializable

            "}, - { "serialized-form.html", - "

            Class pkg1.PublicExcludeInnerClass.PubInnerClass " + - "extends java.lang.Object implements Serializable

            "} - }; + @Test + void testPrivate() { + javadoc("-private", + "-d", "out-private", + "-sourcepath", testSrc, + testSrc("TestSerializedForm.java"), "pkg1"); + checkExit(Exit.OK); - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - SRC_DIR + "/TestSerializedForm.java", "pkg1" - }; + checkOutput("serialized-form.html", true, + "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + + "extends java.lang.Object implements Serializable

            ", + "

            Class " + + "pkg1.PrivateIncludeInnerClass.PriInnerClass extends java.lang.Object implements Serializable

            ", + "

            Class " + + "pkg1.ProtectedInnerClass.ProInnerClass extends java.lang.Object implements Serializable

            "); - private static final String[] ARGS_PRIVATE = new String[] { - "-private", "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, - SRC_DIR + "/TestSerializedForm.java", "pkg1" - }; + checkOutput("serialized-form.html", false, + "

            Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " + + "extends java.lang.Object implements Serializable

            ", + "

            Class pkg1.PrivateInnerClass.PriInnerClass extends " + + "java.lang.Object implements Serializable

            ", + "

            Class pkg1.ProtectedInnerClass.ProInnerClass extends " + + "java.lang.Object implements Serializable

            ", + "

            Class pkg1.PublicExcludeInnerClass.PubInnerClass " + + "extends java.lang.Object implements Serializable

            "); + } /** * @serial @@ -128,12 +119,6 @@ public class TestSerializedForm extends JavadocTester implements Serializable { * The entry point of the test. * @param args the array of command line arguments. */ - public static void main(String[] args) { - TestSerializedForm tester = new TestSerializedForm(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.run(ARGS_PRIVATE, TEST_PRIVATE, NEGATED_TEST_PRIVATE); - tester.printSummary(); - } /** * @param s ObjectInputStream. diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java index 20e28da635e..67893c46650 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java @@ -28,118 +28,142 @@ * @bug 6802694 8025633 8026567 * @summary This test verifies deprecation info in serialized-form.html. * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSerializedFormDeprecationInfo * @run main TestSerializedFormDeprecationInfo */ public class TestSerializedFormDeprecationInfo extends JavadocTester { + public static void main(String... args) throws Exception { + TestSerializedFormDeprecationInfo tester = new TestSerializedFormDeprecationInfo(); + tester.runTests(); + } + + @Test + void testDefault() { + javadoc("-d", "out-default", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.FAILED); // TODO: should be OK + + checkCommentDeprecated(true); + checkNoComment(false); + } + + @Test + void testNoComment() { + javadoc("-d", "out-nocmnt", + "-nocomment", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.FAILED); // TODO: should be OK + + checkNoComment(true); + checkCommentDeprecated(false); + } + + @Test + void testNoDeprecated() { + javadoc("-d", "out-nodepr", + "-nodeprecated", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.FAILED); // TODO: should be OK + + checkNoDeprecated(true); + checkNoCommentNoDeprecated(false); + } + + @Test + void testNoCommentNoDeprecated() { + javadoc("-d", "out-nocmnt-nodepr", + "-nocomment", + "-nodeprecated", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.FAILED); // TODO: should be OK + checkNoCommentNoDeprecated(true); + checkNoDeprecated(false); + } + // Test for normal run of javadoc. The serialized-form.html should // display the inline comments, tags and deprecation information if any. - private static final String[][] TEST_CMNT_DEPR = { - { "serialized-form.html", "
            \n" + - "
            Throws:
            \n" + - "
            " + - "java.io.IOException
            \n" + - "
            See Also:" + - "
            \n" + - "
            " + - "C1.setUndecorated(boolean)
            \n" + - "
            "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).
            \n" + - "
            This field indicates whether the C1 " + - "is undecorated.
            \n" + - " \n" + - "
            \n" + - "
            Since:
            \n" + - "
            1.4
            \n" + - "
            See Also:" + - "
            \n" + - "
            " + - "C1.setUndecorated(boolean)
            \n" + - "
            "}, - { "serialized-form.html", - "Deprecated." + - " As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).
            \n" + - "
            Reads the object stream.
            \n" + - "
            \n" + - "
            Throws:
            \n" + - "
            " + - "IOException
            \n" + - "
            java.io.IOException
            \n" + - "
            "}, - { "serialized-form.html", - "Deprecated." + - " \n" + - "
            " + - "The name for this class.
            "}}; + void checkCommentDeprecated(boolean expectFound) { + checkOutput("serialized-form.html", expectFound, + "
            \n" + + "
            Throws:
            \n" + + "
            " + + "java.io.IOException
            \n" + + "
            See Also:" + + "
            \n" + + "
            " + + "C1.setUndecorated(boolean)
            \n" + + "
            ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
            This field indicates whether the C1 " + + "is undecorated.
            \n" + + " \n" + + "
            \n" + + "
            Since:
            \n" + + "
            1.4
            \n" + + "
            See Also:" + + "
            \n" + + "
            " + + "C1.setUndecorated(boolean)
            \n" + + "
            ", + "Deprecated." + + " As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + "
            Reads the object stream.
            \n" + + "
            \n" + + "
            Throws:
            \n" + + "
            " + + "IOException
            \n" + + "
            java.io.IOException
            \n" + + "
            ", + "Deprecated." + + " \n" + + "
            " + + "The name for this class.
            "); + } // Test with -nocomment option. The serialized-form.html should // not display the inline comments and tags but should display deprecation // information if any. - private static final String[][] TEST_NOCMNT = { - { "serialized-form.html", - "
            boolean undecorated
            \n" + - "
            Deprecated. " + - "As of JDK version 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).
            \n" + - ""}, - { "serialized-form.html", - "" + - "Deprecated. As of JDK version" + - " 1.5, replaced by\n" + - " " + - "setUndecorated(boolean).\n" + - ""}}; + void checkNoComment(boolean expectFound) { + checkOutput("serialized-form.html", expectFound, + "
            boolean undecorated
            \n" + + "
            Deprecated. " + + "As of JDK version 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).
            \n" + + "", + "" + + "Deprecated. As of JDK version" + + " 1.5, replaced by\n" + + " " + + "setUndecorated(boolean).\n" + + ""); + } // Test with -nodeprecated option. The serialized-form.html should // ignore the -nodeprecated tag and display the deprecation info. This // test is similar to the normal run of javadoc in which inline comment, tags // and deprecation information will be displayed. - private static final String[][] TEST_NODEPR = TEST_CMNT_DEPR; + void checkNoDeprecated(boolean expectFound) { + checkCommentDeprecated(expectFound); + } // Test with -nodeprecated and -nocomment options. The serialized-form.html should // ignore the -nodeprecated tag and display the deprecation info but should not // display the inline comments and tags. This test is similar to the test with // -nocomment option. - private static final String[][] TEST_NOCMNT_NODEPR = TEST_NOCMNT; - - 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", "-nocomment", "-sourcepath", SRC_DIR, "pkg1"}; - - private static final String[] ARGS3 = - new String[] { - "-d", OUTPUT_DIR + "-3", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"}; - - private static final String[] ARGS4 = - new String[] { - "-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) { - TestSerializedFormDeprecationInfo tester = new TestSerializedFormDeprecationInfo(); - tester.run(ARGS1, TEST_CMNT_DEPR, TEST_NOCMNT); - tester.run(ARGS2, TEST_NOCMNT, TEST_CMNT_DEPR); - tester.run(ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR); - tester.run(ARGS4, TEST_NOCMNT_NODEPR, TEST_NODEPR); - tester.printSummary(); + void checkNoCommentNoDeprecated(boolean expectFound) { + checkNoComment(expectFound); } } diff --git a/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java b/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java index 4cabbf4d5b7..f9169cef77b 100644 --- a/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java +++ b/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java @@ -24,47 +24,38 @@ /* * @test * @bug 4695326 4750173 4920381 8026567 - * @summary Test the declarartion of simple tags using -tag. Verify that + * @summary Test the declaration of simple tags using -tag. Verify that * "-tag name" is a shortcut for "-tag name:a:Name:". Also verity that * you can escape the ":" character with a back slash so that it is not * considered a separator when parsing the simple tag argument. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSimpleTag * @run main TestSimpleTag */ public class TestSimpleTag extends JavadocTester { - private static final String[][] TEST = - new String[][] { - { "C.html", - "Todo:"}, - { "C.html", - "EJB Beans:"}, - { "C.html", - "Regular Tag:"}, - { "C.html", - "Back-Slash-Tag:"}, - }; - - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-tag", "todo", - "-tag", "ejb\\:bean:a:EJB Beans:", - "-tag", "regular:a:Regular Tag:", - "-tag", "back-slash\\:tag\\\\:a:Back-Slash-Tag:", - SRC_DIR + "/C.java" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSimpleTag tester = new TestSimpleTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-tag", "todo", + "-tag", "ejb\\:bean:a:EJB Beans:", + "-tag", "regular:a:Regular Tag:", + "-tag", "back-slash\\:tag\\\\:a:Back-Slash-Tag:", + testSrc("C.java")); + checkExit(Exit.FAILED); // TODO: investigate why failed + + checkOutput("C.html", true, + "Todo:", + "EJB Beans:", + "Regular Tag:", + "Back-Slash-Tag:"); } } diff --git a/langtools/test/com/sun/javadoc/testSimpleTagExclude/TestSimpleTagExclude.java b/langtools/test/com/sun/javadoc/testSimpleTagExclude/TestSimpleTagExclude.java index d914b0ddc2f..9064ec09151 100644 --- a/langtools/test/com/sun/javadoc/testSimpleTagExclude/TestSimpleTagExclude.java +++ b/langtools/test/com/sun/javadoc/testSimpleTagExclude/TestSimpleTagExclude.java @@ -27,31 +27,27 @@ * @summary Test the parsing of the -tag option. The user should be able to * exclude a simple tag by using -tag tagname:X * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSimpleTagExclude * @run main TestSimpleTagExclude */ public class TestSimpleTagExclude extends JavadocTester { - private static final String[][] NEGATED_TEST = { - { "DummyClass.html", "todo"} - }; - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-tag", "todo:X", - SRC_DIR + "/DummyClass.java" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSimpleTagExclude tester = new TestSimpleTagExclude(); - if (tester.run(ARGS, NO_TEST, NEGATED_TEST) != 0) { - throw new Error("Javadoc failed to execute."); - } - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-tag", "todo:X", + testSrc("DummyClass.java")); + checkExit(Exit.OK); + + checkOutput("DummyClass.html", false, + "todo"); } } diff --git a/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java b/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java index 76087015065..011533fa379 100644 --- a/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java +++ b/langtools/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java @@ -25,8 +25,8 @@ * @test * @bug 8008768 8026567 * @summary Using {@inheritDoc} in simple tag defined via -tag fails - * @library ../lib/ - * @build JavadocTester TestSimpleTagInherit + * @library ../lib + * @build JavadocTester * @run main TestSimpleTagInherit */ @@ -34,28 +34,31 @@ public class TestSimpleTagInherit extends JavadocTester { //Javadoc arguments. private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - "-tag", "custom:optcm:Custom:", - "p" + }; //Input for string search tests. private static final String[][] TEST = { - { "p/TestClass.html", - "
            Custom:
            \n" + - "
            doc for BaseClass class
            " }, - { "p/TestClass.html", - "
            Custom:
            \n" + - "
            doc for BaseClass method
            " } + { } }; - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSimpleTagInherit tester = new TestSimpleTagInherit(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-tag", "custom:optcm:Custom:", + "p"); + checkExit(Exit.OK); + + checkOutput("p/TestClass.html", true, + "
            Custom:
            \n" + + "
            doc for BaseClass class
            ", + "
            Custom:
            \n" + + "
            doc for BaseClass method
            "); } } diff --git a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java index 451cd30bf32..49c54abcde3 100644 --- a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java +++ b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java @@ -26,44 +26,49 @@ * @bug 7180906 8026567 * @summary Test to make sure that the since tag works correctly * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestSinceTag + * @library ../lib + * @build JavadocTester * @run main TestSinceTag */ public class TestSinceTag extends JavadocTester { - //Javadoc arguments. - 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, "-nosince", "pkg1" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg1/C1.html", - "
            \n" + - "
            Since:
            \n" + - "
            JDK1.0
            " - }, - { "serialized-form.html", - "
            \n" + - "
            Since:
            \n" + - "
            1.4
            " - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSinceTag tester = new TestSinceTag(); - tester.run(ARGS1, TEST, NO_TEST); - tester.run(ARGS2, NO_TEST, TEST); + tester.runTests(); tester.printSummary(); } + + @Test + void testSince() { + javadoc("-d", "out-since", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.FAILED); // TODO: investigate + + checkSince(true); + } + + @Test + void testNoSince() { + javadoc("-d", "out-nosince", + "-sourcepath", testSrc, + "-nosince", + "pkg1"); + checkExit(Exit.FAILED); // TODO: investigate + + checkSince(false); + } + + void checkSince(boolean on) { + checkOutput("pkg1/C1.html", on, + "
            \n" + + "
            Since:
            \n" + + "
            JDK1.0
            "); + + checkOutput("serialized-form.html", on, + "
            \n" + + "
            Since:
            \n" + + "
            1.4
            "); + } } diff --git a/langtools/test/com/sun/javadoc/testSingleQuotedLink/TestSingleQuotedLink.java b/langtools/test/com/sun/javadoc/testSingleQuotedLink/TestSingleQuotedLink.java index 506d85da5e2..bdeaec8defc 100644 --- a/langtools/test/com/sun/javadoc/testSingleQuotedLink/TestSingleQuotedLink.java +++ b/langtools/test/com/sun/javadoc/testSingleQuotedLink/TestSingleQuotedLink.java @@ -26,35 +26,32 @@ * @bug 6457406 * @summary Verify that a link in single quotes copied to the class-use page as is. * @author Yuri Nesterenko - * @library ../lib/ - * @build JavadocTester TestSingleQuotedLink + * @library ../lib + * @build JavadocTester * @run main TestSingleQuotedLink */ public class TestSingleQuotedLink extends JavadocTester { - // We are testing the redirection algorithm with a known scenario when a writer is not forced to ignore it: "-use". - private static final String[][] TEST = { - { "pkg1/class-use/C1.html", - "" - } - }; - private static final String[][] NEGATED_TEST = { - { "pkg1/class-use/C1.html", - "pkg1/\'http://download.oracle.com/javase/8/docs/technotes/guides/indexC2.html\'>" - } - }; - 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) { + public static void main(String... args) throws Exception { TestSingleQuotedLink tester = new TestSingleQuotedLink(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void run() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-use", + "pkg1"); + checkExit(Exit.OK); + + // We are testing the redirection algorithm with a known scenario when a + // writer is not forced to ignore it: "-use". + + checkOutput("pkg1/class-use/C1.html", true, + ""); + + checkOutput("pkg1/class-use/C1.html", false, + "pkg1/\'http://download.oracle.com/javase/8/docs/technotes/guides/indexC2.html\'>"); } } diff --git a/langtools/test/com/sun/javadoc/testSourceTab/TestSourceTab.java b/langtools/test/com/sun/javadoc/testSourceTab/TestSourceTab.java index e0a328122ec..1364ece4ae8 100644 --- a/langtools/test/com/sun/javadoc/testSourceTab/TestSourceTab.java +++ b/langtools/test/com/sun/javadoc/testSourceTab/TestSourceTab.java @@ -27,9 +27,8 @@ * @summary Test to make sure that the source documentation is indented properly * when -linksourcetab is used. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSourceTab * @run main TestSourceTab */ @@ -37,45 +36,39 @@ import java.io.*; public class TestSourceTab extends JavadocTester { - private static final String TMP_SRC_DIR = "tmpSrc"; - private static final String OUTPUT_DIR1 = OUTPUT_DIR + "-tabLengthEight"; - private static final String OUTPUT_DIR2 = OUTPUT_DIR + "-tabLengthFour"; - - //Run Javadoc on a source file with that is indented with a single tab per line - private static final String[] ARGS1 = - new String[] { - "-d", OUTPUT_DIR1, "-sourcepath", TMP_SRC_DIR, - "-notimestamp", "-linksource", TMP_SRC_DIR + "/SingleTab/C.java" - }; - - //Run Javadoc on a source file with that is indented with a two tab per line - //If we double the tabs and decrease the tab length by a half, the output should - //be the same as the one generated above. - private static final String[] ARGS2 = - new String[] { - "-d", OUTPUT_DIR2, "-sourcepath", TMP_SRC_DIR, - "-notimestamp", "-sourcetab", "4", TMP_SRC_DIR + "/DoubleTab/C.java" - }; - - //Files to diff - private static final String[] FILES_TO_DIFF = { - "src-html/C.html", - "C.html" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) throws IOException { + public static void main(String... args) throws Exception { TestSourceTab tester = new TestSourceTab(); - tester.run(ARGS1, NO_TEST, NO_TEST); - tester.run(ARGS2, NO_TEST, NO_TEST); - tester.runDiffs(OUTPUT_DIR1, OUTPUT_DIR2, FILES_TO_DIFF); + tester.runTests(); } - TestSourceTab() throws IOException { - initTabs(new File(SRC_DIR), new File(TMP_SRC_DIR)); + @Test + void test() throws Exception { + String tmpSrcDir = "tmpSrc"; + String outdir1 = "out-tabLengthEight"; + String outdir2 = "out-tabLengthFour"; + initTabs(new File(testSrc), new File(tmpSrcDir)); + + // Run Javadoc on a source file with that is indented with a single tab per line + javadoc("-d", outdir1, + "-sourcepath", tmpSrcDir, + "-notimestamp", + "-linksource", + tmpSrcDir + "/SingleTab/C.java"); + checkExit(Exit.OK); + + // Run Javadoc on a source file with that is indented with a two tab per line + // If we double the tabs and decrease the tab length by a half, the output should + // be the same as the one generated above. + javadoc("-d", outdir2, + "-sourcepath", tmpSrcDir, + "-notimestamp", + "-sourcetab", "4", + tmpSrcDir + "/DoubleTab/C.java"); + checkExit(Exit.OK); + + diff(outdir1, outdir2, + "src-html/C.html", + "C.html"); } void initTabs(File from, File to) throws IOException { @@ -91,26 +84,20 @@ public class TestSourceTab extends JavadocTester { String read(File f) throws IOException { StringBuilder sb = new StringBuilder(); - BufferedReader in = new BufferedReader(new FileReader(f)); - try { + try (BufferedReader in = new BufferedReader(new FileReader(f))) { String line; while ((line = in.readLine()) != null) { sb.append(line); - sb.append("\n"); + sb.append(NL); } - } finally { - in.close(); } return sb.toString(); } void write(File f, String s) throws IOException { f.getParentFile().mkdirs(); - Writer out = new FileWriter(f); - try { + try (Writer out = new FileWriter(f)) { out.write(s); - } finally { - out.close(); } } } diff --git a/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java b/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java index 65ceecdfa98..e433ae8eefb 100644 --- a/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java +++ b/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java @@ -26,132 +26,118 @@ * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 * @summary Run tests on doclet stylesheet. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestStylesheet + * @library ../lib + * @build JavadocTester * @run main TestStylesheet */ public class TestStylesheet extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg" - }; + public static void main(String... args) throws Exception { + TestStylesheet tester = new TestStylesheet(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + // TODO: most of this test seems a bit silly, since javadoc is simply + // copying in the stylesheet from the source directory + checkOutput("stylesheet.css", true, + "/* Javadoc style sheet */", + "/*\n" + + "Overall document style\n" + + "*/", + "/*\n" + + "Heading styles\n" + + "*/", + "/*\n" + + "Navigation bar styles\n" + + "*/", + "body {\n" + + " background-color:#ffffff;\n" + + " color:#353833;\n" + + " font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;\n" + + " font-size:14px;\n" + + " margin:0;\n" + + "}", + "ul {\n" + + " list-style-type:disc;\n" + + "}", + ".overviewSummary caption, .memberSummary caption, .typeSummary caption,\n" + + ".useSummary caption, .constantsSummary caption, .deprecatedSummary caption {\n" + + " position:relative;\n" + + " text-align:left;\n" + + " background-repeat:no-repeat;\n" + + " color:#253441;\n" + + " font-weight:bold;\n" + + " clear:none;\n" + + " overflow:hidden;\n" + + " padding:0px;\n" + + " padding-top:10px;\n" + + " padding-left:1px;\n" + + " margin:0px;\n" + + " white-space:pre;\n" + + "}", + ".overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,\n" + + ".useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {\n" + + " white-space:nowrap;\n" + + " padding-top:5px;\n" + + " padding-left:12px;\n" + + " padding-right:12px;\n" + + " padding-bottom:7px;\n" + + " display:inline-block;\n" + + " float:left;\n" + + " background-color:#F8981D;\n" + + " border: none;\n" + + " height:16px;\n" + + "}", + ".memberSummary caption span.activeTableTab span {\n" + + " white-space:nowrap;\n" + + " padding-top:5px;\n" + + " padding-left:12px;\n" + + " padding-right:12px;\n" + + " margin-right:3px;\n" + + " display:inline-block;\n" + + " float:left;\n" + + " background-color:#F8981D;\n" + + " height:16px;\n" + + "}", + ".memberSummary caption span.tableTab span {\n" + + " white-space:nowrap;\n" + + " padding-top:5px;\n" + + " padding-left:12px;\n" + + " padding-right:12px;\n" + + " margin-right:3px;\n" + + " display:inline-block;\n" + + " float:left;\n" + + " background-color:#4D7A97;\n" + + " height:16px;\n" + + "}", + ".memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {\n" + + " padding-top:0px;\n" + + " padding-left:0px;\n" + + " padding-right:0px;\n" + + " background-image:none;\n" + + " float:none;\n" + + " display:inline;\n" + + "}", + "@import url('resources/fonts/dejavu.css');"); - //Input for string search tests. - private static final String[][] TEST = { - { "stylesheet.css", - "/* Javadoc style sheet */"}, - { "stylesheet.css", - "/*\n" + - "Overall document style\n" + - "*/"}, - { "stylesheet.css", - "/*\n" + - "Heading styles\n" + - "*/"}, - { "stylesheet.css", - "/*\n" + - "Navigation bar styles\n" + - "*/"}, - { "stylesheet.css", - "body {\n" + - " background-color:#ffffff;\n" + - " color:#353833;\n" + - " font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;\n" + - " font-size:14px;\n" + - " margin:0;\n" + - "}"}, - { "stylesheet.css", - "ul {\n" + - " list-style-type:disc;\n" + - "}"}, - { "stylesheet.css", - ".overviewSummary caption, .memberSummary caption, .typeSummary caption,\n" + - ".useSummary caption, .constantsSummary caption, .deprecatedSummary caption {\n" + - " position:relative;\n" + - " text-align:left;\n" + - " background-repeat:no-repeat;\n" + - " color:#253441;\n" + - " font-weight:bold;\n" + - " clear:none;\n" + - " overflow:hidden;\n" + - " padding:0px;\n" + - " padding-top:10px;\n" + - " padding-left:1px;\n" + - " margin:0px;\n" + - " white-space:pre;\n" + - "}"}, - { "stylesheet.css", - ".overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,\n" + - ".useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {\n" + - " white-space:nowrap;\n" + - " padding-top:5px;\n" + - " padding-left:12px;\n" + - " padding-right:12px;\n" + - " padding-bottom:7px;\n" + - " display:inline-block;\n" + - " float:left;\n" + - " background-color:#F8981D;\n" + - " border: none;\n" + - " height:16px;\n" + - "}"}, - { "stylesheet.css", - ".memberSummary caption span.activeTableTab span {\n" + - " white-space:nowrap;\n" + - " padding-top:5px;\n" + - " padding-left:12px;\n" + - " padding-right:12px;\n" + - " margin-right:3px;\n" + - " display:inline-block;\n" + - " float:left;\n" + - " background-color:#F8981D;\n" + - " height:16px;\n" + - "}"}, - { "stylesheet.css", - ".memberSummary caption span.tableTab span {\n" + - " white-space:nowrap;\n" + - " padding-top:5px;\n" + - " padding-left:12px;\n" + - " padding-right:12px;\n" + - " margin-right:3px;\n" + - " display:inline-block;\n" + - " float:left;\n" + - " background-color:#4D7A97;\n" + - " height:16px;\n" + - "}"}, - { "stylesheet.css", - ".memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {\n" + - " padding-top:0px;\n" + - " padding-left:0px;\n" + - " padding-right:0px;\n" + - " background-image:none;\n" + - " float:none;\n" + - " display:inline;\n" + - "}"}, - { "stylesheet.css", - "@import url('resources/fonts/dejavu.css');"}, // Test whether a link to the stylesheet file is inserted properly // in the class documentation. - { "pkg/A.html", - ""} - }; - private static final String[][] NEGATED_TEST = { - { "stylesheet.css", - "* {\n" + - " margin:0;\n" + - " padding:0;\n" + - "}"} - }; + checkOutput("pkg/A.html", true, + ""); - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestStylesheet tester = new TestStylesheet(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + checkOutput("stylesheet.css", false, + "* {\n" + + " margin:0;\n" + + " padding:0;\n" + + "}"); } } diff --git a/langtools/test/com/sun/javadoc/testSubTitle/TestSubTitle.java b/langtools/test/com/sun/javadoc/testSubTitle/TestSubTitle.java index e5df26063ee..d2342bd0a0f 100644 --- a/langtools/test/com/sun/javadoc/testSubTitle/TestSubTitle.java +++ b/langtools/test/com/sun/javadoc/testSubTitle/TestSubTitle.java @@ -26,44 +26,38 @@ * @bug 7010342 * @summary Test for correct sub title generation. * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSubTitle * @run main TestSubTitle */ public class TestSubTitle extends JavadocTester { - private static final String[][] TEST = { - { "pkg/package-summary.html", - "
            This is the description of package pkg.
            " - }, - { "pkg/C.html", - "
            pkg
            " - } - }; - private static final String[][] NEG_TEST = { - { "pkg/package-summary.html", + public static void main(String... args) throws Exception { + TestSubTitle tester = new TestSubTitle(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/package-summary.html", true, + "
            This is the description of package pkg.
            "); + + checkOutput("pkg/C.html", true, + "
            pkg
            "); + + checkOutput("pkg/package-summary.html", false, "

            \n" + "

            This is the " + "description of package pkg.
            \n" + - "

            " - }, - { "pkg/C.html", - "

            pkg

            " - } - }; - 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) { - TestSubTitle tester = new TestSubTitle(); - tester.run(ARGS, TEST, NEG_TEST); - tester.printSummary(); + checkOutput("pkg/C.html", false, + "

            pkg

            "); } } diff --git a/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java b/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java index 3f4cf511aaa..1ffeb024e0e 100644 --- a/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java +++ b/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java @@ -28,31 +28,26 @@ * "Method Summary" heading should still show up since the class * inherits methods. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSummaryHeading * @run main TestSummaryHeading */ public class TestSummaryHeading extends JavadocTester { - //Javadoc arguments. - 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", "

            Method Summary

            "} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSummaryHeading tester = new TestSummaryHeading(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("C.html", true, + "

            Method Summary

            "); } } diff --git a/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java b/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java index 57751a9191b..1ff2c9ad2ce 100644 --- a/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java +++ b/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java @@ -27,30 +27,27 @@ * @summary Test to make sure link to superclass is generated for * each class in serialized form page. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSuperClassInSerialForm * @run main TestSuperClassInSerialForm */ public class TestSuperClassInSerialForm extends JavadocTester { - private static final String[][] TEST = { - { "serialized-form.html", - "
            pkg.SubClass extends SuperClass"} - }; - - 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) { + public static void main(String... args) throws Exception { TestSuperClassInSerialForm tester = new TestSuperClassInSerialForm(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("serialized-form.html", true, + "pkg.SubClass" + + " extends SuperClass"); } } diff --git a/langtools/test/com/sun/javadoc/testSupplementary/TestSupplementary.java b/langtools/test/com/sun/javadoc/testSupplementary/TestSupplementary.java index 8b09c1cb1df..7c4355857b8 100644 --- a/langtools/test/com/sun/javadoc/testSupplementary/TestSupplementary.java +++ b/langtools/test/com/sun/javadoc/testSupplementary/TestSupplementary.java @@ -27,9 +27,8 @@ * @summary Test to make sure that "see" tag and "serialField" tag handle supplementary * characters correctly. This test case needs to be run in en_US locale. * @author Naoto Sato - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestSupplementary * @run main TestSupplementary */ @@ -37,33 +36,33 @@ import java.util.Locale; public class TestSupplementary extends JavadocTester { - private static final String[][] TEST = { - {WARNING_OUTPUT, "C.java:38: warning - Tag @see:illegal character: \"119040\" in \"C#method\ud834\udd00()"}, - {WARNING_OUTPUT, "C.java:44: warning - illegal character \ud801 in @serialField tag: field\ud801\ud801 int."}, - {WARNING_OUTPUT, "C.java:44: warning - illegal character \ud834\udd7b in @serialField tag: \ud834\udd7bfield int."}, - }; - private static final String[][] NEGATED_TEST = { - {WARNING_OUTPUT, "C.java:14: warning - Tag @see:illegal character"}, - {WARNING_OUTPUT, "C.java:19: warning - Tag @see:illegal character"}, - {WARNING_OUTPUT, "C.java:24: warning - Tag @see:illegal character"}, - {WARNING_OUTPUT, "C.java:31: warning - illegal character"}, - }; - private static final String[] ARGS = new String[] { - "-locale", "en_US", "-d", OUTPUT_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) { + public static void main(String... args) throws Exception { Locale saveLocale = Locale.getDefault(); try { TestSupplementary tester = new TestSupplementary(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); } finally { Locale.setDefault(saveLocale); } } + + @Test + void test() { + javadoc("-locale", "en_US", + "-d", "out", + testSrc("C.java")); + checkExit(Exit.FAILED); + + checkOutput(Output.WARNING, true, + "C.java:38: warning - Tag @see:illegal character: \"119040\" in \"C#method\ud834\udd00()", + "C.java:44: warning - illegal character \ud801 in @serialField tag: field\ud801\ud801 int.", + "C.java:44: warning - illegal character \ud834\udd7b in @serialField tag: \ud834\udd7bfield int."); + + // TODO: do we need to specify the file and line number in these messages? + checkOutput(Output.WARNING, false, + "C.java:14: warning - Tag @see:illegal character", + "C.java:19: warning - Tag @see:illegal character", + "C.java:24: warning - Tag @see:illegal character", + "C.java:31: warning - illegal character"); + } } diff --git a/langtools/test/com/sun/javadoc/testTagHolderMethod/TestTagHolderMethod.java b/langtools/test/com/sun/javadoc/testTagHolderMethod/TestTagHolderMethod.java index 72082856991..4a590de8d52 100644 --- a/langtools/test/com/sun/javadoc/testTagHolderMethod/TestTagHolderMethod.java +++ b/langtools/test/com/sun/javadoc/testTagHolderMethod/TestTagHolderMethod.java @@ -26,7 +26,7 @@ * @bug 4706525 * @summary Determine if the new Tag.holder() method works properly. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester * @build TestTagHolderMethod * @run main TestTagHolderMethod @@ -36,10 +36,6 @@ import com.sun.javadoc.*; public class TestTagHolderMethod extends JavadocTester { - public static final String[] ARGS = new String[] { - "-docletpath", SRC_DIR, "-doclet", "TestTagHolderMethod", "-sourcepath", - SRC_DIR, "pkg"}; - /** * Doclet entry point. */ @@ -55,14 +51,13 @@ public class TestTagHolderMethod extends JavadocTester { } private static void checkHolders(Doc[] holders) throws Exception { - for (int i = 0; i < holders.length; i++) { - Doc holder = holders[i]; + for (Doc holder : holders) { Tag[] tags = holder.tags(); - for (int j = 0; j < tags.length; j++) { - if (! tags[j].holder().name().equals(holder.name())) { + for (Tag tag : tags) { + if (!tag.holder().name().equals(holder.name())) { throw new Exception("The holder method does not return the correct Doc object."); } else { - System.out.println(tags[j].name() + " is held by " + holder.name()); + System.out.println(tag.name() + " is held by " + holder.name()); } } } @@ -71,9 +66,19 @@ public class TestTagHolderMethod extends JavadocTester { /** * The entry point of the test. * @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 TestTagHolderMethod(); - tester.run(ARGS, new String[][]{}, new String[][]{}); + tester.runTests(); + } + + @Test + void test() { + javadoc("-docletpath", testSrc, // unlikely to be effective + "-doclet", "TestTagHolderMethod", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); } } diff --git a/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java b/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java index 0a284352309..e3ddc6a636f 100644 --- a/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java +++ b/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java @@ -26,46 +26,44 @@ * @bug 4496223 4496270 4618686 4720974 4812240 6253614 6253604 * @summary * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestTagInheritence * @run main TestTagInheritence */ +// TODO: Inheritence should be Inheritance! fix separately as noreg-trivial public class TestTagInheritence extends JavadocTester { - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", - "firstSentence", "firstSentence2" - }; + public static void main(String... args) throws Exception { + TestTagInheritence tester = new TestTagInheritence(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + "-sourcepath", testSrc, + "pkg", "firstSentence", "firstSentence2"); + checkExit(Exit.OK); - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - String[][] tests = new String[42][2]; //Test bad inheritDoc tag warning. - tests[0][0]= WARNING_OUTPUT; - tests[0][1] = "warning - @inheritDoc used but testBadInheritDocTag() " + - "does not override or implement any method."; + checkOutput(Output.WARNING, true, + "warning - @inheritDoc used but testBadInheritDocTag() " + + "does not override or implement any method."); //Test valid usage of inheritDoc tag. - for (int i = 1; i < tests.length-2; i++) { - tests[i][0] = "pkg/TestTagInheritence.html"; - tests[i][1] = "Test " + i + " passes"; + for (int i = 1; i < 40; i++) { + checkOutput("pkg/TestTagInheritence.html", true, + "Test " + i + " passes"); } //First sentence test (6253614) - tests[tests.length - 2][0] = "firstSentence/B.html"; - tests[tests.length - 2][1] = "
            First sentence.
            "; + checkOutput("firstSentence/B.html", true, + "
            First sentence.
            "); //Another first sentence test (6253604) - tests[tests.length - 1][0] = "firstSentence2/C.html"; - tests[tests.length - 1][1] = "
            First sentence.
            "; - - TestTagInheritence tester = new TestTagInheritence(); - tester.run(ARGS, tests, NO_TEST); - tester.printSummary(); + checkOutput("firstSentence2/C.html", true, + "
            First sentence.
            "); } } diff --git a/langtools/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java b/langtools/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java index 514ee736619..e133189214d 100644 --- a/langtools/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java +++ b/langtools/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java @@ -25,31 +25,35 @@ * @test * @summary Determine if proper warning messages are printed when know. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester * @build TestTagMisuse * @run main TestTagMisuse */ public class TestTagMisuse extends JavadocTester { - private static final String[][] TEST = { - {WARNING_OUTPUT, "warning - Tag @param cannot be used in field documentation."}, - {WARNING_OUTPUT, "warning - Tag @throws cannot be used in field documentation."}, - {WARNING_OUTPUT, "warning - Tag @return cannot be used in constructor documentation."}, - {WARNING_OUTPUT, "warning - Tag @throws cannot be used in inline documentation."}, - }; - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR, SRC_DIR + "/TestTagMisuse.java" - }; - /** * The entry point of the test. * @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 { TestTagMisuse tester = new TestTagMisuse(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + testSrc("TestTagMisuse.java")); + checkExit(Exit.OK); + + checkOutput(Output.WARNING, true, + "warning - Tag @param cannot be used in field documentation.", + "warning - Tag @throws cannot be used in field documentation.", + "warning - Tag @return cannot be used in constructor documentation.", + "warning - Tag @throws cannot be used in inline documentation."); } /** diff --git a/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java b/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java index 09551abb744..bb99e3fdc03 100644 --- a/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java +++ b/langtools/test/com/sun/javadoc/testTagOutput/TestTagOutput.java @@ -28,36 +28,32 @@ * @bug 8026370 8026567 * @summary This test checks the generated tag output. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestTagOutput + * @library ../lib + * @build JavadocTester * @run main TestTagOutput */ public class TestTagOutput extends JavadocTester { - private static final String[][] TEST = { - { "pkg1/DeprecatedTag.html", - "
            Deprecated. 
            "}, - { "pkg1/DeprecatedTag.html", - "
            Deprecated. " + - "Do not use this.
            "}}; - - private static final String[][] NEGATED_TEST = { - { "pkg1/DeprecatedTag.html", - "
            Deprecated." + - " 
            "}}; - - 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) { + public static void main(String... args) throws Exception { TestTagOutput tester = new TestTagOutput(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg1"); + checkExit(Exit.OK); + + checkOutput("pkg1/DeprecatedTag.html", true, + "
            Deprecated. 
            ", + "
            Deprecated. " + + "Do not use this.
            "); + + checkOutput("pkg1/DeprecatedTag.html", false, + "
            Deprecated." + + " 
            "); } } diff --git a/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java b/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java index 43188a842be..9ab76f6b4f4 100644 --- a/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java +++ b/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java @@ -29,49 +29,41 @@ * Run Javadoc on some sample source that uses {@inheritDoc}. Make * sure that only the first sentence shows up in the summary table. * @author jamieh - * @library ../lib/ - * @build JavadocTester - * @build TestTaglets - * @build taglets.Foo + * @library ../lib + * @build JavadocTester taglets.Foo * @run main TestTaglets */ public class TestTaglets extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS_4654308 = new String[] { - "-d", "4654308", "-tagletpath", SRC_DIR, "-taglet", "taglets.Foo", - "-sourcepath", SRC_DIR, SRC_DIR + "/C.java" - }; - - private static final String[] ARGS_4767038 = new String[] { - "-d", "4767038", "-sourcepath", SRC_DIR, SRC_DIR + "/Parent.java", - SRC_DIR + "/Child.java" - }; - - //Input for string search tests. - private static final String[][] TEST_4654308 = new String[][] { - { "C.html", "Foo:" + - "
            my only method is here" + - "
            "} - }; - - private static final String[][] TEST_4767038 = new String[][] { - { "Child.html", - "This is the first sentence."} - }; - - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestTaglets tester = new TestTaglets(); - tester.run(ARGS_4654308, TEST_4654308, NO_TEST); - tester.printSummary(); - tester = new TestTaglets(); - tester.run(ARGS_4767038, TEST_4767038, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test_4654308() { + javadoc("-d", "out-4654308", + "-tagletpath", testSrc, // TODO: probably does no good + "-taglet", "taglets.Foo", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("C.html", true, + "Foo:" + + "
            my only method is here" + + "
            "); + } + + @Test + void test_4767038() { + javadoc("-d", "out-4767038", + "-sourcepath", testSrc, + testSrc("Parent.java"), testSrc("Child.java")); + checkExit(Exit.OK); + + checkOutput("Child.html", true, + "This is the first sentence."); } } diff --git a/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java b/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java index fca7de722ac..fcec5953a0a 100644 --- a/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java +++ b/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java @@ -28,28 +28,25 @@ * not documented with a throws tag, we generate a link to it in the * throws section. Make sure that the link is below a Throws heading. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestThrowsHead * @run main TestThrowsHead */ public class TestThrowsHead extends JavadocTester { - private static final String[][] TEST = { - { "C.html", "
            Throws:"} - }; - private static final String[] ARGS = new String[] { - "-d", OUTPUT_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) { + public static void main(String... args) throws Exception { TestThrowsHead tester = new TestThrowsHead(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("C.html", true, + "
            Throws:"); } } diff --git a/langtools/test/com/sun/javadoc/testThrowsInheritence/TestThrowsTagInheritence.java b/langtools/test/com/sun/javadoc/testThrowsInheritence/TestThrowsTagInheritence.java index 543a8a01f09..99fc0a8eadd 100644 --- a/langtools/test/com/sun/javadoc/testThrowsInheritence/TestThrowsTagInheritence.java +++ b/langtools/test/com/sun/javadoc/testThrowsInheritence/TestThrowsTagInheritence.java @@ -28,36 +28,35 @@ * override the throws tags in interface. This test also verifies that throws tags are inherited properly * the case where the name of one exception is not fully qualified. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestThrowsTagInheritence * @run main TestThrowsTagInheritence */ +// TODO: should be TestThrowsInheritance! public class TestThrowsTagInheritence extends JavadocTester { - private static final String[][] TEST = { - //The class should not inherit the tag from the interface. - { "Foo.html", "Test 1 passes."} - }; - private static final String[][] NEGATED_TEST = { - //The class should not inherit the tag from the interface. - { "C.html", "Test 1 fails."} - - }; - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, SRC_DIR + "/C.java", - SRC_DIR + "/I.java", SRC_DIR + "/Foo.java", - SRC_DIR + "/Iface.java" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestThrowsTagInheritence tester = new TestThrowsTagInheritence(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java"), + testSrc("I.java"), + testSrc("Foo.java"), + testSrc("Iface.java")); + checkExit(Exit.OK); + + // The class should not inherit the tag from the interface. + checkOutput("Foo.html", true, + "Test 1 passes."); + + //The class should not inherit the tag from the interface. + checkOutput("C.html", false, + "Test 1 fails."); } } diff --git a/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java b/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java index 63d5280ab3d..3b5b7bca314 100644 --- a/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java +++ b/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java @@ -27,22 +27,26 @@ * @summary Test to make sure that exceptions always show up in the * correct order. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestThrowsTag * @run main TestThrowsTag */ public class TestThrowsTag extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg" - }; + public static void main(String... args) throws Exception { + TestThrowsTag tester = new TestThrowsTag(); + tester.runTests(); + } - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/C.html", + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.FAILED); // TODO: investigate why failed + + checkOutput("pkg/C.html", true, "
            T1 - the first throws tag.
            \n" + "
            T2 - the second throws tag.
            \n" + "
            T3 - the third throws tag.
            \n" + @@ -51,16 +55,6 @@ public class TestThrowsTag extends JavadocTester { "
            T6 - the second inherited throws tag.
            \n" + "
            T7 - the third inherited throws tag.
            \n" + "
            T8 - the fourth inherited throws tag.
            " - }, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestThrowsTag tester = new TestThrowsTag(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + ); } } diff --git a/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java b/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java index 1d21d60b7fb..d5e977250b4 100644 --- a/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java +++ b/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java @@ -26,42 +26,35 @@ * @bug 4714257 * @summary Test to make sure that the title attribute shows up in links. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestTitleInHref * @run main TestTitleInHref */ public class TestTitleInHref extends JavadocTester { - private static final String[][] TEST = { - //Test to make sure that the title shows up in a class link. - { "pkg/Links.html", - ""}, - - //Test to make sure that the title shows up in an interface link. - { "pkg/Links.html", - ""}, - - //Test to make sure that the title shows up in cross link shows up - { "pkg/Links.html", - "This is a cross link to class File"}, - - }; - - 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" - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestTitleInHref tester = new TestTitleInHref(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + String uri = "http://java.sun.com/j2se/1.4/docs/api"; + javadoc("-d", "out", + "-sourcepath", testSrc, + "-linkoffline", uri, testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/Links.html", true, + //Test to make sure that the title shows up in a class link. + "", + //Test to make sure that the title shows up in an interface link. + "", + //Test to make sure that the title shows up in cross link shows up + "" + + "This is a cross link to class File"); } } diff --git a/langtools/test/com/sun/javadoc/testTopOption/TestTopOption.java b/langtools/test/com/sun/javadoc/testTopOption/TestTopOption.java index ba9de8503fb..7d173ed24e6 100644 --- a/langtools/test/com/sun/javadoc/testTopOption/TestTopOption.java +++ b/langtools/test/com/sun/javadoc/testTopOption/TestTopOption.java @@ -26,55 +26,44 @@ * @bug 6227616 * @summary Test the new -top option. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestTopOption * @run main TestTopOption */ public class TestTopOption extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-overview", "SRC_DIR + '/' + overview.html", "-use", "-top", - "TOP TEXT", "-d", OUTPUT_DIR, "-sourcepath", - SRC_DIR, "pkg" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/AnnotationType.html", - "TOP TEXT"}, - { "pkg/class-use/AnnotationType.html", - "TOP TEXT"}, - - { "pkg/Cl.html", - "TOP TEXT"}, - { "pkg/class-use/Cl.html", - "TOP TEXT"}, - - { "pkg/package-summary.html", - "TOP TEXT"}, - { "pkg/package-use.html", - "TOP TEXT"}, - - { "overview-summary.html", - "TOP TEXT"}, - { "overview-tree.html", - "TOP TEXT"}, - { "constant-values.html", - "TOP TEXT"}, - { "help-doc.html", - "TOP TEXT"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestTopOption tester = new TestTopOption(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-overview", testSrc("overview.html"), + "-use", + "-top", "TOP TEXT", + "-d", "out", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkTopText( + "pkg/AnnotationType.html", + "pkg/class-use/AnnotationType.html", + "pkg/Cl.html", + "pkg/class-use/Cl.html", + "pkg/package-summary.html", + "pkg/package-use.html", + "overview-summary.html", + "overview-tree.html", + "constant-values.html", + "help-doc.html"); + } + + void checkTopText(String... files) { + for (String file : files) { + checkOutput(file, true, "TOP TEXT"); + } } } diff --git a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java index 7d896b1e172..189369dd226 100644 --- a/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java +++ b/langtools/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java @@ -26,360 +26,327 @@ * @bug 8005091 8009686 8025633 8026567 * @summary Make sure that type annotations are displayed correctly * @author Bhavesh Patel - * @library ../lib/ + * @library ../lib * @ignore - * @build JavadocTester TestTypeAnnotations + * @build JavadocTester * @run main TestTypeAnnotations */ public class TestTypeAnnotations extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-private", "typeannos" - }; + public static void main(String... args) throws Exception { + TestTypeAnnotations tester = new TestTypeAnnotations(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + "-private", + "typeannos"); + checkExit(Exit.OK); - //Input for string search tests. - private static final String[][] TEST = { // Test for type annotations on Class Extends (ClassExtends.java). - { "typeannos/MyClass.html", - "extends @ClassExtA ParameterizedClass<" + - "@ClassExtB java.lang.String>" - }, - { "typeannos/MyClass.html", - "implements @ClassExtB java.lang.CharSequence, " + - "@ClassExtA ParameterizedInterface<" + - "@ClassExtB java.lang.String>" - }, - { "typeannos/MyInterface.html", - "extends @ClassExtA " + - "ParameterizedInterface<@ClassExtA java.lang.String>, " + - "@ClassExtB java.lang.CharSequence" - }, + checkOutput("typeannos/MyClass.html", true, + "extends @ClassExtA ParameterizedClass<" + + "@ClassExtB java.lang.String>", + + "implements @ClassExtB java.lang.CharSequence, " + + "@ClassExtA ParameterizedInterface<" + + "@ClassExtB java.lang.String>"); + + checkOutput("typeannos/MyInterface.html", true, + "extends @ClassExtA " + + "ParameterizedInterface<@ClassExtA java.lang.String>, " + + "@ClassExtB java.lang.CharSequence"); // Test for type annotations on Class Parameters (ClassParameters.java). - { "typeannos/ExtendsBound.html", - "class ExtendsBound<K extends @ClassParamA java.lang.String>" - }, - { "typeannos/ExtendsGeneric.html", - "
            class ExtendsGeneric<K extends " +
            -            "@ClassParamA Unannotated<" +
            -            "@ClassParamB java.lang.String>>"
            -        },
            -        { "typeannos/TwoBounds.html",
            -            "
            class TwoBounds<K extends " +
            -            "@ClassParamA java.lang.String,V extends @ClassParamB" +
            -            " java.lang.String>"
            -        },
            -        { "typeannos/Complex1.html",
            -            "class Complex1<K extends " +
            -            "@ClassParamA java.lang.String & java.lang.Runnable>"
            -        },
            -        { "typeannos/Complex2.html",
            -            "class Complex2<K extends java.lang." +
            -            "String & @ClassParamB java.lang.Runnable>"
            -        },
            -        { "typeannos/ComplexBoth.html",
            -            "class ComplexBoth<K extends @ClassParamA java.lang.String & @ClassParamA" +
            -            " java.lang.Runnable>"
            -        },
            +        checkOutput("typeannos/ExtendsBound.html", true,
            +                "class ExtendsBound<K extends @ClassParamA java.lang.String>");
            +
            +        checkOutput("typeannos/ExtendsGeneric.html", true,
            +                "
            class ExtendsGeneric<K extends "
            +                + "@ClassParamA Unannotated<"
            +                + "@ClassParamB java.lang.String>>");
            +
            +        checkOutput("typeannos/TwoBounds.html", true,
            +                "
            class TwoBounds<K extends "
            +                + "@ClassParamA java.lang.String,V extends @ClassParamB"
            +                + " java.lang.String>");
            +
            +        checkOutput("typeannos/Complex1.html", true,
            +                "class Complex1<K extends "
            +                + "@ClassParamA java.lang.String & java.lang.Runnable>");
            +
            +        checkOutput("typeannos/Complex2.html", true,
            +                "class Complex2<K extends java.lang."
            +                + "String & @ClassParamB java.lang.Runnable>");
            +
            +        checkOutput("typeannos/ComplexBoth.html", true,
            +                "class ComplexBoth<K extends @ClassParamA java.lang.String & @ClassParamA"
            +                + " java.lang.Runnable>");
             
                     // Test for type annotations on fields (Fields.java).
            -        { "typeannos/DefaultScope.html",
            -            "
            Parameterized<@FldA java.lang.String," +
            -            "@FldB java.lang.String> bothTypeArgs
            " - }, - { "typeannos/DefaultScope.html", - "
            @FldA java.lang.String @FldB [] " +
            -            "array1Deep
            " - }, - { "typeannos/DefaultScope.html", - "
            java.lang.String[] @FldB [] array2SecondOld
            " - }, - { "typeannos/DefaultScope.html", - "
            @FldD java.lang.String @FldC @FldA" +
            -            " [] @FldC @FldB [] array2Deep
            " - }, - { "typeannos/ModifiedScoped.html", - "
            public final Parameterized<@FldA " +
            -            "Parameterized<@FldA java.lang.String," +
            -            "@FldB java.lang.String>,@FldB java.lang.String> " +
            -            "nestedParameterized
            " - }, - { "typeannos/ModifiedScoped.html", - "
            public final @FldA java.lang.String[][] " +
            -            "array2
            " - }, + checkOutput("typeannos/DefaultScope.html", true, + "
            Parameterized<@FldA java.lang.String,"
            +                + "@FldB java.lang.String> bothTypeArgs
            ", + + "
            @FldA java.lang.String @FldB [] "
            +                + "array1Deep
            ", + + "
            java.lang.String[] @FldB [] array2SecondOld
            ", + + "
            @FldD java.lang.String @FldC @FldA"
            +                + " [] @FldC @FldB [] array2Deep
            "); + + checkOutput("typeannos/ModifiedScoped.html", true, + "
            public final Parameterized<@FldA "
            +                + "Parameterized<@FldA java.lang.String,"
            +                + "@FldB java.lang.String>,@FldB java.lang.String> "
            +                + "nestedParameterized
            ", + + "
            public final @FldA java.lang.String[][] "
            +                + "array2
            "); // Test for type annotations on method return types (MethodReturnType.java). - { "typeannos/MtdDefaultScope.html", - "
            public <T> @MRtnA java.lang.String" +
            -            " method()
            " - }, - { "typeannos/MtdDefaultScope.html", - "
            @MRtnA java.lang.String @MRtnA [] " +
            -            "@MRtnB [] array2Deep()
            " - }, - { "typeannos/MtdDefaultScope.html", - "
            @MRtnA java.lang.String[][] array2()
            " - }, - { "typeannos/MtdModifiedScoped.html", - "
            public final MtdParameterized<@MRtnA " +
            -            "MtdParameterized<@MRtnA java.lang." +
            -            "String,@MRtnB java.lang.String>,@MRtnB java." +
            -            "lang.String> nestedMtdParameterized()
            " - }, + checkOutput("typeannos/MtdDefaultScope.html", true, + "
            public <T> @MRtnA java.lang.String"
            +                + " method()
            ", + + "
            @MRtnA java.lang.String @MRtnA [] "
            +                + "@MRtnB [] array2Deep()
            ", + + "
            @MRtnA java.lang.String[][] array2()
            "); + + checkOutput("typeannos/MtdModifiedScoped.html", true, + "
            public final MtdParameterized<@MRtnA "
            +                + "MtdParameterized<@MRtnA java.lang."
            +                + "String,@MRtnB java.lang.String>,@MRtnB java."
            +                + "lang.String> nestedMtdParameterized()
            "); // Test for type annotations on method type parameters (MethodTypeParameters.java). - { "typeannos/UnscopedUnmodified.html", - "
            <K extends @MTyParamA java.lang.String>" +
            -            " void methodExtends()
            " - }, - { "typeannos/UnscopedUnmodified.html", - "
            <K extends @MTyParamA " +
            -            "MtdTyParameterized<@MTyParamB java.lang.String" +
            -            ">> void nestedExtends()
            " - }, - { "typeannos/PublicModifiedMethods.html", - "
            public final <K extends @MTyParamA " +
            -            "java.lang.String> void methodExtends()
            " - }, - { "typeannos/PublicModifiedMethods.html", - "
            public final <K extends @MTyParamA " +
            -            "java.lang.String,V extends @MTyParamA " +
            -            "MtdTyParameterized<@MTyParamB java.lang.String" +
            -            ">> void dual()
            " - }, + checkOutput("typeannos/UnscopedUnmodified.html", true, + "
            <K extends @MTyParamA java.lang.String>"
            +                + " void methodExtends()
            ", + + "
            <K extends @MTyParamA "
            +                + "MtdTyParameterized<@MTyParamB java.lang.String"
            +                + ">> void nestedExtends()
            "); + + checkOutput("typeannos/PublicModifiedMethods.html", true, + "
            public final <K extends @MTyParamA "
            +                + "java.lang.String> void methodExtends()
            ", + + "
            public final <K extends @MTyParamA "
            +                + "java.lang.String,V extends @MTyParamA "
            +                + "MtdTyParameterized<@MTyParamB java.lang.String"
            +                + ">> void dual()
            "); // Test for type annotations on parameters (Parameters.java). - { "typeannos/Parameters.html", - "
            void unannotated(" +
            -            "ParaParameterized<java.lang.String,java.lang.String>" +
            -            " a)
            " - }, - { "typeannos/Parameters.html", - "
            void nestedParaParameterized(" +
            -            "ParaParameterized<@ParamA " +
            -            "ParaParameterized<@ParamA java.lang.String," +
            -            "@ParamB java.lang.String>,@ParamB" +
            -            " java.lang.String> a)
            " - }, - { "typeannos/Parameters.html", - "
            void array2Deep(@ParamA java.lang.String " +
            -            "@ParamA [] @ParamB [] a)
            " - }, + checkOutput("typeannos/Parameters.html", true, + "
            void unannotated("
            +                + "ParaParameterized<java.lang.String,java.lang.String>"
            +                + " a)
            ", + + "
            void nestedParaParameterized("
            +                + "ParaParameterized<@ParamA "
            +                + "ParaParameterized<@ParamA java.lang.String,"
            +                + "@ParamB java.lang.String>,@ParamB"
            +                + " java.lang.String> a)
            ", + + "
            void array2Deep(@ParamA java.lang.String "
            +                + "@ParamA [] @ParamB [] a)
            "); // Test for type annotations on throws (Throws.java). - { "typeannos/ThrDefaultUnmodified.html", - "
            void oneException()\n" +
            -            "           throws @ThrA java.lang.Exception
            " - }, - { "typeannos/ThrDefaultUnmodified.html", - "
            void twoExceptions()\n" +
            -            "            throws @ThrA java.lang.RuntimeException,\n" +
            -            "                   @ThrA java.lang.Exception
            " - }, - { "typeannos/ThrPublicModified.html", - "
            public final void oneException(java.lang.String a)\n" +
            -            "                        throws @ThrA java.lang.Exception
            " - }, - { "typeannos/ThrPublicModified.html", - "
            public final void twoExceptions(java.lang.String a)\n" +
            -            "                         throws @ThrA java.lang.RuntimeException,\n" +
            -            "                                @ThrA java.lang.Exception
            " - }, - { "typeannos/ThrWithValue.html", - "
            void oneException()\n" +
            -            "           throws @ThrB(value=\"m\") java.lang.Exception
            " - }, - { "typeannos/ThrWithValue.html", - "
            void twoExceptions()\n" +
            -            "            throws @ThrB(value=\"m\") java.lang.RuntimeException,\n" +
            -            "                   @ThrA java.lang.Exception
            " - }, + checkOutput("typeannos/ThrDefaultUnmodified.html", true, + "
            void oneException()\n"
            +                + "           throws @ThrA java.lang.Exception
            ", + + "
            void twoExceptions()\n"
            +                + "            throws @ThrA java.lang.RuntimeException,\n"
            +                + "                   @ThrA java.lang.Exception
            "); + + checkOutput("typeannos/ThrPublicModified.html", true, + "
            public final void oneException(java.lang.String a)\n"
            +                + "                        throws @ThrA java.lang.Exception
            ", + + "
            public final void twoExceptions(java.lang.String a)\n"
            +                + "                         throws @ThrA java.lang.RuntimeException,\n"
            +                + "                                @ThrA java.lang.Exception
            "); + + checkOutput("typeannos/ThrWithValue.html", true, + "
            void oneException()\n"
            +                + "           throws @ThrB(value=\"m\") java.lang.Exception
            ", + + "
            void twoExceptions()\n"
            +                + "            throws @ThrB(value=\"m\") java.lang.RuntimeException,\n"
            +                + "                   @ThrA java.lang.Exception
            "); // Test for type annotations on type parameters (TypeParameters.java). - { "typeannos/TestMethods.html", - "
            <K,V extends @TyParaA java.lang.String> " +
            -            "void secondAnnotated()
            " - }, + checkOutput("typeannos/TestMethods.html", true, + "
            <K,V extends @TyParaA java.lang.String> "
            +                + "void secondAnnotated()
            "); // Test for type annotations on wildcard type (Wildcards.java). - { "typeannos/BoundTest.html", - "
            void wcExtends(MyList<? extends @WldA" +
            -            " java.lang.String> l)
            " - }, - { "typeannos/BoundTest.html", - "
            MyList<? super @WldA java.lang.String>" +
            -            " returnWcSuper()
            " - }, - { "typeannos/BoundWithValue.html", - "
            void wcSuper(MyList<? super @WldB(value=\"m\") java.lang." +
            -            "String> l)
            " - }, - { "typeannos/BoundWithValue.html", - "
            MyList<? extends @WldB(value=\"m\") java.lang.String" +
            -            "> returnWcExtends()
            " - }, + checkOutput("typeannos/BoundTest.html", true, + "
            void wcExtends(MyList<? extends @WldA"
            +                + " java.lang.String> l)
            ", + + "
            MyList<? super @WldA java.lang.String>"
            +                + " returnWcSuper()
            "); + + checkOutput("typeannos/BoundWithValue.html", true, + "
            void wcSuper(MyList<? super @WldB(value=\"m\") java.lang."
            +                + "String> l)
            ", + + "
            MyList<? extends @WldB(value=\"m\") java.lang.String"
            +                + "> returnWcExtends()
            "); // Test for receiver annotations (Receivers.java). - { "typeannos/DefaultUnmodified.html", - "
            void withException(@RcvrA " +
            -            "DefaultUnmodified this)\n" +
            -            "            throws java." +
            -            "lang.Exception
            " - }, - { "typeannos/DefaultUnmodified.html", - "
            java.lang.String nonVoid(@RcvrA @RcvrB" +
            -            "(value=\"m\")" +
            -            " DefaultUnmodified this)
            " - }, - { "typeannos/DefaultUnmodified.html", - "
            <T extends java.lang.Runnable> void accept(" +
            -            "@RcvrA DefaultUnmodified this,\n" +
            -            "                                           T r)\n" +
            -            "                                    throws java.lang.Exception
            " - }, - { "typeannos/PublicModified.html", - "
            public final java.lang.String nonVoid(" +
            -            "@RcvrA PublicModified this)
            " - }, - { "typeannos/PublicModified.html", - "
            public final <T extends java.lang.Runnable> " +
            -            "void accept(@RcvrA PublicModified this,\n" +
            -            "                                                        T r)\n" +
            -            "                                                 throws java.lang.Exception
            " - }, - { "typeannos/WithValue.html", - "
            <T extends java.lang.Runnable> void accept(" +
            -            "@RcvrB(" +
            -            "value=\"m\") WithValue this,\n" +
            -            "                                           T r)\n" +
            -            "                                    throws java.lang.Exception
            " - }, - { "typeannos/WithFinal.html", - "
            java.lang.String nonVoid(@RcvrB(value=\"m\") WithFinal" +
            -            " this)
            " - }, - { "typeannos/WithBody.html", - "
            void field(@RcvrA WithBody this)
            " - }, - { "typeannos/Generic2.html", - "
            void test2(@RcvrA Generic2<X> this)
            " - } - }; + checkOutput("typeannos/DefaultUnmodified.html", true, + "
            void withException(@RcvrA "
            +                + "DefaultUnmodified this)\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) { - TestTypeAnnotations tester = new TestTypeAnnotations(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + "
            java.lang.String nonVoid(@RcvrA @RcvrB"
            +                + "(value=\"m\")"
            +                + " DefaultUnmodified this)
            ", + + "
            <T extends java.lang.Runnable> void accept("
            +                + "@RcvrA DefaultUnmodified this,\n"
            +                + "                                           T r)\n"
            +                + "                                    throws java.lang.Exception
            "); + + checkOutput("typeannos/PublicModified.html", true, + "
            public final java.lang.String nonVoid("
            +                + "@RcvrA PublicModified this)
            ", + + "
            public final <T extends java.lang.Runnable> "
            +                + "void accept(@RcvrA PublicModified this,\n"
            +                + "                                                        T r)\n"
            +                + "                                                 throws java.lang.Exception
            "); + + checkOutput("typeannos/WithValue.html", true, + "
            <T extends java.lang.Runnable> void accept("
            +                + "@RcvrB("
            +                + "value=\"m\") WithValue this,\n"
            +                + "                                           T r)\n"
            +                + "                                    throws java.lang.Exception
            "); + + checkOutput("typeannos/WithFinal.html", true, + "
            java.lang.String nonVoid(@RcvrB(value=\"m\") WithFinal"
            +                + " this)
            "); + + checkOutput("typeannos/WithBody.html", true, + "
            void field(@RcvrA WithBody this)
            "); + + checkOutput("typeannos/Generic2.html", true, + "
            void test2(@RcvrA Generic2<X> this)
            "); } } diff --git a/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java b/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java index d07899011ca..0612c6af322 100644 --- a/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java +++ b/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java @@ -30,66 +30,61 @@ * class-use pages. The class/annotation pages should check for type * parameter links in the class/annotation signature section when -linksource is set. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestTypeParameters + * @library ../lib + * @build JavadocTester * @run main TestTypeParameters */ public class TestTypeParameters extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS1 = new String[]{ - "-d", OUTPUT_DIR + "-1", "-use", "-sourcepath", SRC_DIR, - "pkg" - }; - private static final String[] ARGS2 = new String[]{ - "-d", OUTPUT_DIR + "-2", "-linksource", "-sourcepath", SRC_DIR, - "pkg" - }; + public static void main(String... args) throws Exception { + TestTypeParameters tester = new TestTypeParameters(); + tester.runTests(); + } - //Input for string search tests. - private static final String[][] TEST1 = { - { "pkg/C.html", - "
            " - }, - { "pkg/C.html", - "<T> java.lang.Object" - }, - { "pkg/package-summary.html", - "C<E extends Parent>" - }, - { "pkg/class-use/Foo4.html", - "" + - "ClassUseTest3<T extends ParamTest2<java.util.List<? extends " + - "Foo4>>>" - }, - //Nested type parameters - { "pkg/C.html", - "\n" + - "\n" + - "" - }, - }; - private static final String[][] TEST2 = { - { "pkg/ClassUseTest3.html", + @Test + void test1() { + javadoc("-d", "out-1", + "-use", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/C.html", true, + "", + "<T> java.lang.Object"); + + checkOutput("pkg/package-summary.html", true, + "C<E extends Parent>"); + + checkOutput("pkg/class-use/Foo4.html", true, + "" + + "ClassUseTest3<T extends ParamTest2<java.util.List<? extends " + + "Foo4>>>"); + + // Nested type parameters + checkOutput("pkg/C.html", true, + "\n" + + "\n" + + ""); + } + + + @Test + void test2() { + javadoc("-d", "out-2", + "-linksource", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/ClassUseTest3.html", true, "public class " + "ClassUseTest3<T extends ParamTest2<java.util.List<? extends " + - "Foo4>>>" - } - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { - TestTypeParameters tester = new TestTypeParameters(); - tester.run(ARGS1, TEST1, NO_TEST); - tester.run(ARGS2, TEST2, NO_TEST); - tester.printSummary(); + "Foo4>>>"); } } diff --git a/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java b/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java index ff61c3459a7..85e8a42d912 100644 --- a/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java +++ b/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java @@ -27,49 +27,40 @@ * @summary Reference unnamed package as "Unnamed", not empty string. * Generate a package summary for the unnamed package. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestUnnamedPackage * @run main TestUnnamedPackage */ public class TestUnnamedPackage extends JavadocTester { - //Javadoc arguments. - 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 = { - { "package-summary.html", - "

            Package <Unnamed>

            " - }, - { "package-summary.html", - "This is a package comment for the unnamed package." - }, - { "package-summary.html", - "This is a class in the unnamed package." - }, - { "package-tree.html", - "

            Hierarchy For Package <Unnamed>

            " - }, - { "index-all.html", - "title=\"class in <Unnamed>\"" - }, - { "C.html", ""} - }; - private static final String[][] NEGATED_TEST = { - {ERROR_OUTPUT, "BadSource"}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestUnnamedPackage tester = new TestUnnamedPackage(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-sourcepath", testSrc, + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput("package-summary.html", true, + "

            Package <Unnamed>

            ", + "This is a package comment for the unnamed package.", + "This is a class in the unnamed package."); + + checkOutput("package-tree.html", true, + "

            Hierarchy For Package <Unnamed>

            "); + + checkOutput("index-all.html", true, + "title=\"class in <Unnamed>\""); + + checkOutput("C.html", true, + "
            "); + + checkOutput(Output.ERROR, false, + "BadSource"); } } diff --git a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java index 594c61aaf40..572aa097f94 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java +++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java @@ -26,100 +26,76 @@ * @bug 4496290 4985072 7006178 7068595 8016328 * @summary A simple test to determine if -use works. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestUseOption * @run main TestUseOption */ public class TestUseOption extends JavadocTester { - //Input for string search tests. - private static final String[] TEST2 = { - "Field in C1.", - "Field in C2.", - "Field in C4.", - "Field in C5.", - "Field in C6.", - "Field in C7.", - "Field in C8.", - "Method in C1.", - "Method in C2.", - "Method in C4.", - "Method in C5.", - "Method in C6.", - "Method in C7.", - "Method in C8.", - }; - - private static final String[][] TEST3 = { - { "class-use/UsedInC.html", - "Uses of " + - "UsedInC in <Unnamed>" - }, - { "package-use.html", - "" - } - }; - - private static final String[][] TEST4 = { - { "pkg2/class-use/C3.html", - "" + - "Frames" - } - }; - - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2" - }; - - private static final String[] ARGS2 = new String[] { - "-d", OUTPUT_DIR+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2" - }; - - private static final String[] ARGS3 = new String[] { - "-d", OUTPUT_DIR + "-3", "-sourcepath", SRC_DIR, "-use", - SRC_DIR + "/C.java", SRC_DIR + "/UsedInC.java" - }; - - private static final String[] ARGS4 = new String[] { - "-d", OUTPUT_DIR + "-4", "-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 { - String[][] tests = new String[11][2]; - //Eight tests for class use. - for (int i = 0; i < 8; i++) { - tests[i][0] = "pkg1/class-use/C1.html"; - tests[i][1] = "Test " + (i + 1) + " passes"; - } - //Three more tests for package use. - for (int i = 8, j = 1; i < tests.length; i++, j++) { - tests[i][0] = "pkg1/package-use.html"; - tests[i][1] = "Test " + j + " passes"; - } + public static void main(String... args) throws Exception { TestUseOption tester = new TestUseOption(); - tester.run(ARGS, tests, NO_TEST); - tester.printSummary(); - tester.run(ARGS2, NO_TEST, NO_TEST); - String usePageContents = tester.readFileToString("pkg1/class-use/UsedClass.html"); - int prevIndex = -1; - int currentIndex = -1; - for (int i = 0; i < TEST2.length; i++) { - currentIndex = usePageContents.indexOf(TEST2[i]); - System.err.println(TEST2[i] + " at index " + currentIndex); - if (currentIndex < prevIndex) - throw new Exception(TEST2[i] + " is in the wrong order."); - prevIndex = currentIndex; + tester.runTests(); + } + + @Test + void test1() { + javadoc("-d", "out-1", + "-sourcepath", testSrc, + "-use", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + // Eight tests for class use. + for (int i = 1; i <= 8; i++) { + checkOutput("pkg1/class-use/C1.html", true, + "Test " + i + " passes"); } - tester.printSummary(); - tester.run(ARGS3, TEST3, NO_TEST); - tester.run(ARGS4, TEST4, NO_TEST); - tester.printSummary(); + + // Three more tests for package use. + for (int i = 1; i <= 3; i++) { + checkOutput("pkg1/package-use.html", true, + "Test " + i + " passes"); + } + + checkOrder("pkg1/class-use/UsedClass.html", + "Field in C1.", + "Field in C2.", + "Field in C4.", + "Field in C5.", + "Field in C6.", + "Field in C7.", + "Field in C8.", + "Method in C1.", + "Method in C2.", + "Method in C4.", + "Method in C5.", + "Method in C6.", + "Method in C7.", + "Method in C8." + ); + + checkOutput("pkg2/class-use/C3.html", true, + "" + + "Frames" + ); + } + + @Test + void test2() { + javadoc("-d", "out-2", + "-sourcepath", testSrc, + "-use", + testSrc("C.java"), testSrc("UsedInC.java")); + checkExit(Exit.OK); + + checkOutput("class-use/UsedInC.html", true, + "Uses of " + + "UsedInC in <Unnamed>" + ); + checkOutput("package-use.html", true, + "" + ); } } diff --git a/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java b/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java index 1c34fd5295c..9dfe0921493 100644 --- a/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java +++ b/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java @@ -27,141 +27,114 @@ * @summary This test ensures that the value tag works in all * use cases. The explainations for each test case are written below. * @author jamieh - * @library ../lib/ - * @build JavadocTester TestValueTag + * @library ../lib + * @build JavadocTester * @run main TestValueTag */ public class TestValueTag extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = - new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-tag", - "todo", "pkg1", "pkg2" - }; - - private static final String[] ARGS1 = - new String[] { - "-Xdoclint:none", - "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "-tag", - "todo", "pkg1", "pkg2" - }; - - //Input for string search tests. - private static final String[][] TEST = { - //Base case: using @value on a constant. - { "pkg1/Class1.html", - "Result: \"Test 1 passes\""}, - //Retrieve value of constant in same class. - { "pkg1/Class1.html", - "Result: \"Test 2 passes\""}, - { "pkg1/Class1.html", - "Result: \"Test 3 passes\""}, - { "pkg1/Class1.html", - "Result: \"Test 4 passes\""}, - { "pkg1/Class1.html", - "Result: \"Test 5 passes\""}, - { "pkg1/Class1.html", - "Result: \"Test 6 passes\""}, - //Retrieve value of constant in different class. - { "pkg1/Class2.html", - "Result: \"Test 7 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 8 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 9 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 10 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 11 passes\""}, - //Retrieve value of constant in different package - { "pkg1/Class2.html", - "Result: \"Test 12 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 13 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 14 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 15 passes\""}, - { "pkg1/Class2.html", - "Result: \"Test 16 passes\""}, - //Retrieve value of constant from a package page - { "pkg2/package-summary.html", - "Result: \"Test 17 passes\""}, - //Test @value tag used with custom tag. - { "pkg1/CustomTagUsage.html", - "
            Todo:
            \n" + - "
            the value of this constant is 55.
            "}, - //Test @value errors printed dues to invalid use or when used with - //non-constant or with bad references. - {ERROR_OUTPUT,"error: value does not refer to a constant\n" + - " * Result: {@value TEST_12_ERROR}" - }, - {ERROR_OUTPUT,"error: {@value} not allowed here\n" + - " * Result: {@value}" - }, - {ERROR_OUTPUT,"error: value does not refer to a constant\n" + - " * Result: {@value NULL}" - }, - {ERROR_OUTPUT,"error: {@value} not allowed here\n" + - " * Invalid (null): {@value}" - }, - {ERROR_OUTPUT,"error: {@value} not allowed here\n" + - " * Invalid (non-constant field): {@value}" - }, - {ERROR_OUTPUT,"error: value does not refer to a constant\n" + - " * Here is a bad value reference: {@value UnknownClass#unknownConstant}" - }, - {ERROR_OUTPUT,"error: reference not found\n" + - " * Here is a bad value reference: {@value UnknownClass#unknownConstant}" - }, - {ERROR_OUTPUT,"error: {@value} not allowed here\n" + - " * @todo the value of this constant is {@value}" - } - }; - private static final String[][] TEST1 = { - //Test @value warning printed when used with non-constant. - {WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " + - "can only be used in constants." - }, - {WARNING_OUTPUT,"warning - @value tag (which references NULL) " + - "can only be used in constants." - }, - {WARNING_OUTPUT,"warning - @value tag (which references TEST_12_ERROR) " + - "can only be used in constants." - }, - //Test warning printed for bad reference. - {WARNING_OUTPUT,"warning - UnknownClass#unknownConstant (referenced by " + - "@value tag) is an unknown reference." - }, - //Test warning printed for invalid use of @value. - {WARNING_OUTPUT,"warning - @value tag cannot be used here." - } - }; - private static final String[][] NEGATED_TEST = { - //Base case: using @value on a constant. - { "pkg1/Class1.html", - "Result: \"Test 12 " + - "generates an error message\""}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestValueTag tester = new TestValueTag(); - tester.run(ARGS, TEST, NEGATED_TEST); - checkForException(tester); - tester.run(ARGS1, TEST1, NO_TEST); - checkForException(tester); - tester.printSummary(); + tester.runTests(); } - public static void checkForException(TestValueTag tester) { - if (tester.getErrorOutput().contains("DocletAbortException")) { - throw new AssertionError("javadoc threw DocletAbortException"); - } + @Test + void test1() { + javadoc("-d", "out1", + "-sourcepath", testSrc, + "-tag", "todo", + "pkg1", "pkg2"); + checkExit(Exit.FAILED); + + checkOutput("pkg1/Class1.html", true, + // Base case: using @value on a constant. + "Result: \"Test 1 passes\"", + // Retrieve value of constant in same class. + "Result: \"Test 2 passes\"", + "Result: \"Test 3 passes\"", + "Result: \"Test 4 passes\"", + "Result: \"Test 5 passes\"", + "Result: \"Test 6 passes\""); + + checkOutput("pkg1/Class2.html", true, + // Retrieve value of constant in different class. + "Result: \"Test 7 passes\"", + "Result: \"Test 8 passes\"", + "Result: \"Test 9 passes\"", + "Result: \"Test 10 passes\"", + "Result: \"Test 11 passes\"", + // Retrieve value of constant in different package + "Result: \"Test 12 passes\"", + "Result: \"Test 13 passes\"", + "Result: \"Test 14 passes\"", + "Result: \"Test 15 passes\"", + "Result: \"Test 16 passes\""); + + checkOutput("pkg2/package-summary.html", true, + // Retrieve value of constant from a package page + "Result: \"Test 17 passes\""); + + checkOutput("pkg1/CustomTagUsage.html", true, + // Test @value tag used with custom tag. + "
            Todo:
            \n" + + "
            the value of this constant is 55.
            "); + + checkOutput(Output.ERROR, true, + // Test @value errors printed due to invalid use or when used with + // non-constant or with bad references. + "error: value does not refer to a constant\n" + + " * Result: {@value TEST_12_ERROR}", + "error: {@value} not allowed here\n" + + " * Result: {@value}", + "error: value does not refer to a constant\n" + + " * Result: {@value NULL}", + "error: {@value} not allowed here\n" + + " * Invalid (null): {@value}", + "error: {@value} not allowed here\n" + + " * Invalid (non-constant field): {@value}", + "error: value does not refer to a constant\n" + + " * Here is a bad value reference: {@value UnknownClass#unknownConstant}", + "error: reference not found\n" + + " * Here is a bad value reference: {@value UnknownClass#unknownConstant}", + "error: {@value} not allowed here\n" + + " * @todo the value of this constant is {@value}" + ); + + checkOutput("pkg1/Class1.html", false, + //Base case: using @value on a constant. + "Result: \"Test 12 " + + "generates an error message\""); + + checkForException(); + } + + @Test() + void test2() { + javadoc("-Xdoclint:none", + "-d", "out2", + "-sourcepath", testSrc, + "-tag", "todo", + "pkg1", "pkg2"); + checkExit(Exit.OK); + checkOutput(Output.WARNING, true, + //Test @value warning printed when used with non-constant. + "warning - @value tag (which references nonConstant) " + + "can only be used in constants.", + "warning - @value tag (which references NULL) " + + "can only be used in constants.", + "warning - @value tag (which references TEST_12_ERROR) " + + "can only be used in constants.", + //Test warning printed for bad reference. + "warning - UnknownClass#unknownConstant (referenced by " + + "@value tag) is an unknown reference.", + //Test warning printed for invalid use of @value. + "warning - @value tag cannot be used here." + ); + checkForException(); + } + + void checkForException() { + checkOutput(Output.STDERR, false, "DocletAbortException"); } } diff --git a/langtools/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java b/langtools/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java index 637d4d6ee24..8d090f9bf5a 100644 --- a/langtools/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java +++ b/langtools/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java @@ -24,33 +24,31 @@ /* * @test * @bug 4693440 - * @summary Test to make sure that warning is printed when bad paramenter + * @summary Test to make sure that warning is printed when bad parameter * name is used with param. * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestWarnBadParamNames * @run main TestWarnBadParamNames */ public class TestWarnBadParamNames extends JavadocTester { - private static final String[][] TEST = { - {WARNING_OUTPUT, "warning - @param argument \"int\" is not a parameter name."}, - {WARNING_OUTPUT, "warning - @param argument \"IDontExist\" is not a parameter name."}, - {WARNING_OUTPUT, "warning - Parameter \"arg\" is documented more than once."}, - }; - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_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) { + public static void main(String... args) throws Exception { TestWarnBadParamNames tester = new TestWarnBadParamNames(); - tester.run(ARGS, TEST, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-Xdoclint:none", + "-d", "out", + testSrc("C.java")); + checkExit(Exit.OK); + + checkOutput(Output.WARNING, true, + "warning - @param argument \"int\" is not a parameter name.", + "warning - @param argument \"IDontExist\" is not a parameter name.", + "warning - Parameter \"arg\" is documented more than once."); } } diff --git a/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java b/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java index c2c13ab736a..8554624ac48 100644 --- a/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java +++ b/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java @@ -30,55 +30,50 @@ * a "link unresolved" warning. * Make sure error message starts with "error -". * @author jamieh - * @library ../lib/ + * @library ../lib * @build JavadocTester - * @build TestWarnings * @run main TestWarnings */ public class TestWarnings extends JavadocTester { - - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg" - }; - - private static final String[] ARGS2 = new String[] { - "-Xdoclint:none", "-d", OUTPUT_DIR + "-2", "-private", "-sourcepath", SRC_DIR, - "pkg" - }; - - //Input for string search tests. - private static final String[][] TEST = { - {WARNING_OUTPUT, - "X.java:11: warning - Missing closing '}' character for inline tag"}, - {ERROR_OUTPUT, - "package.html: error - Body tag missing from HTML"}, - - }; - private static final String[][] NEGATED_TEST = { - { "pkg/X.html", "can't find m()"}, - { "pkg/X.html", "can't find X()"}, - { "pkg/X.html", "can't find f"}, - }; - - private static final String[][] TEST2 = { - { "pkg/X.html", - "m()
            "}, - { "pkg/X.html", - "X()
            "}, - { "pkg/X.html", - "f
            "}, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestWarnings tester = new TestWarnings(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.run(ARGS2, TEST2, NO_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testDefault() { + javadoc("-Xdoclint:none", + "-d", "out-default", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.FAILED); // TODO: investigate; suspect bad input HTML + + checkOutput(Output.WARNING, true, + "X.java:11: warning - Missing closing '}' character for inline tag"); + checkOutput(Output.ERROR, true, + "package.html: error - Body tag missing from HTML"); + + checkOutput("pkg/X.html", false, + "can't find m()"); + checkOutput("pkg/X.html", false, + "can't find X()"); + checkOutput("pkg/X.html", false, + "can't find f"); + } + + @Test + void testPrivate() { + javadoc("-Xdoclint:none", + "-d", "out-private", + "-private", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.FAILED); // TODO: investigate; suspect bad input HTML + + checkOutput("pkg/X.html", true, + "m()
            ", + "X()
            ", + "f
            "); } } diff --git a/langtools/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java b/langtools/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java index cfeb106b1ef..060fbcee19c 100644 --- a/langtools/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java +++ b/langtools/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java @@ -26,180 +26,192 @@ * @bug 8016675 8026736 * @summary Test for window title. * @author Bhavesh Patel - * @library ../lib/ - * @build JavadocTester TestWindowTitle + * @library ../lib + * @build JavadocTester * @run main TestWindowTitle */ - public class TestWindowTitle extends JavadocTester { - //Window title with JavaScript special characters. - private static final String TITLE_JS_CHARS = - "Testing \"Window 'Title'\" with a \\ backslash and a / " + - "forward slash and a \u00e8 unicode char also a tab and also a " + - "\t special character another \u0002 unicode)"; - private static final String[] ARGS_JS_CHARS = new String[]{ - "-d", OUTPUT_DIR + "-1", "-windowtitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] TEST_JS_CHARS = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + - "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + - "also a tab and also a \\t special character another \\u0002 unicode))\";" - }, - }; - private static final String[][] NEG_TEST_JS_CHARS = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing \"Window \'Title\'\" " + - "with a \\ backslash and a / forward slash and a \u00E8 unicode char " + - "also a tab and also a \t special character another \u0002 unicode))\";" - } - }; - - //Window title with a script tag. - private static final String TITLE_SCRIPT_TAG = - "Testing script tag in title ."; - private static final String[] ARGS_SCRIPT_TAG = new String[]{ - "-d", OUTPUT_DIR + "-2", "-windowtitle", TITLE_SCRIPT_TAG, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] TEST_SCRIPT_TAG = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing script tag in title alert" + - "(\\\"Should not pop up\\\").)\";" - }, - { "p2/C2.html", - "parent.document.title=\"C2 (Testing script tag in title alert" + - "(\\\"Should not pop up\\\").)\";" - } - }; - private static final String[][] NEG_TEST_SCRIPT_TAG = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing script tag in title .)\";" - }, - { "p2/C2.html", - "parent.document.title=\"C2 (Testing script tag in title .)\";" - } - }; - - //Window title with other HTML tags. - private static final String TITLE_HTML_TAGS = - "Testing another

            HTML

            tag. Another

            tag

            . A " + - "tag with attributes. "; - private static final String[] ARGS_EMPTY_TAGS = new String[]{ - "-d", OUTPUT_DIR + "-5", "-windowtitle", TITLE_EMPTY_TAGS, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] TEST_EMPTY_TAGS = { - { "overview-summary.html", - "parent.document.title=\"Overview\";" - } - }; - private static final String[][] NEG_TEST_EMPTY_TAGS = { - { "overview-summary.html", - "parent.document.title=\"Overview ()\";" - } - }; - - //Window title with unicode characters. - private static final String TITLE_UNICODE_CHARS = - "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e."; - private static final String[] ARGS_UNICODE_CHARS = new String[]{ - "-d", OUTPUT_DIR + "-6", "-windowtitle", TITLE_UNICODE_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] TEST_UNICODE_CHARS = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing unicode alert(\\\"Should " + - "not pop up\\\").)\";" - } - }; - private static final String[][] NEG_TEST_UNICODE_CHARS = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing unicode .)\";" - } - }; - - //An empty window title. - private static final String TITLE_EMPTY = - ""; - private static final String[] ARGS_EMPTY_TITLE = new String[]{ - "-d", OUTPUT_DIR + "-7", "-windowtitle", TITLE_EMPTY, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] TEST_EMPTY = { - { "overview-summary.html", - "parent.document.title=\"Overview\";" - } - }; - - //Test doctitle. - private static final String[] ARGS_DOCTITLE = new String[]{ - "-d", OUTPUT_DIR + "-8", "-doctitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" - }; - private static final String[][] NEG_TEST_DOCTITLE = { - { "overview-summary.html", - "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + - "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + - "also a tab and also a \\t special character another \\u0002 unicode)\";" - }, - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestWindowTitle tester = new TestWindowTitle(); - tester.run(ARGS_JS_CHARS, TEST_JS_CHARS, NEG_TEST_JS_CHARS); - tester.run(ARGS_SCRIPT_TAG, TEST_SCRIPT_TAG, NEG_TEST_SCRIPT_TAG); - tester.run(ARGS_HTML_TAGS, TEST_HTML_TAGS, NEG_TEST_HTML_TAGS); - tester.run(ARGS_HTML_ENTITIES, TEST_HTML_ENTITIES, NEG_TEST_HTML_ENTITIES); - tester.run(ARGS_EMPTY_TAGS, TEST_EMPTY_TAGS, NEG_TEST_EMPTY_TAGS); - tester.run(ARGS_UNICODE_CHARS, TEST_UNICODE_CHARS, NEG_TEST_UNICODE_CHARS); - tester.run(ARGS_EMPTY_TITLE, TEST_EMPTY, NO_TEST); - tester.run(ARGS_DOCTITLE, NO_TEST, NEG_TEST_DOCTITLE); + tester.runTests(); tester.printSummary(); } + + @Test + void testJavaScriptChars() { + // Window title with JavaScript special characters. + String title = "Testing \"Window 'Title'\" with a \\ backslash and a / " + + "forward slash and a \u00e8 unicode char also a tab and also a " + + "\t special character another \u0002 unicode)"; + + javadoc("-d", "out-js-chars", + "-windowtitle", title, + "-sourcepath", testSrc, + "p1", "p2"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", true, + "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + + "also a tab and also a \\t special character another \\u0002 unicode))\";" + ); + + checkOutput("overview-summary.html", false, + "parent.document.title=\"Overview (Testing \"Window \'Title\'\" " + + "with a \\ backslash and a / forward slash and a \u00E8 unicode char " + + "also a tab and also a \t special character another \u0002 unicode))\";" + ); + } + + @Test + void testScriptTag() { + // Window title with a script tag. + String title = "Testing script tag in title ."; + + javadoc("-d", "out-script", + "-windowtitle", title, + "-sourcepath", testSrc, + "p1", "p2"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", true, + "parent.document.title=\"Overview (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" + ); + + checkOutput("p2/C2.html", true, + "parent.document.title=\"C2 (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" + ); + + checkOutput("overview-summary.html", false, + "parent.document.title=\"Overview (Testing script tag in title .)\";" + ); + + checkOutput("p2/C2.html", false, + "parent.document.title=\"C2 (Testing script tag in title .)\";" + ); + } + + @Test + void testHtmlTags() { + // Window title with other HTML tags. + String title = "Testing another

            HTML

            tag. Another

            tag

            . A " + + "tag with attributes. "; + + javadoc("-d", "out-empty-tags", + "-windowtitle", title, + "-sourcepath", testSrc, + "p1", "p2"); + + checkOutput("overview-summary.html", true, + "parent.document.title=\"Overview\";" + ); + + checkOutput("overview-summary.html", false, + "parent.document.title=\"Overview ()\";" + ); + } + + @Test + void testUnicode() { + //Window title with unicode characters. + String title = "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e."; + + javadoc("-d", "out-unicode", + "-windowtitle", title, + "-sourcepath", testSrc, + "p1", "p2"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", true, + "parent.document.title=\"Overview (Testing unicode alert(\\\"Should " + + "not pop up\\\").)\";" + ); + + checkOutput("overview-summary.html", false, + "parent.document.title=\"Overview (Testing unicode .)\";" + ); + } + + @Test + void testEmpty() { + // An empty window title. + String title = ""; + javadoc("-d", "out-empty", + "-windowtitle", title, + "-sourcepath", testSrc, "p1", "p2"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", true, + "parent.document.title=\"Overview\";" + ); + } + + @Test + void testDocTitle() { + // Window title with JavaScript special characters, specified with -doctitle + String title = "Testing \"Window 'Title'\" with a \\ backslash and a / " + + "forward slash and a \u00e8 unicode char also a tab and also a " + + "\t special character another \u0002 unicode)"; + + javadoc("-d", "out-doctitle", + "-doctitle", title, + "-sourcepath", testSrc, + "p1", "p2"); + checkExit(Exit.OK); + + checkOutput("overview-summary.html", false, + "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + + "also a tab and also a \\t special character another \\u0002 unicode)\";" + ); + } } diff --git a/langtools/test/com/sun/javadoc/testXOption/TestXOption.java b/langtools/test/com/sun/javadoc/testXOption/TestXOption.java index 8d21b6ee51f..4227d6a40bc 100644 --- a/langtools/test/com/sun/javadoc/testXOption/TestXOption.java +++ b/langtools/test/com/sun/javadoc/testXOption/TestXOption.java @@ -25,43 +25,48 @@ * @test * @bug 8007687 * @summary Make sure that the -X option works properly. - * @library ../lib/ - * @build JavadocTester TestXOption + * @library ../lib + * @build JavadocTester * @run main TestXOption */ public class TestXOption extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-X", - SRC_DIR + "/TestXOption.java" - }; - - private static final String[] ARGS2 = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, - SRC_DIR + "/TestXOption.java" - }; - - private static final String[][] TEST = { - {NOTICE_OUTPUT, "-Xmaxerrs "}, - {NOTICE_OUTPUT, "-Xmaxwarns "}, - {STANDARD_OUTPUT, "-Xdocrootparent "}, - {STANDARD_OUTPUT, "-Xdoclint "}, - {STANDARD_OUTPUT, "-Xdoclint:"}, - }; - - //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) { + public static void main(String... args) throws Exception { TestXOption tester = new TestXOption(); - int actualExitCode = tester.run(ARGS, TEST, NO_TEST); - tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode); - tester.printSummary(); + tester.runTests(); + } + + @Test + void testWithOption() { + javadoc("-d", "out1", + "-sourcepath", testSrc, + "-X", + testSrc("TestXOption.java")); + checkExit(Exit.OK); + checkOutput(true); + } + + @Test + void testWithoutOption() { + javadoc("-d", "out2", + "-sourcepath", testSrc, + testSrc("TestXOption.java")); + checkExit(Exit.OK); + checkOutput(false); + } + + private void checkOutput(boolean expectFound) { + // TODO: It's an ugly hidden side-effect of the current doclet API + // that the -X output from the tool and the -X output from the doclet + // come out on different streams! + // When we clean up the doclet API, this should be rationalized. + checkOutput(Output.NOTICE, expectFound, + "-Xmaxerrs ", + "-Xmaxwarns "); + checkOutput(Output.STDOUT, expectFound, + "-Xdocrootparent ", + "-Xdoclint ", + "-Xdoclint:"); } } diff --git a/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java b/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java index d2ab2abcedc..00df273bad8 100644 --- a/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java +++ b/langtools/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java @@ -27,91 +27,84 @@ * @summary Smoke test for ensuring that annotations are emitted to javadoc * * @author Mahmood Ali - * @library ../../lib/ + * @library ../../lib * @ignore * @build JavadocTester - * @build TestSmoke * @run main TestSmoke */ public class TestSmoke extends JavadocTester { - //Javadoc arguments. - private static final String[] ARGS = new String[] { - "-d", OUTPUT_DIR, "-private", "-sourcepath", SRC_DIR, "pkg" - }; - - //Input for string search tests. - private static final String[][] TEST = { - { "pkg/T0x1C.html", "@DA"}, - { "pkg/T0x1D.html", "@DA"}, - { "pkg/T0x0D.html", "@DA"}, - { "pkg/T0x06.html", "@DA"}, - { "pkg/T0x0B.html", "@DA"}, - { "pkg/T0x0F.html", "@DA"}, - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x20.html", "@DA"}, - */ - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x20A.html", "@DTPA"}, - */ - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x20B.html", "@DA"}, - */ - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x22.html", "@DA"}, - */ - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x22A.html", "@DTPA"}, - */ - /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java - { "pkg/T0x22B.html", "@DA"}, - */ - { "pkg/T0x10.html", "@DA"}, - { "pkg/T0x10A.html", "@DA"}, - { "pkg/T0x12.html", "@DA"}, - { "pkg/T0x11.html", "@DA"}, - { "pkg/T0x13.html", "@DA"}, - { "pkg/T0x15.html", "@DA"}, - { "pkg/T0x14.html", "@DA"}, - { "pkg/T0x16.html", "@DA"} - }; - - private static final String[][] NEGATED_TEST = { - { "pkg/T0x1C.html", "@A"}, - { "pkg/T0x1D.html", "@A"}, - { "pkg/T0x00.html", "@A"}, - { "pkg/T0x01.html", "@A"}, - { "pkg/T0x02.html", "@A"}, - { "pkg/T0x04.html", "@A"}, - { "pkg/T0x08.html", "@A"}, - { "pkg/T0x0D.html", "@A"}, - { "pkg/T0x06.html", "@A"}, - { "pkg/T0x0B.html", "@A"}, - { "pkg/T0x0F.html", "@A"}, - { "pkg/T0x20.html", "@A"}, - { "pkg/T0x20A.html", "@A"}, - { "pkg/T0x20B.html", "@A"}, - { "pkg/T0x22.html", "@A"}, - { "pkg/T0x22A.html", "@A"}, - { "pkg/T0x22B.html", "@A"}, - { "pkg/T0x10.html", "@A"}, - { "pkg/T0x10A.html", "@A"}, - { "pkg/T0x12.html", "@A"}, - { "pkg/T0x11.html", "@A"}, - { "pkg/T0x13.html", "@A"}, - { "pkg/T0x15.html", "@A"}, - { "pkg/T0x14.html", "@A"}, - { "pkg/T0x16.html", "@A"} - }; - - /** - * The entry point of the test. - * @param args the array of command line arguments. - */ - public static void main(String[] args) { + public static void main(String... args) throws Exception { TestSmoke tester = new TestSmoke(); - tester.run(ARGS, TEST, NEGATED_TEST); - tester.printSummary(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-private", + "-sourcepath", testSrc, + "pkg"); + checkExit(Exit.OK); + + checkOutput("pkg/T0x1C.html", true, "@DA"); + checkOutput("pkg/T0x1D.html", true, "@DA"); + checkOutput("pkg/T0x0D.html", true, "@DA"); + checkOutput("pkg/T0x06.html", true, "@DA"); + checkOutput("pkg/T0x0B.html", true, "@DA"); + checkOutput("pkg/T0x0F.html", true, "@DA"); + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x20.html", true, "@DA"); + */ + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x20A.html", true, "@DTPA"); + */ + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x20B.html", true, "@DA"); + */ + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x22.html", true, "@DA"); + */ + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x22A.html", true, "@DTPA"); + */ + /* @ignore 8013406: Test cases fail in javadoc test TestSmoke.java + checkOutput("pkg/T0x22B.html", true, "@DA"); + */ + checkOutput("pkg/T0x10.html", true, "@DA"); + checkOutput("pkg/T0x10A.html", true, "@DA"); + checkOutput("pkg/T0x12.html", true, "@DA"); + checkOutput("pkg/T0x11.html", true, "@DA"); + checkOutput("pkg/T0x13.html", true, "@DA"); + checkOutput("pkg/T0x15.html", true, "@DA"); + checkOutput("pkg/T0x14.html", true, "@DA"); + checkOutput("pkg/T0x16.html", true, "@DA"); + + checkOutput("pkg/T0x1C.html", false, "@A"); + checkOutput("pkg/T0x1D.html", false, "@A"); + checkOutput("pkg/T0x00.html", false, "@A"); + checkOutput("pkg/T0x01.html", false, "@A"); + checkOutput("pkg/T0x02.html", false, "@A"); + checkOutput("pkg/T0x04.html", false, "@A"); + checkOutput("pkg/T0x08.html", false, "@A"); + checkOutput("pkg/T0x0D.html", false, "@A"); + checkOutput("pkg/T0x06.html", false, "@A"); + checkOutput("pkg/T0x0B.html", false, "@A"); + checkOutput("pkg/T0x0F.html", false, "@A"); + checkOutput("pkg/T0x20.html", false, "@A"); + checkOutput("pkg/T0x20A.html", false, "@A"); + checkOutput("pkg/T0x20B.html", false, "@A"); + checkOutput("pkg/T0x22.html", false, "@A"); + checkOutput("pkg/T0x22A.html", false, "@A"); + checkOutput("pkg/T0x22B.html", false, "@A"); + checkOutput("pkg/T0x10.html", false, "@A"); + checkOutput("pkg/T0x10A.html", false, "@A"); + checkOutput("pkg/T0x12.html", false, "@A"); + checkOutput("pkg/T0x11.html", false, "@A"); + checkOutput("pkg/T0x13.html", false, "@A"); + checkOutput("pkg/T0x15.html", false, "@A"); + checkOutput("pkg/T0x14.html", false, "@A"); + checkOutput("pkg/T0x16.html", false, "@A"); } } diff --git a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java index 5896d6e9dda..a3a627fa578 100644 --- a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java +++ b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java @@ -1,30 +1,8 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8029569 + * @test /nodynamiccopyright/ + * @bug 8029569 8037379 * @summary internal javac cast exception when resolving varargs ambiguity + * fix for JDK-8029569 doesn't cover all possible cases * @compile/fail/ref=VarargsAmbiguityCrashTest.out -XDrawDiagnostics VarargsAmbiguityCrashTest.java */ diff --git a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out index 28991e006ce..5cf8fb0be38 100644 --- a/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out +++ b/langtools/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out @@ -1,2 +1,2 @@ -VarargsAmbiguityCrashTest.java:33:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest +VarargsAmbiguityCrashTest.java:11:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest 1 error diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java index c1d226a3b78..2493edfbf9e 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java @@ -42,7 +42,7 @@ import com.sun.tools.classfile.TypeAnnotation.TargetType; public class Driver { - private static final PrintStream out = System.out; + private static final PrintStream out = System.err; public static void main(String[] args) throws Exception { if (args.length == 0 || args.length > 1) diff --git a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java new file mode 100644 index 00000000000..4e292488ac0 --- /dev/null +++ b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8040822 + * @summary Check that all TaskEvents are balanced. + */ + +import java.io.*; +import java.net.URI; +import java.util.*; +import java.util.Map.Entry; + +import javax.tools.*; + +import com.sun.source.util.*; +import com.sun.source.util.TaskEvent.Kind; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.comp.CompileStates.CompileState; + +public class EventsBalancedTest { + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + + public static void main(String... args) throws IOException { + new EventsBalancedTest().test(); + } + + void test() throws IOException { + TestSource a = new TestSource("B", "class B extends A { }"); + TestSource b = new TestSource("A", "abstract class A { }"); + + test(null, Arrays.asList(a, b)); + test(null, Arrays.asList(b, a)); + test(Arrays.asList("-XD-relax"), Arrays.asList(a, b)); + test(Arrays.asList("-XD-relax"), Arrays.asList(b, a)); + + for (CompileState stop : CompileState.values()) { + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, + "-XDshouldStopPolicyIfError=" + stop), + Arrays.asList(a, b)); + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, + "-XDshouldStopPolicyIfError=" + stop), + Arrays.asList(b, a)); + } + } + + void test(Iterable options, Iterable files) throws IOException { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + TestListener listener = new TestListener(); + JavacTask task = tool.getTask(pw, fm, null, options, null, files); + + task.setTaskListener(listener); + + task.call(); + + for (Entry e : listener.kind2Count.entrySet()) { + if (e.getValue() != null && e.getValue() != 0) { + throw new IllegalStateException("Not balanced event: " + e.getKey()); + } + } + } + + static class TestListener implements TaskListener { + final Map kind2Count = new HashMap<>(); + + int get(Kind k) { + Integer count = kind2Count.get(k); + + if (count == null) + kind2Count.put(k, count = 0); + + return count; + } + + @Override + public void started(TaskEvent e) { + kind2Count.put(e.getKind(), get(e.getKind()) + 1); + } + + @Override + public void finished(TaskEvent e) { + int count = get(e.getKind()); + + if (count <= 0) + throw new IllegalStateException("count<=0 for: " + e.getKind()); + + kind2Count.put(e.getKind(), count - 1); + } + + } + static class TestSource extends SimpleJavaFileObject { + final String content; + public TestSource(String fileName, String content) { + super(URI.create("myfo:/" + fileName + ".java"), JavaFileObject.Kind.SOURCE); + this.content = content; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return content; + } + } + +} diff --git a/langtools/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java b/langtools/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java new file mode 100644 index 00000000000..8b7c170167d --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8028503 + * @summary javac, for method references a primitive type can be added as a bound + * @compile PrimitiveTypeInBoundForMethodRefTest.java + */ + +class PrimitiveTypeInBoundForMethodRefTest { + + interface Mapper { + U map(T t); + } + + static Iterable map(Mapper mapper) { + return null; + } + + static void test() { + Iterable map = map(PrimitiveTypeInBoundForMethodRefTest::length); + } + + public static int length(String s) { + return 0; + } +} diff --git a/langtools/test/tools/javac/generics/typevars/IntersectionSubVar.java b/langtools/test/tools/javac/generics/typevars/IntersectionSubVar.java new file mode 100644 index 00000000000..0293067cb3f --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/IntersectionSubVar.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8042656 + * @summary Subtyping for intersection types containing type variables + * @compile IntersectionSubVar.java + */ + +class IntersectionSubVar { + + interface Box { + void set(T arg); + T get(); + } + + Box glb(Box arg1, Box arg2) { + return null; + } + + void takeBox(Box box) {} + + void test(Box arg1, Box arg2, Box arg3) { + T t = glb(arg1, arg2).get(); // assign T&Cloneable to T + takeBox(arg3); // inference tests Box <: Box + } + +} diff --git a/langtools/test/tools/javac/lambda/MethodReference42.out b/langtools/test/tools/javac/lambda/MethodReference42.out index ab324c44665..1a4309fca62 100644 --- a/langtools/test/tools/javac/lambda/MethodReference42.out +++ b/langtools/test/tools/javac/lambda/MethodReference42.out @@ -1,4 +1,4 @@ -MethodReference42.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference42.SAM1, @811, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) -MethodReference42.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference42.SAM3, @855, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) +MethodReference42.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference42.SAM1, @811, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))) +MethodReference42.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference42.SAM3, @855, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number))) MethodReference42.java:41:9: compiler.err.ref.ambiguous: m4, kindname.method, m4(MethodReference42.SAM2), MethodReference42, kindname.method, m4(MethodReference42.SAM3), MethodReference42 3 errors diff --git a/langtools/test/tools/javac/lambda/MethodReference44.out b/langtools/test/tools/javac/lambda/MethodReference44.out index 56c991c21f9..10681e0130d 100644 --- a/langtools/test/tools/javac/lambda/MethodReference44.out +++ b/langtools/test/tools/javac/lambda/MethodReference44.out @@ -1,4 +1,4 @@ -MethodReference44.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference44.SAM1, @864, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) -MethodReference44.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference44.SAM3, @932, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) +MethodReference44.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference44.SAM1, @864, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))) +MethodReference44.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference44.SAM3, @932, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number))) MethodReference44.java:43:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference44.SAM2), MethodReference44, kindname.method, g4(MethodReference44.SAM3), MethodReference44 3 errors diff --git a/langtools/test/tools/javac/lambda/MostSpecific10.java b/langtools/test/tools/javac/lambda/MostSpecific10.java new file mode 100644 index 00000000000..4e31788d79e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific10.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034223 + * @summary Structural most-specific logic for lambdas, method refs, parens, and conditionals + * @compile MostSpecific10.java + */ +class MostSpecific10 { + + interface GetInt { + int get(); + } + + interface GetInteger { + Integer get(); + } + + void m(GetInt getter) {} + void m(GetInteger getter) {} + + void test(boolean cond) { + m(() -> 23); + m("abc"::length); + m(( () -> 23 )); + m(( "abc"::length )); + m(cond ? () -> 23 : "abc"::length); + m(( cond ? () -> 23 : "abc"::length )); + m(cond ? (() -> 23) : ("abc"::length) ); + m(( cond ? () -> 23 : cond ? ("abc"::length) : (() -> 23) )); + } + +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific11.java b/langtools/test/tools/javac/lambda/MostSpecific11.java new file mode 100644 index 00000000000..9946ddd67ea --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific11.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034223 + * @summary Return type Object is not more specific than return type String + * @compile MostSpecific11.java + */ +class MostSpecific11 { + + interface I { Object run(); } + interface J { String run(); } + + void m(I arg) {} + void m(J arg) {} + + void test() { + m(() -> { throw new RuntimeException(); }); + } + +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific12.java b/langtools/test/tools/javac/lambda/MostSpecific12.java new file mode 100644 index 00000000000..3a82c88358e --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific12.java @@ -0,0 +1,38 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing with inference variables in function parameter types + * @compile/fail/ref=MostSpecific12.out -XDrawDiagnostics MostSpecific12.java + */ +class MostSpecific12 { + + interface I { void take(T arg1, String arg2); } + interface J { void take(String arg1, T arg2); } + interface K { void take(String arg1, String arg2); } + + void m1(I arg) {} + void m1(K arg) {} + + void m2(J arg) {} + void m2(K arg) {} + + void m3(I arg) {} + void m3(J arg) {} + + void test() { + m1((String s1, String s2) -> {}); // ok + m2((String s1, String s2) -> {}); // ok + m3((String s1, String s2) -> {}); // error + + m1(this::referencedMethod); // ok + m2(this::referencedMethod); // ok + m3(this::referencedMethod); // error + + m1(String::compareTo); // ok + m2(String::compareTo); // ok + m3(String::compareTo); // error + } + + void referencedMethod(String s1, String s2) {} + +} diff --git a/langtools/test/tools/javac/lambda/MostSpecific12.out b/langtools/test/tools/javac/lambda/MostSpecific12.out new file mode 100644 index 00000000000..827ba7dd1ec --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific12.out @@ -0,0 +1,4 @@ +MostSpecific12.java:25:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(MostSpecific12.I), MostSpecific12, kindname.method, m3(MostSpecific12.J), MostSpecific12 +MostSpecific12.java:29:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(MostSpecific12.I), MostSpecific12, kindname.method, m3(MostSpecific12.J), MostSpecific12 +MostSpecific12.java:33:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(MostSpecific12.I), MostSpecific12, kindname.method, m3(MostSpecific12.J), MostSpecific12 +3 errors diff --git a/langtools/test/tools/javac/lambda/MostSpecific13.java b/langtools/test/tools/javac/lambda/MostSpecific13.java new file mode 100644 index 00000000000..364bcf961f8 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific13.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing with inference variables in function parameter types + * @compile/fail/ref=MostSpecific13.out -XDrawDiagnostics MostSpecific13.java + */ +class MostSpecific13 { + + interface UnaryOp { T apply(T arg); } + interface IntegerToNumber { Number apply(Integer arg); } + + void m(UnaryOp f) {} + void m(IntegerToNumber f) {} + + void test() { + m((Integer i) -> i); // error + m(this::id); // error + } + + Integer id(Integer arg) { return arg; } +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific13.out b/langtools/test/tools/javac/lambda/MostSpecific13.out new file mode 100644 index 00000000000..42f26242377 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific13.out @@ -0,0 +1,3 @@ +MostSpecific13.java:16:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific13.UnaryOp), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 +MostSpecific13.java:17:9: compiler.err.ref.ambiguous: m, kindname.method, m(MostSpecific13.UnaryOp), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 +2 errors diff --git a/langtools/test/tools/javac/lambda/MostSpecific14.java b/langtools/test/tools/javac/lambda/MostSpecific14.java new file mode 100644 index 00000000000..29e2a621916 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific14.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing for nested functional interface types + * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java + */ +class MostSpecific14 { + interface ToNumber { Number get(); } + interface ToToNumber { ToNumber get(); } + interface Factory { T get(); } + + void m1(Factory> f) {} + void m1(ToToNumber f) {} + + void m2(Factory> f) {} + void m2(ToToNumber f) {} + + void m3(Factory> f) {} + void m3(ToToNumber f) {} + + + void test() { + m1(() -> () -> 23); // ok: choose ToToNumber + m2(() -> () -> 23); // error: ambiguous + m3(() -> () -> 23); // ok: choose Factory> + + m1(() -> this::getInteger); // ok: choose ToToNumber + m2(() -> this::getInteger); // error: ambiguous + m3(() -> this::getInteger); // ok: choose Factory> + } + + Integer getInteger() { return 23; } +} \ No newline at end of file diff --git a/langtools/test/tools/javac/lambda/MostSpecific14.out b/langtools/test/tools/javac/lambda/MostSpecific14.out new file mode 100644 index 00000000000..2c23097bb31 --- /dev/null +++ b/langtools/test/tools/javac/lambda/MostSpecific14.out @@ -0,0 +1,3 @@ +MostSpecific14.java:24:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 +MostSpecific14.java:28:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 +2 errors diff --git a/langtools/test/tools/javac/lambda/TargetType16.java b/langtools/test/tools/javac/lambda/TargetType16.java index 1de0d125b99..5b205876b20 100644 --- a/langtools/test/tools/javac/lambda/TargetType16.java +++ b/langtools/test/tools/javac/lambda/TargetType16.java @@ -1,9 +1,9 @@ /* * @test /nodynamiccopyright/ - * @bug 8003280 + * @bug 8003280 8034223 * @summary Add lambda tests * Check void-compatibility in strict vs. loose conversion contexts - * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java + * @compile TargetType16.java */ class TargetType16 { @@ -20,6 +20,6 @@ class TargetType16 { static void m(SAM2 s2) { } public static void main(String[] args) { - m(() -> { throw new AssertionError(); }); //ambiguous + m(() -> { throw new AssertionError(); }); // prefer SAM2 } } diff --git a/langtools/test/tools/javac/lambda/TargetType16.out b/langtools/test/tools/javac/lambda/TargetType16.out deleted file mode 100644 index f803ca37b38..00000000000 --- a/langtools/test/tools/javac/lambda/TargetType16.out +++ /dev/null @@ -1,2 +0,0 @@ -TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, m(TargetType16.SAM2), TargetType16 -1 error diff --git a/langtools/test/tools/javac/lambda/TargetType23.java b/langtools/test/tools/javac/lambda/TargetType23.java index 0786af38318..bac45e9351e 100644 --- a/langtools/test/tools/javac/lambda/TargetType23.java +++ b/langtools/test/tools/javac/lambda/TargetType23.java @@ -31,7 +31,12 @@ class TargetType23 { void call(Sam2 s) { } void call(Sam3 s) { } + void call2(Sam0 s) { } + void call2(Sam2 s) { } + void call2(Sam3 s) { } + void test() { - call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match + call(()-> { throw new RuntimeException(); }); // ambiguous - call(Sam1) vs. call(Sam2) + call2(()-> { throw new RuntimeException(); }); // ok } } diff --git a/langtools/test/tools/javac/lambda/TargetType23.out b/langtools/test/tools/javac/lambda/TargetType23.out index 2b40d26ccc1..049a5aad417 100644 --- a/langtools/test/tools/javac/lambda/TargetType23.out +++ b/langtools/test/tools/javac/lambda/TargetType23.out @@ -1,2 +1,2 @@ -TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, call(TargetType23.Sam3), TargetType23 +TargetType23.java:39:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam1), TargetType23, kindname.method, call(TargetType23.Sam2), TargetType23 1 error diff --git a/langtools/test/tools/javac/options/xprefer/XPreferTest.java b/langtools/test/tools/javac/options/xprefer/XPreferTest.java index ab2488f8cdc..7d9c6da190e 100644 --- a/langtools/test/tools/javac/options/xprefer/XPreferTest.java +++ b/langtools/test/tools/javac/options/xprefer/XPreferTest.java @@ -26,6 +26,7 @@ * @summary Tests which path is used to represent an implicit type given * various xprefer arguments and multiple .class / .java files involved. * @bug 8028196 + * @ignore 8042839 XPreferTest fails on Windows */ import java.io.File; diff --git a/langtools/test/tools/javac/resolve/AmbiguityErrorTest.java b/langtools/test/tools/javac/resolve/AmbiguityErrorTest.java new file mode 100644 index 00000000000..0641c146806 --- /dev/null +++ b/langtools/test/tools/javac/resolve/AmbiguityErrorTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8041663 + */ + +public class AmbiguityErrorTest { + + public interface A { } + + public interface B extends A { } + + public interface C { + A m(B strategy); + } + + public interface D { + A m(A strategy); + A m(B strategy); + } + + public interface T1 extends C, D { } + public interface T2 extends D, C { } + + int count; + + class T1Impl implements T1, T2 { + public A m(B strategy) { + count++; + return null; + } + public A m(A strategy) { + throw new AssertionError("Should not get here."); + } + } + + public static void main(String... args) { + new AmbiguityErrorTest().test(); + } + + void test() { + T1 t1 = new T1Impl(); + T2 t2 = new T1Impl(); + final B b = new B() { }; + t1.m(b); + t2.m(b); + + if (count != 2) { + throw new IllegalStateException("Did not call the methods properly"); + } + } + +} diff --git a/langtools/test/tools/javac/resolve/ResolveHarness.java b/langtools/test/tools/javac/resolve/ResolveHarness.java index 7d79f1c851f..1abd5c45960 100644 --- a/langtools/test/tools/javac/resolve/ResolveHarness.java +++ b/langtools/test/tools/javac/resolve/ResolveHarness.java @@ -23,8 +23,8 @@ /* * @test - * @bug 7098660 8014649 - * @summary Write better overload resolution/inference tests + * @bug 7098660 8014649 8034223 + * @summary Test harness for overload resolution/inference tests * @library /tools/javac/lib * @build JavacTestingAbstractProcessor ResolveHarness * @run main ResolveHarness diff --git a/langtools/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java b/langtools/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java index 63fc7525af6..2c61182c15a 100644 --- a/langtools/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java +++ b/langtools/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java @@ -23,44 +23,44 @@ @TraceResolve(keys={"compiler.err.ref.ambiguous"}) class PrimitiveOverReferenceVarargsAmbiguous { - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_byte(byte... b) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_byte(Byte... b) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_short(short... s) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_short(Short... s) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_int(int... i) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_int(Integer... i) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_long(long... l) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_long(Long... l) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_float(float... f) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_float(Float... f) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_double(double... d) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_double(Double... d) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_char(char... c) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_char(Character... c) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_bool(boolean... z) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_bool(Boolean... z) {} { diff --git a/langtools/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java b/langtools/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java new file mode 100644 index 00000000000..0ac1598404a --- /dev/null +++ b/langtools/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +@TraceResolve(keys={"compiler.err.ref.ambiguous"}) +class PrimitiveVsReferenceSamePhase { + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_byte(Byte b1, byte b2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_byte(Byte b1, Byte b2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_short(Short s1, short s2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_short(Short s1, Short s2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_int(Integer i1, int i2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_int(Integer i1, Integer i2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_long(Long l1, long l2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_long(Long l1, Long l2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_float(Float f1, float f2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_float(Float f1, Float f2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_double(Double d1, double d2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_double(Double d1, Double d2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_char(Character c1, char c2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_char(Character c1, Character c2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_bool(Boolean z1, boolean z2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_bool(Boolean z1, Boolean z2) {} + + { + m_byte((byte)0, (byte)0); + m_short((short)0, (short)0); + m_int(0, 0); + m_long(0L, 0L); + m_float(0.0f, 0.0f); + m_double(0.0, 0.0); + m_char('?', '?'); + m_bool(false, false); + } +} diff --git a/langtools/test/tools/javac/types/TypeHarness.java b/langtools/test/tools/javac/types/TypeHarness.java index b4837907820..f826c2acecb 100644 --- a/langtools/test/tools/javac/types/TypeHarness.java +++ b/langtools/test/tools/javac/types/TypeHarness.java @@ -255,7 +255,8 @@ public class TypeHarness { public ClassType Class(long flags, Type... typeArgs) { ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol); - csym.type = new ClassType(Type.noType, List.from(typeArgs), csym); + csym.type = new ClassType(Type.noType, List.from(typeArgs), csym, + Type.noAnnotations); ((ClassType)csym.type).supertype_field = predef.objectType; return (ClassType)csym.type; } @@ -301,7 +302,7 @@ public class TypeHarness { } public ArrayType Array(Type elemType) { - return new ArrayType(elemType, predef.arrayClass); + return new ArrayType(elemType, predef.arrayClass, Type.noAnnotations); } public TypeVar TypeVariable() { @@ -310,16 +311,16 @@ public class TypeHarness { public TypeVar TypeVariable(Type bound) { TypeSymbol tvsym = new TypeVariableSymbol(0, syntheticName(), null, predef.noSymbol); - tvsym.type = new TypeVar(tvsym, bound, null); + tvsym.type = new TypeVar(tvsym, bound, null, Type.noAnnotations); return (TypeVar)tvsym.type; } public WildcardType Wildcard(BoundKind bk, Type bound) { - return new WildcardType(bound, bk, predef.boundClass); + return new WildcardType(bound, bk, predef.boundClass, Type.noAnnotations); } public CapturedType CapturedVariable(Type upper, Type lower) { - return new CapturedType(syntheticName(), predef.noSymbol, upper, lower, null); + return new CapturedType(syntheticName(), predef.noSymbol, upper, lower, null, Type.noAnnotations); } public ClassType Intersection(Type classBound, Type... intfBounds) {
            <W extends java.lang.String,V extends " + - "java.util.List>
            java.lang.Object
            <W extends java.lang.String,V extends " + + "java.util.List>
            java.lang.Object
            " + - "UsedInC " + + "UsedInC