This commit is contained in:
Lana Steuck 2017-03-09 23:15:55 +00:00
commit e837893b3a
43 changed files with 480 additions and 213 deletions

View File

@ -251,7 +251,7 @@ public interface ModuleElement extends Element, QualifiedNameable {
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @throws UnknownDirectiveException a visitor implementation may optionally throw this exception
* @implSpec This implementation throws {@code UnknownDirectiveException}.
* @implSpec This implementation throws {@code new UnknownDirectiveException(d, p)}.
*/
default R visitUnknown(Directive d, P p) {
throw new UnknownDirectiveException(d, p);

View File

@ -106,7 +106,7 @@ public abstract class AbstractAnnotationValueVisitor6<R, P>
*
* @implSpec The default implementation of this method in {@code
* AbstractAnnotationValueVisitor6} will always throw {@code
* UnknownAnnotationValueException}. This behavior is not
* new UnknownAnnotationValueException(av, p)}. This behavior is not
* required of a subclass.
*
* @param av {@inheritDoc}

View File

@ -111,7 +111,7 @@ public abstract class AbstractElementVisitor6<R, P> implements ElementVisitor<R,
*
* @implSpec The default implementation of this method in
* {@code AbstractElementVisitor6} will always throw
* {@code UnknownElementException}.
* {@code new UnknownElementException(e, p)}.
* This behavior is not required of a subclass.
*
* @param e {@inheritDoc}

View File

@ -142,7 +142,7 @@ public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
*
* @implSpec The default implementation of this method in {@code
* AbstractTypeVisitor6} will always throw {@code
* UnknownTypeException}. This behavior is not required of a
* new UnknownTypeException(t, p)}. This behavior is not required of a
* subclass.
*
* @param t {@inheritDoc}

View File

@ -29,8 +29,6 @@ import com.sun.tools.javac.code.Kinds.Kind;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
@ -40,6 +38,8 @@ import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
import static com.sun.tools.javac.code.Scope.LookupKind.RECURSIVE;
import static com.sun.tools.javac.util.Iterators.createCompoundIterator;
import static com.sun.tools.javac.util.Iterators.createFilterIterator;
/** A scope represents an area of visibility in a Java program. The
* Scope class is a container for symbols which provides
@ -898,7 +898,11 @@ public abstract class Scope {
return tsym.members().getSymbols(sf, lookupKind);
}
};
return si.importFrom((TypeSymbol) origin.owner) :: iterator;
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
@ -918,7 +922,11 @@ public abstract class Scope {
return tsym.members().getSymbolsByName(name, sf, lookupKind);
}
};
return si.importFrom((TypeSymbol) origin.owner) :: iterator;
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
@ -942,22 +950,19 @@ public abstract class Scope {
public SymbolImporter(boolean inspectSuperTypes) {
this.inspectSuperTypes = inspectSuperTypes;
}
Stream<Symbol> importFrom(TypeSymbol tsym) {
List<Iterable<Symbol>> importFrom(TypeSymbol tsym, List<Iterable<Symbol>> results) {
if (tsym == null || !processed.add(tsym))
return Stream.empty();
return results;
Stream<Symbol> result = Stream.empty();
if (inspectSuperTypes) {
// also import inherited names
result = importFrom(types.supertype(tsym.type).tsym);
results = importFrom(types.supertype(tsym.type).tsym, results);
for (Type t : types.interfaces(tsym.type))
result = Stream.concat(importFrom(t.tsym), result);
results = importFrom(t.tsym, results);
}
return Stream.concat(StreamSupport.stream(doLookup(tsym).spliterator(), false)
.filter(s -> filter.accepts(origin, s)),
result);
return results.prepend(doLookup(tsym));
}
abstract Iterable<Symbol> doLookup(TypeSymbol tsym);
}

View File

@ -30,12 +30,12 @@ import java.util.ArrayDeque;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import java.util.function.Function;
import javax.lang.model.type.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.TypeMetadata.Entry;
import com.sun.tools.javac.code.Types.TypeMapping;
import com.sun.tools.javac.comp.Infer.IncorporationAction;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.DefinedBy.Api;
@ -222,18 +222,12 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
this.metadata = metadata;
}
/** An abstract class for mappings from types to types
/**
* A subclass of {@link Types.TypeMapping} which applies a mapping recursively to the subterms
* of a given type expression. This mapping returns the original type is no changes occurred
* when recursively mapping the original type's subterms.
*/
public static abstract class TypeMapping<S> extends Types.MapVisitor<S> implements Function<Type, Type> {
@Override
public Type apply(Type type) {
return visit(type);
}
List<Type> visit(List<Type> ts, S s) {
return ts.map(t -> visit(t, s));
}
public static abstract class StructuralTypeMapping<S> extends Types.TypeMapping<S> {
@Override
public Type visitClassType(ClassType t, S s) {
@ -298,11 +292,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
};
}
@Override
public Type visitCapturedType(CapturedType t, S s) {
return visitTypeVar(t, s);
}
@Override
public Type visitForAll(ForAll t, S s) {
return visit(t.qtype, s);
@ -373,7 +362,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return accept(stripMetadata, null);
}
//where
private final static TypeMapping<Void> stripMetadata = new TypeMapping<Void>() {
private final static TypeMapping<Void> stripMetadata = new StructuralTypeMapping<Void>() {
@Override
public Type visitClassType(ClassType t, Void aVoid) {
return super.visitClassType((ClassType)t.typeNoMetadata(), aVoid);
@ -2125,7 +2114,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
}
}
//where
TypeMapping<Void> toTypeVarMap = new TypeMapping<Void>() {
TypeMapping<Void> toTypeVarMap = new StructuralTypeMapping<Void>() {
@Override
public Type visitUndetVar(UndetVar uv, Void _unused) {
return uv.inst != null ? uv.inst : uv.qtype;

View File

@ -34,6 +34,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.stream.Collector;
import javax.tools.JavaFileObject;
@ -2095,7 +2096,7 @@ public class Types {
}
}
// where
private TypeMapping<Boolean> erasure = new TypeMapping<Boolean>() {
private TypeMapping<Boolean> erasure = new StructuralTypeMapping<Boolean>() {
private Type combineMetadata(final Type s,
final Type t) {
if (t.getMetadata() != TypeMetadata.EMPTY) {
@ -3019,7 +3020,7 @@ public class Types {
return t.map(new Subst(from, to));
}
private class Subst extends TypeMapping<Void> {
private class Subst extends StructuralTypeMapping<Void> {
List<Type> from;
List<Type> to;
@ -4707,6 +4708,25 @@ public class Types {
final public Type visit(Type t) { return t.accept(this, null); }
public Type visitType(Type t, S s) { return t; }
}
/**
* An abstract class for mappings from types to types (see {@link Type#map(TypeMapping)}.
* This class implements the functional interface {@code Function}, that allows it to be used
* fluently in stream-like processing.
*/
public static class TypeMapping<S> extends MapVisitor<S> implements Function<Type, Type> {
@Override
public Type apply(Type type) { return visit(type); }
List<Type> visit(List<Type> ts, S s) {
return ts.map(t -> visit(t, s));
}
@Override
public Type visitCapturedType(CapturedType t, S s) {
return visitTypeVar(t, s);
}
}
// </editor-fold>

View File

@ -3058,7 +3058,8 @@ public class Attr extends JCTree.Visitor {
if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
if (resType.isErroneous() ||
new FunctionalReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
new FunctionalReturnContext(checkContext).compatible(resType, returnType,
checkContext.checkWarner(tree, resType, returnType))) {
incompatibleReturnType = null;
}
}

View File

@ -28,7 +28,8 @@ package com.sun.tools.javac.comp;
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
import com.sun.source.tree.NewClassTree;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.TypeMapping;
import com.sun.tools.javac.code.Type.StructuralTypeMapping;
import com.sun.tools.javac.code.Types.TypeMapping;
import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext;
import com.sun.tools.javac.comp.Resolve.ResolveError;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
@ -929,7 +930,7 @@ public class DeferredAttr extends JCTree.Visitor {
* where T is computed by retrieving the type that has already been
* computed for D during a previous deferred attribution round of the given kind.
*/
class DeferredTypeMap extends TypeMapping<Void> {
class DeferredTypeMap extends StructuralTypeMapping<Void> {
DeferredAttrContext deferredAttrContext;
protected DeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {

View File

@ -26,6 +26,7 @@
package com.sun.tools.javac.comp;
import com.sun.tools.javac.code.Type.UndetVar.UndetVarListener;
import com.sun.tools.javac.code.Types.TypeMapping;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.TreeInfo;
@ -61,9 +62,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import com.sun.tools.javac.main.Option;
import static com.sun.tools.javac.code.TypeTag.*;
@ -628,7 +626,7 @@ public class Infer {
}
}
TypeMapping<Void> fromTypeVarFun = new TypeMapping<Void>() {
TypeMapping<Void> fromTypeVarFun = new StructuralTypeMapping<Void>() {
@Override
public Type visitTypeVar(TypeVar tv, Void aVoid) {
UndetVar uv = new UndetVar(tv, incorporationEngine(), types);

View File

@ -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
@ -334,6 +334,9 @@ public class InferenceContext {
}
InferenceContext min(List<Type> roots, boolean shouldSolve, Warner warn) {
if (roots.length() == inferencevars.length()) {
return this;
}
ReachabilityVisitor rv = new ReachabilityVisitor();
rv.scan(roots);
if (rv.min.size() == inferencevars.length()) {
@ -347,8 +350,8 @@ public class InferenceContext {
ListBuffer<Type> minUndetVars = new ListBuffer<>();
for (Type minVar : minVars) {
UndetVar uv = (UndetVar)asUndetVar(minVar);
Assert.check(uv.incorporationActions.size() == 0);
UndetVar uv2 = new UndetVar((TypeVar)minVar, infer.incorporationEngine(), types);
Assert.check(uv.incorporationActions.isEmpty());
UndetVar uv2 = uv.dup(types);
for (InferenceBound ib : InferenceBound.values()) {
List<Type> newBounds = uv.getBounds(ib).stream()
.filter(b -> !redundantVars.contains(b))
@ -363,15 +366,19 @@ public class InferenceContext {
for (Type t : minContext.inferencevars) {
//add listener that forwards notifications to original context
minContext.addFreeTypeListener(List.of(t), (inferenceContext) -> {
List<Type> depVars = List.from(rv.minMap.get(t));
solve(depVars, warn);
notifyChange();
((UndetVar)asUndetVar(t)).setInst(inferenceContext.asInstType(t));
infer.doIncorporation(inferenceContext, warn);
solve(List.from(rv.minMap.get(t)), warn);
notifyChange();
});
}
if (shouldSolve) {
//solve definitively unreachable variables
List<Type> unreachableVars = redundantVars.diff(List.from(rv.equiv));
solve(unreachableVars, warn);
minContext.addFreeTypeListener(minVars, (inferenceContext) -> {
solve(unreachableVars, warn);
notifyChange();
});
}
return minContext;
}

View File

@ -2354,7 +2354,7 @@ public class ClassReader {
(flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
if (majorVersion > Version.V52.major ||
(majorVersion == Version.V52.major && minorVersion >= Version.V52.minor)) {
if ((flags & STATIC) == 0) {
if ((flags & (STATIC | PRIVATE)) == 0) {
currentOwner.flags_field |= DEFAULT;
flags |= DEFAULT | ABSTRACT;
}

View File

@ -28,6 +28,7 @@ package com.sun.tools.javac.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.function.Function;
import java.util.function.Predicate;
/** Utilities for Iterators.
*
@ -92,4 +93,32 @@ public class Iterators {
return null;
}
};
public static <E> Iterator<E> createFilterIterator(Iterator<E> input, Predicate<E> test) {
return new Iterator<E>() {
private E current = update();
private E update () {
while (input.hasNext()) {
E sym = input.next();
if (test.test(sym)) {
return sym;
}
}
return null;
}
@Override
public boolean hasNext() {
return current != null;
}
@Override
public E next() {
E res = current;
current = update();
return res;
}
};
}
}

View File

@ -23,16 +23,13 @@
* questions.
*/
package jdk.javadoc.doclets;
package jdk.javadoc.doclet;
import java.util.Locale;
import java.util.Set;
import javax.lang.model.SourceVersion;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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,7 +23,7 @@
* questions.
*/
package jdk.javadoc.doclet.taglet;
package jdk.javadoc.doclet;
import java.util.List;
import java.util.Set;
@ -31,11 +31,15 @@ import java.util.Set;
import com.sun.source.doctree.DocTree;
/**
* The interface for a custom tag used by Doclets. A custom
* tag must implement this interface, and must have a public
* default constructor (i.e. a public constructor with no
* The interface for a custom taglet supported by doclets such as
* the {@link jdk.javadoc.doclet.StandardDoclet standard doclet}.
* Custom taglets are used to handle custom tags in documentation
* comments.
*
* <p>A custom taglet must implement this interface, and must have
* a public default constructor (i.e. a public constructor with no
* parameters), by which, the doclet will instantiate and
* register the custom tag.
* register the custom taglet.
*
* @since 9
*/
@ -43,16 +47,14 @@ import com.sun.source.doctree.DocTree;
public interface Taglet {
/**
* Returns the set of locations in which a taglet may be used.
* @return the set of locations in which a taglet may be used
* allowed in or an empty set.
* Returns the set of locations in which a tag may be used.
* @return the set of locations in which a tag may be used
*/
Set<Location> getAllowedLocations();
/**
* Indicates the tag is an inline or a body tag.
* @return true if this <code>Taglet</code>
* is an inline tag, false otherwise.
* Indicates whether this taglet is for inline tags or not.
* @return true if this taglet is for an inline tag, and false otherwise
*/
boolean isInlineTag();
@ -63,26 +65,21 @@ public interface Taglet {
String getName();
/**
* Given the {@link DocTree DocTree} representation of this custom
* tag, return its string representation, which is output
* to the generated page.
* @param tag the <code>Tag</code> representation of this custom tag.
* @return the string representation of this <code>Tag</code>.
*/
String toString(DocTree tag);
/**
* Given a List of {@link DocTree DocTrees} representing this custom
* tag, return its string representation, which is output
* to the generated page. This method should
* return null if this taglet represents an inline or body tag.
* @param tags the list of <code>DocTree</code>s representing this custom tag.
* @return the string representation of this <code>Tag</code>.
* Returns the string representation of a series of instances of
* this tag to be included in the generated output.
* If this taglet is for an {@link #isInlineTag inline} tag} it will
* be called once per instance of the tag, each time with a singleton list.
* Otherwise, if this tag is a block tag, it will be called once per
* comment, with a list of all the instances of the tag in the comment.
* @param tags the list of {@code DocTree} containing one or more
* instances of this tag
* @return the string representation of the tags to be included in
* the generated output
*/
String toString(List<? extends DocTree> tags);
/**
* The kind of location.
* The kind of location in which a tag may be used.
*/
public static enum Location {
/** In an Overview document. */

View File

@ -29,6 +29,12 @@
* to inspect the source-level structures of programs and
* libraries, including API comments embedded in the source.
*
* <p>
* The {@link StandardDoclet standard doclet} can be used to
* generate HTML-formatted documentation. It supports user-defined
* {@link Taglet taglets}, which can be used to generate customized
* output for user-defined tags in documentation comments.
*
* <p style="font-style: italic">
* <b>Note:</b> The declarations in this package supersede those
* in the older package {@code com.sun.javadoc}. For details on the

View File

@ -34,7 +34,7 @@ import javax.lang.model.element.TypeElement;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclets.StandardDoclet;
import jdk.javadoc.doclet.StandardDoclet;
import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet;
import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;

View File

@ -251,7 +251,7 @@ public class TagletManager {
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
Class<?> customTagClass = tagClassLoader.loadClass(classname);
Object instance = customTagClass.getConstructor().newInstance();
Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.Taglet)instance);
String tname = newLegacy.getName();
Taglet t = customTags.get(tname);
if (t != null) {
@ -315,8 +315,8 @@ public class TagletManager {
private void checkTaglet(Object taglet) {
if (taglet instanceof Taglet) {
checkTagName(((Taglet) taglet).getName());
} else if (taglet instanceof jdk.javadoc.doclet.taglet.Taglet) {
jdk.javadoc.doclet.taglet.Taglet legacyTaglet = (jdk.javadoc.doclet.taglet.Taglet) taglet;
} else if (taglet instanceof jdk.javadoc.doclet.Taglet) {
jdk.javadoc.doclet.Taglet legacyTaglet = (jdk.javadoc.doclet.Taglet) taglet;
customTags.remove(legacyTaglet.getName());
customTags.put(legacyTaglet.getName(), new UserTaglet(legacyTaglet));
checkTagName(legacyTaglet.getName());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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,6 +24,7 @@
*/
package jdk.javadoc.internal.doclets.toolkit.taglets;
import java.util.Collections;
import java.util.List;
import javax.lang.model.element.Element;
@ -33,10 +34,10 @@ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
import static jdk.javadoc.doclet.Taglet.Location.*;
/**
* A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.taglet.Taglet}
* A taglet wrapper, allows the public taglet {@link jdk.javadoc.doclet.Taglet}
* wrapped into an internal Taglet representation.
*
* <p><b>This is NOT part of any supported API.
@ -48,9 +49,9 @@ import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
*/
public class UserTaglet implements Taglet {
final private jdk.javadoc.doclet.taglet.Taglet userTaglet;
final private jdk.javadoc.doclet.Taglet userTaglet;
public UserTaglet(jdk.javadoc.doclet.taglet.Taglet t) {
public UserTaglet(jdk.javadoc.doclet.Taglet t) {
userTaglet = t;
}
@ -131,7 +132,7 @@ public class UserTaglet implements Taglet {
*/
public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer){
Content output = writer.getOutputInstance();
output.addContent(new RawHtml(userTaglet.toString(tag)));
output.addContent(new RawHtml(userTaglet.toString(Collections.singletonList(tag))));
return output;
}

View File

@ -188,6 +188,11 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
.classTrees(classTrees.toList())
.scanSpecifiedItems();
// abort, if errors were encountered during modules initialization
if (messager.hasErrors()) {
return null;
}
// Parse the files in the packages and subpackages to be documented
ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>();
parse(etable.getFilesToParse(), packageTrees, false);

View File

@ -93,7 +93,7 @@ public class Start extends ToolOption.Helper {
com.sun.tools.doclets.standard.Standard.class;
private static final Class<?> StdDoclet =
jdk.javadoc.doclets.StandardDoclet.class;
jdk.javadoc.doclet.StandardDoclet.class;
/** Context for this invocation. */
private final Context context;

View File

@ -40,8 +40,6 @@ module jdk.javadoc {
exports com.sun.tools.javadoc;
exports jdk.javadoc.doclet;
exports jdk.javadoc.doclet.taglet;
exports jdk.javadoc.doclets;
provides java.util.spi.ToolProvider
with jdk.javadoc.internal.tool.JavadocToolProvider;

View File

@ -524,7 +524,7 @@ class JdepsTask {
e.printStackTrace();
return EXIT_CMDERR;
} catch (MultiReleaseException e) {
reportError(e.getKey(), (Object)e.getMsg());
reportError(e.getKey(), e.getParams());
return EXIT_CMDERR; // could be EXIT_ABNORMAL sometimes
} finally {
log.flush();

View File

@ -34,7 +34,7 @@ package com.sun.tools.jdeps;
class MultiReleaseException extends RuntimeException {
private static final long serialVersionUID = 4474870142461654108L;
private final String key;
private final String[] msg;
private final Object[] params;
/**
* Constructs an {@code MultiReleaseException} with the specified detail
@ -42,13 +42,13 @@ class MultiReleaseException extends RuntimeException {
*
* @param key
* The key that identifies the message in the jdeps.properties file
* @param msg
* @param params
* The detail message array
*/
public MultiReleaseException(String key, String... msg) {
public MultiReleaseException(String key, Object... params) {
super();
this.key = key;
this.msg = msg;
this.params = params;
}
/**
@ -63,7 +63,7 @@ class MultiReleaseException extends RuntimeException {
*
* @return the detailed error message array
*/
public String[] getMsg() {
return msg;
public Object[] getParams() {
return params;
}
}

View File

@ -93,7 +93,7 @@ main.opt.m=\
main.opt.R=\
\ -R -recursive Recursively traverse all run-time dependences.\n\
\ The -R option implies -filter:none. If -p,\n\
\ -e, -foption is specified, only the matching\n\
\ -e, -f option is specified, only the matching\n\
\ dependences are analyzed.
main.opt.I=\
@ -196,8 +196,8 @@ err.module.not.found=module not found: {0}
err.root.module.not.set=root module set empty
err.option.already.specified={0} option specified more than once.
err.filter.not.specified=--package (-p), --regex (-e), --require option must be specified
err.multirelease.option.exists={0} is not a multi-release jar file, but the --multi-release option is set
err.multirelease.option.notfound={0} is a multi-release jar file, but the --multi-release option is not set
err.multirelease.option.exists={0} is not a multi-release jar file but --multi-release option is set
err.multirelease.option.notfound={0} is a multi-release jar file but --multi-release option is not set
err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2}
err.multirelease.jar.malformed=malformed multi-release jar, {0}, bad entry: {1}
warn.invalid.arg=Path does not exist: {0}

View File

@ -43,7 +43,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
@ -82,7 +81,7 @@ class ConsoleIOContext extends IOContext {
ConsoleIOContext(JShellTool repl, InputStream cmdin, PrintStream cmdout) throws Exception {
this.repl = repl;
this.input = new StopDetectingInputStream(() -> repl.state.stop(), ex -> repl.hard("Error on input: %s", ex));
this.input = new StopDetectingInputStream(() -> repl.stop(), ex -> repl.hard("Error on input: %s", ex));
Terminal term;
if (System.getProperty("test.jdk") != null) {
term = new TestTerminal(input);
@ -617,7 +616,7 @@ class ConsoleIOContext extends IOContext {
@Override
public void perform(ConsoleReader in) throws IOException {
repl.state.eval("import " + type + ";");
repl.processCompleteSource("import " + type + ";");
in.println("Imported: " + type);
performToVar(in, stype);
}
@ -641,7 +640,7 @@ class ConsoleIOContext extends IOContext {
@Override
public void perform(ConsoleReader in) throws IOException {
repl.state.eval("import " + fqn + ";");
repl.processCompleteSource("import " + fqn + ";");
in.println("Imported: " + fqn);
in.redrawLine();
}

View File

@ -187,7 +187,7 @@ public class JShellTool implements MessageHandler {
private Options options;
SourceCodeAnalysis analysis;
JShell state = null;
private JShell state = null;
Subscription shutdownSubscription = null;
static final EditorSetting BUILT_IN_EDITOR = new EditorSetting(null, false);
@ -1704,6 +1704,11 @@ public class JShellTool implements MessageHandler {
return null;
}
// Attempt to stop currently running evaluation
void stop() {
state.stop();
}
// --- Command implementations ---
private static final String[] SET_SUBCOMMANDS = new String[]{
@ -2857,7 +2862,7 @@ public class JShellTool implements MessageHandler {
}
}
//where
private boolean processCompleteSource(String source) throws IllegalStateException {
boolean processCompleteSource(String source) throws IllegalStateException {
debug("Compiling: %s", source);
boolean failed = false;
boolean isActive = false;

View File

@ -36,7 +36,7 @@ import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type.CapturedType;
import com.sun.tools.javac.code.Type.TypeMapping;
import com.sun.tools.javac.code.Type.StructuralTypeMapping;
import com.sun.tools.javac.code.Type.TypeVar;
import com.sun.tools.javac.code.Type.WildcardType;
import com.sun.tools.javac.code.Types;
@ -158,7 +158,7 @@ class VarTypePrinter extends TypePrinter {
}
}
class TypeProjection extends TypeMapping<Boolean> {
class TypeProjection extends StructuralTypeMapping<Boolean> {
List<Type> vars;
Set<Type> seen = new HashSet<>();

View File

@ -26,12 +26,11 @@ import java.util.List;
import java.util.Set;
import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.taglet.Taglet;
import jdk.javadoc.doclet.Taglet;
public class Check implements Taglet {
private static final String TAG_NAME = "check";
private static final String TAG_HEADER = "Check:";
private final EnumSet<Location> allowedSet = EnumSet.allOf(Location.class);
@ -45,6 +44,7 @@ public class Check implements Taglet {
*
* @return false since the tag is not an inline tag.
*/
@Override
public boolean isInlineTag() {
return false;
}
@ -54,28 +54,19 @@ public class Check implements Taglet {
*
* @return the name of this tag.
*/
@Override
public String getName() {
return TAG_NAME;
}
/**
* Given the DocTree representation of this custom tag, return its string
* representation.
*
* @param tag the DocTree representing this custom tag.
*/
public String toString(DocTree tag) {
return "<dt><span class=\"simpleTagLabel\">" + TAG_HEADER + ":</span></dt><dd>" +
tag.toString() + "</dd>\n";
}
/**
* Given an array of DocTrees representing this custom tag, return its string
* Given a list of DocTrees representing this custom tag, return its string
* representation.
*
* @param tags the array of tags representing this custom tag.
* @return null to test if the javadoc throws an exception or not.
*/
@Override
public String toString(List<? extends DocTree> tags) {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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,7 +23,7 @@
/*
* @test
* @bug 4638723 8015882
* @bug 4638723 8015882 8176131 8176331
* @summary Test to ensure that the refactored version of the standard
* doclet still works with Taglets that implement the 1.4.0 interface.
* @author jamieh

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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,9 +32,9 @@ import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.UnknownBlockTagTree;
import com.sun.source.doctree.UnknownInlineTagTree;
import com.sun.source.util.SimpleDocTreeVisitor;
import jdk.javadoc.doclet.taglet.Taglet;
import jdk.javadoc.doclet.taglet.Taglet.Location;
import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.doclet.Taglet.Location;
import static jdk.javadoc.doclet.Taglet.Location.*;
/**
@ -83,19 +83,6 @@ public class ToDoTaglet implements Taglet {
return false;
}
/**
* Given the <code>DocTree</code> representation of this custom
* tag, return its string representation.
* @param tag the <code>DocTree</code> representing this custom tag.
*/
public String toString(DocTree tag) {
return "<DT><B>" + HEADER + "</B><DD>"
+ "<table summary=\"Summary\" cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">"
+ getText(tag)
+ "</td></tr></table></DD>\n";
}
/**
* Given an array of <code>Tag</code>s representing this custom
* tag, return its string representation.
@ -104,7 +91,7 @@ public class ToDoTaglet implements Taglet {
@Override
public String toString(List<? extends DocTree> tags) {
if (tags.isEmpty()) {
return null;
return "";
}
String result = "\n<DT><B>" + HEADER + "</B><DD>";
result += "<table summary=\"Summary\" cellpadding=2 cellspacing=0><tr><td bgcolor=\"yellow\">";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -26,8 +26,8 @@ import java.util.List;
import java.util.Set;
import com.sun.source.doctree.DocTree;
import jdk.javadoc.doclet.taglet.Taglet;
import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
import jdk.javadoc.doclet.Taglet;
import static jdk.javadoc.doclet.Taglet.Location.*;
/**
* A sample Inline Taglet representing {@underline ...}. The text
@ -69,20 +69,10 @@ public class UnderlineTaglet implements Taglet {
/**
* Given the <code>DocTree</code> representation of this custom
* tag, return its string representation.
* @param tag he <code>DocTree</code> representation of this custom tag.
*/
@Override
public String toString(DocTree tag) {
return "<u>" + ToDoTaglet.getText(tag) + "</u>";
}
/**
* This method should not be called since arrays of inline tags do not
* exist. Method {@link #tostring(DocTree)} should be used to convert this
* inline tag to a string.
* @param tags the <code>DocTree</code> representation of this custom tag.
*/
@Override
public String toString(List<? extends DocTree> tags) {
return null;
return "<u>" + ToDoTaglet.getText(tags.get(0)) + "</u>";
}
}

View File

@ -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,7 +23,7 @@
/*
* @test
* @bug 8035473 8154482 8154399 8159096
* @bug 8035473 8154482 8154399 8159096 8176131 8176331
* @summary make sure the javadoc tool responds correctly to Xold,
* old doclets and taglets.
* @library /tools/lib
@ -87,7 +87,7 @@ public class EnsureNewOldDoclet extends TestRunner {
CLASS_NAME + "\\$OldTaglet.*");
final static String OLD_STDDOCLET = "com.sun.tools.doclets.standard.Standard";
final static String NEW_STDDOCLET = "jdk.javadoc.doclets.StandardDoclet";
final static String NEW_STDDOCLET = "jdk.javadoc.doclet.StandardDoclet";
public EnsureNewOldDoclet() throws Exception {
@ -340,7 +340,7 @@ public class EnsureNewOldDoclet extends TestRunner {
}
}
public static class NewTaglet implements jdk.javadoc.doclet.taglet.Taglet {
public static class NewTaglet implements jdk.javadoc.doclet.Taglet {
@Override
public Set<Location> getAllowedLocations() {
@ -357,11 +357,6 @@ public class EnsureNewOldDoclet extends TestRunner {
return "NewTaglet";
}
@Override
public String toString(DocTree tag) {
return tag.toString();
}
@Override
public String toString(List<? extends DocTree> tags) {
return tags.toString();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
@ -45,7 +45,7 @@ import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.UnknownBlockTagTree;
import com.sun.source.doctree.UnknownInlineTagTree;
import com.sun.source.util.SimpleDocTreeVisitor;
import jdk.javadoc.doclet.taglet.Taglet;
import jdk.javadoc.doclet.Taglet;
/**
* A sample Inline Taglet representing {@underline ...}. This tag can
@ -85,22 +85,12 @@ public class UnderlineTaglet implements Taglet {
}
/**
* Given the <code>Tag</code> representation of this custom
* Given the <code>DocTree</code> representation of this custom
* tag, return its string representation.
* @param tag he <code>Tag</code> representation of this custom tag.
*/
public String toString(DocTree tag) {
return "<u>" + getText(tag) + "</u>";
}
/**
* This method should not be called since arrays of inline tags do not
* exist. Method {@link #tostring(Tag)} should be used to convert this
* inline tag to a string.
* @param tags the array of <code>Tag</code>s representing of this custom tag.
* @param tags the list of trees representing of this custom tag.
*/
public String toString(List<? extends DocTree> tags) {
return null;
return "<u>" + getText(tags.get(0)) + "</u>";
}
static String getText(DocTree dt) {

View File

@ -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
@ -184,6 +184,10 @@ public class ModuleTestBase extends TestRunner {
assertPresent(regex, Task.OutputKind.DIRECT);
}
void assertErrorNotPresent(String regex) throws Exception {
assertNotPresent(regex, Task.OutputKind.DIRECT);
}
void assertPresent(String regex, Task.OutputKind kind) throws Exception {
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind));
if (foundList.isEmpty()) {
@ -192,6 +196,14 @@ public class ModuleTestBase extends TestRunner {
}
}
void assertNotPresent(String regex, Task.OutputKind kind) throws Exception {
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind));
if (!foundList.isEmpty()) {
dumpDocletDiagnostics();
throw new Exception(regex + " found in: " + kind);
}
}
void dumpDocletDiagnostics() {
for (Task.OutputKind kind : Task.OutputKind.values()) {
String output = currentTask.getOutput(kind);

View File

@ -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,7 +23,7 @@
/*
* @test
* @bug 8159305 8166127
* @bug 8159305 8166127 8175860
* @summary Tests primarily the module graph computations.
* @modules
* jdk.javadoc/jdk.javadoc.internal.api
@ -38,6 +38,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import toolbox.*;
import toolbox.Task.Expect;
@ -92,6 +93,29 @@ public class Modules extends ModuleTestBase {
}
@Test
public void testMissingModuleWithSourcePath(Path base) throws Exception {
Path src = base.resolve("src");
Path mod = src.resolve("m1");
ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
mb1.comment("The first module.")
.exports("m1pub")
.requires("m2")
.classes("package m1pub; /** Class A */ public class A {}")
.classes("package m1pro; /** Class B */ public class B {}")
.write(src);
Path javafile = Paths.get(mod.toString(), "m1pub/A.java");
execNegativeTask("--source-path", mod.toString(),
javafile.toString());
assertErrorPresent("error: cannot access module-info");
assertErrorNotPresent("error - fatal error encountered");
}
@Test
public void testMultipleModulesAggregatedModuleOption(Path base) throws Exception {
Path src = base.resolve("src");

View File

@ -1,12 +1,10 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
@ -23,15 +21,23 @@
* questions.
*/
/**
* The Taglet API provides a way to declare custom tags that can be
* used by the standard doclet.
*
* <p style="font-style: italic">
* <b>Note:</b> The declarations in this package supersede those
* in the older package {@code com.sun.tools.doclets}.
* </p>
*
* @since 9
/*
* @test
* @bug 8175235
* @summary type inference regression after JDK-8046685
* @compile InferenceRegressionTest01.java
*/
package jdk.javadoc.doclet.taglet;
import java.util.function.Predicate;
abstract class InferenceRegressionTest01 {
void f(String r) {
a(r, c(o(p(s -> s.isEmpty()))));
}
abstract <U> U o(U u);
abstract <E> Predicate<E> c(Predicate<E> xs);
abstract <S> void a(S a, Predicate<S> m);
abstract <V> Predicate<V> p(Predicate<V> p);
}

View File

@ -0,0 +1,104 @@
/*
* 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 8175235
* @summary type inference regression after JDK-8046685
* @library /tools/javac/lib
* @modules jdk.compiler/com.sun.source.util
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.code
* jdk.compiler/com.sun.tools.javac.file
* jdk.compiler/com.sun.tools.javac.tree
* jdk.compiler/com.sun.tools.javac.util
* @build DPrinter
* @run main InferenceRegressionTest02
*/
import java.io.*;
import java.net.URI;
import java.util.Arrays;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Trees;
import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.Context;
public class InferenceRegressionTest02 {
public static void main(String... args) throws Exception {
new InferenceRegressionTest02().run();
}
void run() throws Exception {
Context context = new Context();
JavacFileManager.preRegister(context);
Trees trees = JavacTrees.instance(context);
StringWriter strOut = new StringWriter();
PrintWriter pw = new PrintWriter(strOut);
DPrinter dprinter = new DPrinter(pw, trees);
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, Arrays.asList(new JavaSource()));
Iterable<? extends CompilationUnitTree> elements = ct.parse();
ct.analyze();
Assert.check(elements.iterator().hasNext());
dprinter.treeTypes(true).printTree("", (JCTree)elements.iterator().next());
String output = strOut.toString();
Assert.check(!output.contains("java.lang.Object"), "there shouldn't be any type instantiated to Object");
}
static class JavaSource extends SimpleJavaFileObject {
String source =
"import java.util.function.*;\n" +
"import java.util.*;\n" +
"import java.util.stream.*;\n" +
"class Foo {\n" +
" void test(List<Map.Entry<Foo, Foo>> ls) {\n" +
" Map<Foo, Set<Foo>> res = ls.stream()\n" +
" .collect(Collectors.groupingBy(Map.Entry::getKey,\n" +
" HashMap::new,\n" +
" Collectors.mapping(Map.Entry::getValue, Collectors.toSet())));\n" +
" }\n" +
"}";
public JavaSource() {
super(URI.create("myfo:/Foo.java"), JavaFileObject.Kind.SOURCE);
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return source;
}
}
}

View File

@ -0,0 +1,58 @@
/*
* 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 8175184
* @summary Annotation processor observes interface private methods as default methods
* @library /tools/javac/lib
* @modules java.compiler
* jdk.compiler
* @build JavacTestingAbstractProcessor PrivateInterfaceMethodProcessorTest
* @compile/process -processor PrivateInterfaceMethodProcessorTest -proc:only PrivateInterfaceMethodProcessorTest_I
*/
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import static javax.lang.model.util.ElementFilter.*;
interface PrivateInterfaceMethodProcessorTest_I {
private void foo() {}
}
public class PrivateInterfaceMethodProcessorTest extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
for (Element element : roundEnv.getRootElements()) {
for (ExecutableElement method : methodsIn(element.getEnclosedElements())) {
if (method.isDefault()) {
throw new AssertionError("Unexpected default method seen");
}
}
}
}
return true;
}
}

View File

@ -0,0 +1,31 @@
/*
* @test /nodynamiccopyright/
* @bug 8175317
* @summary javac does not issue unchecked warnings when checking method reference return types
* @compile/fail/ref=T8175317.out -Werror -Xlint:unchecked -XDrawDiagnostics T8175317.java
*/
import java.util.function.*;
import java.util.*;
class T8175317 {
void m(Supplier<List<String>> s) { }
void testMethodLambda(List l) {
m(() -> l);
}
void testAssignLambda(List l) {
Supplier<List<String>> s = () -> l;
}
void testMethodMref() {
m(this::g);
}
void testAssignMref() {
Supplier<List<String>> s = this::g;
}
List g() { return null; }
}

View File

@ -0,0 +1,7 @@
T8175317.java:15:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.function.Supplier<java.util.List<java.lang.String>>, java.util.function.Supplier<java.util.List<java.lang.String>>, kindname.class, T8175317
T8175317.java:19:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<java.lang.String>
T8175317.java:23:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.function.Supplier<java.util.List<java.lang.String>>, java.util.function.Supplier<java.util.List<java.lang.String>>, kindname.class, T8175317
T8175317.java:27:36: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<java.lang.String>
- compiler.err.warnings.and.werror
1 error
4 warnings

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* 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
@ -23,8 +23,22 @@
* questions.
*/
/**
* This package contains standard, supported doclets.
/*
* @test
* @bug 8176265
* @summary Method overload resolution on a covariant base type doesn't work in 9
* @compile T8176265.java
*/
package jdk.javadoc.doclets;
class T8176265<T> {
static class Sup<E> { }
static class Sub<E> extends Sup<E> { }
void method(Sup<? super T> f) { }
void method(Sub<? super T> f) { }
static <Z> void m(T8176265<? extends Z> test, Sub<Z> sz) {
test.method(sz);
}
}

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8153654
* @bug 8153654 8176333
* @summary Tests for jdeps tool with multi-release jar files
* @modules jdk.jdeps/com.sun.tools.jdeps
* @library mrjar mrjar/base mrjar/9 mrjar/10 mrjar/v9 mrjar/v10
@ -67,7 +67,7 @@ public class MultiReleaseJar {
checkResult(r, false, "Warning: Path does not exist: missing.jar");
r = run("jdeps -v Version.jar");
checkResult(r, false, "the --multi-release option is not set");
checkResult(r, false, "--multi-release option is not set");
r = run("jdeps --multi-release base -v Version.jar");
checkResult(r, true,
@ -105,7 +105,7 @@ public class MultiReleaseJar {
checkResult(r, false, "Error: invalid argument for option: 9.1");
r = run("jdeps -v -R -cp Version.jar test/Main.class");
checkResult(r, false, "the --multi-release option is not set");
checkResult(r, false, "--multi-release option is not set");
r = run("jdeps -v -R -cp Version.jar -multi-release 9 test/Main.class");
checkResult(r, false,