# HG changeset patch # User lana # Date 1484939400 0 # Node ID b73702608fc6bf4a4a1a9bd894440e8cfe317046 # Parent 8c70d170e62c0c58b5bc3ba666bd140399b98c9c# Parent 2614e1907a0b7912a8cb3d2b833126a0dc83ba4c Merge diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/AnnotationValueVisitor.java Fri Jan 20 19:10:00 2017 +0000 @@ -68,8 +68,8 @@ * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods * were not used when extending {@code javax.lang.model.*} - * to cover Java SE 8 language features. However, default methods may - * be used in subsequent revisions of the {@code javax.lang.model.*} + * to cover Java SE 8 language features. However, default methods + * are used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher * platform versions. * @@ -90,11 +90,16 @@ R visit(AnnotationValue av, P p); /** - * A convenience method equivalent to {@code v.visit(av, null)}. + * A convenience method equivalent to {@code visit(av, null)}. + * + * @implSpec The default implementation is {@code visit(av, null)}. + * * @param av the value to visit * @return a visitor-specified result */ - R visit(AnnotationValue av); + default R visit(AnnotationValue av) { + return visit(av, null); + } /** * Visits a {@code boolean} value in an annotation. diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Fri Jan 20 19:10:00 2017 +0000 @@ -59,8 +59,8 @@ * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods * were not used when extending {@code javax.lang.model.*} - * to cover Java SE 8 language features. However, default methods may - * be used in subsequent revisions of the {@code javax.lang.model.*} + * to cover Java SE 8 language features. However, default methods + * are used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher * platform versions. * @@ -85,11 +85,16 @@ R visit(Element e, P p); /** - * A convenience method equivalent to {@code v.visit(e, null)}. + * A convenience method equivalent to {@code visit(e, null)}. + * + * @implSpec The default implementation is {@code visit(e, null)}. + * * @param e the element to visit * @return a visitor-specified result */ - R visit(Element e); + default R visit(Element e) { + return visit(e, null); + } /** * Visits a package element. @@ -146,10 +151,16 @@ /** * Visits a module element. + * + * @implSpec Visits a {@code ModuleElement} by calling {@code + * visitUnknown(e, p)}. + * * @param e the element to visit * @param p a visitor-specified parameter * @return a visitor-specified result * @since 9 */ - R visitModule(ModuleElement e, P p); + default R visitModule(ModuleElement e, P p) { + return visitUnknown(e, p); + } } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java Fri Jan 20 19:10:00 2017 +0000 @@ -59,8 +59,8 @@ * javax.lang.model.*} packages bundled in Java SE 8 were required to * also be runnable on Java SE 7. Therefore, default methods * were not used when extending {@code javax.lang.model.*} - * to cover Java SE 8 language features. However, default methods may - * be used in subsequent revisions of the {@code javax.lang.model.*} + * to cover Java SE 8 language features. However, default methods + * are used in subsequent revisions of the {@code javax.lang.model.*} * packages that are only required to run on Java SE 8 and higher * platform versions. * @@ -85,11 +85,16 @@ R visit(TypeMirror t, P p); /** - * A convenience method equivalent to {@code v.visit(t, null)}. + * A convenience method equivalent to {@code visit(t, null)}. + * + * @implSpec The default implementation is {@code visit(t, null)}. + * * @param t the element to visit * @return a visitor-specified result */ - R visit(TypeMirror t); + default R visit(TypeMirror t) { + return visit(t, null); + } /** * Visits a primitive type. diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -65,17 +65,17 @@ * @see AbstractAnnotationValueVisitor8 * @see AbstractAnnotationValueVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public abstract class AbstractAnnotationValueVisitor6 implements AnnotationValueVisitor { /** * Constructor for concrete subclasses to call. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected AbstractAnnotationValueVisitor6() {} /** diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -59,13 +59,13 @@ * @see AbstractAnnotationValueVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public abstract class AbstractAnnotationValueVisitor7 extends AbstractAnnotationValueVisitor6 { /** * Constructor for concrete subclasses to call. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected AbstractAnnotationValueVisitor7() { super(); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -67,15 +67,15 @@ * @see AbstractElementVisitor8 * @see AbstractElementVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public abstract class AbstractElementVisitor6 implements ElementVisitor { /** * Constructor for concrete subclasses to call. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected AbstractElementVisitor6(){} /** @@ -139,6 +139,7 @@ */ @Override public R visitModule(ModuleElement e, P p) { - return visitUnknown(e, p); + // Use implementation from interface default method + return ElementVisitor.super.visitModule(e, p); } } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -63,12 +63,12 @@ * @see AbstractElementVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public abstract class AbstractElementVisitor7 extends AbstractElementVisitor6 { /** * Constructor for concrete subclasses to call. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected AbstractElementVisitor7(){ super(); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -66,15 +66,15 @@ * @see AbstractTypeVisitor8 * @see AbstractTypeVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public abstract class AbstractTypeVisitor6 implements TypeVisitor { /** * Constructor for concrete subclasses to call. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected AbstractTypeVisitor6() {} /** diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -63,12 +63,12 @@ * @see AbstractTypeVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public abstract class AbstractTypeVisitor7 extends AbstractTypeVisitor6 { /** * Constructor for concrete subclasses to call. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected AbstractTypeVisitor7() { super(); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -81,17 +81,17 @@ * @see ElementKindVisitor8 * @see ElementKindVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class ElementKindVisitor6 extends SimpleElementVisitor6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected ElementKindVisitor6() { super(null); } @@ -101,7 +101,10 @@ * default value. * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected ElementKindVisitor6(R defaultValue) { super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -76,13 +76,13 @@ * @see ElementKindVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class ElementKindVisitor7 extends ElementKindVisitor6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected ElementKindVisitor7() { super(null); } @@ -93,6 +93,7 @@ * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected ElementKindVisitor7(R defaultValue) { super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java Fri Jan 20 19:10:00 2017 +0000 @@ -92,10 +92,7 @@ * @see ElementScanner8 * @see ElementScanner9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class ElementScanner6 extends AbstractElementVisitor6 { /** @@ -106,7 +103,10 @@ /** * Constructor for concrete subclasses; uses {@code null} for the * default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected ElementScanner6(){ DEFAULT_VALUE = null; } @@ -116,7 +116,10 @@ * default value. * * @param defaultValue the default value + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected ElementScanner6(R defaultValue){ DEFAULT_VALUE = defaultValue; } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java Fri Jan 20 19:10:00 2017 +0000 @@ -89,13 +89,13 @@ * @see ElementScanner9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class ElementScanner7 extends ElementScanner6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected ElementScanner7(){ super(null); } @@ -106,6 +106,7 @@ * * @param defaultValue the default value */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected ElementScanner7(R defaultValue){ super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -74,10 +74,7 @@ * @see SimpleAnnotationValueVisitor8 * @see SimpleAnnotationValueVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleAnnotationValueVisitor6 extends AbstractAnnotationValueVisitor6 { @@ -92,7 +89,10 @@ /** * Constructor for concrete subclasses; uses {@code null} for the * default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleAnnotationValueVisitor6() { super(); DEFAULT_VALUE = null; @@ -103,7 +103,10 @@ * default value. * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleAnnotationValueVisitor6(R defaultValue) { super(); DEFAULT_VALUE = defaultValue; diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -66,13 +66,13 @@ * @see SimpleAnnotationValueVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleAnnotationValueVisitor7 extends SimpleAnnotationValueVisitor6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleAnnotationValueVisitor7() { super(null); } @@ -83,6 +83,7 @@ * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleAnnotationValueVisitor7(R defaultValue) { super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -78,10 +78,7 @@ * @see SimpleElementVisitor8 * @see SimpleElementVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleElementVisitor6 extends AbstractElementVisitor6 { /** @@ -94,7 +91,10 @@ /** * Constructor for concrete subclasses; uses {@code null} for the * default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleElementVisitor6(){ DEFAULT_VALUE = null; } @@ -104,7 +104,10 @@ * default value. * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleElementVisitor6(R defaultValue){ DEFAULT_VALUE = defaultValue; } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -72,13 +72,13 @@ * @see SimpleElementVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleElementVisitor7 extends SimpleElementVisitor6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleElementVisitor7(){ super(null); } @@ -89,6 +89,7 @@ * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleElementVisitor7(R defaultValue){ super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -78,10 +78,7 @@ * @see SimpleTypeVisitor8 * @see SimpleTypeVisitor9 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleTypeVisitor6 extends AbstractTypeVisitor6 { /** @@ -94,7 +91,10 @@ /** * Constructor for concrete subclasses; uses {@code null} for the * default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleTypeVisitor6(){ DEFAULT_VALUE = null; } @@ -104,7 +104,10 @@ * default value. * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected SimpleTypeVisitor6(R defaultValue){ DEFAULT_VALUE = defaultValue; } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -72,13 +72,13 @@ * @see SimpleTypeVisitor9 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleTypeVisitor7 extends SimpleTypeVisitor6 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleTypeVisitor7(){ super(null); } @@ -89,6 +89,7 @@ * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected SimpleTypeVisitor7(R defaultValue){ super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java Fri Jan 20 19:10:00 2017 +0000 @@ -76,16 +76,16 @@ * @see TypeKindVisitor7 * @see TypeKindVisitor8 * @since 1.6 - * @deprecated Release 6 is obsolete; update to a visitor for a newer - * release level. */ -@Deprecated @SupportedSourceVersion(RELEASE_6) public class TypeKindVisitor6 extends SimpleTypeVisitor6 { /** * Constructor for concrete subclasses to call; uses {@code null} * for the default value. + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected TypeKindVisitor6() { super(null); } @@ -96,7 +96,10 @@ * for the default value. * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ + @Deprecated protected TypeKindVisitor6(R defaultValue) { super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java --- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java Fri Jan 20 19:10:00 2017 +0000 @@ -73,13 +73,13 @@ * @see TypeKindVisitor8 * @since 1.7 */ -@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class TypeKindVisitor7 extends TypeKindVisitor6 { /** * Constructor for concrete subclasses to call; uses {@code null} * for the default value. */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected TypeKindVisitor7() { super(null); } @@ -90,6 +90,7 @@ * * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} */ + @SuppressWarnings("deprecation") // Superclass constructor deprecated protected TypeKindVisitor7(R defaultValue) { super(defaultValue); } diff -r 8c70d170e62c -r b73702608fc6 langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java Fri Jan 20 19:10:00 2017 +0000 @@ -98,7 +98,7 @@ * @param t the DocCommentTree to create the path for. */ public DocTreePath(TreePath treePath, DocCommentTree t) { - this.treePath = Objects.requireNonNull(treePath); + this.treePath = treePath; this.docComment = Objects.requireNonNull(t); this.parent = null; this.leaf = t; diff -r 8c70d170e62c -r b73702608fc6 langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -31,6 +31,7 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; +import javax.lang.model.element.PackageElement; import javax.tools.Diagnostic; import javax.tools.FileObject; import javax.tools.JavaCompiler.CompilationTask; @@ -127,17 +128,22 @@ /** * Returns a doc tree path containing the doc comment tree of the given file. - * The file must be an HTML file, in which case the doc comment tree represents the - * contents of the <body> tag, and any enclosing tags are ignored. + * The file must be an HTML file, in which case the doc comment tree represents + * the contents of the {@code } tag, and any enclosing tags are ignored. + * Any references to source code elements contained in {@code @see} and + * {@code {@link}} tags in the doc comment tree will be evaluated in the + * context of the given package element. * Returns {@code null} if no doc comment was found. - * Future releases may support additional file types. * - * @param fileObject the content container - * @return a doc tree path containing the doc comment read from the given file. + * @param fileObject a file object encapsulating the HTML content + * @param packageElement a package element to associate with the given file object + * representing a legacy package.html, null otherwise + * @return a doc tree path containing the doc comment parsed from the given file + * @throws IllegalArgumentException if the fileObject is not an HTML file * * @since 9 */ - public abstract DocTreePath getDocTreePath(FileObject fileObject); + public abstract DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement); /** * Returns the language model element referred to by the leaf node of the given diff -r 8c70d170e62c -r b73702608fc6 langtools/src/jdk.compiler/share/classes/com/sun/tools/doclint/Checker.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/doclint/Checker.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/doclint/Checker.java Fri Jan 20 19:10:00 2017 +0000 @@ -423,7 +423,16 @@ break; case OTHER: - env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName); + switch (t) { + case SCRIPT: + // ", true), // script tag in Lower Case + UC("", true), // script tag in Upper Case + WS("< script >#ALERT", false, "-Xdoclint:none"), // script tag with invalid white space + SP("", true), // script tag with an attribute + ON("x", true), // event handler attribute + URI("x", true); // javascript URI + + /** + * Creates an HTML fragment to be injected into a template. + * @param text the HTML fragment to put into a doc comment or option. + * @param hasScript whether or not this fragment does contain legal JavaScript + * @param opts any additional options to be specified when javadoc is run + */ + Comment(String text, boolean hasScript, String... opts) { + this.text = text; + this.hasScript = hasScript; + this.opts = Arrays.asList(opts); + } + + final String text; + final boolean hasScript; + final List opts; + }; + + /** + * Representative samples of positions in which javadoc may find JavaScript. + * Each template contains a series of strings, which are written to files or inferred as options. + * The first source file implies a corresponding output file which should not be written + * if the comment contains JavaScript and JavaScript is not allowed. + */ + enum Template { + OVR(" overview #COMMENT ", "package p; public class C { }"), + PKGINFO("#COMMENT package p;", "package p; public class C { }"), + PKGHTML("#COMMENT package p;", "package p; public class C { }"), + CLS("package p; #COMMENT public class C { }"), + CON("package p; public class C { #COMMENT public C() { } }"), + FLD("package p; public class C { #COMMENT public int f; }"), + MTH("package p; public class C { #COMMENT public void m() { } }"), + TOP("-top", "lorem #COMMENT ipsum", "package p; public class C { }"), + HDR("-header", "lorem #COMMENT ipsum", "package p; public class C { }"), + FTR("-footer", "lorem #COMMENT ipsum", "package p; public class C { }"), + BTM("-bottom", "lorem #COMMENT ipsum", "package p; public class C { }"), + DTTL("-doctitle", "lorem #COMMENT ipsum", "package p; public class C { }"), + PHDR("-packagesheader", "lorem #COMMENT ipsum", "package p; public class C { }"); + + Template(String... args) { + opts = new ArrayList(); + sources = new ArrayList(); + int i = 0; + while (args[i].startsWith("-")) { + // all options being tested have a single argument that follow the option + opts.add(args[i++]); + opts.add(args[i++]); + } + while(i < args.length) { + sources.add(args[i++]); + } + } + + // groups: 1 or not; 2: package name; 3: class name + private final Pattern pat = + Pattern.compile("(?i)()?.*?(?:package ([a-z]+);.*?(?:class ([a-z]+).*)?)?"); + + /** + * Infer the file in which to write the given source. + * @param dir the base source directory + * @param src the source text + * @return the file in which the source should be written + */ + File getSrcFile(File srcDir, String src) { + String f; + Matcher m = pat.matcher(src); + if (!m.matches()) + throw new Error("match failed"); + if (m.group(3) != null) { + f = m.group(2) + "/" + m.group(3) + ".java"; + } else if (m.group(2) != null) { + f = m.group(2) + "/" + (m.group(1) == null ? "package-info.java" : "package.html"); + } else { + f = "overview.html"; + } + return new File(srcDir, f); + } + + /** + * Get the options to give to javadoc. + * @param srcDir the srcDir to use -overview is needed + * @return + */ + List getOpts(File srcDir) { + if (!opts.isEmpty()) { + return opts; + } else if (sources.get(0).contains("overview")) { + return Arrays.asList("-overview", getSrcFile(srcDir, sources.get(0)).getPath()); + } else { + return Collections.emptyList(); + } + } + + /** + * Gets the output file corresponding to the first source file. + * This file should not be written if the comment contains JavaScript and JavaScripot is + * not allowed. + * @param dir the base output directory + * @return the output file + */ + File getOutFile(File outDir) { + String f; + Matcher m = pat.matcher(sources.get(0)); + if (!m.matches()) + throw new Error("match failed"); + if (m.group(3) != null) { + f = m.group(2) + "/" + m.group(3) + ".html"; + } else if (m.group(2) != null) { + f = m.group(2) + "/package-summary.html"; + } else { + f = "overview-summary.html"; + } + return new File(outDir, f); + } + + final List opts; + final List sources; + }; + + enum Option { + OFF(null), + ON("--allow-script-in-comments"); + + Option(String text) { + this.text = text; + } + + final String text; + }; + + private PrintStream out = System.err; + + public void run() throws Exception { + int count = 0; + for (Template template: Template.values()) { + for (Comment comment: Comment.values()) { + for (Option option: Option.values()) { + if (test(template, comment, option)) { + count++; + } + } + } + } + + out.println(count + " test cases run"); + if (errors > 0) { + throw new Exception(errors + " errors occurred"); + } + } + + boolean test(Template template, Comment comment, Option option) throws IOException { + if (option == Option.ON && !comment.hasScript) { + // skip --allowScriptInComments if comment does not contain JavaScript + return false; + } + + String test = template + "-" + comment + "-" + option; + out.println("Test: " + test); + + File dir = new File(test); + dir.mkdirs(); + File srcDir = new File(dir, "src"); + File outDir = new File(dir, "out"); + + String alert = "alert(\"" + test + "\");"; + for (String src: template.sources) { + writeFile(template.getSrcFile(srcDir, src), + src.replace("#COMMENT", + "/** " + comment.text.replace("#ALERT", alert) + " **/")); + } + + List opts = new ArrayList(); + opts.add("-sourcepath"); + opts.add(srcDir.getPath()); + opts.add("-d"); + opts.add(outDir.getPath()); + if (option.text != null) + opts.add(option.text); + for (String opt: template.getOpts(srcDir)) { + opts.add(opt.replace("#COMMENT", comment.text.replace("#ALERT", alert))); + } + opts.addAll(comment.opts); + opts.add("-noindex"); // index not required; save time/space writing files + opts.add("p"); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = javadoc(opts, pw); + pw.close(); + String log = sw.toString(); + writeFile(new File(dir, "log.txt"), log); + + out.println("opts: " + opts); + out.println(" rc: " + rc); + out.println(" log:"); + out.println(log); + + String ERROR = "Use --allow-script-in-comment"; + File outFile = template.getOutFile(outDir); + + boolean expectErrors = comment.hasScript && (option == Option.OFF); + + if (expectErrors) { + check(rc != 0, "unexpected exit code: " + rc); + check(log.contains(ERROR), "expected error message not found"); + check(!outFile.exists(), "output file found unexpectedly"); + } else { + check(rc == 0, "unexpected exit code: " + rc); + check(!log.contains(ERROR), "error message found"); + check(outFile.exists(), "output file not found"); + } + + out.println(); + return true; + } + + int javadoc(List opts, PrintWriter pw) { + return jdk.javadoc.internal.tool.Main.execute(opts.toArray(new String[opts.size()]), pw); + } + + File writeFile(File f, String text) throws IOException { + f.getParentFile().mkdirs(); + FileWriter fw = new FileWriter(f); + try { + fw.write(text); + } finally { + fw.close(); + } + return f; + } + + void check(boolean cond, String errMessage) { + if (!cond) { + error(errMessage); + } + } + + void error(String message) { + out.println("Error: " + message); + errors++; + } + + int errors = 0; +} + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/jdk/javadoc/tool/treeapi/TestDocTrees.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/tool/treeapi/TestDocTrees.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, 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 8157611 + * @summary test DocTrees is working correctly relative to HTML access + * @modules + * jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @library /tools/lib + * @build toolbox.ToolBox toolbox.TestRunner + * @run main TestDocTrees + */ + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import toolbox.*; +import toolbox.Task.Expect; + +import static toolbox.Task.OutputKind.*; + +/** + * This class is used to test DocTrees functionality relating to + * package and overview HTML files. + */ +public class TestDocTrees extends TestRunner { + final ToolBox tb; + final File testFile; + final File testSrc; + final File overviewFile; + + TestDocTrees() throws IOException { + super(System.err); + tb = new ToolBox(); + testSrc = new File(System.getProperty("test.src")); + testFile = new File(testSrc, "TestDocTrees.java"); + overviewFile = new File(testSrc, "overview.html"); + } + + protected void runTests() throws Exception { + runTests(m -> new Object[]{Paths.get(m.getName())}); + } + + public static void main(String... args) throws Exception { + new TestDocTrees().runTests(); + } + + @Test + public void testOverviewWithRelease8(Path out) { + execTask("-d", out.toString(), + "--release", "8", + "-Xdoclint:all", + "-Xdoclint:-missing", + "-sourcepath", testSrc.getAbsolutePath(), + testFile.getAbsolutePath(), + "-overview", overviewFile.getAbsolutePath()); + } + + @Test + public void testOverviewWithoutRelease(Path out) throws Exception { + execTask("-d", out.toString(), + "-Xdoclint:all", + "-Xdoclint:-missing", + "-sourcepath", testSrc.getAbsolutePath(), + testFile.getAbsolutePath(), + "-overview", overviewFile.getAbsolutePath()); + } + + private Task.Result execTask(String... args) { + JavadocTask et = new JavadocTask(tb, Task.Mode.CMDLINE); + //args.forEach((a -> System.err.println("arg: " + a))); + return et.options(args).run(); + } +} diff -r 8c70d170e62c -r b73702608fc6 langtools/test/jdk/javadoc/tool/treeapi/overview.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/tool/treeapi/overview.html Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,27 @@ + + + + {@link omg.what.gives} + + \ No newline at end of file diff -r 8c70d170e62c -r b73702608fc6 langtools/test/jdk/jshell/ExternalEditorTest.java --- a/langtools/test/jdk/jshell/ExternalEditorTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/jdk/jshell/ExternalEditorTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -24,7 +24,7 @@ /* * @test * @summary Testing external editor. - * @bug 8143955 8080843 8163816 8143006 8169828 + * @bug 8143955 8080843 8163816 8143006 8169828 8171130 * @modules jdk.jshell/jdk.internal.jshell.tool * @build ReplToolTesting CustomEditor EditorTestBase * @run testng ExternalEditorTest @@ -50,6 +50,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; public class ExternalEditorTest extends EditorTestBase { @@ -119,6 +120,28 @@ super.testEditor(defaultStartup, args, t); } + @Test + public void testStatementSemicolonAddition() { + testEditor( + a -> assertCommand(a, "if (true) {}", ""), + a -> assertCommand(a, "if (true) {} else {}", ""), + a -> assertCommand(a, "Object o", "o ==> null"), + a -> assertCommand(a, "if (true) o = new Object() { int x; }", ""), + a -> assertCommand(a, "if (true) o = new Object() { int y; }", ""), + a -> assertCommand(a, "System.err.flush()", ""), // test still ; for expression statement + a -> assertEditOutput(a, "/ed", "", () -> { + assertEquals(getSource(), + "if (true) {}\n" + + "if (true) {} else {}\n" + + "Object o;\n" + + "if (true) o = new Object() { int x; };\n" + + "if (true) o = new Object() { int y; };\n" + + "System.err.flush();\n"); + exit(); + }) + ); + } + private static boolean isWindows() { return System.getProperty("os.name").startsWith("Windows"); } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/jdk/jshell/ToolCommandOptionTest.java --- a/langtools/test/jdk/jshell/ToolCommandOptionTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/jdk/jshell/ToolCommandOptionTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8157395 8157393 8157517 8158738 8167128 8163840 8167637 8170368 8172102 + * @bug 8157395 8157393 8157517 8158738 8167128 8163840 8167637 8170368 8172102 8172179 * @summary Tests of jshell comand options, and undoing operations * @modules jdk.jshell/jdk.internal.jshell.tool * jdk.compiler/com.sun.tools.javac.api @@ -273,14 +273,13 @@ (a) -> assertCommand(a, "/set start DEFAULT PRINTING", ""), (a) -> assertCommandOutputContains(a, "/set start", - "void println", "import java.util.*"), + "/set start DEFAULT PRINTING", "void println", "import java.util.*"), (a) -> assertCommand(a, "/set start " + startup.toString(), ""), - (a) -> assertCommand(a, "/set start", - "| startup.jsh:\n" + - "| int iAmHere = 1234;\n" + - "| \n" + - "| /set start startup.jsh"), + (a) -> assertCommandOutputContains(a, "/set start", + "| /set start " + startup + "\n" + + "| ---- " + startup + " @ ", " ----\n" + + "| int iAmHere = 1234;\n"), (a) -> assertCommand(a, "/se sta -no", ""), (a) -> assertCommand(a, "/set start", @@ -322,11 +321,18 @@ "| /set start -retain -none"), (a) -> assertCommand(a, "/set start -retain " + startup.toString(), ""), - (a) -> assertCommand(a, "/set start", - "| startup.jsh:\n" + - "| int iAmHere = 1234;\n" + - "| \n" + - "| /set start -retain startup.jsh") + (a) -> assertCommand(a, "/set start DEFAULT PRINTING", + ""), + (a) -> assertCommandOutputStartsWith(a, "/set start", + "| /set start -retain " + startup.toString() + "\n" + + "| /set start DEFAULT PRINTING\n" + + "| ---- " + startup.toString() + " @ "), + (a) -> assertCommandOutputContains(a, "/set start", + "| ---- DEFAULT ----\n", + "| ---- PRINTING ----\n", + "| int iAmHere = 1234;\n", + "| void println(String s)", + "| import java.io.*;") ); } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/jdk/jshell/ToolFormatTest.java --- a/langtools/test/jdk/jshell/ToolFormatTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/jdk/jshell/ToolFormatTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 + * @bug 8148316 8148317 8151755 8152246 8153551 8154812 8157261 8163840 8166637 8161969 8173007 * @summary Tests for output customization * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -38,8 +38,6 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -140,6 +138,66 @@ ); } + public void testSetFormatSelectorSample() { + test( + (a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet", + "| Created new feedback mode: ate"), + (a) -> assertCommand(a, "/set feedback ate", ""), + + (a) -> assertCommand(a, "/set format ate display '---replaced,modified,added-primary---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++replaced,modified,added-primary+++' replaced,modified,added-primary", ""), + (a) -> assertCommand(a, "\"replaced,modified,added-primary\"", "+++replaced,modified,added-primary+++"), + + (a) -> assertCommand(a, "/set format ate display '---added-primary,update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++added-primary,update+++' added-primary,update", ""), + (a) -> assertCommand(a, "\"added-primary,update\"", "+++added-primary,update+++"), + + + (a) -> assertCommand(a, "/set format ate display '---method-replaced-primary---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++method-replaced-primary+++' method-replaced-primary", ""), + (a) -> assertCommand(a, "\"method-replaced-primary\"", "---method-replaced-primary---"), + + (a) -> assertCommand(a, "/set format ate display '---method-replaced-update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++method-replaced-update+++' method-replaced-update", ""), + (a) -> assertCommand(a, "\"method-replaced-update\"", "---method-replaced-update---"), + + (a) -> assertCommand(a, "/set format ate display '---method-added-update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++method-added-update+++' method-added-update", ""), + (a) -> assertCommand(a, "\"method-added-update\"", "---method-added-update---"), + + (a) -> assertCommand(a, "/set format ate display '---method-added---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++method-added+++' method-added", ""), + (a) -> assertCommand(a, "\"method-added\"", "---method-added---"), + + (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary,update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary,update+++' class-modified,added-primary,update", ""), + (a) -> assertCommand(a, "\"class-modified,added-primary,update\"", "---class-modified,added-primary,update---"), + + (a) -> assertCommand(a, "/set format ate display '---class-modified,added-primary---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-primary+++' class-modified,added-primary", ""), + (a) -> assertCommand(a, "\"class-modified,added-primary\"", "---class-modified,added-primary---"), + + (a) -> assertCommand(a, "/set format ate display '---class-modified,added-update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++class-modified,added-update+++' class-modified,added-update", ""), + (a) -> assertCommand(a, "\"class-modified,added-update\"", "---class-modified,added-update---"), + + (a) -> assertCommand(a, "/set format ate display '---replaced,added---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++replaced,added+++' replaced,added", ""), + (a) -> assertCommand(a, "\"replaced,added\"", "+++replaced,added+++"), + + (a) -> assertCommand(a, "/set format ate display '---replaced-primary,update---'", ""), + (a) -> assertCommand(a, "/set format ate display '+++replaced-primary,update+++' replaced-primary,update", ""), + (a) -> assertCommand(a, "\"replaced-primary,update\"", "---replaced-primary,update---"), + + (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "| Feedback mode: normal") + ); + } + + // This test is exhaustive and takes to long for routine testing -- disabled. + // A sampling of these has been added (above: testSetFormatSelectorSample). + // See 8173007 + // Save for possible future deep testing or debugging + @Test(enabled = false) public void testSetFormatSelector() { List tests = new ArrayList<>(); tests.add((a) -> assertCommandOutputStartsWith(a, "/set mode ate -quiet", @@ -202,6 +260,11 @@ tests.add((a) -> assertCommand(a, "/set format ate display '" + no + "'", "")); tests.add((a) -> assertCommand(a, "/set format ate display '" + yes + "' " + select, "")); tests.add((a) -> assertCommand(a, "\"" + select + "\"", expect)); + /**** for sample generation **** + System.err.println(" (a) -> assertCommand(a, \"/set format ate display '" + no + "'\", \"\"),"); + System.err.println(" (a) -> assertCommand(a, \"/set format ate display '" + yes + "' " + select + "\", \"\"),"); + System.err.println(" (a) -> assertCommand(a, \"\\\"" + select + "\\\"\", \"" + expect + "\"),\n"); + ****/ } } } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/doclint/html/OtherTagsTest.out --- a/langtools/test/tools/doclint/html/OtherTagsTest.out Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/doclint/html/OtherTagsTest.out Fri Jan 20 19:10:00 2017 +0000 @@ -19,10 +19,7 @@ OtherTagsTest.java:21: error: element not allowed in documentation comments: * <noframes> ^ -OtherTagsTest.java:22: error: element not allowed in documentation comments: - ^ OtherTagsTest.java:23: error: element not allowed in documentation comments: * <title> ^ -9 errors +8 errors diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java --- a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -143,6 +143,7 @@ Arrays.asList(new File(System.getProperty("test.src"), this.getClass().getName() + ".java"))); java.util.List options = Arrays.asList( + "--add-modules", "jdk.jdeps", "--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED", "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/classfiles/attributes/Module/ModuleTest.java --- a/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -24,7 +24,7 @@ /* * @test * @summary Module attribute tests - * @bug 8080878 8161906 8162713 + * @bug 8080878 8161906 8162713 8170250 * @modules java.compiler * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -53,6 +53,28 @@ } @Test + public void testOpenEmptyModule(Path base) throws Exception { + ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m", ModuleFlag.OPEN) + .write(base); + compile(base); + testModuleAttribute(base, moduleDescriptor); + } + + @Test + public void testModuleName(Path base) throws Exception { + testName("module.name", base.resolve("dot")); + testName("module.exports.component.subcomponent.more.dots", base.resolve("dots")); + testName("moduleName", base.resolve("noDots")); + } + + private void testName(String name, Path path) throws Exception{ + ModuleDescriptor moduleDescriptor = new ModuleDescriptor(name) + .write(path); + compile(path); + testModuleAttribute(path, moduleDescriptor); + } + + @Test public void testExports(Path base) throws Exception { ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") .exports("pack") @@ -92,16 +114,6 @@ } @Test - public void testQualifiedDynamicExports(Path base) throws Exception { - ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") - .exportsTo("pack", "jdk.compiler") - .write(base); - tb.writeJavaFiles(base, "package pack; public class A { }"); - compile(base); - testModuleAttribute(base, moduleDescriptor); - } - - @Test public void testSeveralQualifiedExports(Path base) throws Exception { ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") .exportsTo("pack", "jdk.compiler, jdk.jdeps") @@ -121,6 +133,47 @@ } @Test + public void testOpens(Path base) throws Exception { + ModuleDescriptor moduleDescriptor = new ModuleDescriptor("module.name") + .opens("pack") + .write(base); + tb.writeJavaFiles(base, "package pack; public class C extends java.util.ArrayList{ }"); + compile(base); + testModuleAttribute(base, moduleDescriptor); + } + + @Test + public void testQualifiedOpens(Path base) throws Exception { + ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") + .opensTo("pack", "jdk.compiler") + .write(base); + tb.writeJavaFiles(base, "package pack; public class A { }"); + compile(base); + testModuleAttribute(base, moduleDescriptor); + } + + @Test + public void testSeveralOpens(Path base) throws Exception { + ModuleDescriptor moduleDescriptor = new ModuleDescriptor("module.m1.name") + .opensTo("pack", "jdk.compiler, jdk.jdeps") + .opensTo("pack2", "jdk.jdeps") + .opensTo("pack3", "jdk.compiler") + .opensTo("pack4", "jdk.compiler, jdk.jdeps") + .opensTo("pack5", "jdk.compiler") + .opens("pack6") + .write(base); + tb.writeJavaFiles(base, + "package pack; public class A {}", + "package pack2; public class B {}", + "package pack3; public class C {}", + "package pack4; public class C {}", + "package pack5; public class C {}", + "package pack6; public class C {}"); + compile(base); + testModuleAttribute(base, moduleDescriptor); + } + + @Test public void testRequires(Path base) throws Exception { ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") .requires("jdk.compiler") @@ -182,10 +235,12 @@ .provides("java.util.Collection", "pack2.D") .provides("java.util.List", "pack2.D") .requires("jdk.compiler") + .provides("javax.tools.FileObject", "pack2.E") .provides("com.sun.tools.javac.Main", "pack2.C") .write(base); tb.writeJavaFiles(base, "package pack2; public class D extends java.util.ArrayList{ }", - "package pack2; public class C extends com.sun.tools.javac.Main{ }"); + "package pack2; public class C extends com.sun.tools.javac.Main{ }", + "package pack2; public class E extends javax.tools.SimpleJavaFileObject{ public E(){ super(null,null); } }"); compile(base); testModuleAttribute(base, moduleDescriptor); } @@ -203,9 +258,10 @@ public void testSeveralUses(Path base) throws Exception { ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m") .uses("java.util.List") - .uses("java.util.Collection") + .uses("java.util.Collection") // from java.base .requires("jdk.compiler") - .uses("javax.tools.JavaCompiler") + .uses("javax.tools.JavaCompiler") // from java.compiler + .uses("com.sun.tools.javac.Main") // from jdk.compiler .write(base); compile(base); testModuleAttribute(base, moduleDescriptor); @@ -216,9 +272,10 @@ Path m1 = base.resolve("m1x"); ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1x") .exports("pack1") - .exports("pack3") + .opens("pack3") .exportsTo("packTo1", "m2x") - .exportsTo("packTo3", "m3x") + .opensTo("packTo1", "m2x") // the same as exportsTo + .opensTo("packTo3", "m3x") .requires("jdk.compiler") .requires("m2x", RequiresFlag.TRANSITIVE) .requires("m3x", RequiresFlag.STATIC) @@ -230,9 +287,49 @@ .requires("m5x", RequiresFlag.STATIC) .requires("m6x", RequiresFlag.TRANSITIVE) .requires("java.compiler") - .exportsTo("packTo4", "java.compiler") + .opensTo("packTo4", "java.compiler") .exportsTo("packTo2", "java.compiler") - .exports("pack4") + .opens("pack2") // same as exports + .opens("pack4") + .exports("pack2") + .write(m1); + tb.writeJavaFiles(m1, "package pack1; public class C extends java.util.ArrayList{ }", + "package pack2; public class D extends java.util.ArrayList{ }", + "package pack3; public class D extends java.util.ArrayList{ }", + "package pack4; public class D extends java.util.ArrayList{ }"); + tb.writeJavaFiles(m1, + "package packTo1; public class T1 {}", + "package packTo2; public class T2 {}", + "package packTo3; public class T3 {}", + "package packTo4; public class T4 {}"); + tb.writeJavaFiles(base.resolve("m2x"), "module m2x { }"); + tb.writeJavaFiles(base.resolve("m3x"), "module m3x { }"); + tb.writeJavaFiles(base.resolve("m4x"), "module m4x { }"); + tb.writeJavaFiles(base.resolve("m5x"), "module m5x { }"); + tb.writeJavaFiles(base.resolve("m6x"), "module m6x { }"); + compile(base, "--module-source-path", base.toString(), + "-d", base.toString()); + testModuleAttribute(m1, moduleDescriptor); + } + + @Test + public void testOpenComplexModule(Path base) throws Exception { + Path m1 = base.resolve("m1x"); + ModuleDescriptor moduleDescriptor = new ModuleDescriptor("m1x", ModuleFlag.OPEN) + .exports("pack1") + .exportsTo("packTo1", "m2x") + .requires("jdk.compiler") + .requires("m2x", RequiresFlag.TRANSITIVE) + .requires("m3x", RequiresFlag.STATIC) + .requires("m4x", RequiresFlag.TRANSITIVE, RequiresFlag.STATIC) + .provides("java.util.List", "pack1.C", "pack2.D") + .uses("java.util.List") + .uses("java.nio.file.Path") + .requires("jdk.jdeps", RequiresFlag.STATIC, RequiresFlag.TRANSITIVE) + .requires("m5x", RequiresFlag.STATIC) + .requires("m6x", RequiresFlag.TRANSITIVE) + .requires("java.compiler") + .exportsTo("packTo2", "java.compiler") .exports("pack2") .write(m1); tb.writeJavaFiles(m1, "package pack1; public class C extends java.util.ArrayList{ }", diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java --- a/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -25,7 +25,6 @@ import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Module_attribute; -import com.sun.tools.javac.util.Pair; import java.io.IOException; import java.lang.annotation.Retention; @@ -36,11 +35,11 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -74,20 +73,30 @@ ClassFile classFile = ClassFile.read(modulePath.resolve("module-info.class")); Module_attribute moduleAttribute = (Module_attribute) classFile.getAttribute("Module"); ConstantPool constantPool = classFile.constant_pool; - + testModuleName(moduleDescriptor, moduleAttribute, constantPool); + testModuleFlags(moduleDescriptor, moduleAttribute); testRequires(moduleDescriptor, moduleAttribute, constantPool); testExports(moduleDescriptor, moduleAttribute, constantPool); + testOpens(moduleDescriptor, moduleAttribute, constantPool); testProvides(moduleDescriptor, moduleAttribute, constantPool); testUses(moduleDescriptor, moduleAttribute, constantPool); } + private void testModuleName(ModuleDescriptor moduleDescriptor, Module_attribute module, ConstantPool constantPool) throws ConstantPoolException { + tr.checkEquals(constantPool.getModuleInfo(module.module_name).getName(), moduleDescriptor.name, "Unexpected module name"); + } + + private void testModuleFlags(ModuleDescriptor moduleDescriptor, Module_attribute module) { + tr.checkEquals(module.module_flags, moduleDescriptor.flags, "Unexpected module flags"); + } + private void testRequires(ModuleDescriptor moduleDescriptor, Module_attribute module, ConstantPool constantPool) throws ConstantPoolException { tr.checkEquals(module.requires_count, moduleDescriptor.requires.size(), "Wrong amount of requires."); - List> actualRequires = new ArrayList<>(); + List actualRequires = new ArrayList<>(); for (Module_attribute.RequiresEntry require : module.requires) { - actualRequires.add(Pair.of( - require.getRequires(constantPool).replace('/', '.'), + actualRequires.add(new Requires( + require.getRequires(constantPool), require.requires_flags)); } tr.checkContains(actualRequires, moduleDescriptor.requires, "Lists of requires don't match"); @@ -104,18 +113,36 @@ tr.checkEquals(export.exports_to_count, expectedTo.size(), "Wrong amount of exports to"); List actualTo = new ArrayList<>(); for (int toIdx : export.exports_to_index) { - actualTo.add(constantPool.getModuleInfo(toIdx).getName().replace('/', '.')); + actualTo.add(constantPool.getModuleInfo(toIdx).getName()); } tr.checkContains(actualTo, expectedTo, "Lists of \"exports to\" don't match."); } } } + private void testOpens(ModuleDescriptor moduleDescriptor, Module_attribute module, ConstantPool constantPool) throws ConstantPoolException { + tr.checkEquals(module.opens_count, moduleDescriptor.opens.size(), "Wrong amount of opens."); + for (Module_attribute.OpensEntry open : module.opens) { + String pkg = constantPool.getPackageInfo(open.opens_index).getName(); + if (tr.checkTrue(moduleDescriptor.opens.containsKey(pkg), "Unexpected open " + pkg)) { + Open expectedOpen = moduleDescriptor.opens.get(pkg); + tr.checkEquals(expectedOpen.mask, open.opens_flags, "Wrong open flags"); + List expectedTo = expectedOpen.to; + tr.checkEquals(open.opens_to_count, expectedTo.size(), "Wrong amount of opens to"); + List actualTo = new ArrayList<>(); + for (int toIdx : open.opens_to_index) { + actualTo.add(constantPool.getModuleInfo(toIdx).getName()); + } + tr.checkContains(actualTo, expectedTo, "Lists of \"opens to\" don't match."); + } + } + } + private void testUses(ModuleDescriptor moduleDescriptor, Module_attribute module, ConstantPool constantPool) throws ConstantPoolException { tr.checkEquals(module.uses_count, moduleDescriptor.uses.size(), "Wrong amount of uses."); List actualUses = new ArrayList<>(); for (int usesIdx : module.uses_index) { - String uses = constantPool.getClassInfo(usesIdx).getBaseName().replace('/', '.'); + String uses = constantPool.getClassInfo(usesIdx).getBaseName(); actualUses.add(uses); } tr.checkContains(actualUses, moduleDescriptor.uses, "Lists of uses don't match"); @@ -131,10 +158,10 @@ tr.checkEquals(moduleProvidesCount, moduleDescriptorProvidesCount, "Wrong amount of provides."); Map> actualProvides = new HashMap<>(); for (Module_attribute.ProvidesEntry provide : module.provides) { - String provides = constantPool.getClassInfo(provide.provides_index).getBaseName().replace('/', '.'); + String provides = constantPool.getClassInfo(provide.provides_index).getBaseName(); List impls = new ArrayList<>(); for (int i = 0; i < provide.with_count; i++) { - String with = constantPool.getClassInfo(provide.with_index[i]).getBaseName().replace('/', '.'); + String with = constantPool.getClassInfo(provide.with_index[i]).getBaseName(); impls.add(with); } actualProvides.put(provides, impls); @@ -163,9 +190,27 @@ int getMask(); } + public enum ModuleFlag implements Mask { + OPEN("open", Module_attribute.ACC_OPEN); + + private final String token; + private final int mask; + + ModuleFlag(String token, int mask) { + this.token = token; + this.mask = mask; + } + + @Override + public int getMask() { + return mask; + } + } + public enum RequiresFlag implements Mask { TRANSITIVE("transitive", Module_attribute.ACC_TRANSITIVE), - STATIC("static", Module_attribute.ACC_STATIC_PHASE); + STATIC("static", Module_attribute.ACC_STATIC_PHASE), + MANDATED("", Module_attribute.ACC_MANDATED); private final String token; private final int mask; @@ -181,13 +226,30 @@ } } - public enum ExportFlag implements Mask { + public enum ExportsFlag implements Mask { SYNTHETIC("", Module_attribute.ACC_SYNTHETIC); private final String token; private final int mask; - ExportFlag(String token, int mask) { + ExportsFlag(String token, int mask) { + this.token = token; + this.mask = mask; + } + + @Override + public int getMask() { + return mask; + } + } + + public enum OpensFlag implements Mask { + SYNTHETIC("", Module_attribute.ACC_SYNTHETIC); + + private final String token; + private final int mask; + + OpensFlag(String token, int mask) { this.token = token; this.mask = mask; } @@ -199,27 +261,64 @@ } private class Export { - String pkg; - int mask; - List to = new ArrayList<>(); + private final String pkg; + private final int mask; + private final List to = new ArrayList<>(); - public Export(String pkg, int mask) { + Export(String pkg, int mask) { + this.pkg = pkg; + this.mask = mask; + } + } + + private class Open { + private final String pkg; + private final int mask; + private final List to = new ArrayList<>(); + + Open(String pkg, int mask) { this.pkg = pkg; this.mask = mask; } } + private class Requires { + private final String module; + private final int mask; + + Requires(String module, int mask) { + this.module = module; + this.mask = mask; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Requires requires = (Requires) o; + return mask == requires.mask && + Objects.equals(module, requires.module); + } + + @Override + public int hashCode() { + return Objects.hash(module, mask); + } + } + protected class ModuleDescriptor { private final String name; - //pair is name of module and flag(public,mandated,synthetic) - private final List> requires = new ArrayList<>(); + private final int flags; + + private final List requires = new ArrayList<>(); { - requires.add(new Pair<>("java.base", Module_attribute.ACC_MANDATED)); + requires.add(new Requires("java.base", computeMask(RequiresFlag.MANDATED))); } private final Map exports = new HashMap<>(); + private final Map opens = new HashMap<>(); //List of service and implementation private final Map> provides = new LinkedHashMap<>(); @@ -227,22 +326,26 @@ private static final String LINE_END = ";\n"; - StringBuilder content = new StringBuilder("module "); + StringBuilder content = new StringBuilder(""); - public ModuleDescriptor(String moduleName) { + public ModuleDescriptor(String moduleName, ModuleFlag... flags) { this.name = moduleName; - content.append(name).append('{').append('\n'); + this.flags = computeMask(flags); + for (ModuleFlag flag : flags) { + content.append(flag.token).append(" "); + } + content.append("module ").append(moduleName).append('{').append('\n'); } public ModuleDescriptor requires(String module) { - this.requires.add(Pair.of(module, 0)); + this.requires.add(new Requires(module, 0)); content.append(" requires ").append(module).append(LINE_END); return this; } public ModuleDescriptor requires(String module, RequiresFlag... flags) { - this.requires.add(new Pair<>(module, computeMask(flags))); + this.requires.add(new Requires(module, computeMask(flags))); content.append(" requires "); for (RequiresFlag flag : flags) { @@ -253,26 +356,52 @@ return this; } - public ModuleDescriptor exports(String pkg, ExportFlag... flags) { - this.exports.putIfAbsent(pkg, new Export(pkg, computeMask(flags))); + public ModuleDescriptor exports(String pkg, ExportsFlag... flags) { + this.exports.put(toInternalForm(pkg), new Export(toInternalForm(pkg), computeMask(flags))); content.append(" exports "); - for (ExportFlag flag : flags) { + for (ExportsFlag flag : flags) { content.append(flag.token).append(" "); } content.append(pkg).append(LINE_END); return this; } - public ModuleDescriptor exportsTo(String pkg, String to, ExportFlag... flags) { + public ModuleDescriptor exportsTo(String pkg, String to, ExportsFlag... flags) { List tos = Pattern.compile(",") .splitAsStream(to) .map(String::trim) .collect(Collectors.toList()); - this.exports.computeIfAbsent(pkg, k -> new Export(pkg, computeMask(flags))) + this.exports.compute(toInternalForm(pkg), (k,v) -> new Export(k, computeMask(flags))) .to.addAll(tos); content.append(" exports "); - for (ExportFlag flag : flags) { + for (ExportsFlag flag : flags) { + content.append(flag.token).append(" "); + } + content.append(pkg).append(" to ").append(to).append(LINE_END); + return this; + } + + public ModuleDescriptor opens(String pkg, OpensFlag... flags) { + this.opens.put(toInternalForm(pkg), new Open(toInternalForm(pkg), computeMask(flags))); + content.append(" opens "); + for (OpensFlag flag : flags) { + content.append(flag.token).append(" "); + } + content.append(pkg).append(LINE_END); + return this; + } + + public ModuleDescriptor opensTo(String pkg, String to, OpensFlag... flags) { + List tos = Pattern.compile(",") + .splitAsStream(to) + .map(String::trim) + .collect(Collectors.toList()); + this.opens.compute(toInternalForm(pkg), (k,v) -> new Open(toInternalForm(k), computeMask(flags))) + .to.addAll(tos); + + content.append(" opens "); + for (OpensFlag flag : flags) { content.append(flag.token).append(" "); } content.append(pkg).append(" to ").append(to).append(LINE_END); @@ -280,7 +409,10 @@ } public ModuleDescriptor provides(String provides, String... with) { - this.provides.put(provides, Arrays.asList(with)); + List impls = Arrays.stream(with) + .map(this::toInternalForm) + .collect(Collectors.toList()); + this.provides.put(toInternalForm(provides), impls); content.append(" provides ") .append(provides) .append(" with ") @@ -290,8 +422,8 @@ } public ModuleDescriptor uses(String... uses) { - Collections.addAll(this.uses, uses); for (String use : uses) { + this.uses.add(toInternalForm(use)); content.append(" uses ").append(use).append(LINE_END); } return this; @@ -305,7 +437,11 @@ return this; } - private int computeMask(Mask[] masks) { + private String toInternalForm(String name) { + return name.replace('.', '/'); + } + + private int computeMask(Mask... masks) { return Arrays.stream(masks) .map(Mask::getMask) .reduce((a, b) -> a | b) diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java --- a/langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, 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 @@ -82,7 +82,8 @@ Set copy = new HashSet<>(expected); copy.removeAll(found); if (!found.containsAll(expected)) { - return checkTrue(false, message + " FAIL : not found elements : " + copy); + return checkTrue(false, message + " FAIL : not found elements : " + copy + "\n" + + "Actual: " + found); } else { return checkTrue(true, message + " PASS : all elements found"); } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/classreader/FileSystemClosedTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/classreader/FileSystemClosedTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016, 2017, 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 8147414 + * @summary java.nio.file.ClosedFileSystemException in javadoc + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.JarTask toolbox.JavacTask toolbox.ToolBox + * @run main FileSystemClosedTest + */ + +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.ClosedFileSystemException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import toolbox.ToolBox; +import toolbox.JarTask; +import toolbox.JavacTask; + +public class FileSystemClosedTest { + public static void main(String... args) throws Exception { + new FileSystemClosedTest().run(); + } + + void run() throws Exception { + ToolBox tb = new ToolBox(); + Path jar = createJar(tb); + + Path src = Paths.get("src"); + tb.writeJavaFiles(src, "class C { p1.C1 c1; }"); + + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + PrintWriter out = new PrintWriter(System.err, true); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + List options = Arrays.asList("-classpath", jar.toString()); + Iterable files = fm.getJavaFileObjects(src.resolve("C.java")); + com.sun.source.util.JavacTask task = + (com.sun.source.util.JavacTask) comp.getTask(out, fm, null, options, null, files); + task.parse(); + + Elements elems = task.getElements(); + + try { + // Use p1, p1.C1 as a control to verify normal behavior + PackageElement p1 = elems.getPackageElement("p1"); + TypeElement p1C1 = elems.getTypeElement("p1.C1"); + System.err.println("p1: " + p1 + "; p1C1: " + p1C1); + if (p1C1 == null) { + throw new Exception("p1.C1 not found"); + } + + // Now repeat for p2, p2.C2, closing the file manager early + PackageElement p2 = elems.getPackageElement("p2"); + System.err.println("closing file manager"); + fm.close(); + TypeElement p2C2 = elems.getTypeElement("p2.C2"); + System.err.println("p2: " + p2 + "; p2C2: " + p2C2); + if (p2C2 != null) { + throw new Exception("p1.C1 found unexpectedly"); + } + } catch (ClosedFileSystemException e) { + throw new Exception("unexpected exception thrown", e); + } + + } + + private Path createJar(ToolBox tb) throws IOException { + Path jarSrc = Paths.get("jarSrc"); + Path jarClasses = Paths.get("jarClasses"); + Path jar = Paths.get("jar.jar"); + Files.createDirectories(jarClasses); + + tb.writeJavaFiles(jarSrc, + "package p1; public class C1 { }", + "package p2; public class C2 { }"); + + new JavacTask(tb) + .outdir(jarClasses) + .files(tb.findJavaFiles(jarSrc)) + .run() + .writeAll(); + new JarTask(tb) + .run("cf", jar.toString(), "-C", jarClasses.toString(), "p1", "p2"); + + return jar; + } +} + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/Example.java --- a/langtools/test/tools/javac/diags/Example.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/diags/Example.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, 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 @@ -66,6 +66,7 @@ modulePathFiles = new ArrayList(); classPathFiles = new ArrayList(); additionalFiles = new ArrayList(); + nonEmptySrcFiles = new ArrayList(); findFiles(file, srcFiles); for (File f: srcFiles) { @@ -99,11 +100,11 @@ } } } else if (f.isFile()) { - if (f.getName().endsWith(".java")) { - files.add(f); - } else if (f.getName().equals("modulesourcepath")) { - moduleSourcePathDir = f; - } + if (f.getName().endsWith(".java")) { + files.add(f); + } else if (f.getName().equals("modulesourcepath")) { + moduleSourcePathDir = f; + } } } @@ -132,8 +133,10 @@ foundInfo(f); runOpts = Arrays.asList(runMatch.group(1).trim().split(" +")); } - if (javaPat.matcher(line).matches()) + if (javaPat.matcher(line).matches()) { + nonEmptySrcFiles.add(f); break; + } } } catch (IOException e) { throw new Error(e); @@ -236,6 +239,7 @@ // source for import statements or a magic comment for (File pf: procFiles) { if (pf.getName().equals("CreateBadClassFile.java")) { + pOpts.add("--add-modules=jdk.jdeps"); pOpts.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED"); } } @@ -263,7 +267,9 @@ if (moduleSourcePathDir != null) { opts.add("--module-source-path"); opts.add(moduleSourcePathDir.getPath()); - files = moduleSourcePathFiles; + files = new ArrayList<>(); + files.addAll(moduleSourcePathFiles); + files.addAll(nonEmptySrcFiles); // srcFiles containing declarations } if (additionalFiles.size() > 0) { @@ -343,6 +349,7 @@ List modulePathFiles; List classPathFiles; List additionalFiles; + List nonEmptySrcFiles; File infoFile; private List runOpts; private List options; diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples.not-yet.txt --- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Fri Jan 20 19:10:00 2017 +0000 @@ -103,6 +103,7 @@ compiler.warn.big.major.version # ClassReader compiler.warn.future.attr # ClassReader compiler.warn.illegal.char.for.encoding +compiler.warn.incubating.modules # requires adjusted classfile compiler.warn.invalid.archive.file compiler.warn.override.bridge compiler.warn.position.overflow # CRTable: caused by files with long lines >= 1024 chars diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java --- a/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/diags/examples/DirPathElementNotDirectory/DirPathElementNotDirectory.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -24,5 +24,3 @@ // key: compiler.warn.dir.path.element.not.directory // options: -Xlint:path // run: simple - -class DirPathElementNotDirectory { } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/ModuleNotOnModuleSourcePath/ModuleNotOnModuleSourcePath.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/ModuleNotOnModuleSourcePath/ModuleNotOnModuleSourcePath.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 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. + */ + +// key: compiler.err.module.not.found.on.module.source.path + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/ModuleNotOnModuleSourcePath/modulesourcepath/m/extra/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/ModuleNotOnModuleSourcePath/modulesourcepath/m/extra/module-info.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 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. + */ + +module m { } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/NotInModuleOnModuleSourcePath/NotInModuleOnModuleSourcePath.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/NotInModuleOnModuleSourcePath/NotInModuleOnModuleSourcePath.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016, 2017, 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. + */ + +// key: compiler.err.not.in.module.on.module.source.path + +package p; class C { } + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/NotInModuleOnModuleSourcePath/modulesourcepath/m/module-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/NotInModuleOnModuleSourcePath/modulesourcepath/m/module-info.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 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. + */ + +module m { } + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java --- a/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/diags/examples/UnnamedPackageInNamedModule/UnnamedPackageInNamedModule.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -22,5 +22,3 @@ */ // key: compiler.err.unnamed.pkg.not.allowed.named.modules - -class UnnamedPackageInNamedModule {} diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java --- a/langtools/test/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8132096 + * @bug 8132096 8157611 * @summary test the APIs in the DocTree interface * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.file @@ -48,12 +48,15 @@ import java.util.Locale; import javax.lang.model.element.Element; +import javax.lang.model.element.PackageElement; +import javax.lang.model.util.Elements; import javax.tools.FileObject; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import com.sun.source.doctree.DocTree; import com.sun.source.doctree.DocCommentTree; +import com.sun.source.util.DocTreePath; import com.sun.source.util.DocTrees; import com.sun.source.util.JavacTask; import com.sun.tools.javac.api.JavacTool; @@ -90,6 +93,9 @@ // tests files relative path in an unnamed package test.runRelativePathTest("OverviewTest.java", "overview0.html"); + // tests doctreepath using package element and package.html + test.runDocTreePath("pkg/Anchor.java", "package.html"); + // test for correct parsing using valid and some invalid html tags for (int i = 0; i < 7; i++) { String hname = "overview" + i + ".html"; @@ -152,6 +158,7 @@ } } } + /** * Tests DocTrees.getDocCommentTree(Element e, String relpath) using relative path. * @@ -219,6 +226,49 @@ } } + /** + * Tests DocTrees.getDocTreePath(PackageElement p, FileObject fo). + * + * @param javaFileName the java anchor file + * @param pkgFileName the package file name + * @throws Exception e if something goes awry + */ + public void runDocTreePath(String javaFileName, String pkgFileName) throws Exception { + List javaFiles = new ArrayList<>(); + javaFiles.add(new File(testSrc, javaFileName)); + + List dirs = new ArrayList<>(); + dirs.add(new File(testSrc)); + + try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) { + fm.setLocation(javax.tools.StandardLocation.SOURCE_PATH, dirs); + Iterable fos = fm.getJavaFileObjectsFromFiles(javaFiles); + + final JavacTask t = javac.getTask(null, fm, null, null, null, fos); + final DocTrees trees = DocTrees.instance(t); + final Elements elementUtils = t.getElements(); + + Iterable elements = t.analyze(); + + Element klass = elements.iterator().next(); + PackageElement pkg = elementUtils.getPackageOf(klass); + + FileObject htmlFo = fm.getFileForInput(javax.tools.StandardLocation.SOURCE_PATH, + t.getElements().getPackageOf(klass).getQualifiedName().toString(), + "package.html"); + System.out.println(); + DocTreePath treePath = trees.getDocTreePath(htmlFo, pkg); + DocCommentTree dcTree = treePath.getDocComment(); + + StringWriter sw = new StringWriter(); + printer.print(dcTree, sw); + String found = sw.toString(); + + String expected = getExpected(htmlFo.openReader(true)); + astcheck(pkgFileName, expected, found); + } + } + void astcheck(String testinfo, String expected, String found) { System.err.print("ASTChecker: " + testinfo); check0(expected, found); diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/lib/combo/ReusableContext.java --- a/langtools/test/tools/javac/lib/combo/ReusableContext.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/lib/combo/ReusableContext.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -38,6 +38,7 @@ import com.sun.tools.javac.code.Type.ClassType; import com.sun.tools.javac.code.TypeTag; import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.comp.Check; import com.sun.tools.javac.comp.CompileStates; import com.sun.tools.javac.comp.Enter; @@ -95,6 +96,7 @@ Types.instance(this).newRound(); Check.instance(this).newRound(); Modules.instance(this).newRound(); + Annotate.instance(this).newRound(); CompileStates.instance(this).clear(); MultiTaskListener.instance(this).clear(); diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java --- a/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/modules/ConvenientAccessErrorsTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -23,11 +23,12 @@ /* * @test - * @bug 8169197 8172668 + * @bug 8169197 8172668 8173117 * @summary Check convenient errors are produced for inaccessible classes. * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase * @run main ConvenientAccessErrorsTest */ @@ -37,6 +38,10 @@ import java.util.Arrays; import java.util.List; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Convert; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; import toolbox.JarTask; import toolbox.JavacTask; import toolbox.Task; @@ -79,6 +84,37 @@ } @Test + public void testNoDepNested(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { exports api; }", + "package api; public class Api { public static class Nested {} }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { }", + "package test; public class Test { api.Api.Nested nested; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test public void testNotExported(Path base) throws Exception { Path src = base.resolve("src"); Path src_m1 = src.resolve("m1x"); @@ -390,8 +426,7 @@ List expected = Arrays.asList( "Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", - "Test.java:1:49: compiler.err.not.def.access.package.cant.access: api.Api, api, (compiler.misc.not.def.access.not.exported: api, m1x)", - "2 errors"); + "1 error"); if (!expected.equals(log)) throw new Exception("expected output not found; actual: " + log); @@ -593,4 +628,80 @@ throw new Exception("expected output not found; actual: " + log); } + @Test + public void testInaccessibleInSourceModuleViaBinaryModule(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "@Deprecated module m1x { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires transitive m1x; }"); + Path src_m3 = src.resolve("m3x"); + tb.writeJavaFiles(src_m3, + "module m3x { requires transitive m2x; exports api; }", + "package api; class Api { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll(); + + tb.cleanDirectory(classes.resolve("m2x")); //force completion from source if needed + Files.delete(classes.resolve("m2x")); + + tb.cleanDirectory(src_m3); //binary only module + Files.delete(src_m3); + + //m4x does not depend on m1x/m2x/m3x, so cannot access api.Api + //but the recovery search should not complete m2x, as that would cause a deprecation warning: + Path src_m4 = src.resolve("m4x"); + tb.writeJavaFiles(src_m4, + "module m4x { }", + "package m4x; public class Test extends api.Api { }"); + + List log = new JavacTask(tb) + .options("-XDrawDiagnostics", + "--module-source-path", src.toString(), + "--module-path", classes.toString(), + "-Xlint:deprecation") + .outdir(classes) + .files(findJavaFiles(src_m4)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expected = Arrays.asList( + "Test.java:1:40: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m4x, api, m3x)", + "1 error"); + + if (!expected.equals(log)) + throw new Exception("expected output not found; actual: " + log); + } + + @Test + public void testConvertNameCandidates(Path base) throws Exception { + Context ctx = new Context(); + Names names = Names.instance(ctx); + Name name = names.fromString("com.sun.tools.javac.Attr.BreakAttr"); + + com.sun.tools.javac.util.List actual = + Convert.classCandidates(name).map(n -> n.toString()); + List expected = Arrays.asList( + "com.sun$tools$javac$Attr$BreakAttr", + "com.sun.tools$javac$Attr$BreakAttr", + "com.sun.tools.javac$Attr$BreakAttr", + "com.sun.tools.javac.Attr$BreakAttr", + "com.sun.tools.javac.Attr.BreakAttr" + ); + + if (!expected.equals(actual)) { + throw new Exception("Expected names not generated: " + actual); + } + } } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/EdgeCases.java --- a/langtools/test/tools/javac/modules/EdgeCases.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/modules/EdgeCases.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -23,13 +23,14 @@ /* * @test - * @bug 8154283 8167320 + * @bug 8154283 8167320 8171098 8172809 8173117 * @summary tests for multi-module mode compilation * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.code * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase * @run main EdgeCases */ @@ -44,7 +45,16 @@ import java.util.Objects; import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedOptions; +import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; +import javax.lang.model.element.ModuleElement; +import javax.lang.model.element.ModuleElement.RequiresDirective; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.ElementFilter; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; @@ -484,4 +494,164 @@ throw new AssertionError("Unexpected output: " + log); } } + + @Test + public void testInvisibleClassVisiblePackageClash(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }", + "package m1x;\n" + + "import m1x.a.*; public class Test { A a; }\n", + "package m1x.a;\n" + + "public class A { }\n"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { }", + "package m1x;\n" + + "public class a { public static class A { } }\n"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + new JavacTask(tb) + .options("--module-source-path", src.toString(), + "-XDrawDiagnostics") + .outdir(classes) + .files(findJavaFiles(src)) + .run() + .writeAll(); + } + + @Test + public void testStripUnknownRequired(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "module m1x { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { }"); + Path src_m3 = src.resolve("m3x"); + tb.writeJavaFiles(src_m3, + "module m3x { }"); + Path src_m4 = src.resolve("m4x"); + tb.writeJavaFiles(src_m4, + "module m4x { }"); + Path src_test = src.resolve("test"); + tb.writeJavaFiles(src_test, + "module test { requires m1x; requires m2x; requires java.base; requires m3x; requires m4x; }"); + Path src_compile = src.resolve("compile"); + tb.writeJavaFiles(src_compile, + "module compile { exports p to test; }", + "package p; public class Test { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log = new JavacTask(tb) + .options("-processor", ListRequires.class.getName(), + "--module-source-path", src.toString(), + "--limit-modules", "compile", + "-XDaccessInternalAPI=true") + .outdir(classes) + .files(findJavaFiles(src_compile)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.STDOUT); + + List expected = Arrays.asList( + "from directives:", + "java.base", + "from requires:", + "java.base" + ); + if (!Objects.equals(log, expected)) + throw new AssertionError("Unexpected output: " + log); + } + + @SupportedAnnotationTypes("*") + @SupportedOptions("expectedEnclosedElements") + public static final class ListRequires extends AbstractProcessor { + + private int round; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (round++ == 0) { + ModuleElement compileE = processingEnv.getElementUtils().getModuleElement("compile"); + ModuleElement testE = ElementFilter.exportsIn(compileE.getDirectives()).get(0).getTargetModules().get(0); + + System.out.println("from directives:"); + for (RequiresDirective rd : ElementFilter.requiresIn(testE.getDirectives())) { + System.out.println(rd.getDependency().getSimpleName()); + } + + System.out.println("from requires:"); + for (RequiresDirective rd : ((ModuleSymbol) testE).requires) { + System.out.println(rd.getDependency().getSimpleName()); + } + } + + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + } + + @Test + public void testOnDemandCompletionModuleInfoJava(Path base) throws Exception { + Path src = base.resolve("src"); + Path src_m1 = src.resolve("m1x"); + tb.writeJavaFiles(src_m1, + "@Deprecated module m1x { }"); + Path src_m2 = src.resolve("m2x"); + tb.writeJavaFiles(src_m2, + "module m2x { requires m1x; }"); + Path src_m3 = src.resolve("m3x"); + tb.writeJavaFiles(src_m3, + "module m3x { requires m2x; requires m1x; }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + List log; + List expected; + + log = new JavacTask(tb) + .options("--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src_m1)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList(""); + + if (!expected.equals(log)) { + throw new IllegalStateException(log.toString()); + } + + log = new JavacTask(tb) + .options("--module-source-path", src.toString(), + "-XDrawDiagnostics", + "-Xlint:deprecation") + .outdir(classes) + .files(findJavaFiles(src_m3)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "module-info.java:1:23: compiler.warn.has.been.deprecated.module: m1x", + "module-info.java:1:37: compiler.warn.has.been.deprecated.module: m1x", + "2 warnings" + ); + + if (!expected.equals(log)) { + throw new IllegalStateException(log.toString()); + } + } + } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/IncubatingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/modules/IncubatingTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2015, 2017, 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 8171177 + * @summary Verify that ModuleResolution attribute flags are honored. + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.jdeps/com.sun.tools.classfile + * jdk.jdeps/com.sun.tools.javap + * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask ModuleTestBase + * @run main IncubatingTest + */ + +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Attributes; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ClassWriter; +import com.sun.tools.classfile.ConstantPool; +import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info; +import com.sun.tools.classfile.ConstantPool.CPInfo; +import com.sun.tools.classfile.ModuleResolution_attribute; +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.Task.Expect; + +public class IncubatingTest extends ModuleTestBase { + + public static void main(String... args) throws Exception { + new IncubatingTest().runTests(); + } + + @Test + public void testDoNotResolve(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module jdk.i { exports api; }", + "package api; public class Api { }"); + Path classes = base.resolve("classes"); + Files.deleteIfExists(classes); + Path iClasses = classes.resolve("jdk.i"); + tb.createDirectories(iClasses); + + new JavacTask(tb) + .outdir(iClasses) + .files(findJavaFiles(src)) + .run() + .writeAll(); + + copyJavaBase(classes); + + Path jdkIModuleInfo = iClasses.resolve("module-info.class"); + addModuleResolutionAttribute(jdkIModuleInfo, ModuleResolution_attribute.DO_NOT_RESOLVE_BY_DEFAULT); + + Path testSrc = base.resolve("test-src"); + tb.writeJavaFiles(testSrc, + "class T { api.Api api; }"); + Path testClasses = base.resolve("test-classes"); + tb.createDirectories(testClasses); + + List log; + List expected; + + log = new JavacTask(tb) + .options("--system", "none", + "--upgrade-module-path", classes.toString(), + "-XDrawDiagnostics") + .outdir(testClasses) + .files(findJavaFiles(testSrc)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)", + "1 error" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + log = new JavacTask(tb) + .options("--system", "none", + "--upgrade-module-path", classes.toString(), + "--add-modules", "ALL-SYSTEM", + "-XDrawDiagnostics") + .outdir(testClasses) + .files(findJavaFiles(testSrc)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "T.java:1:11: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, jdk.i)", + "1 error" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + new JavacTask(tb) + .options("--system", "none", + "--upgrade-module-path", classes.toString(), + "--add-modules", "jdk.i") + .outdir(testClasses) + .files(findJavaFiles(testSrc)) + .run() + .writeAll(); + + Path testModuleSrc = base.resolve("test-module-src"); + tb.writeJavaFiles(testModuleSrc, + "module test { requires jdk.i; }", //explicit requires of an incubating module + "class T { api.Api api; }"); + Path testModuleClasses = base.resolve("test-module-classes"); + tb.createDirectories(testModuleClasses); + + new JavacTask(tb) + .options("--system", "none", + "--upgrade-module-path", classes.toString()) + .outdir(testModuleClasses) + .files(findJavaFiles(testModuleSrc)) + .run() + .writeAll(); + } + + @Test + public void testIncubating(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + "module jdk.i { exports api; }", + "package api; public class Api { }"); + Path classes = base.resolve("classes"); + Files.deleteIfExists(classes); + Path iClasses = classes.resolve("jdk.i"); + tb.createDirectories(iClasses); + + new JavacTask(tb) + .outdir(iClasses) + .files(findJavaFiles(src)) + .run() + .writeAll(); + + Path jdkIModuleInfo = iClasses.resolve("module-info.class"); + addModuleResolutionAttribute(jdkIModuleInfo, ModuleResolution_attribute.WARN_INCUBATING); + + Path testSrc = base.resolve("test-src"); + tb.writeJavaFiles(testSrc, + "class T { api.Api api; }"); + Path testClasses = base.resolve("test-classes"); + tb.createDirectories(testClasses); + + List log; + List expected; + + log = new JavacTask(tb) + .options("--module-path", classes.toString(), + "--add-modules", "jdk.i", + "-XDrawDiagnostics", + "-Werror") + .outdir(testClasses) + .files(findJavaFiles(testSrc)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "- compiler.warn.incubating.modules: jdk.i", + "- compiler.err.warnings.and.werror", + "1 error", + "1 warning" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + + Path testModuleSrc = base.resolve("test-module-src"); + tb.writeJavaFiles(testModuleSrc, + "module test { requires jdk.i; }", //explicit requires of an incubating module + "class T { api.Api api; }"); + Path testModuleClasses = base.resolve("test-module-classes"); + tb.createDirectories(testModuleClasses); + + log = new JavacTask(tb) + .options("--module-path", classes.toString(), + "-XDrawDiagnostics", + "-Werror") + .outdir(testModuleClasses) + .files(findJavaFiles(testModuleSrc)) + .run(Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + expected = Arrays.asList( + "- compiler.warn.incubating.modules: jdk.i", + "- compiler.err.warnings.and.werror", + "1 error", + "1 warning" + ); + + if (!expected.equals(log)) { + throw new AssertionError("Unexpected output: " + log); + } + } + + private void copyJavaBase(Path targetDir) throws IOException { + FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/")); + Path javaBase = jrt.getPath("modules", "java.base"); + + if (!Files.exists(javaBase)) { + throw new AssertionError("No java.base?"); + } + + Path javaBaseClasses = targetDir.resolve("java.base"); + + for (Path clazz : tb.findFiles("class", javaBase)) { + Path target = javaBaseClasses.resolve(javaBase.relativize(clazz).toString()); + Files.createDirectories(target.getParent()); + Files.copy(clazz, target); + } + } + + private void addModuleResolutionAttribute(Path classfile, int resolution_flags) throws Exception { + ClassFile cf = ClassFile.read(classfile); + Attributes attrs = cf.attributes; + List cpData = new ArrayList<>(); + cpData.add(null); + for (CPInfo info : cf.constant_pool.entries()) { + cpData.add(info); + if (info.size() == 2) + cpData.add(null); + } + cpData.add(new CONSTANT_Utf8_info(Attribute.ModuleResolution)); + ConstantPool newCP = new ConstantPool(cpData.toArray(new CPInfo[0])); + ModuleResolution_attribute res = new ModuleResolution_attribute(newCP, resolution_flags); + Map newAttributeMap = new HashMap<>(attrs.map); + newAttributeMap.put(Attribute.ModuleResolution, res); + Attributes newAttrs = new Attributes(newAttributeMap); + ClassFile newCF = new ClassFile(cf.magic, + cf.minor_version, + cf.major_version, + newCP, + cf.access_flags, + cf.this_class, + cf.super_class, + cf.interfaces, + cf.fields, + cf.methods, + newAttrs); + try (OutputStream out = Files.newOutputStream(classfile)) { + new ClassWriter().write(newCF, out); + } + } +} diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/ModulesAndModuleSourcePathTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/modules/ModulesAndModuleSourcePathTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017, 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 8165102 + * @summary incorrect message from javac + * @library /tools/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase + * @run main ModulesAndModuleSourcePathTest + */ + +import java.nio.file.Files; +import java.nio.file.Path; + +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class ModulesAndModuleSourcePathTest extends ModuleTestBase { + public static void main(String... args) throws Exception { + ModulesAndModuleSourcePathTest t = new ModulesAndModuleSourcePathTest(); + t.runTests(); + } + + @Test + public void testModuleNotInModuleSrcPath(Path base) throws Exception { + Path src = base.resolve("src"); + Path m = src.resolve("m"); + Path extra = m.resolve("extra"); + tb.writeJavaFiles(extra, "module m {}"); + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + + String log = new JavacTask(tb) + .options("-XDrawDiagnostics", "--module-source-path", src.toString()) + .outdir(classes) + .files(findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + if (!log.contains("module-info.java:1:1: compiler.err.module.not.found.on.module.source.path")) + throw new Exception("expected output not found"); + } +} diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/MultiModuleModeTest.java --- a/langtools/test/tools/javac/modules/MultiModuleModeTest.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/modules/MultiModuleModeTest.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -90,7 +90,7 @@ .writeAll() .getOutput(Task.OutputKind.DIRECT); - if (!log.contains("C.java:1:1: compiler.err.unnamed.pkg.not.allowed.named.modules")) + if (!log.contains("C.java:1:1: compiler.err.not.in.module.on.module.source.path")) throw new Exception("expected output not found"); } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/modules/PackageMultipleModules.java --- a/langtools/test/tools/javac/modules/PackageMultipleModules.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -70,9 +70,10 @@ .writeAll() .getOutputLines(Task.OutputKind.DIRECT); - List expected = Arrays.asList("A.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m1x, test, m2x)", - "B.java:1:22: compiler.err.package.not.visible: test, (compiler.misc.not.def.access.does.not.read: m2x, test, m1x)", - "2 errors"); + List expected = Arrays.asList( + "A.java:1:26: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.package, test, null)", + "B.java:1:26: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.package, test, null)", + "2 errors"); if (!log.equals(expected)) throw new Exception("expected output not found"); } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/processing/model/TestVisitorDefaults.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/processing/model/TestVisitorDefaults.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2017, 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 8172910 + * @summary Test behavior of default methods on visitors. + * @modules java.compiler + */ + +import java.util.List; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.*; +import javax.lang.model.type.*; +import javax.lang.model.util.*; + +/** + * Verify expected behavior of default methods on visitors. + */ +public class TestVisitorDefaults { + public static void main(String... args) { + DirectElementVisitorChild dvc = new DirectElementVisitorChild(); + if (!"visitUnknown".equals(dvc.visitModule(null, null))) { + throw new RuntimeException("Problem with DirectElementVisitorChild"); + } + if (!"visit".equals(dvc.visit(null))) { + throw new RuntimeException("Problem with DirectElementVisitorChild"); + } + + IndirectElementVisitorChild ivc = new IndirectElementVisitorChild(); + if (!"visitUnknown".equals(ivc.visitModule(null, null))) { + throw new RuntimeException("Problem with IndirectElementVisitorChild"); + } + + DirectTypeVisitorChild dtvc = new DirectTypeVisitorChild(); + if (!"visit".equals(dtvc.visit(null))) { + throw new RuntimeException("Problem with DirectTypeVisitorChild"); + } + + DirectAnnotationVisitorChild davc = new DirectAnnotationVisitorChild(); + if (!"visit".equals(davc.visit(null))) { + throw new RuntimeException("Problem with DirectAnnotationVisitorChild"); + } + } + + private static class DirectElementVisitorChild + implements ElementVisitor { + + public DirectElementVisitorChild() { + super(); + } + + @Override + public String visitModule(ModuleElement e, Object o) { + return ElementVisitor.super.visitModule(e, null); + } + + @Override + public String visitUnknown(Element e, Object o) { + return "visitUnknown"; + } + + @Override + public String visit(Element e) { + return ElementVisitor.super.visit(e); + } + + @Override + public String visit(Element e, Object o) { + return "visit"; + } + + @Override + public String visitExecutable(ExecutableElement e, Object o) { return throwUOE(); } + @Override + public String visitPackage(PackageElement e, Object o) { return throwUOE(); } + @Override + public String visitType(TypeElement e, Object o) { return throwUOE(); } + @Override + public String visitTypeParameter(TypeParameterElement e, Object o) { return throwUOE(); } + @Override + public String visitVariable(VariableElement e, Object o) { return throwUOE(); } + } + + private static class IndirectElementVisitorChild + extends AbstractElementVisitor6 { + + public IndirectElementVisitorChild() { + super(); + } + + @Override + public String visitModule(ModuleElement e, Object o) { + return super.visitModule(e, o); + } + + + @Override + public String visitUnknown(Element e, Object o) { + return "visitUnknown"; + } + + @Override + public String visitExecutable(ExecutableElement e, Object o) { return throwUOE(); } + @Override + public String visitPackage(PackageElement e, Object o) { return throwUOE(); } + @Override + public String visitType(TypeElement e, Object o) { return throwUOE(); } + @Override + public String visitTypeParameter(TypeParameterElement e, Object o) { return throwUOE(); } + @Override + public String visitVariable(VariableElement e, Object o) { return throwUOE(); } + } + + + private static class DirectTypeVisitorChild + implements TypeVisitor { + + public DirectTypeVisitorChild() { + super(); + } + + @Override + public String visit(TypeMirror t) { + return TypeVisitor.super.visit(t); + } + + @Override + public String visit(TypeMirror t, Object o) { + return "visit"; + } + + @Override + public String visitUnknown(TypeMirror t, Object o) { return throwUOE(); } + @Override + public String visitArray(ArrayType t, Object o) { return throwUOE(); } + @Override + public String visitDeclared(DeclaredType t, Object o) { return throwUOE(); } + @Override + public String visitError(ErrorType t, Object o) { return throwUOE(); } + @Override + public String visitExecutable(ExecutableType t, Object o) { return throwUOE(); } + @Override + public String visitIntersection(IntersectionType t, Object o) { return throwUOE(); } + @Override + public String visitNoType(NoType t, Object o) { return throwUOE(); } + @Override + public String visitNull(NullType t, Object o) { return throwUOE(); } + @Override + public String visitPrimitive(PrimitiveType t, Object o) { return throwUOE(); } + @Override + public String visitTypeVariable(TypeVariable t, Object o) { return throwUOE(); } + @Override + public String visitUnion(UnionType t, Object o) { return throwUOE(); } + @Override + public String visitWildcard(WildcardType t, Object o) { return throwUOE(); } + } + + private static class DirectAnnotationVisitorChild + implements AnnotationValueVisitor { + + @Override + public String visit(AnnotationValue av) { + return AnnotationValueVisitor.super.visit(av); + } + + @Override + public String visit(AnnotationValue av, Object o) { + return "visit"; + } + + @Override + public String visitAnnotation(AnnotationMirror a, Object o) { return throwUOE(); } + @Override + public String visitArray(List vals, + Object o) { return throwUOE(); } + @Override + public String visitBoolean(boolean b, Object o) { return throwUOE(); } + @Override + public String visitByte(byte b, Object o) { return throwUOE(); } + @Override + public String visitChar(char c, Object o) { return throwUOE(); } + @Override + public String visitDouble(double d, Object o) { return throwUOE(); } + @Override + public String visitEnumConstant(VariableElement c, Object o) { return throwUOE(); } + @Override + public String visitFloat(float f, Object o) { return throwUOE(); } + @Override + public String visitInt(int i, Object o) { return throwUOE(); } + @Override + public String visitLong(long i, Object o) { return throwUOE(); } + @Override + public String visitShort(short s, Object o) { return throwUOE(); } + @Override + public String visitString(String s, Object o) { return throwUOE(); } + @Override + public String visitType(TypeMirror t, Object o) { return throwUOE(); } + @Override + public String visitUnknown(AnnotationValue av, Object o) { return throwUOE(); } + } + + private static String throwUOE() { + throw new UnsupportedOperationException(); + } +} diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javac/processing/model/testgetallmembers/Main.java --- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2017, 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 @@ -88,6 +88,8 @@ Path path = fm.asPath(file); int moduleIndex = path.getNameCount() - type.split("\\Q.\\E").length - 1; String moduleName = path.getName(moduleIndex).toString(); + if (moduleName.startsWith("jdk.incubator.")) //incubator modules not in module graph by default + continue; try { ModuleElement me = elements.getModuleElement(moduleName); me.getClass(); diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javadoc/8147801/T8147801.java --- a/langtools/test/tools/javadoc/8147801/T8147801.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javadoc/8147801/T8147801.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -32,6 +32,8 @@ */ import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.nio.file.ClosedFileSystemException; import java.nio.file.Files; import java.nio.file.Path; @@ -80,19 +82,22 @@ void test(boolean withOption) { System.err.println("Testing " + (withOption ? "with" : "without") + " option"); try { + String dump = ""; RootDoc root = getRootDoc(withOption); for (ClassDoc cd: root.specifiedClasses()) { - dump("", cd); + dump += dump(cd); } - if (!withOption) { - error("expected option did not occur"); + if (dump.contains("lib.Lib2.i")) { + if (!withOption) { + error("control case failed: Lib2 class file was read, unexpectedly, without using option"); + } + } else { + if (withOption) { + error("test case failed: could not read Lib2 class file, using option"); + } } } catch (ClosedFileSystemException e) { - if (withOption) { - error("Unexpected exception: " + e); - } else { - System.err.println("Exception received as expected: " + e); - } + error("Unexpected exception: " + e); } System.err.println(); } @@ -118,12 +123,21 @@ return cachedRoot; } - void dump(String prefix, ClassDoc cd) { - System.err.println(prefix + "class: " + cd); + String dump(ClassDoc cd) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + dump(pw, "", cd); + String out = sw.toString(); + System.err.println(out); + return out; + } + + void dump(PrintWriter out, String prefix, ClassDoc cd) { + out.println(prefix + "class: " + cd); for (FieldDoc fd: cd.fields()) { - System.err.println(fd); + out.println(prefix + " " + fd); if (fd.type().asClassDoc() != null) { - dump(prefix + " ", fd.type().asClassDoc()); + dump(out, prefix + " ", fd.type().asClassDoc()); } } } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javadoc/8147801/jarsrc/lib/Lib2.java --- a/langtools/test/tools/javadoc/8147801/jarsrc/lib/Lib2.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javadoc/8147801/jarsrc/lib/Lib2.java Fri Jan 20 19:10:00 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, 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 @@ -24,5 +24,5 @@ package lib; public class Lib2 { - int i; + public int i; } diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javadoc/TestScriptInComment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javadoc/TestScriptInComment.java Fri Jan 20 19:10:00 2017 +0000 @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 8138725 + * @summary test --allow-script-in-comments + * @modules jdk.javadoc/com.sun.tools.javadoc + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Combo-style test, exercising combinations of different HTML fragments that may contain + * JavaScript, different places to place those fragments, and whether or not to allow the use + * of JavaScript. + */ +public class TestScriptInComment { + public static void main(String... args) throws Exception { + new TestScriptInComment().run(); + } + + /** + * Representative samples of different fragments of HTML that may contain JavaScript. + * To facilitate checking the output manually in a browser, the text "#ALERT" will be + * replaced by a JavaScript call of "alert(msg)", using a message string that is specific + * to the test case. + */ + enum Comment { + LC("", true), // script tag in Lower Case + UC("", true), // script tag in Upper Case + WS("< script >#ALERT", false, "-Xdoclint:none"), // script tag with invalid white space + SA("", true), // script tag with an attribute + ON("x", true), // event handler attribute + URI("x", true); // javadcript URI + + /** + * Creates an HTML fragment to be injected into a template. + * @param text the HTML fragment to put into a doc comment or option. + * @param hasScript whether or not this fragment does contain legal JavaScript + * @param opts any additional options to be specified when javadoc is run + */ + Comment(String text, boolean hasScript, String... opts) { + this.text = text; + this.hasScript = hasScript; + this.opts = Arrays.asList(opts); + } + + final String text; + final boolean hasScript; + final List opts; + }; + + /** + * Representative samples of positions in which javadoc may find JavaScript. + * Each template contains a series of strings, which are written to files or inferred as options. + * The first source file implies a corresponding output file which should not be written + * if the comment contains JavaScript and JavaScript is not allowed. + */ + enum Template { + OVR(" overview #COMMENT ", "package p; public class C { }"), + PKGINFO("#COMMENT package p;", "package p; public class C { }"), + PKGHTML("#COMMENT package p;", "package p; public class C { }"), + CLS("package p; #COMMENT public class C { }"), + CON("package p; public class C { #COMMENT public C() { } }"), + FLD("package p; public class C { #COMMENT public int f; }"), + MTH("package p; public class C { #COMMENT public void m() { } }"), + TOP("-top", "lorem #COMMENT ipsum", "package p; public class C { }"), + HDR("-header", "lorem #COMMENT ipsum", "package p; public class C { }"), + FTR("-footer", "lorem #COMMENT ipsum", "package p; public class C { }"), + BTM("-bottom", "lorem #COMMENT ipsum", "package p; public class C { }"), + DTTL("-doctitle", "lorem #COMMENT ipsum", "package p; public class C { }"), + PHDR("-packagesheader", "lorem #COMMENT ipsum", "package p; public class C { }"); + + Template(String... args) { + opts = new ArrayList(); + sources = new ArrayList(); + int i = 0; + while (args[i].startsWith("-")) { + // all options being tested have a single argument that follow the option + opts.add(args[i++]); + opts.add(args[i++]); + } + while(i < args.length) { + sources.add(args[i++]); + } + } + + // groups: 1 or not; 2: package name; 3: class name + private final Pattern pat = + Pattern.compile("(?i)()?.*?(?:package ([a-z]+);.*?(?:class ([a-z]+).*)?)?"); + + /** + * Infer the file in which to write the given source. + * @param dir the base source directory + * @param src the source text + * @return the file in which the source should be written + */ + File getSrcFile(File srcDir, String src) { + String f; + Matcher m = pat.matcher(src); + if (!m.matches()) + throw new Error("match failed"); + if (m.group(3) != null) { + f = m.group(2) + "/" + m.group(3) + ".java"; + } else if (m.group(2) != null) { + f = m.group(2) + "/" + (m.group(1) == null ? "package-info.java" : "package.html"); + } else { + f = "overview.html"; + } + return new File(srcDir, f); + } + + /** + * Get the options to give to javadoc. + * @param srcDir the srcDir to use -overview is needed + * @return + */ + List getOpts(File srcDir) { + if (!opts.isEmpty()) { + return opts; + } else if (sources.get(0).contains("overview")) { + return Arrays.asList("-overview", getSrcFile(srcDir, sources.get(0)).getPath()); + } else { + return Collections.emptyList(); + } + } + + /** + * Gets the output file corresponding to the first source file. + * This file should not be written if the comment contains JavaScript and JavaScripot is + * not allowed. + * @param dir the base output directory + * @return the output file + */ + File getOutFile(File outDir) { + String f; + Matcher m = pat.matcher(sources.get(0)); + if (!m.matches()) + throw new Error("match failed"); + if (m.group(3) != null) { + f = m.group(2) + "/" + m.group(3) + ".html"; + } else if (m.group(2) != null) { + f = m.group(2) + "/package-summary.html"; + } else { + f = "overview-summary.html"; + } + return new File(outDir, f); + } + + final List opts; + final List sources; + }; + + enum Option { + OFF(null), + ON("--allow-script-in-comments"); + + Option(String text) { + this.text = text; + } + + final String text; + }; + + private PrintStream out = System.err; + + public void run() throws Exception { + int count = 0; + for (Template template: Template.values()) { + for (Comment comment: Comment.values()) { + for (Option option: Option.values()) { + if (test(template, comment, option)) { + count++; + } + } + } + } + + out.println(count + " test cases run"); + if (errors > 0) { + throw new Exception(errors + " errors occurred"); + } + } + + boolean test(Template template, Comment comment, Option option) throws IOException { + if (option == Option.ON && !comment.hasScript) { + // skip --allowScriptInComments if comment does not contain JavaScript + return false; + } + + String test = template + "-" + comment + "-" + option; + out.println("Test: " + test); + + File dir = new File(test); + dir.mkdirs(); + File srcDir = new File(dir, "src"); + File outDir = new File(dir, "out"); + + String alert = "alert(\"" + test + "\");"; + for (String src: template.sources) { + writeFile(template.getSrcFile(srcDir, src), + src.replace("#COMMENT", + "/** " + comment.text.replace("#ALERT", alert) + " **/")); + } + + List opts = new ArrayList(); + opts.add("-sourcepath"); + opts.add(srcDir.getPath()); + opts.add("-d"); + opts.add(outDir.getPath()); + if (option.text != null) + opts.add(option.text); + for (String opt: template.getOpts(srcDir)) { + opts.add(opt.replace("#COMMENT", comment.text.replace("#ALERT", alert))); + } + opts.addAll(comment.opts); + opts.add("-noindex"); // index not required; save time/space writing files + opts.add("p"); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = javadoc(opts, pw); + pw.close(); + String log = sw.toString(); + writeFile(new File(dir, "log.txt"), log); + + out.println("opts: " + opts); + out.println(" rc: " + rc); + out.println(" log:"); + out.println(log); + + String ERROR = "Use --allow-script-in-comment"; + File outFile = template.getOutFile(outDir); + + boolean expectErrors = comment.hasScript && (option == Option.OFF); + + if (expectErrors) { + check(rc != 0, "unexpected exit code: " + rc); + check(log.contains(ERROR), "expected error message not found"); + check(!outFile.exists(), "output file found unexpectedly"); + } else { + check(rc == 0, "unexpected exit code: " + rc); + check(!log.contains(ERROR), "error message found"); + check(outFile.exists(), "output file not found"); + } + + out.println(); + return true; + } + + int javadoc(List opts, PrintWriter pw) { + return com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, + "com.sun.tools.doclets.standard.Standard", opts.toArray(new String[opts.size()])); + } + + File writeFile(File f, String text) throws IOException { + f.getParentFile().mkdirs(); + FileWriter fw = new FileWriter(f); + try { + fw.write(text); + } finally { + fw.close(); + } + return f; + } + + void check(boolean cond, String errMessage) { + if (!cond) { + error(errMessage); + } + } + + void error(String message) { + out.println("Error: " + message); + errors++; + } + + int errors = 0; +} + diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/javap/T7004698.java --- a/langtools/test/tools/javap/T7004698.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/javap/T7004698.java Fri Jan 20 19:10:00 2017 +0000 @@ -42,6 +42,7 @@ File srcFile = new File(srcDir, T7004698.class.getSimpleName() + ".java"); File classesDir = new File("."); compile("-Xjcov", + "--add-modules", "jdk.jdeps", "--add-exports", "jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED", "-d", classesDir.getPath(), srcFile.getPath()); diff -r 8c70d170e62c -r b73702608fc6 langtools/test/tools/jdeps/APIDeps.java --- a/langtools/test/tools/jdeps/APIDeps.java Wed Jul 05 22:43:19 2017 +0200 +++ b/langtools/test/tools/jdeps/APIDeps.java Fri Jan 20 19:10:00 2017 +0000 @@ -60,6 +60,9 @@ Path testsrc = Paths.get(System.getProperty("test.src")); List options = new ArrayList<>(); + // jdk.jdeps is a service provider module so needs to be explicitly included + options.add("--add-modules=jdk.jdeps"); + // add --add-exports String testModules = System.getProperty("test.modules", ""); List addExports = new ArrayList<>();