--- a/langtools/.hgtags Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/.hgtags Wed Jul 05 22:52:01 2017 +0200
@@ -398,3 +398,4 @@
03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153
6a9dd3d893b0a493a3e5d8d392815b5ee76a02d9 jdk-9+154
dfcfdb2db85f1bb434209f56ca557ea6f9830aa8 jdk-9+155
+6f91e41163bc09e9b3ec72e8d1185f39296ee5d4 jdk-9+156
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java Wed Jul 05 22:52:01 2017 +0200
@@ -102,7 +102,7 @@
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ModuleFinder",
"moduleFinderClass", "ofMethod");
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Configuration",
- "configurationClass", "resolveRequiresAndUsesMethod");
+ "configurationClass", "resolveAndBindMethod");
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Layer",
"layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod");
ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Module",
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/Element.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/Element.java Wed Jul 05 22:52:01 2017 +0200
@@ -123,6 +123,8 @@
* @see TypeElement#getSimpleName
* @see VariableElement#getSimpleName
* @see ModuleElement#getSimpleName
+ * @revised 9
+ * @spec JPMS
*/
Name getSimpleName();
@@ -158,6 +160,8 @@
*
* @return the enclosing element, or {@code null} if there is none
* @see Elements#getPackageOf
+ * @revised 9
+ * @spec JPMS
*/
Element getEnclosingElement();
@@ -193,6 +197,8 @@
* @see Elements#getAllMembers
* @jls 8.8.9 Default Constructor
* @jls 8.9 Enums
+ * @revised 9
+ * @spec JPMS
*/
List<? extends Element> getEnclosedElements();
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java Wed Jul 05 22:52:01 2017 +0200
@@ -99,6 +99,7 @@
/**
* A module.
* @since 9
+ * @spec JPMS
*/
MODULE;
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Wed Jul 05 22:52:01 2017 +0200
@@ -159,6 +159,7 @@
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 9
+ * @spec JPMS
*/
default R visitModule(ModuleElement e, P p) {
return visitUnknown(e, p);
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java Wed Jul 05 22:52:01 2017 +0200
@@ -33,6 +33,7 @@
*
* @see javax.lang.model.util.Elements#getModuleOf
* @since 9
+ * @spec JPMS
*/ // TODO: add @jls to module section
public interface ModuleElement extends Element, QualifiedNameable {
@@ -104,6 +105,7 @@
* future versions of the Java™ programming language.
*
* @since 9
+ * @spec JPMS
*/
enum DirectiveKind {
/** A "requires (static|transitive)* module-name" directive. */
@@ -122,6 +124,7 @@
* Represents a "module statement" within the declaration of this module.
*
* @since 9
+ * @spec JPMS
*
*/ // TODO: add jls to Module Statement
interface Directive {
@@ -136,6 +139,7 @@
/**
* A dependency of a module.
* @since 9
+ * @spec JPMS
*/
interface RequiresDirective extends Directive {
/**
@@ -160,6 +164,7 @@
/**
* An exported package of a module.
* @since 9
+ * @spec JPMS
*/
interface ExportsDirective extends Directive {
@@ -181,6 +186,7 @@
/**
* An opened package of a module.
* @since 9
+ * @spec JPMS
*/
interface OpensDirective extends Directive {
@@ -202,6 +208,7 @@
/**
* An implementation of a service provided by a module.
* @since 9
+ * @spec JPMS
*/
interface ProvidesDirective extends Directive {
/**
@@ -220,6 +227,7 @@
/**
* A reference to a service used by a module.
* @since 9
+ * @spec JPMS
*/
interface UsesDirective extends Directive {
/**
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java Wed Jul 05 22:52:01 2017 +0200
@@ -93,6 +93,9 @@
* source version} without modules.
*
* @return the enclosing module or {@code null} if no such module exists
+ *
+ * @revised 9
+ * @spec JPMS
*/
@Override
Element getEnclosingElement();
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeKind.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeKind.java Wed Jul 05 22:52:01 2017 +0200
@@ -157,6 +157,7 @@
* A pseudo-type corresponding to a module element.
* @see NoType
* @since 9
+ * @spec JPMS
*/
MODULE;
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Wed Jul 05 22:52:01 2017 +0200
@@ -136,6 +136,7 @@
* @return the result of {@code visitUnknown}
*
* @since 9
+ * @spec JPMS
*/
@Override
public R visitModule(ModuleElement e, P p) {
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor9.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor9.java Wed Jul 05 22:52:01 2017 +0200
@@ -63,6 +63,7 @@
* @see AbstractElementVisitor7
* @see AbstractElementVisitor8
* @since 9
+ * @spec JPMS
*/
@SupportedSourceVersion(RELEASE_9)
public abstract class AbstractElementVisitor9<R, P> extends AbstractElementVisitor8<R, P> {
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java Wed Jul 05 22:52:01 2017 +0200
@@ -189,6 +189,7 @@
* @return a list of modules in {@code elements}
* @param elements the elements to filter
* @since 9
+ * @spec JPMS
*/
public static List<ModuleElement>
modulesIn(Iterable<? extends Element> elements) {
@@ -200,6 +201,7 @@
* @return a set of modules in {@code elements}
* @param elements the elements to filter
* @since 9
+ * @spec JPMS
*/
public static Set<ModuleElement>
modulesIn(Set<? extends Element> elements) {
@@ -236,6 +238,7 @@
* @return a list of {@code exports} directives in {@code directives}
* @param directives the directives to filter
* @since 9
+ * @spec JPMS
*/
public static List<ExportsDirective>
exportsIn(Iterable<? extends Directive> directives) {
@@ -258,6 +261,7 @@
* @return a list of {@code provides} directives in {@code directives}
* @param directives the directives to filter
* @since 9
+ * @spec JPMS
*/
public static List<ProvidesDirective>
providesIn(Iterable<? extends Directive> directives) {
@@ -269,6 +273,7 @@
* @return a list of {@code requires} directives in {@code directives}
* @param directives the directives to filter
* @since 9
+ * @spec JPMS
*/
public static List<RequiresDirective>
requiresIn(Iterable<? extends Directive> directives) {
@@ -280,6 +285,7 @@
* @return a list of {@code uses} directives in {@code directives}
* @param directives the directives to filter
* @since 9
+ * @spec JPMS
*/
public static List<UsesDirective>
usesIn(Iterable<? extends Directive> directives) {
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java Wed Jul 05 22:52:01 2017 +0200
@@ -75,6 +75,7 @@
* @see ElementKindVisitor7
* @see ElementKindVisitor8
* @since 9
+ * @spec JPMS
*/
@SupportedSourceVersion(RELEASE_9)
public class ElementKindVisitor9<R, P> extends ElementKindVisitor8<R, P> {
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Wed Jul 05 22:52:01 2017 +0200
@@ -88,6 +88,7 @@
* @see ElementScanner7
* @see ElementScanner8
* @since 9
+ * @spec JPMS
*/
@SupportedSourceVersion(RELEASE_9)
public class ElementScanner9<R, P> extends ElementScanner8<R, P> {
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java Wed Jul 05 22:52:01 2017 +0200
@@ -111,6 +111,7 @@
* @param name the name
* @return the named module element, or {@code null} if it cannot be found
* @since 9
+ * @spec JPMS
*/
default ModuleElement getModuleElement(CharSequence name) {
return null;
@@ -359,6 +360,7 @@
* @param type the element being examined
* @return the module of an element
* @since 9
+ * @spec JPMS
*/
default ModuleElement getModuleOf(Element type) {
return null;
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Wed Jul 05 22:52:01 2017 +0200
@@ -71,6 +71,7 @@
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
* @since 9
+ * @spec JPMS
*/
@SupportedSourceVersion(RELEASE_9)
public class SimpleElementVisitor9<R, P> extends SimpleElementVisitor8<R, P> {
--- a/langtools/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java Wed Jul 05 22:52:01 2017 +0200
@@ -165,22 +165,42 @@
fileManager.close();
}
+ /**
+ * @since 9
+ * @spec JPMS
+ */
public Location getLocationForModule(Location location, String moduleName) throws IOException {
return fileManager.getLocationForModule(location, moduleName);
}
+ /**
+ * @since 9
+ * @spec JPMS
+ */
public Location getLocationForModule(Location location, JavaFileObject fo, String pkgName) throws IOException {
return fileManager.getLocationForModule(location, fo, pkgName);
}
+ /**
+ * @since 9
+ * @spec JPMS
+ */
public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException {
return fileManager.getServiceLoader(location, service);
}
+ /**
+ * @since 9
+ * @spec JPMS
+ */
public String inferModuleName(Location location) throws IOException {
return fileManager.inferModuleName(location);
}
+ /**
+ * @since 9
+ * @spec JPMS
+ */
public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
return fileManager.listLocationsForModules(location);
}
--- a/langtools/src/java.compiler/share/classes/javax/tools/JavaFileManager.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/tools/JavaFileManager.java Wed Jul 05 22:52:01 2017 +0200
@@ -165,6 +165,7 @@
*
* @return true if this location is expected to contain modules
* @since 9
+ * @spec JPMS
*/
default boolean isModuleOrientedLocation() {
return getName().matches("\\bMODULE\\b");
@@ -472,6 +473,7 @@
* @throws IllegalArgumentException if the location is neither an output location nor a
* module-oriented location
* @since 9
+ * @spec JPMS
*/ // TODO: describe failure modes
default Location getLocationForModule(Location location, String moduleName) throws IOException {
throw new UnsupportedOperationException();
@@ -499,6 +501,7 @@
* @throws IllegalArgumentException if the location is neither an output location nor a
* module-oriented location
* @since 9
+ * @spec JPMS
*/
default Location getLocationForModule(Location location, JavaFileObject fo, String pkgName) throws IOException {
throw new UnsupportedOperationException();
@@ -522,6 +525,7 @@
* @throws IOException if an I/O error occurred
* @throws UnsupportedOperationException if this operation if not supported by this file manager
* @since 9
+ * @spec JPMS
*/ // TODO: describe failure modes
default <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException {
throw new UnsupportedOperationException();
@@ -540,6 +544,7 @@
* @throws UnsupportedOperationException if this operation if not supported by this file manager
* @throws IllegalArgumentException if the location is not one known to this file manager
* @since 9
+ * @spec JPMS
*/ // TODO: describe failure modes
default String inferModuleName(Location location) throws IOException {
throw new UnsupportedOperationException();
@@ -559,6 +564,7 @@
* @throws UnsupportedOperationException if this operation if not supported by this file manager
* @throws IllegalArgumentException if the location is not a module-oriented location
* @since 9
+ * @spec JPMS
*/ // TODO: describe failure modes
default Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
throw new UnsupportedOperationException();
--- a/langtools/src/java.compiler/share/classes/javax/tools/StandardLocation.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/tools/StandardLocation.java Wed Jul 05 22:52:01 2017 +0200
@@ -64,6 +64,7 @@
/**
* Location to search for modules containing annotation processors.
+ * @spec JPMS
* @since 9
*/
ANNOTATION_PROCESSOR_MODULE_PATH,
@@ -82,27 +83,38 @@
/**
* Location to search for the source code of modules.
+ * @spec JPMS
* @since 9
*/
MODULE_SOURCE_PATH,
/**
* Location to search for upgradeable system modules.
+ * @spec JPMS
* @since 9
*/
UPGRADE_MODULE_PATH,
/**
* Location to search for system modules.
+ * @spec JPMS
* @since 9
*/
SYSTEM_MODULES,
/**
* Location to search for precompiled user modules.
+ * @spec JPMS
* @since 9
*/
- MODULE_PATH;
+ MODULE_PATH,
+
+ /**
+ * Location to search for module patches.
+ * @since 9
+ * @spec JPMS
+ */
+ PATCH_MODULE_PATH;
/**
* Returns a location object with the given name. The following
@@ -115,6 +127,9 @@
*
* @param name a name
* @return a location
+ *
+ * @revised 9
+ * @spec JPMS
*/
public static Location locationFor(final String name) {
if (locations.isEmpty()) {
@@ -158,6 +173,7 @@
case UPGRADE_MODULE_PATH:
case SYSTEM_MODULES:
case MODULE_PATH:
+ case PATCH_MODULE_PATH:
return true;
default:
return false;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java Wed Jul 05 22:52:01 2017 +0200
@@ -361,7 +361,7 @@
@Override @DefinedBy(Api.COMPILER)
public Location getLocationForModule(Location location, JavaFileObject fo, String pkgName) throws IOException {
try {
- return clientJavaFileManager.getLocationForModule(location, fo, pkgName);
+ return clientJavaFileManager.getLocationForModule(location, unwrap(fo), pkgName);
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException | Error e) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -418,6 +418,7 @@
private Symbol attributeDocReference(TreePath path, DCReference ref) {
Env<AttrContext> env = getAttrContext(path);
+ if (env == null) return null;
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
new Log.DeferredDiagnosticHandler(log);
@@ -881,6 +882,7 @@
case INTERFACE:
// System.err.println("CLASS: " + ((JCClassDecl)tree).sym.getSimpleName());
env = enter.getClassEnv(((JCClassDecl)tree).sym);
+ if (env == null) return null;
break;
case METHOD:
// System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Wed Jul 05 22:52:01 2017 +0200
@@ -553,20 +553,47 @@
Location classLocn = msym.classLocation;
Location sourceLocn = msym.sourceLocation;
+ Location patchLocn = msym.patchLocation;
+ Location patchOutLocn = msym.patchOutputLocation;
- if (wantClassFiles && (classLocn != null)) {
- fillIn(p, classLocn,
- list(classLocn,
- p,
- packageName,
- classKinds));
- }
- if (wantSourceFiles && (sourceLocn != null)) {
- fillIn(p, sourceLocn,
- list(sourceLocn,
- p,
- packageName,
- sourceKinds));
+ boolean prevPreferCurrent = preferCurrent;
+
+ try {
+ preferCurrent = false;
+ if (wantClassFiles && (patchOutLocn != null)) {
+ fillIn(p, patchOutLocn,
+ list(patchOutLocn,
+ p,
+ packageName,
+ classKinds));
+ }
+ if ((wantClassFiles || wantSourceFiles) && (patchLocn != null)) {
+ Set<JavaFileObject.Kind> combined = EnumSet.noneOf(JavaFileObject.Kind.class);
+ combined.addAll(classKinds);
+ combined.addAll(sourceKinds);
+ fillIn(p, patchLocn,
+ list(patchLocn,
+ p,
+ packageName,
+ combined));
+ }
+ preferCurrent = true;
+ if (wantClassFiles && (classLocn != null)) {
+ fillIn(p, classLocn,
+ list(classLocn,
+ p,
+ packageName,
+ classKinds));
+ }
+ if (wantSourceFiles && (sourceLocn != null)) {
+ fillIn(p, sourceLocn,
+ list(sourceLocn,
+ p,
+ packageName,
+ sourceKinds));
+ }
+ } finally {
+ preferCurrent = prevPreferCurrent;
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java Wed Jul 05 22:52:01 2017 +0200
@@ -53,8 +53,8 @@
/** Flags for RequiresDirective. */
public enum RequiresFlag {
- TRANSITIVE(0x0010),
- STATIC_PHASE(0x0020),
+ TRANSITIVE(0x0020),
+ STATIC_PHASE(0x0040),
SYNTHETIC(0x1000),
MANDATED(0x8000),
EXTRA(0x10000);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java Wed Jul 05 22:52:01 2017 +0200
@@ -267,6 +267,7 @@
private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) {
ListBuffer<ModuleSymbol> results = new ListBuffer<>();
Map<Name, Location> namesInSet = new HashMap<>();
+ boolean multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
while (moduleLocationIterator.hasNext()) {
Set<Location> locns = (moduleLocationIterator.next());
namesInSet.clear();
@@ -279,10 +280,29 @@
// module has already been found, so ignore this instance
continue;
}
+ if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) &&
+ msym.patchLocation == null) {
+ msym.patchLocation =
+ fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH,
+ msym.name.toString());
+ checkModuleInfoOnLocation(msym.patchLocation, Kind.CLASS, Kind.SOURCE);
+ if (msym.patchLocation != null &&
+ multiModuleMode &&
+ fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
+ msym.patchOutputLocation =
+ fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
+ msym.name.toString());
+ checkModuleInfoOnLocation(msym.patchOutputLocation, Kind.CLASS);
+ }
+ }
if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) {
- msym.sourceLocation = l;
- if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
- msym.classLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString());
+ if (msym.patchLocation == null) {
+ msym.sourceLocation = l;
+ if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
+ msym.classLocation =
+ fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT,
+ msym.name.toString());
+ }
}
} else {
msym.classLocation = l;
@@ -291,7 +311,8 @@
moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) {
msym.flags_field |= Flags.SYSTEM_MODULE;
}
- if (toFind == msym || toFind == null) {
+ if (toFind == null ||
+ (toFind == msym && (msym.sourceLocation != null || msym.classLocation != null))) {
// Note: cannot return msym directly, because we must finish
// processing this set first
results.add(msym);
@@ -311,6 +332,21 @@
return results.toList();
}
+ private void checkModuleInfoOnLocation(Location location, Kind... kinds) throws IOException {
+ if (location == null)
+ return ;
+
+ for (Kind kind : kinds) {
+ JavaFileObject file = fileManager.getJavaFileForInput(location,
+ names.module_info.toString(),
+ kind);
+ if (file != null) {
+ log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(file));
+ return;
+ }
+ }
+ }
+
private void findModuleInfo(ModuleSymbol msym) {
try {
JavaFileObject src_fo = (msym.sourceLocation == null) ? null
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jul 05 22:52:01 2017 +0200
@@ -908,6 +908,8 @@
public Name version;
public JavaFileManager.Location sourceLocation;
public JavaFileManager.Location classLocation;
+ public JavaFileManager.Location patchLocation;
+ public JavaFileManager.Location patchOutputLocation;
/** All directives, in natural order. */
public List<com.sun.tools.javac.code.Directive> directives;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 22:52:01 2017 +0200
@@ -3994,10 +3994,16 @@
rs.methodArguments(argtypes.map(checkDeferredMap)),
kindName(sym.location()),
sym.location());
- owntype = new MethodType(owntype.getParameterTypes(),
- types.erasure(owntype.getReturnType()),
- types.erasure(owntype.getThrownTypes()),
- syms.methodClass);
+ if (resultInfo.pt != Infer.anyPoly ||
+ !owntype.hasTag(METHOD) ||
+ !owntype.isPartial()) {
+ //if this is not a partially inferred method type, erase return type. Otherwise,
+ //erasure is carried out in PartiallyInferredMethodType.check().
+ owntype = new MethodType(owntype.getParameterTypes(),
+ types.erasure(owntype.getReturnType()),
+ types.erasure(owntype.getThrownTypes()),
+ syms.methodClass);
+ }
}
PolyKind pkind = (sym.type.hasTag(FORALL) &&
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,7 @@
import javax.tools.JavaFileManager;
import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Kinds.KindName;
import com.sun.tools.javac.code.Kinds.KindSelector;
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
@@ -155,6 +156,7 @@
public Env<AttrContext> getClassEnv(TypeSymbol sym) {
Env<AttrContext> localEnv = getEnv(sym);
+ if (localEnv == null) return null;
Env<AttrContext> lintEnv = localEnv;
while (lintEnv.info.lint == null)
lintEnv = lintEnv.next;
@@ -400,8 +402,14 @@
c = syms.enterClass(env.toplevel.modle, tree.name, packge);
packge.members().enterIfAbsent(c);
if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) {
+ KindName topElement = KindName.CLASS;
+ if ((tree.mods.flags & ENUM) != 0) {
+ topElement = KindName.ENUM;
+ } else if ((tree.mods.flags & INTERFACE) != 0) {
+ topElement = KindName.INTERFACE;
+ }
log.error(tree.pos(),
- "class.public.should.be.in.file", tree.name);
+ "class.public.should.be.in.file", topElement, tree.name);
}
} else {
if (!tree.name.isEmpty() &&
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 22:52:01 2017 +0200
@@ -319,7 +319,8 @@
* need to use it several times: with several targets.
*/
saved_undet = inferenceContext.save();
- if (allowGraphInference && !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+ boolean unchecked = warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED);
+ if (allowGraphInference && !unchecked) {
boolean shouldPropagate = shouldPropagate(getReturnType(), resultInfo, inferenceContext);
InferenceContext minContext = shouldPropagate ?
@@ -338,7 +339,10 @@
}
}
inferenceContext.solve(noWarnings);
- return inferenceContext.asInstType(this).getReturnType();
+ Type ret = inferenceContext.asInstType(this).getReturnType();
+ //inline logic from Attr.checkMethod - if unchecked conversion was required, erase
+ //return type _after_ resolution
+ return unchecked ? types.erasure(ret) : ret;
} catch (InferenceException ex) {
resultInfo.checkContext.report(null, ex.getDiagnostic());
Assert.error(); //cannot get here (the above should throw)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java Wed Jul 05 22:52:01 2017 +0200
@@ -145,7 +145,7 @@
public final boolean multiModuleMode;
- private final String moduleOverride;
+ private final String legacyModuleOverride;
private final Name java_se;
private final Name java_;
@@ -192,7 +192,7 @@
lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
- moduleOverride = options.get(Option.XMODULE);
+ legacyModuleOverride = options.get(Option.XMODULE);
multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
ClassWriter classWriter = ClassWriter.instance(context);
@@ -366,9 +366,26 @@
JavaFileObject prev = log.useSource(tree.sourcefile);
try {
- Location locn = getModuleLocation(tree);
- if (locn != null) {
- Name name = names.fromString(fileManager.inferModuleName(locn));
+ Location msplocn = getModuleLocation(tree);
+ Location plocn = fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) ?
+ fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH,
+ tree.sourcefile, getPackageName(tree)) :
+ null;
+
+ if (plocn != null) {
+ Name name = names.fromString(fileManager.inferModuleName(plocn));
+ ModuleSymbol msym = moduleFinder.findModule(name);
+ tree.modle = msym;
+ rootModules.add(msym);
+
+ if (msplocn != null) {
+ Name mspname = names.fromString(fileManager.inferModuleName(msplocn));
+ if (name != mspname) {
+ log.error(tree.pos(), Errors.FilePatchedAndMsp(name, mspname));
+ }
+ }
+ } else if (msplocn != null) {
+ Name name = names.fromString(fileManager.inferModuleName(msplocn));
ModuleSymbol msym;
JCModuleDecl decl = tree.getModuleDecl();
if (decl != null) {
@@ -383,7 +400,7 @@
msym = syms.enterModule(name);
}
if (msym.sourceLocation == null) {
- msym.sourceLocation = locn;
+ msym.sourceLocation = msplocn;
if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) {
msym.classLocation = fileManager.getLocationForModule(
StandardLocation.CLASS_OUTPUT, msym.name.toString());
@@ -414,7 +431,9 @@
}
defaultModule = syms.unnamedModule;
} else {
+ ModuleSymbol module = null;
if (defaultModule == null) {
+ String moduleOverride = singleModuleOverride(trees);
switch (rootModules.size()) {
case 0:
defaultModule = moduleFinder.findSingleModule();
@@ -422,38 +441,49 @@
if (moduleOverride != null) {
checkNoAllModulePath();
defaultModule = moduleFinder.findModule(names.fromString(moduleOverride));
- defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
+ if (legacyModuleOverride != null) {
+ defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
+ }
+ defaultModule.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
} else {
// Question: why not do findAllModules and initVisiblePackages here?
// i.e. body of unnamedModuleCompleter
defaultModule.completer = getUnnamedModuleCompleter();
+ defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
defaultModule.classLocation = StandardLocation.CLASS_PATH;
}
} else {
- checkSpecifiedModule(trees, Errors.ModuleInfoWithXmoduleClasspath);
+ checkSpecifiedModule(trees, moduleOverride, Errors.ModuleInfoWithPatchedModuleClassoutput);
checkNoAllModulePath();
defaultModule.complete();
// Question: why not do completeModule here?
defaultModule.completer = sym -> completeModule((ModuleSymbol) sym);
+ defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
}
rootModules.add(defaultModule);
break;
case 1:
- checkSpecifiedModule(trees, Errors.ModuleInfoWithXmoduleSourcepath);
+ checkSpecifiedModule(trees, moduleOverride, Errors.ModuleInfoWithPatchedModuleSourcepath);
checkNoAllModulePath();
defaultModule = rootModules.iterator().next();
+ defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
defaultModule.classLocation = StandardLocation.CLASS_OUTPUT;
break;
default:
Assert.error("too many modules");
}
- defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
} else if (rootModules.size() == 1 && defaultModule == rootModules.iterator().next()) {
defaultModule.complete();
defaultModule.completer = sym -> completeModule((ModuleSymbol) sym);
} else {
Assert.check(rootModules.isEmpty());
- rootModules.add(defaultModule);
+ String moduleOverride = singleModuleOverride(trees);
+ if (moduleOverride != null) {
+ module = moduleFinder.findModule(names.fromString(moduleOverride));
+ } else {
+ module = defaultModule;
+ }
+ rootModules.add(module);
}
if (defaultModule != syms.unnamedModule) {
@@ -461,12 +491,56 @@
syms.unnamedModule.classLocation = StandardLocation.CLASS_PATH;
}
+ if (module == null) {
+ module = defaultModule;
+ }
+
for (JCCompilationUnit tree: trees) {
- tree.modle = defaultModule;
+ tree.modle = module;
}
}
}
+ private String singleModuleOverride(List<JCCompilationUnit> trees) {
+ if (!fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH)) {
+ return legacyModuleOverride;
+ }
+
+ Set<String> override = new LinkedHashSet<>();
+ for (JCCompilationUnit tree : trees) {
+ JavaFileObject fo = tree.sourcefile;
+
+ try {
+ Location loc =
+ fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH,
+ fo, getPackageName(tree));
+
+ if (loc != null) {
+ override.add(fileManager.inferModuleName(loc));
+ }
+ } catch (IOException ex) {
+ throw new Error(ex);
+ }
+ }
+
+ switch (override.size()) {
+ case 0: return legacyModuleOverride;
+ case 1: return override.iterator().next();
+ default:
+ log.error(Errors.TooManyPatchedModules(override));
+ return null;
+ }
+ }
+
+ private String getPackageName(JCCompilationUnit tree) {
+ if (tree.getModuleDecl() != null) {
+ return null;
+ } else {
+ JCPackageDecl pkg = tree.getPackage();
+ return (pkg == null) ? "" : TreeInfo.fullName(pkg.pid).toString();
+ }
+ }
+
/**
* Determine the location for the module on the module source path
* or source output directory which contains a given CompilationUnit.
@@ -478,32 +552,23 @@
* @throws IOException if there is a problem while searching for the module.
*/
private Location getModuleLocation(JCCompilationUnit tree) throws IOException {
- Name pkgName;
- if (tree.getModuleDecl() != null) {
- pkgName = null;
- } else {
- JCPackageDecl pkg = tree.getPackage();
- pkgName = (pkg == null) ? names.empty : TreeInfo.fullName(pkg.pid);
- }
-
+ String pkgName = getPackageName(tree);
JavaFileObject fo = tree.sourcefile;
- // For now, just check module source path.
- // We may want to check source path as well.
Location loc =
fileManager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH,
- fo, (pkgName == null) ? null : pkgName.toString());
+ fo, (pkgName == null) ? null : pkgName);
if (loc == null) {
Location sourceOutput = fileManager.hasLocation(StandardLocation.SOURCE_OUTPUT) ?
StandardLocation.SOURCE_OUTPUT : StandardLocation.CLASS_OUTPUT;
loc =
fileManager.getLocationForModule(sourceOutput,
- fo, (pkgName == null) ? null : pkgName.toString());
+ fo, (pkgName == null) ? null : pkgName);
}
return loc;
}
- private void checkSpecifiedModule(List<JCCompilationUnit> trees, JCDiagnostic.Error error) {
+ private void checkSpecifiedModule(List<JCCompilationUnit> trees, String moduleOverride, JCDiagnostic.Error error) {
if (moduleOverride != null) {
JavaFileObject prev = log.useSource(trees.head.sourcefile);
try {
@@ -1594,8 +1659,8 @@
}
public void newRound() {
+ allModules = null;
rootModules = null;
- allModules = null;
warnedMissing.clear();
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Jul 05 22:52:01 2017 +0200
@@ -968,7 +968,7 @@
Collection<Path> paths = locations.getLocation(location);
ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()]));
Layer bootLayer = Layer.boot();
- Configuration cf = bootLayer.configuration().resolveRequiresAndUses(ModuleFinder.of(), finder, Collections.emptySet());
+ Configuration cf = bootLayer.configuration().resolveAndBind(ModuleFinder.of(), finder, Collections.emptySet());
Layer layer = bootLayer.defineModulesWithOneLoader(cf, ClassLoader.getSystemClassLoader());
return ServiceLoaderHelper.load(layer, service);
} else {
@@ -980,7 +980,7 @@
public Location getLocationForModule(Location location, JavaFileObject fo, String pkgName) throws IOException {
checkModuleOrientedOrOutputLocation(location);
if (!(fo instanceof PathFileObject))
- throw new IllegalArgumentException(fo.getName());
+ return null;
int depth = 1; // allow 1 for filename
if (pkgName != null && !pkgName.isEmpty()) {
depth += 1;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Jul 05 22:52:01 2017 +0200
@@ -432,7 +432,7 @@
/**
* @see JavaFileManager#getLocationForModule(Location, JavaFileObject, String)
*/
- Location getLocationForModule(Path dir) {
+ Location getLocationForModule(Path dir) throws IOException {
return null;
}
@@ -545,7 +545,7 @@
l = new ModuleLocationHandler(location.getName() + "[" + name + "]",
name,
Collections.singleton(out),
- true, false);
+ true);
moduleLocations.put(name, l);
pathLocations.put(out.toAbsolutePath(), l);
}
@@ -864,29 +864,14 @@
protected final String name;
protected final String moduleName;
protected final Collection<Path> searchPath;
- protected final Collection<Path> searchPathWithOverrides;
protected final boolean output;
ModuleLocationHandler(String name, String moduleName, Collection<Path> searchPath,
- boolean output, boolean allowOverrides) {
+ boolean output) {
this.name = name;
this.moduleName = moduleName;
this.searchPath = searchPath;
this.output = output;
-
- if (allowOverrides && patchMap != null) {
- SearchPath mPatch = patchMap.get(moduleName);
- if (mPatch != null) {
- SearchPath sp = new SearchPath();
- sp.addAll(mPatch);
- sp.addAll(searchPath);
- searchPathWithOverrides = sp;
- } else {
- searchPathWithOverrides = searchPath;
- }
- } else {
- searchPathWithOverrides = searchPath;
- }
}
@Override @DefinedBy(Api.COMPILER)
@@ -909,7 +894,7 @@
// For now, we always return searchPathWithOverrides. This may differ from the
// JVM behavior if there is a module-info.class to be found in the overriding
// classes.
- return searchPathWithOverrides;
+ return searchPath;
}
@Override // defined by LocationHandler
@@ -985,6 +970,11 @@
}
private void checkValidModulePathEntry(Path p) {
+ if (!Files.exists(p)) {
+ // warning may be generated later
+ return;
+ }
+
if (Files.isDirectory(p)) {
// either an exploded module or a directory of modules
return;
@@ -1063,7 +1053,7 @@
String name = location.getName()
+ "[" + pathIndex + ":" + moduleName + "]";
ModuleLocationHandler l = new ModuleLocationHandler(name, moduleName,
- Collections.singleton(path), false, true);
+ Collections.singleton(path), false);
return Collections.singleton(l);
} catch (ModuleNameReader.BadClassFile e) {
log.error(Errors.LocnBadModuleInfo(path));
@@ -1088,7 +1078,7 @@
String name = location.getName()
+ "[" + pathIndex + "." + (index++) + ":" + moduleName + "]";
ModuleLocationHandler l = new ModuleLocationHandler(name, moduleName,
- Collections.singleton(modulePath), false, true);
+ Collections.singleton(modulePath), false);
result.add(l);
}
return result;
@@ -1105,7 +1095,7 @@
String name = location.getName()
+ "[" + pathIndex + ":" + moduleName + "]";
ModuleLocationHandler l = new ModuleLocationHandler(name, moduleName,
- Collections.singleton(modulePath), false, true);
+ Collections.singleton(modulePath), false);
return Collections.singleton(l);
}
@@ -1272,7 +1262,7 @@
pathLocations = new LinkedHashMap<>();
map.forEach((k, v) -> {
String name = location.getName() + "[" + k + "]";
- ModuleLocationHandler h = new ModuleLocationHandler(name, k, v, false, false);
+ ModuleLocationHandler h = new ModuleLocationHandler(name, k, v, false);
moduleLocations.put(k, h);
v.forEach(p -> pathLocations.put(normalize(p), h));
});
@@ -1412,6 +1402,7 @@
private Path systemJavaHome;
private Path modules;
private Map<String, ModuleLocationHandler> systemModules;
+ private Map<Path, Location> pathLocations;
SystemModulesLocationHandler() {
super(StandardLocation.SYSTEM_MODULES, Option.SYSTEM);
@@ -1486,6 +1477,12 @@
}
@Override
+ Location getLocationForModule(Path dir) throws IOException {
+ initSystemModules();
+ return (pathLocations == null) ? null : pathLocations.get(dir);
+ }
+
+ @Override
Iterable<Set<Location>> listLocationsForModules() throws IOException {
initSystemModules();
Set<Location> locns = new LinkedHashSet<>();
@@ -1539,18 +1536,96 @@
}
systemModules = new LinkedHashMap<>();
+ pathLocations = new LinkedHashMap<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(modules, Files::isDirectory)) {
for (Path entry : stream) {
String moduleName = entry.getFileName().toString();
String name = location.getName() + "[" + moduleName + "]";
ModuleLocationHandler h = new ModuleLocationHandler(name, moduleName,
- Collections.singleton(entry), false, true);
+ Collections.singleton(entry), false);
systemModules.put(moduleName, h);
+ pathLocations.put(normalize(entry), h);
}
}
}
}
+ private class PatchModulesLocationHandler extends BasicLocationHandler {
+ private final Map<String, ModuleLocationHandler> moduleLocations = new HashMap<>();
+ private final Map<Path, Location> pathLocations = new HashMap<>();
+
+ PatchModulesLocationHandler() {
+ super(StandardLocation.PATCH_MODULE_PATH, Option.PATCH_MODULE);
+ }
+
+ @Override
+ boolean handleOption(Option option, String value) {
+ if (!options.contains(option)) {
+ return false;
+ }
+
+ // Allow an extended syntax for --patch-module consisting of a series
+ // of values separated by NULL characters. This is to facilitate
+ // supporting deferred file manager options on the command line.
+ // See Option.PATCH_MODULE for the code that composes these multiple
+ // values.
+ for (String v : value.split("\0")) {
+ int eq = v.indexOf('=');
+ if (eq > 0) {
+ String moduleName = v.substring(0, eq);
+ SearchPath mPatchPath = new SearchPath()
+ .addFiles(v.substring(eq + 1));
+ String name = location.getName() + "[" + moduleName + "]";
+ ModuleLocationHandler h = new ModuleLocationHandler(name, moduleName, mPatchPath, false);
+ moduleLocations.put(moduleName, h);
+ for (Path r : mPatchPath) {
+ pathLocations.put(normalize(r), h);
+ }
+ } else {
+ // Should not be able to get here;
+ // this should be caught and handled in Option.PATCH_MODULE
+ log.error(Errors.LocnInvalidArgForXpatch(value));
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ boolean isSet() {
+ return !moduleLocations.isEmpty();
+ }
+
+ @Override
+ Collection<Path> getPaths() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ void setPaths(Iterable<? extends Path> files) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ Location getLocationForModule(String name) throws IOException {
+ return moduleLocations.get(name);
+ }
+
+ @Override
+ Location getLocationForModule(Path dir) throws IOException {
+ return (pathLocations == null) ? null : pathLocations.get(dir);
+ }
+
+ @Override
+ Iterable<Set<Location>> listLocationsForModules() throws IOException {
+ Set<Location> locns = new LinkedHashSet<>();
+ for (Location l: moduleLocations.values())
+ locns.add(l);
+ return Collections.singleton(locns);
+ }
+
+ }
+
Map<Location, LocationHandler> handlersForLocation;
Map<Option, LocationHandler> handlersForOption;
@@ -1568,6 +1643,7 @@
new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
new ModuleSourcePathLocationHandler(),
+ new PatchModulesLocationHandler(),
// TODO: should UPGRADE_MODULE_PATH be merged with SYSTEM_MODULES?
new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
@@ -1582,51 +1658,9 @@
}
}
- private Map<String, SearchPath> patchMap;
-
boolean handleOption(Option option, String value) {
- switch (option) {
- case PATCH_MODULE:
- if (value == null) {
- patchMap = null;
- } else {
- // Allow an extended syntax for --patch-module consisting of a series
- // of values separated by NULL characters. This is to facilitate
- // supporting deferred file manager options on the command line.
- // See Option.PATCH_MODULE for the code that composes these multiple
- // values.
- for (String v : value.split("\0")) {
- int eq = v.indexOf('=');
- if (eq > 0) {
- String mName = v.substring(0, eq);
- SearchPath mPatchPath = new SearchPath()
- .addFiles(v.substring(eq + 1));
- boolean ok = true;
- for (Path p : mPatchPath) {
- Path mi = p.resolve("module-info.class");
- if (Files.exists(mi)) {
- log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
- ok = false;
- }
- }
- if (ok) {
- if (patchMap == null) {
- patchMap = new LinkedHashMap<>();
- }
- patchMap.put(mName, mPatchPath);
- }
- } else {
- // Should not be able to get here;
- // this should be caught and handled in Option.PATCH_MODULE
- log.error(Errors.LocnInvalidArgForXpatch(value));
- }
- }
- }
- return true;
- default:
- LocationHandler h = handlersForOption.get(option);
- return (h == null ? false : h.handleOption(option, value));
- }
+ LocationHandler h = handlersForOption.get(option);
+ return (h == null ? false : h.handleOption(option, value));
}
boolean hasLocation(Location location) {
@@ -1665,7 +1699,7 @@
return (h == null ? null : h.getLocationForModule(name));
}
- Location getLocationForModule(Location location, Path dir) {
+ Location getLocationForModule(Location location, Path dir) throws IOException {
LocationHandler h = getHandler(location);
return (h == null ? null : h.getLocationForModule(dir));
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,7 +38,6 @@
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.jvm.Code.*;
import com.sun.tools.javac.jvm.Items.*;
-import com.sun.tools.javac.main.Option;
import com.sun.tools.javac.tree.EndPosTable;
import com.sun.tools.javac.tree.JCTree.*;
@@ -67,10 +66,9 @@
private final TreeMaker make;
private final Names names;
private final Target target;
- private Name accessDollar;
+ private final Name accessDollar;
private final Types types;
private final Lower lower;
- private final Flow flow;
private final Annotate annotate;
private final StringConcat concat;
@@ -95,7 +93,7 @@
/** Constant pool, reset by genClass.
*/
- private Pool pool;
+ private final Pool pool;
protected Gen(Context context) {
context.put(genKey, this);
@@ -113,7 +111,6 @@
methodType = new MethodType(null, null, null, syms.methodClass);
accessDollar = names.
fromString("access" + target.syntheticNameChar());
- flow = Flow.instance(context);
lower = Lower.instance(context);
Options options = Options.instance(context);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Jul 05 22:52:01 2017 +0200
@@ -598,9 +598,6 @@
&& !fm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
log.error(Errors.NoOutputDir);
}
- if (options.isSet(Option.XMODULE)) {
- log.error(Errors.XmoduleNoModuleSourcepath);
- }
}
if (fm.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH) &&
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Jul 05 22:52:01 2017 +0200
@@ -1450,6 +1450,11 @@
return;
}
+ if (!modules.multiModuleMode && env.toplevel.modle != modules.getDefaultModule()) {
+ //can only generate classfiles for a single module:
+ return;
+ }
+
if (compileStates.isDone(env, CompileState.LOWER)) {
results.addAll(desugaredEnvs.get(env));
return;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java Wed Jul 05 22:52:01 2017 +0200
@@ -579,7 +579,7 @@
}
},
- XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) {
+ XMODULE("-Xmodule:", "opt.arg.module", "opt.module", HIDDEN, BASIC) {
@Override
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
String prev = helper.get(XMODULE);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 22:52:01 2017 +0200
@@ -1246,9 +1246,9 @@
# In the following string, {0} is the name of the class in the Java source.
# It really should be used two times..
-# 0: name
+# 0: kind name, 1: name
compiler.err.class.public.should.be.in.file=\
- class {0} is public, should be declared in a file named {0}.java
+ {0} {1} is public, should be declared in a file named {1}.java
## All errors which do not refer to a particular line in the source code are
## preceded by this string.
@@ -1292,7 +1292,7 @@
compiler.warn.outdir.is.in.exploded.module=\
the output directory is within an exploded module: {0}
-# 0: path
+# 0: file object
compiler.err.locn.module-info.not.allowed.on.patch.path=\
module-info.class not allowed on patch path: {0}
@@ -2957,14 +2957,20 @@
compiler.err.module.decl.sb.in.module-info.java=\
module declarations should be in a file named module-info.java
-compiler.err.module-info.with.xmodule.sourcepath=\
- illegal combination of -Xmodule and module-info on sourcepath
-
-compiler.err.module-info.with.xmodule.classpath=\
- illegal combination of -Xmodule and module-info on classpath
-
-compiler.err.xmodule.no.module.sourcepath=\
- illegal combination of -Xmodule and --module-source-path
+compiler.err.module-info.with.patched.module.sourcepath=\
+ compiling a module patch with module-info on sourcepath
+
+compiler.err.module-info.with.patched.module.classoutput=\
+ compiling a module patch with module-info on class output
+
+# 0: set of string
+compiler.err.too.many.patched.modules=\
+ too many patched modules ({0}), use --module-source-path
+
+# 0: name, 1: name
+compiler.err.file.patched.and.msp=\
+ file accessible from both --patch-module and --module-source-path, \
+ but belongs to a different module on each path: {0}, {1}
compiler.err.processorpath.no.processormodulepath=\
illegal combination of -processorpath and --processor-module-path
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java Wed Jul 05 22:52:01 2017 +0200
@@ -272,12 +272,12 @@
init();
}
- public Configuration resolveRequiresAndUses(
+ public Configuration resolveAndBind(
ModuleFinder beforeFinder,
ModuleFinder afterFinder,
Collection<String> roots) {
try {
- Object result = resolveRequiresAndUsesMethod.invoke(theRealConfiguration,
+ Object result = resolveAndBindMethod.invoke(theRealConfiguration,
beforeFinder.theRealModuleFinder,
afterFinder.theRealModuleFinder,
roots
@@ -293,7 +293,7 @@
// -----------------------------------------------------------------------------------------
private static Class<?> configurationClass = null;
- private static Method resolveRequiresAndUsesMethod;
+ private static Method resolveAndBindMethod;
static final Class<?> getConfigurationClass() {
init();
@@ -305,7 +305,7 @@
try {
configurationClass = Class.forName("java.lang.module.Configuration", false, null);
Class<?> moduleFinderInterface = ModuleFinder.getModuleFinderClass();
- resolveRequiresAndUsesMethod = configurationClass.getDeclaredMethod("resolveRequiresAndUses",
+ resolveAndBindMethod = configurationClass.getDeclaredMethod("resolveAndBind",
moduleFinderInterface,
moduleFinderInterface,
Collection.class
--- a/langtools/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java Wed Jul 05 22:52:01 2017 +0200
@@ -49,12 +49,15 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.Elements;
+import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -542,8 +545,13 @@
if (type == null)
return null;
- String binaryName = origin.getElements().getBinaryName(type).toString();
- Pair<JavacTask, CompilationUnitTree> source = findSource(binaryName);
+ Elements elements = origin.getElements();
+ String binaryName = elements.getBinaryName(type).toString();
+ ModuleElement module = elements.getModuleOf(type);
+ String moduleName = module == null || module.isUnnamed()
+ ? null
+ : module.getQualifiedName().toString();
+ Pair<JavacTask, CompilationUnitTree> source = findSource(moduleName, binaryName);
if (source == null)
return null;
@@ -636,7 +644,8 @@
}.scan(cut, null);
}
- private Pair<JavacTask, CompilationUnitTree> findSource(String binaryName) throws IOException {
+ private Pair<JavacTask, CompilationUnitTree> findSource(String moduleName,
+ String binaryName) throws IOException {
JavaFileObject jfo = fm.getJavaFileForInput(StandardLocation.SOURCE_PATH,
binaryName,
JavaFileObject.Kind.SOURCE);
@@ -645,7 +654,10 @@
return null;
List<JavaFileObject> jfos = Arrays.asList(jfo);
- JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, baseFileManager, d -> {}, null, null, jfos);
+ JavaFileManager patchFM = moduleName != null
+ ? new PatchModuleFileManager(baseFileManager, jfo, moduleName)
+ : baseFileManager;
+ JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, patchFM, d -> {}, null, null, jfos);
Iterable<? extends CompilationUnitTree> cuts = task.parse();
task.enter();
@@ -657,6 +669,61 @@
public void close() throws IOException {
fm.close();
}
+
+ private static final class PatchModuleFileManager
+ extends ForwardingJavaFileManager<JavaFileManager> {
+
+ private final JavaFileObject file;
+ private final String moduleName;
+
+ public PatchModuleFileManager(JavaFileManager fileManager,
+ JavaFileObject file,
+ String moduleName) {
+ super(fileManager);
+ this.file = file;
+ this.moduleName = moduleName;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Location getLocationForModule(Location location,
+ JavaFileObject fo,
+ String pkgName) throws IOException {
+ return fo == file
+ ? PATCH_LOCATION
+ : super.getLocationForModule(location, fo, pkgName);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public String inferModuleName(Location location) throws IOException {
+ return location == PATCH_LOCATION
+ ? moduleName
+ : super.inferModuleName(location);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean hasLocation(Location location) {
+ return location == StandardLocation.PATCH_MODULE_PATH ||
+ super.hasLocation(location);
+ }
+
+ private static final Location PATCH_LOCATION = new Location() {
+ @Override @DefinedBy(Api.COMPILER)
+ public String getName() {
+ return "PATCH_LOCATION";
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean isOutputLocation() {
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean isModuleOrientedLocation() {
+ return false;
+ }
+
+ };
+ }
}
}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java Wed Jul 05 22:52:01 2017 +0200
@@ -204,13 +204,6 @@
}
},
- XMODULE("-Xmodule:", false) {
- @Override
- public void process(Helper helper, String arg) throws InvalidValueException {
- Option.XMODULE.process(helper.getOptionHelper(), arg);
- }
- },
-
PATCH_MODULE("--patch-module", true) {
@Override
public void process(Helper helper, String arg) throws InvalidValueException {
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties Wed Jul 05 22:52:01 2017 +0200
@@ -82,7 +82,6 @@
\ Specify additional modules to be considered as required by a\n\
\ given module. <other-module> may be ALL-UNNAMED to require\n\
\ the unnamed module.\n\
-\ -Xmodule:<module-name> Specify a module to which the classes being compiled belong.\n\
\ --patch-module <module>=<file>(:<file>)*\n\
\ Override or augment a module with classes and resources\n\
\ in JAR files or directories\n
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Wed Jul 05 22:52:01 2017 +0200
@@ -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
@@ -144,6 +144,7 @@
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
if (configuration.allowTag(HtmlTag.MAIN)) {
htmlTree.addContent(div);
+ body.addContent(htmlTree);
} else {
body.addContent(div);
}
@@ -183,21 +184,12 @@
protected void addOverviewHeader(Content body) {
addConfigurationTitle(body);
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
- HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
- subTitleDiv.addStyle(HtmlStyle.subTitle);
- addSummaryComment(configuration.overviewElement, subTitleDiv);
- Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
- Content see = new ContentBuilder();
- see.addContent(contents.seeLabel);
- see.addContent(" ");
- Content descPara = HtmlTree.P(see);
- Content descLink = getHyperLink(getDocLink(
- SectionName.OVERVIEW_DESCRIPTION),
- contents.descriptionLabel, "", "");
- descPara.addContent(descLink);
- div.addContent(descPara);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ addOverviewComment(div);
if (configuration.allowTag(HtmlTag.MAIN)) {
htmlTree.addContent(div);
+ body.addContent(htmlTree);
} else {
body.addContent(div);
}
@@ -213,29 +205,17 @@
*/
protected void addOverviewComment(Content htmltree) {
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
- htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
addInlineComment(configuration.overviewElement, htmltree);
}
}
/**
- * Adds the tag information as provided in the file specified by the
- * "-overview" option on the command line.
+ * Not required for this page.
*
* @param body the documentation tree to which the overview will be added
*/
@Override
- protected void addOverview(Content body) {
- HtmlTree div = new HtmlTree(HtmlTag.DIV);
- div.addStyle(HtmlStyle.contentContainer);
- addOverviewComment(div);
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- body.addContent(htmlTree);
- } else {
- body.addContent(div);
- }
- }
+ protected void addOverview(Content body) {}
/**
* Adds the top text (from the -top option), the upper
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -134,6 +134,7 @@
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
if (configuration.allowTag(HtmlTag.MAIN)) {
htmlTree.addContent(div);
+ body.addContent(htmlTree);
} else {
body.addContent(div);
}
@@ -176,21 +177,12 @@
protected void addOverviewHeader(Content body) {
addConfigurationTitle(body);
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
- HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
- subTitleDiv.addStyle(HtmlStyle.subTitle);
- addSummaryComment(configuration.overviewElement, subTitleDiv);
- Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
- Content descBody = new ContentBuilder();
- descBody.addContent(contents.seeLabel);
- descBody.addContent(" ");
- Content descPara = HtmlTree.P(descBody);
- Content descLink = getHyperLink(getDocLink(
- SectionName.OVERVIEW_DESCRIPTION),
- contents.descriptionLabel, "", "");
- descPara.addContent(descLink);
- div.addContent(descPara);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ addOverviewComment(div);
if (configuration.allowTag(HtmlTag.MAIN)) {
htmlTree.addContent(div);
+ body.addContent(htmlTree);
} else {
body.addContent(div);
}
@@ -206,29 +198,17 @@
*/
protected void addOverviewComment(Content htmltree) {
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
- htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
addInlineComment(configuration.overviewElement, htmltree);
}
}
/**
- * Adds the tag information as provided in the file specified by the
- * "-overview" option on the command line.
+ * Not required for this page.
*
* @param body the documentation tree to which the overview will be added
*/
@Override
- protected void addOverview(Content body) {
- HtmlTree div = new HtmlTree(HtmlTag.DIV);
- div.addStyle(HtmlStyle.contentContainer);
- addOverviewComment(div);
- if (configuration.allowTag(HtmlTag.MAIN)) {
- htmlTree.addContent(div);
- body.addContent(htmlTree);
- } else {
- body.addContent(div);
- }
- }
+ protected void addOverview(Content body) {}
/**
* Adds the top text (from the -top option), the upper
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Wed Jul 05 22:52:01 2017 +0200
@@ -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
@@ -169,11 +169,42 @@
var tresult = new Array();
var mresult = new Array();
var tgresult = new Array();
+ var secondaryresult = new Array();
var displayCount = 0;
var exactMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term) + "$", "i");
camelCaseRegexp = ($.ui.autocomplete.escapeRegex(request.term)).split(/(?=[A-Z])/).join("([a-z0-9_$]*?)");
var camelCaseMatcher = new RegExp("^" + camelCaseRegexp);
secondaryMatcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
+
+ // Return the nested innermost name from the specified object
+ function nestedName(e) {
+ return e.l.substring(e.l.lastIndexOf(".") + 1);
+ }
+
+ // Sort array items by short name (as opposed to fully qualified name).
+ // Additionally, sort by the nested type name, when present,
+ // as opposed to top level short name.
+ function sortAndConcatResults(a1, a2) {
+ var sortingKey;
+ var sortArray = function(e1, e2) {
+ var l = sortingKey(e1);
+ var m = sortingKey(e2);
+ if (l < m)
+ return -1;
+ if (l > m)
+ return 1;
+ return 0;
+ };
+ sortingKey = function(e) {
+ return nestedName(e).toUpperCase();
+ };
+ a1.sort(sortArray);
+ a2.sort(sortArray);
+ a1 = a1.concat(a2);
+ a2.length = 0;
+ return a1;
+ }
+
if (moduleSearchIndex) {
var mdleCount = 0;
$.each(moduleSearchIndex, function(index, item) {
@@ -184,10 +215,11 @@
} else if (camelCaseMatcher.test(item.l)) {
result.unshift(item);
} else if (secondaryMatcher.test(item.l)) {
- result.push(item);
+ secondaryresult.push(item);
}
});
displayCount = mdleCount;
+ result = sortAndConcatResults(result, secondaryresult);
}
if (packageSearchIndex) {
var pCount = 0;
@@ -197,48 +229,51 @@
pkg = (item.m)
? (item.m + "/" + item.l)
: item.l;
- if (exactMatcher.test(item.l)) {
+ var s = nestedName(item);
+ if (exactMatcher.test(s)) {
presult.unshift(item);
pCount++;
} else if (camelCaseMatcher.test(pkg)) {
presult.unshift(item);
} else if (secondaryMatcher.test(pkg)) {
- presult.push(item);
+ secondaryresult.push(item);
}
});
- result = result.concat(presult);
+ result = result.concat(sortAndConcatResults(presult, secondaryresult));
displayCount = (pCount > displayCount) ? pCount : displayCount;
}
if (typeSearchIndex) {
var tCount = 0;
$.each(typeSearchIndex, function(index, item) {
item[category] = catTypes;
- if (exactMatcher.test(item.l)) {
+ var s = nestedName(item);
+ if (exactMatcher.test(s)) {
tresult.unshift(item);
tCount++;
- } else if (camelCaseMatcher.test(item.l)) {
+ } else if (camelCaseMatcher.test(s)) {
tresult.unshift(item);
} else if (secondaryMatcher.test(item.p + "." + item.l)) {
- tresult.push(item);
+ secondaryresult.push(item);
}
});
- result = result.concat(tresult);
+ result = result.concat(sortAndConcatResults(tresult, secondaryresult));
displayCount = (tCount > displayCount) ? tCount : displayCount;
}
if (memberSearchIndex) {
var mCount = 0;
$.each(memberSearchIndex, function(index, item) {
item[category] = catMembers;
- if (exactMatcher.test(item.l)) {
+ var s = nestedName(item);
+ if (exactMatcher.test(s)) {
mresult.unshift(item);
mCount++;
- } else if (camelCaseMatcher.test(item.l)) {
+ } else if (camelCaseMatcher.test(s)) {
mresult.unshift(item);
} else if (secondaryMatcher.test(item.c + "." + item.l)) {
- mresult.push(item);
+ secondaryresult.push(item);
}
});
- result = result.concat(mresult);
+ result = result.concat(sortAndConcatResults(mresult, secondaryresult));
displayCount = (mCount > displayCount) ? mCount : displayCount;
}
if (tagSearchIndex) {
@@ -249,10 +284,10 @@
tgresult.unshift(item);
tgCount++;
} else if (secondaryMatcher.test(item.l)) {
- tgresult.push(item);
+ secondaryresult.push(item);
}
});
- result = result.concat(tgresult);
+ result = result.concat(sortAndConcatResults(tgresult, secondaryresult));
displayCount = (tgCount > displayCount) ? tgCount : displayCount;
}
displayCount = (displayCount > 500) ? displayCount : 500;
@@ -312,4 +347,4 @@
}
}
});
-});
\ No newline at end of file
+});
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java Wed Jul 05 22:52:01 2017 +0200
@@ -181,13 +181,6 @@
}
},
- XMODULE("-Xmodule:", EXTENDED, false) {
- @Override
- public void process(Helper helper, String arg) throws InvalidValueException {
- Option.XMODULE.process(helper.getOptionHelper(), arg);
- }
- },
-
PATCH_MODULE("--patch-module", EXTENDED, true) {
@Override
public void process(Helper helper, String arg) throws InvalidValueException {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties Wed Jul 05 22:52:01 2017 +0200
@@ -238,11 +238,6 @@
given module. <other-module> may be ALL-UNNAMED to require\n\
the unnamed module.
-main.opt.Xmodule.arg=\
- <module-name>
-main.opt.Xmodule.desc=\
- Specify a module to which the classes being compiled belong
-
main.opt.patch.module.arg=\
<module>=<file>(:<file>)*
main.opt.patch.module.desc=\
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Module_attribute.java Wed Jul 05 22:52:01 2017 +0200
@@ -38,8 +38,8 @@
* deletion without notice.</b>
*/
public class Module_attribute extends Attribute {
- public static final int ACC_TRANSITIVE = 0x10;
- public static final int ACC_STATIC_PHASE = 0x20;
+ public static final int ACC_TRANSITIVE = 0x20;
+ public static final int ACC_STATIC_PHASE = 0x40;
public static final int ACC_OPEN = 0x20;
public static final int ACC_SYNTHETIC = 0x1000;
public static final int ACC_MANDATED = 0x8000;
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java Wed Jul 05 22:52:01 2017 +0200
@@ -118,7 +118,7 @@
}
this.configuration = Configuration.empty()
- .resolveRequires(finder, ModuleFinder.of(), mods);
+ .resolve(finder, ModuleFinder.of(), mods);
this.configuration.modules().stream()
.map(ResolvedModule::reference)
@@ -272,7 +272,7 @@
return nameToModule.values().stream();
} else {
return Configuration.empty()
- .resolveRequires(finder, ModuleFinder.of(), roots)
+ .resolve(finder, ModuleFinder.of(), roots)
.modules().stream()
.map(ResolvedModule::name)
.map(nameToModule::get);
@@ -422,18 +422,13 @@
}
private ModuleDescriptor dropHashes(ModuleDescriptor md) {
- ModuleDescriptor.Builder builder = ModuleDescriptor.module(md.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(md.name());
md.requires().forEach(builder::requires);
md.exports().forEach(builder::exports);
md.opens().forEach(builder::opens);
md.provides().stream().forEach(builder::provides);
md.uses().stream().forEach(builder::uses);
-
- Set<String> concealed = new HashSet<>(md.packages());
- md.exports().stream().map(Exports::source).forEach(concealed::remove);
- md.opens().stream().map(Opens::source).forEach(concealed::remove);
- concealed.forEach(builder::contains);
-
+ builder.packages(md.packages());
return builder.build();
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java Wed Jul 05 22:52:01 2017 +0200
@@ -26,8 +26,6 @@
package com.sun.tools.jdeps;
import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Exports;
-import java.lang.module.ModuleDescriptor.Opens;
import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
@@ -55,6 +53,7 @@
private final ModuleDescriptor descriptor;
private final Map<String, Set<String>> exports;
+ private final Map<String, Set<String>> opens;
private final boolean isSystem;
private final URI location;
@@ -63,6 +62,7 @@
this.descriptor = null;
this.location = null;
this.exports = Collections.emptyMap();
+ this.opens = Collections.emptyMap();
this.isSystem = true;
}
@@ -70,12 +70,14 @@
URI location,
ModuleDescriptor descriptor,
Map<String, Set<String>> exports,
+ Map<String, Set<String>> opens,
boolean isSystem,
ClassFileReader reader) {
super(name, location, reader);
this.descriptor = descriptor;
this.location = location;
this.exports = Collections.unmodifiableMap(exports);
+ this.opens = Collections.unmodifiableMap(opens);
this.isSystem = isSystem;
}
@@ -124,35 +126,52 @@
return descriptor.packages();
}
- /**
- * Tests if the package of the given name is exported.
- */
- public boolean isExported(String pn) {
- return exports.containsKey(pn) ? exports.get(pn).isEmpty() : false;
- }
-
public boolean isJDKUnsupported() {
return JDK_UNSUPPORTED.equals(this.name());
}
/**
- * Converts this module to a strict module with the given dependences
+ * Converts this module to a normal module with the given dependences
*
* @throws IllegalArgumentException if this module is not an automatic module
*/
- public Module toStrictModule(Map<String, Boolean> requires) {
+ public Module toNormalModule(Map<String, Boolean> requires) {
if (!isAutomatic()) {
- throw new IllegalArgumentException(name() + " already a strict module");
+ throw new IllegalArgumentException(name() + " not an automatic module");
}
- return new StrictModule(this, requires);
+ return new NormalModule(this, requires);
+ }
+
+ /**
+ * Tests if the package of the given name is exported.
+ */
+ public boolean isExported(String pn) {
+ return exports.containsKey(pn) && exports.get(pn).isEmpty();
}
/**
- * Tests if the package of the given name is qualifiedly exported
- * to the target.
+ * Tests if the package of the given name is exported to the target
+ * in a qualified fashion.
*/
public boolean isExported(String pn, String target) {
- return isExported(pn) || exports.containsKey(pn) && exports.get(pn).contains(target);
+ return isExported(pn)
+ || exports.containsKey(pn) && exports.get(pn).contains(target);
+ }
+
+ /**
+ * Tests if the package of the given name is open.
+ */
+ public boolean isOpen(String pn) {
+ return opens.containsKey(pn) && opens.get(pn).isEmpty();
+ }
+
+ /**
+ * Tests if the package of the given name is open to the target
+ * in a qualified fashion.
+ */
+ public boolean isOpen(String pn, String target) {
+ return isOpen(pn)
+ || opens.containsKey(pn) && opens.get(pn).contains(target);
}
@Override
@@ -193,19 +212,28 @@
}
Map<String, Set<String>> exports = new HashMap<>();
+ Map<String, Set<String>> opens = new HashMap<>();
- descriptor.exports().stream()
- .forEach(exp -> exports.computeIfAbsent(exp.source(), _k -> new HashSet<>())
- .addAll(exp.targets()));
-
- return new Module(name, location, descriptor, exports, isSystem, reader);
+ if (descriptor.isAutomatic()) {
+ // ModuleDescriptor::exports and opens returns an empty set
+ descriptor.packages().forEach(pn -> exports.put(pn, Collections.emptySet()));
+ descriptor.packages().forEach(pn -> opens.put(pn, Collections.emptySet()));
+ } else {
+ descriptor.exports().stream()
+ .forEach(exp -> exports.computeIfAbsent(exp.source(), _k -> new HashSet<>())
+ .addAll(exp.targets()));
+ descriptor.opens().stream()
+ .forEach(exp -> opens.computeIfAbsent(exp.source(), _k -> new HashSet<>())
+ .addAll(exp.targets()));
+ }
+ return new Module(name, location, descriptor, exports, opens, isSystem, reader);
}
}
private static class UnnamedModule extends Module {
private UnnamedModule() {
super("unnamed", null, null,
- Collections.emptyMap(),
+ Collections.emptyMap(), Collections.emptyMap(),
false, null);
}
@@ -230,19 +258,22 @@
}
}
- private static class StrictModule extends Module {
+ /**
+ * A normal module has a module-info.class
+ */
+ private static class NormalModule extends Module {
private final ModuleDescriptor md;
/**
- * Converts the given automatic module to a strict module.
+ * Converts the given automatic module to a normal module.
*
* Replace this module's dependences with the given requires and also
* declare service providers, if specified in META-INF/services configuration file
*/
- private StrictModule(Module m, Map<String, Boolean> requires) {
- super(m.name(), m.location, m.descriptor, m.exports, m.isSystem, m.reader());
+ private NormalModule(Module m, Map<String, Boolean> requires) {
+ super(m.name(), m.location, m.descriptor, m.exports, m.opens, m.isSystem, m.reader());
- ModuleDescriptor.Builder builder = ModuleDescriptor.module(m.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(m.name());
requires.keySet().forEach(mn -> {
if (requires.get(mn).equals(Boolean.TRUE)) {
builder.requires(Set.of(ModuleDescriptor.Requires.Modifier.TRANSITIVE), mn);
@@ -250,16 +281,10 @@
builder.requires(mn);
}
});
- m.descriptor.exports().forEach(e -> builder.exports(e));
- m.descriptor.opens().forEach(o -> builder.opens(o));
- m.descriptor.uses().forEach(s -> builder.uses(s));
- m.descriptor.provides().forEach(p -> builder.provides(p));
-
- Set<String> concealed = new HashSet<>(m.descriptor.packages());
- m.descriptor.exports().stream().map(Exports::source).forEach(concealed::remove);
- m.descriptor.opens().stream().map(Opens::source).forEach(concealed::remove);
- concealed.forEach(builder::contains);
-
+ // exports all packages
+ m.descriptor.packages().forEach(builder::exports);
+ m.descriptor.uses().forEach(builder::uses);
+ m.descriptor.provides().forEach(builder::provides);
this.md = builder.build();
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java Wed Jul 05 22:52:01 2017 +0200
@@ -150,7 +150,7 @@
private ModuleDescriptor descriptor(Set<Module> requiresTransitive,
Set<Module> requires) {
- ModuleDescriptor.Builder builder = ModuleDescriptor.module(root.name());
+ ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(root.name());
if (!root.name().equals(JAVA_BASE))
builder.requires(Set.of(MANDATED), JAVA_BASE);
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleExportsAnalyzer.java Wed Jul 05 22:52:01 2017 +0200
@@ -181,7 +181,7 @@
RootModule(String name) {
super(name);
- ModuleDescriptor.Builder builder = ModuleDescriptor.module(name);
+ ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(name);
this.descriptor = builder.build();
}
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java Wed Jul 05 22:52:01 2017 +0200
@@ -43,10 +43,12 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.stream.Collectors.*;
@@ -60,8 +62,8 @@
final Analyzer analyzer;
// an input JAR file (loaded as an automatic module for analysis)
- // maps to an explicit module to generate module-info.java
- final Map<Module, Module> automaticToExplicitModule;
+ // maps to a normal module to generate module-info.java
+ final Map<Module, Module> automaticToNormalModule;
public ModuleInfoBuilder(JdepsConfiguration configuration,
List<String> args,
Path outputdir,
@@ -78,20 +80,20 @@
.map(fn -> Paths.get(fn))
.collect(toList());
- // automatic module to convert to explicit module
- this.automaticToExplicitModule = ModuleFinder.of(paths.toArray(new Path[0]))
+ // automatic module to convert to normal module
+ this.automaticToNormalModule = ModuleFinder.of(paths.toArray(new Path[0]))
.findAll().stream()
.map(configuration::toModule)
.collect(toMap(Function.identity(), Function.identity()));
- Optional<Module> om = automaticToExplicitModule.keySet().stream()
+ Optional<Module> om = automaticToNormalModule.keySet().stream()
.filter(m -> !m.descriptor().isAutomatic())
.findAny();
if (om.isPresent()) {
throw new UncheckedBadArgs(new BadArgs("err.genmoduleinfo.not.jarfile",
om.get().getPathName()));
}
- if (automaticToExplicitModule.isEmpty()) {
+ if (automaticToNormalModule.isEmpty()) {
throw new UncheckedBadArgs(new BadArgs("err.invalid.path", args));
}
}
@@ -115,13 +117,13 @@
Path file = outputdir.resolve(m.name()).resolve("module-info.java");
// computes requires and requires transitive
- Module explicitModule = toExplicitModule(m, apiDeps);
- if (explicitModule != null) {
- automaticToExplicitModule.put(m, explicitModule);
+ Module normalModule = toNormalModule(m, apiDeps);
+ if (normalModule != null) {
+ automaticToNormalModule.put(m, normalModule);
// generate module-info.java
System.out.format("writing to %s%n", file);
- writeModuleInfo(file, explicitModule.descriptor());
+ writeModuleInfo(file, normalModule.descriptor());
} else {
// find missing dependences
System.out.format("Missing dependence: %s not generated%n", file);
@@ -139,7 +141,7 @@
return m == NOT_FOUND || m == REMOVED_JDK_INTERNALS;
}
- private Module toExplicitModule(Module module, Set<Archive> requiresTransitive)
+ private Module toNormalModule(Module module, Set<Archive> requiresTransitive)
throws IOException
{
// done analysis
@@ -159,21 +161,21 @@
.map(Archive::getModule)
.forEach(d -> requires.putIfAbsent(d.name(), Boolean.FALSE));
- return module.toStrictModule(requires);
+ return module.toNormalModule(requires);
}
/**
* Returns the stream of resulting modules
*/
Stream<Module> modules() {
- return automaticToExplicitModule.values().stream();
+ return automaticToNormalModule.values().stream();
}
/**
* Returns the stream of resulting ModuleDescriptors
*/
public Stream<ModuleDescriptor> descriptors() {
- return automaticToExplicitModule.entrySet().stream()
+ return automaticToNormalModule.entrySet().stream()
.map(Map.Entry::getValue)
.map(Module::descriptor);
}
@@ -205,13 +207,14 @@
md.requires().stream()
.filter(req -> !req.name().equals("java.base")) // implicit requires
.sorted(Comparator.comparing(Requires::name))
- .forEach(req -> writer.format(" requires %s;%n", req));
+ .forEach(req -> writer.format(" requires %s;%n",
+ toString(req.modifiers(), req.name())));
if (!open) {
md.exports().stream()
.peek(exp -> {
- if (exp.targets().size() > 0)
- throw new InternalError(md.name() + " qualified exports: " + exp);
+ if (exp.isQualified())
+ throw new InternalError(md.name() + " qualified exports: " + exp);
})
.sorted(Comparator.comparing(Exports::source))
.forEach(exp -> writer.format(" exports %s;%n", exp.source()));
@@ -231,7 +234,16 @@
}
private Set<Module> automaticModules() {
- return automaticToExplicitModule.keySet();
+ return automaticToNormalModule.keySet();
+ }
+
+ /**
+ * Returns a string containing the given set of modifiers and label.
+ */
+ private static <M> String toString(Set<M> mods, String what) {
+ return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase(Locale.US)),
+ Stream.of(what)))
+ .collect(Collectors.joining(" "));
}
/**
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -90,6 +90,17 @@
}
/**
+ * Release a JShell instance.
+ *
+ * @param state the JShell instance
+ */
+ public static void release(JShell state) {
+ if (debugMap != null) {
+ debugMap.remove(state);
+ }
+ }
+
+ /**
* Tests if any of the specified debug flags are enabled.
*
* @param state the JShell instance
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java Wed Jul 05 22:52:01 2017 +0200
@@ -310,6 +310,8 @@
int firstLine = 0;
PRINT_PAGE: while (true) {
+ in.print(lastNote.replaceAll(".", " ") + ConsoleReader.RESET_LINE);
+
int toPrint = height - 1;
while (toPrint > 0 && firstLine < lines.length) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java Wed Jul 05 22:52:01 2017 +0200
@@ -116,6 +116,13 @@
name, type, value, unresolved, errorLines);
}
+ public String format(String field, FormatCase fc, FormatAction fa, FormatWhen fw,
+ FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
+ String name, String type, String value, String unresolved, List<String> errorLines) {
+ return mode.format(field, fc, fa, fw, fr, fu, fe,
+ name, type, value, unresolved, errorLines);
+ }
+
public String truncateVarValue(String value) {
return mode.truncateVarValue(value);
}
@@ -463,6 +470,14 @@
String format(FormatCase fc, FormatAction fa, FormatWhen fw,
FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
String name, String type, String value, String unresolved, List<String> errorLines) {
+ return format("display", fc, fa, fw, fr, fu, fe,
+ name, type, value, unresolved, errorLines);
+ }
+
+ // Compute the display output given full context and values
+ String format(String field, FormatCase fc, FormatAction fa, FormatWhen fw,
+ FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
+ String name, String type, String value, String unresolved, List<String> errorLines) {
// Convert the context into a bit representation used as selectors for store field formats
long bits = bits(fc, fa, fw, fr, fu, fe);
String fname = name==null? "" : name;
@@ -476,7 +491,7 @@
fname, ftype, fvalue, funresolved, "*cannot-use-errors-here*", el))
.collect(joining());
return String.format(
- format("display", bits),
+ format(field, bits),
fname, ftype, fvalue, funresolved, errors, "*cannot-use-err-here*");
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Jul 05 22:52:01 2017 +0200
@@ -36,12 +36,9 @@
import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
-import java.net.URL;
import java.nio.charset.Charset;
-import java.nio.file.AccessDeniedException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
@@ -812,6 +809,12 @@
}
}
+ /**
+ * The entry point into the JShell tool.
+ *
+ * @param args the command-line arguments
+ * @throws Exception catastrophic fatal exception
+ */
public void start(String[] args) throws Exception {
OptionParserCommandLine commandLineArgs = new OptionParserCommandLine();
options = commandLineArgs.parse(args);
@@ -842,30 +845,33 @@
hardmsg("jshell.msg.welcome", version());
}
// Be sure history is always saved so that user code isn't lost
- Runtime.getRuntime().addShutdownHook(new Thread() {
+ Thread shutdownHook = new Thread() {
@Override
public void run() {
replayableHistory.storeHistory(prefs);
}
- });
+ };
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
// execute from user input
try (IOContext in = new ConsoleIOContext(this, cmdin, console)) {
- start(in);
+ while (regenerateOnDeath) {
+ if (!live) {
+ resetState();
+ }
+ run(in);
+ }
+ } finally {
+ replayableHistory.storeHistory(prefs);
+ closeState();
+ try {
+ Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ } catch (Exception ex) {
+ // ignore, this probably caused by VM aready being shutdown
+ // and this is the last act anyhow
+ }
}
}
- }
-
- private void start(IOContext in) {
- try {
- while (regenerateOnDeath) {
- if (!live) {
- resetState();
- }
- run(in);
- }
- } finally {
- closeState();
- }
+ closeState();
}
private EditorSetting configEditor() {
@@ -1019,6 +1025,8 @@
live = false;
JShell oldState = state;
if (oldState != null) {
+ state = null;
+ analysis = null;
oldState.unsubscribe(shutdownSubscription); // No notification
oldState.close();
}
@@ -2006,7 +2014,6 @@
private boolean cmdExit() {
regenerateOnDeath = false;
live = false;
- replayableHistory.storeHistory(prefs);
fluffmsg("jshell.msg.goodbye");
return true;
}
@@ -2614,9 +2621,16 @@
if (stream == null) {
return false;
}
- stream.forEachOrdered(mk
- -> hard(" %s %s", mk.name(), mk.signature())
- );
+ stream.forEachOrdered(meth -> {
+ String sig = meth.signature();
+ int i = sig.lastIndexOf(")") + 1;
+ if (i <= 0) {
+ hard(" %s", meth.name());
+ } else {
+ hard(" %s %s%s", sig.substring(i), meth.name(), sig.substring(0, i));
+ }
+ printSnippetStatus(meth, true);
+ });
return true;
}
@@ -2648,6 +2662,7 @@
break;
}
hard(" %s %s", kind, ck.name());
+ printSnippetStatus(ck, true);
});
return true;
}
@@ -2837,7 +2852,8 @@
return true;
}
} else {
- new DisplayEvent(ste, false, ste.value(), diagnostics).displayDeclarationAndValue();
+ new DisplayEvent(ste, FormatWhen.PRIMARY, ste.value(), diagnostics)
+ .displayDeclarationAndValue();
}
} else {
if (diagnostics.isEmpty()) {
@@ -2851,7 +2867,8 @@
List<Diag> other = errorsOnly(diagnostics);
// display update information
- new DisplayEvent(ste, true, ste.value(), other).displayDeclarationAndValue();
+ new DisplayEvent(ste, FormatWhen.UPDATE, ste.value(), other)
+ .displayDeclarationAndValue();
}
}
return false;
@@ -2889,10 +2906,7 @@
}
//where
void printUnresolvedException(UnresolvedReferenceException ex) {
- DeclarationSnippet corralled = ex.getSnippet();
- List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled).collect(toList()));
- new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors)
- .displayDeclarationAndValue();
+ printSnippetStatus(ex.getSnippet(), false);
}
//where
void printEvalException(EvalException ex) {
@@ -2934,23 +2948,38 @@
return act;
}
+ void printSnippetStatus(DeclarationSnippet sn, boolean resolve) {
+ List<Diag> otherErrors = errorsOnly(state.diagnostics(sn).collect(toList()));
+ new DisplayEvent(sn, state.status(sn), resolve, otherErrors)
+ .displayDeclarationAndValue();
+ }
+
class DisplayEvent {
private final Snippet sn;
private final FormatAction action;
- private final boolean update;
+ private final FormatWhen update;
private final String value;
private final List<String> errorLines;
private final FormatResolve resolution;
private final String unresolved;
private final FormatUnresolved unrcnt;
private final FormatErrors errcnt;
+ private final boolean resolve;
- DisplayEvent(SnippetEvent ste, boolean update, String value, List<Diag> errors) {
- this(ste.snippet(), ste.status(), toAction(ste.status(), ste.previousStatus(), ste.isSignatureChange()), update, value, errors);
+ DisplayEvent(SnippetEvent ste, FormatWhen update, String value, List<Diag> errors) {
+ this(ste.snippet(), ste.status(), false,
+ toAction(ste.status(), ste.previousStatus(), ste.isSignatureChange()),
+ update, value, errors);
}
- DisplayEvent(Snippet sn, Status status, FormatAction action, boolean update, String value, List<Diag> errors) {
+ DisplayEvent(Snippet sn, Status status, boolean resolve, List<Diag> errors) {
+ this(sn, status, resolve, FormatAction.USED, FormatWhen.UPDATE, null, errors);
+ }
+
+ private DisplayEvent(Snippet sn, Status status, boolean resolve,
+ FormatAction action, FormatWhen update, String value, List<Diag> errors) {
this.sn = sn;
+ this.resolve =resolve;
this.action = action;
this.update = update;
this.value = value;
@@ -2958,6 +2987,12 @@
for (Diag d : errors) {
displayDiagnostics(sn.source(), d, errorLines);
}
+ if (resolve) {
+ // resolve needs error lines indented
+ for (int i = 0; i < errorLines.size(); ++i) {
+ errorLines.set(i, " " + errorLines.get(i));
+ }
+ }
long unresolvedCount;
if (sn instanceof DeclarationSnippet && (status == Status.RECOVERABLE_DEFINED || status == Status.RECOVERABLE_NOT_DEFINED)) {
resolution = (status == Status.RECOVERABLE_NOT_DEFINED)
@@ -3012,10 +3047,17 @@
}
private void custom(FormatCase fcase, String name, String type) {
- String display = feedback.format(fcase, action, (update ? FormatWhen.UPDATE : FormatWhen.PRIMARY),
- resolution, unrcnt, errcnt,
- name, type, value, unresolved, errorLines);
- if (interactive()) {
+ if (resolve) {
+ String resolutionErrors = feedback.format("resolve", fcase, action, update,
+ resolution, unrcnt, errcnt,
+ name, type, value, unresolved, errorLines);
+ if (!resolutionErrors.trim().isEmpty()) {
+ hard(" %s", resolutionErrors);
+ }
+ } else if (interactive()) {
+ String display = feedback.format(fcase, action, update,
+ resolution, unrcnt, errcnt,
+ name, type, value, unresolved, errorLines);
cmdout.print(display);
}
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Wed Jul 05 22:52:01 2017 +0200
@@ -845,12 +845,12 @@
/set format verbose action ' update overwrote' overwrote-update \n\
/set format verbose action ' update dropped' dropped-update \n\
\n\
-/set format verbose until ', however, it cannot be instanciated or its methods invoked until' defined-class-primary \n\
+/set format verbose until ', however, it cannot be instantiated or its methods invoked until' defined-class-primary \n\
/set format verbose until ', however, its methods cannot be invoked until' defined-interface-primary \n\
/set format verbose until ', however, it cannot be used until' defined-enum,annotation-primary \n\
/set format verbose until ', however, it cannot be invoked until' defined-method-primary \n\
/set format verbose until ', however, it cannot be referenced until' notdefined-primary \n\
-/set format verbose until ' which cannot be instanciated or its methods invoked until' defined-class-update \n\
+/set format verbose until ' which cannot be instantiated or its methods invoked until' defined-class-update \n\
/set format verbose until ' whose methods cannot be invoked until' defined-interface-update \n\
/set format verbose until ' which cannot be invoked until' defined-method-update \n\
/set format verbose until ' which cannot be referenced until' notdefined-update \n\
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/DeclarationSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/DeclarationSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -45,6 +45,8 @@
* <code>DeclarationSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
*/
public abstract class DeclarationSnippet extends PersistentSnippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Diag.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Diag.java Wed Jul 05 22:52:01 2017 +0200
@@ -30,6 +30,8 @@
/**
* Diagnostic information for a Snippet.
+ *
+ * @since 9
* @see jdk.jshell.JShell#diagnostics(jdk.jshell.Snippet)
*/
public abstract class Diag {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ErroneousSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ErroneousSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* <code>ErroneousSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
*/
public class ErroneousSnippet extends Snippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/EvalException.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/EvalException.java Wed Jul 05 22:52:01 2017 +0200
@@ -38,6 +38,8 @@
* the Snippet id and for snippets without a method name (for example an
* expression) <code>StackTraceElement.getMethodName()</code> will be the
* empty string.
+ *
+ * @since 9
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class EvalException extends JShellException {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ExpressionSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* <code>ExpressionSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
* @jls 15: Expression.
*/
public class ExpressionSnippet extends Snippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* {@code ImportSnippet} is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
* @jls 8.3: importDeclaration.
*/
public class ImportSnippet extends PersistentSnippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 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
@@ -44,8 +44,10 @@
import java.util.function.BiFunction;
import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
+import javax.tools.StandardJavaFileManager;
import jdk.internal.jshell.debug.InternalDebugControl;
import jdk.jshell.Snippet.Status;
import jdk.jshell.spi.ExecutionControl.EngineTerminationException;
@@ -77,7 +79,9 @@
* <p>
* This class is not thread safe, except as noted, all access should be through
* a single thread.
+ *
* @author Robert Field
+ * @since 9
*/
public class JShell implements AutoCloseable {
@@ -92,6 +96,7 @@
final BiFunction<Snippet, Integer, String> idGenerator;
final List<String> extraRemoteVMOptions;
final List<String> extraCompilerOptions;
+ final Function<StandardJavaFileManager, StandardJavaFileManager> fileManagerMapping;
private int nextKeyIndex = 1;
@@ -115,6 +120,7 @@
this.idGenerator = b.idGenerator;
this.extraRemoteVMOptions = b.extraRemoteVMOptions;
this.extraCompilerOptions = b.extraCompilerOptions;
+ this.fileManagerMapping = b.fileManagerMapping;
try {
if (b.executionControlProvider != null) {
executionControl = b.executionControlProvider.generate(new ExecutionEnvImpl(),
@@ -171,6 +177,7 @@
ExecutionControlProvider executionControlProvider;
Map<String,String> executionControlParameters;
String executionControlSpec;
+ Function<StandardJavaFileManager, StandardJavaFileManager> fileManagerMapping;
Builder() { }
@@ -365,6 +372,28 @@
}
/**
+ * Configure the {@code FileManager} to be used by compilation and
+ * source analysis.
+ * If not set or passed null, the compiler's standard file manager will
+ * be used (identity mapping).
+ * For use in special applications where the compiler's normal file
+ * handling needs to be overridden. See the file manager APIs for more
+ * information.
+ * The file manager input enables forwarding file managers, if this
+ * is not needed, the incoming file manager can be ignored (constant
+ * function).
+ *
+ * @param mapping a function that given the compiler's standard file
+ * manager, returns a file manager to use
+ * @return the {@code Builder} instance (for use in chained
+ * initialization)
+ */
+ public Builder fileManager(Function<StandardJavaFileManager, StandardJavaFileManager> mapping) {
+ this.fileManagerMapping = mapping;
+ return this;
+ }
+
+ /**
* Builds a JShell state engine. This is the entry-point to all JShell
* functionality. This creates a remote process for execution. It is
* thus important to close the returned instance.
@@ -501,6 +530,7 @@
* @throws IllegalStateException if this {@code JShell} instance is closed.
*/
public void addToClasspath(String path) {
+ checkIfAlive();
// Compiler
taskFactory.addToClasspath(path);
// Runtime
@@ -543,17 +573,7 @@
*/
@Override
public void close() {
- if (!closed) {
- closeDown();
- try {
- executionControl().close();
- } catch (Throwable ex) {
- // don't care about exceptions on close
- }
- if (sourceCodeAnalysis != null) {
- sourceCodeAnalysis.close();
- }
- }
+ closeDown();
}
/**
@@ -826,6 +846,15 @@
} catch (Throwable thr) {
// Don't care about dying exceptions
}
+ try {
+ executionControl().close();
+ } catch (Throwable ex) {
+ // don't care about exceptions on close
+ }
+ if (sourceCodeAnalysis != null) {
+ sourceCodeAnalysis.close();
+ }
+ InternalDebugControl.release(this);
}
}
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShellException.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShellException.java Wed Jul 05 22:52:01 2017 +0200
@@ -27,6 +27,8 @@
/**
* The superclass of JShell generated exceptions
+ *
+ * @since 9
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class JShellException extends Exception {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java Wed Jul 05 22:52:01 2017 +0200
@@ -30,8 +30,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Files;
@@ -71,10 +69,6 @@
private final JShell proc;
- // Upcoming Jigsaw
- private Method inferModuleNameMethod = null;
- private Method listLocationsForModulesMethod = null;
-
Iterable<? extends Path> getLocationAsPaths(Location loc) {
return this.stdFileManager.getLocationAsPaths(loc);
}
@@ -165,7 +159,9 @@
}
public MemoryFileManager(StandardJavaFileManager standardManager, JShell proc) {
- this.stdFileManager = standardManager;
+ this.stdFileManager = proc.fileManagerMapping != null
+ ? proc.fileManagerMapping.apply(standardManager)
+ : standardManager;
this.proc = proc;
}
@@ -184,43 +180,6 @@
return new SourceMemoryJavaFileObject(origin, name, code);
}
- // Make compatible with Jigsaw
- public String inferModuleName(Location location) {
- try {
- if (inferModuleNameMethod == null) {
- inferModuleNameMethod = JavaFileManager.class.getDeclaredMethod("inferModuleName", Location.class);
- }
- @SuppressWarnings("unchecked")
- String result = (String) inferModuleNameMethod.invoke(stdFileManager, location);
- return result;
- } catch (NoSuchMethodException | SecurityException ex) {
- throw new InternalError("Cannot lookup JavaFileManager method", ex);
- } catch (IllegalAccessException |
- IllegalArgumentException |
- InvocationTargetException ex) {
- throw new InternalError("Cannot invoke JavaFileManager method", ex);
- }
- }
-
- // Make compatible with Jigsaw
- public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
- try {
- if (listLocationsForModulesMethod == null) {
- listLocationsForModulesMethod = JavaFileManager.class.getDeclaredMethod("listLocationsForModules", Location.class);
- }
- @SuppressWarnings("unchecked")
- Iterable<Set<Location>> result = (Iterable<Set<Location>>) listLocationsForModulesMethod.invoke(stdFileManager, location);
- return result;
- } catch (NoSuchMethodException | SecurityException ex) {
- throw new InternalError("Cannot lookup JavaFileManager method", ex);
- } catch (IllegalAccessException |
- IllegalArgumentException |
- InvocationTargetException ex) {
- throw new InternalError("Cannot invoke JavaFileManager method", ex);
- }
- }
-
-
/**
* Returns a class loader for loading plug-ins from the given location. For
* example, to load annotation processors, a compiler will request a class
@@ -580,6 +539,26 @@
", sibling: " + sibling);
}
+ @Override
+ public Location getLocationForModule(Location location, String moduleName) throws IOException {
+ return stdFileManager.getLocationForModule(location, moduleName);
+ }
+
+ @Override
+ public Location getLocationForModule(Location location, JavaFileObject fo, String pkgName) throws IOException {
+ return stdFileManager.getLocationForModule(location, fo, pkgName);
+ }
+
+ @Override
+ public String inferModuleName(Location location) throws IOException {
+ return stdFileManager.inferModuleName(location);
+ }
+
+ @Override
+ public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
+ return stdFileManager.listLocationsForModules(location);
+ }
+
/**
* Flushes any resources opened for output by this file manager
* directly or indirectly. Flushing a closed file manager has no
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MethodSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MethodSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -35,6 +35,8 @@
* <code>MethodSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
* @jls 8.4: MethodDeclaration.
*/
public class MethodSnippet extends DeclarationSnippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterImportSnippetWrap.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterImportSnippetWrap.java Wed Jul 05 22:52:01 2017 +0200
@@ -32,7 +32,7 @@
* The outer wrap for a set of snippets wrapped in a generated class
* @author Robert Field
*/
-public class OuterImportSnippetWrap extends OuterWrap {
+class OuterImportSnippetWrap extends OuterWrap {
private final Snippet snippet;
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterSnippetsClassWrap.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterSnippetsClassWrap.java Wed Jul 05 22:52:01 2017 +0200
@@ -35,7 +35,7 @@
* The outer wrap for a set of snippets wrapped in a generated class
* @author Robert Field
*/
-public class OuterSnippetsClassWrap extends OuterWrap {
+class OuterSnippetsClassWrap extends OuterWrap {
private final String className;
private final LinkedHashMap<Wrap, Snippet> wrapToSnippet;
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/OuterWrapMap.java Wed Jul 05 22:52:01 2017 +0200
@@ -44,7 +44,7 @@
*
* @author Robert Field
*/
-public class OuterWrapMap {
+class OuterWrapMap {
private final JShell state;
private final Map<String,OuterSnippetsClassWrap> classOuters = new HashMap<>();
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/PersistentSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/PersistentSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* <code>PersistentSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
*/
public abstract class PersistentSnippet extends Snippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -39,7 +39,9 @@
* state engine, query {@code JShell} passing the Snippet.
* <p>
* Because it is immutable, {@code Snippet} (and subclasses) is thread-safe.
+ *
* @author Robert Field
+ * @since 9
* @see jdk.jshell.JShell#status
*/
public abstract class Snippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetEvent.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetEvent.java Wed Jul 05 22:52:01 2017 +0200
@@ -38,7 +38,9 @@
* {@code SnippetEvent} is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
* @author Robert Field
+ * @since 9
*/
public class SnippetEvent {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java Wed Jul 05 22:52:01 2017 +0200
@@ -39,6 +39,7 @@
* etc.
* Also includes completion suggestions, as might be used in tab-completion.
*
+ * @since 9
*/
public abstract class SourceCodeAnalysis {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/StatementSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/StatementSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* <code>StatementSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
* @jls 14.5: Statement.
*/
public class StatementSnippet extends Snippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypeDeclSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TypeDeclSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -36,6 +36,8 @@
* <code>TypeDeclSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
*/
public class TypeDeclSnippet extends DeclarationSnippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/UnresolvedReferenceException.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/UnresolvedReferenceException.java Wed Jul 05 22:52:01 2017 +0200
@@ -36,6 +36,8 @@
* the Snippet id and for snippets without a method name (for example an
* expression) <code>StackTraceElement.getName()</code> will be the
* empty string.
+ *
+ * @since 9
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class UnresolvedReferenceException extends JShellException {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarSnippet.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/VarSnippet.java Wed Jul 05 22:52:01 2017 +0200
@@ -35,6 +35,8 @@
* <code>VarSnippet</code> is immutable: an access to
* any of its methods will always return the same result.
* and thus is thread-safe.
+ *
+ * @since 9
* @jls 8.3: FieldDeclaration.
*/
public class VarSnippet extends DeclarationSnippet {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DirectExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -39,6 +39,7 @@
*
* @author Robert Field
* @author Jan Lahoda
+ * @since 9
*/
public class DirectExecutionControl implements ExecutionControl {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/FailOverExecutionControlProvider.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/FailOverExecutionControlProvider.java Wed Jul 05 22:52:01 2017 +0200
@@ -37,6 +37,8 @@
/**
* Tries other providers in sequence until one works.
+ *
+ * @since 9
*/
public class FailOverExecutionControlProvider implements ExecutionControlProvider{
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -33,6 +33,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,6 +61,7 @@
*
* @author Robert Field
* @author Jan Lahoda
+ * @since 9
*/
public class JdiDefaultExecutionControl extends JdiExecutionControl {
@@ -97,7 +99,8 @@
// Set-up the JDI connection
JdiInitiator jdii = new JdiInitiator(port,
- env.extraRemoteVMOptions(), remoteAgent, isLaunch, host, timeout);
+ env.extraRemoteVMOptions(), remoteAgent, isLaunch, host,
+ timeout, Collections.emptyMap());
VirtualMachine vm = jdii.vm();
Process process = jdii.process();
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -37,7 +37,9 @@
import static java.util.stream.Collectors.toMap;
/**
- * Abstract JDI implementation of {@link jdk.jshell.spi.ExecutionControl}
+ * Abstract JDI implementation of {@link jdk.jshell.spi.ExecutionControl}.
+ *
+ * @since 9
*/
public abstract class JdiExecutionControl extends StreamingExecutionControl implements ExecutionControl {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiExecutionControlProvider.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiExecutionControlProvider.java Wed Jul 05 22:52:01 2017 +0200
@@ -35,7 +35,9 @@
/**
* A provider of remote JDI-controlled execution engines.
+ *
* @author Robert Field
+ * @since 9
*/
public class JdiExecutionControlProvider implements ExecutionControlProvider {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java Wed Jul 05 22:52:01 2017 +0200
@@ -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
@@ -47,6 +47,8 @@
/**
* Sets up a JDI connection, providing the resulting JDI {@link VirtualMachine}
* and the {@link Process} the remote agent is running in.
+ *
+ * @since 9
*/
public class JdiInitiator {
@@ -66,16 +68,20 @@
* Start the remote agent and establish a JDI connection to it.
*
* @param port the socket port for (non-JDI) commands
- * @param remoteVMOptions any user requested VM options
+ * @param remoteVMOptions any user requested VM command-line options
* @param remoteAgent full class name of remote agent to launch
* @param isLaunch does JDI do the launch? That is, LaunchingConnector,
* otherwise we start explicitly and use ListeningConnector
* @param host explicit hostname to use, if null use discovered
* hostname, applies to listening only (!isLaunch)
- * @param timeout the start-up time-out in milliseconds
+ * @param timeout the start-up time-out in milliseconds. If zero or negative,
+ * will not wait thus will timeout immediately if not already started.
+ * @param customConnectorArgs custom arguments passed to the connector.
+ * These are JDI com.sun.jdi.connect.Connector arguments.
*/
public JdiInitiator(int port, List<String> remoteVMOptions, String remoteAgent,
- boolean isLaunch, String host, int timeout) {
+ boolean isLaunch, String host, int timeout,
+ Map<String, String> customConnectorArgs) {
this.remoteAgent = remoteAgent;
this.connectTimeout = (int) (timeout * CONNECT_TIMEOUT_FACTOR);
String connectorName
@@ -96,6 +102,7 @@
argumentName2Value.put("localAddress", host);
}
}
+ argumentName2Value.putAll(customConnectorArgs);
this.connectorArgs = mergeConnectorArgs(connector, argumentName2Value);
this.vm = isLaunch
? launchTarget()
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LoaderDelegate.java Wed Jul 05 22:52:01 2017 +0200
@@ -34,6 +34,8 @@
* This interface specifies the loading specific subset of
* {@link jdk.jshell.spi.ExecutionControl}. For use in encapsulating the
* {@link java.lang.ClassLoader} implementation.
+ *
+ * @since 9
*/
public interface LoaderDelegate {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -33,6 +33,7 @@
* in the same JVM as the JShell-core.
*
* @author Grigory Ptashko
+ * @since 9
*/
public class LocalExecutionControl extends DirectExecutionControl {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControlProvider.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControlProvider.java Wed Jul 05 22:52:01 2017 +0200
@@ -32,7 +32,9 @@
/**
* A provider of execution engines which run in the same process as JShell.
+ *
* @author Robert Field
+ * @since 9
*/
public class LocalExecutionControlProvider implements ExecutionControlProvider{
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -45,6 +45,7 @@
*
* @author Jan Lahoda
* @author Robert Field
+ * @since 9
*/
public class RemoteExecutionControl extends DirectExecutionControl implements ExecutionControl {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/StreamingExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -37,6 +37,7 @@
* execution takes place.
*
* @author Robert Field
+ * @since 9
*/
public class StreamingExecutionControl implements ExecutionControl {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java Wed Jul 05 22:52:01 2017 +0200
@@ -53,6 +53,7 @@
*
* @author Jan Lahoda
* @author Robert Field
+ * @since 9
*/
public class Util {
@@ -60,7 +61,7 @@
private static final int TAG_CLOSED = 1;
private static final int TAG_EXCEPTION = 2;
- // never instanciated
+ // never instantiated
private Util() {}
/**
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/package-info.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/package-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -30,5 +30,7 @@
* Also, provides related communication utilities.
* This package may be used to define alternative execution engines.
* The default JShell execution engine is included.
+ *
+ * @since 9
*/
package jdk.jshell.execution;
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/package-info.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/package-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -140,6 +140,8 @@
* provide source boundary and completeness analysis to address cases like
* those. <code>SourceCodeAnalysis</code> also provides suggested completions
* of input, as might be used in tab-completion.
+ *
+ * @since 9
*/
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -45,6 +45,8 @@
* <p>
* Methods defined in this interface should only be called by the core JShell
* implementation.
+ *
+ * @since 9
*/
public interface ExecutionControl extends AutoCloseable {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControlProvider.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControlProvider.java Wed Jul 05 22:52:01 2017 +0200
@@ -33,7 +33,9 @@
* evaluate Snippets. Alternate execution engines can be created by
* implementing this interface, then configuring JShell with the provider or
* the providers name and parameter specifier.
+ *
* @author Robert Field
+ * @since 9
*/
public interface ExecutionControlProvider {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionEnv.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionEnv.java Wed Jul 05 22:52:01 2017 +0200
@@ -36,6 +36,7 @@
* This interface is designed to provide the access to core JShell functionality
* needed to implement ExecutionControl.
*
+ * @since 9
* @see ExecutionControl
*/
public interface ExecutionEnv {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/SPIResolutionException.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/SPIResolutionException.java Wed Jul 05 22:52:01 2017 +0200
@@ -33,6 +33,8 @@
* <p>
* This exception is seen by the execution engine, but not seen by
* the end user nor through the JShell API.
+ *
+ * @since 9
*/
@SuppressWarnings("serial") // serialVersionUID intentionally omitted
public class SPIResolutionException extends RuntimeException {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/package-info.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/package-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -66,6 +66,7 @@
* <li>failover:1(jdi),2(jdi:launch(true),timeout(3000)),3(local)</li>
* </ul>
*
+ * @since 9
* @see jdk.jshell.execution for execution implementation support
*/
package jdk.jshell.spi;
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/JavaShellToolBuilder.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/JavaShellToolBuilder.java Wed Jul 05 22:52:01 2017 +0200
@@ -40,6 +40,8 @@
* configuration methods have sensible defaults which will be used if they are
* not called.. After zero or more calls to configuration methods, the tool is
* launched with a call to {@link #run(java.lang.String...) }.
+ *
+ * @since 9
*/
public interface JavaShellToolBuilder {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/package-info.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/package-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -47,6 +47,8 @@
* .run("--feedback", "silent", "MyStart");
* }
* </pre>
+ *
+ * @since 9
*/
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PRINTING.jsh Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/tool/resources/PRINTING.jsh Wed Jul 05 22:52:01 2017 +0200
@@ -17,5 +17,5 @@
void println(char s[]) { System.out.println(s); }
void println(String s) { System.out.println(s); }
void println(Object obj) { System.out.println(obj); }
-void printf(Locale l, String format, Object... args) { System.out.printf(l, format, args); }
+void printf(java.util.Locale l, String format, Object... args) { System.out.printf(l, format, args); }
void printf(String format, Object... args) { System.out.printf(format, args); }
--- a/langtools/src/jdk.jshell/share/classes/module-info.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/module-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -51,6 +51,8 @@
* independent, operate at different levels, and do not share functionality or
* definitions.
* </p>
+ *
+ * @since 9
*/
module jdk.jshell {
requires transitive java.compiler;
--- a/langtools/test/ProblemList.txt Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/ProblemList.txt Wed Jul 05 22:52:01 2017 +0200
@@ -36,7 +36,7 @@
#
# jshell
-jdk/jshell/UserJdiUserRemoteTest.java 8173204 linux-all
+jdk/jshell/UserJdiUserRemoteTest.java 8173079 linux-all
jdk/jshell/UserInputTest.java 8169536 generic-all
###########################################################################
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/TestOverview.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * 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 8173302
+ * @summary make sure the overview-summary and module-summary pages don't
+ * don't have the See link, and the overview is copied correctly.
+ * @library ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build JavadocTester
+ * @run main TestOverview
+ */
+
+public class TestOverview extends JavadocTester {
+
+ public static void main(String... args) throws Exception {
+ TestOverview tester = new TestOverview();
+ tester.runTests();
+ }
+
+ @Test
+ void test1() {
+ javadoc("-d", "out-1",
+ "-doctitle", "Document Title",
+ "-windowtitle", "Window Title",
+ "-overview", testSrc("overview.html"),
+ "-sourcepath", testSrc("src"),
+ "p1", "p2");
+ checkExit(Exit.OK);
+ checkOutput("overview-summary.html", true,
+ "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>\n"
+ + "</div>\n"
+ + "<div class=\"contentContainer\">\n"
+ + "<div class=\"block\">This is line1. This is line 2.</div>\n"
+ + "</div>\n"
+ + "<div class=\"contentContainer\">"
+ );
+ }
+
+ @Test
+ void test2() {
+ javadoc("-d", "out-2",
+ "-doctitle", "Document Title",
+ "-windowtitle", "Window Title",
+ "-overview", testSrc("overview.html"),
+ "-sourcepath", testSrc("msrc"),
+ "p1", "p2");
+ checkExit(Exit.OK);
+ checkOutput("overview-summary.html", true,
+ "<div class=\"header\">\n"
+ + "<h1 class=\"title\">Document Title</h1>\n"
+ + "</div>\n"
+ + "<div class=\"contentContainer\">\n"
+ + "<div class=\"block\">This is line1. This is line 2.</div>\n"
+ + "</div>\n"
+ + "<div class=\"contentContainer\">"
+ );
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/msrc/module-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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 module acme.
+ */
+module acme {
+ exports p1;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/msrc/p1/C.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package p1;
+
+public class C {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/msrc/p2/C2.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package p2;
+
+public class C2 {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/overview.html Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<body bgcolor="white">
+ This is line1. This is line 2.
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/src/p1/C.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package p1;
+
+public class C {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOverview/src/p2/C2.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package p2;
+
+public class C2 {}
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Wed Jul 05 22:52:01 2017 +0200
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8141492 8071982 8141636 8147890 8166175
+ * @bug 8141492 8071982 8141636 8147890 8166175 8168965
* @summary Test the search feature of javadoc.
* @author bpatel
* @library ../lib
@@ -486,6 +486,9 @@
checkOutput("search.js", true,
"camelCaseRegexp = ($.ui.autocomplete.escapeRegex(request.term)).split(/(?=[A-Z])/).join(\"([a-z0-9_$]*?)\");",
"var camelCaseMatcher = new RegExp(\"^\" + camelCaseRegexp);",
- "camelCaseMatcher.test(item.l)");
+ "camelCaseMatcher.test(item.l)",
+ "var secondaryresult = new Array();",
+ "function nestedName(e) {",
+ "function sortAndConcatResults(a1, a2) {");
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/FileManagerTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,114 @@
+/*
+ * 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 8173845
+ * @summary test custom file managers
+ * @build KullaTesting TestingInputStream
+ * @run testng FileManagerTest
+ */
+
+
+import java.io.File;
+import java.io.IOException;
+
+import java.util.Set;
+import javax.tools.ForwardingJavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+import javax.tools.StandardJavaFileManager;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class FileManagerTest extends KullaTesting {
+
+ boolean encountered;
+
+ class MyFileManager extends ForwardingJavaFileManager<StandardJavaFileManager>
+ implements StandardJavaFileManager {
+
+ protected MyFileManager(StandardJavaFileManager fileManager) {
+ super(fileManager);
+ }
+
+ @Override
+ public Iterable<JavaFileObject> list(Location location,
+ String packageName,
+ Set<Kind> kinds,
+ boolean recurse)
+ throws IOException {
+ //System.out.printf("list(%s, %s, %s, %b)\n",
+ // location, packageName, kinds, recurse);
+ if (packageName.equals("java.lang.reflect")) {
+ encountered = true;
+ }
+ return fileManager.list(location, packageName, kinds, recurse);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) {
+ return fileManager.getJavaFileObjectsFromFiles(files);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) {
+ return fileManager.getJavaFileObjects(files);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) {
+ return fileManager.getJavaFileObjectsFromStrings(names);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) {
+ return fileManager.getJavaFileObjects(names);
+ }
+
+ @Override
+ public void setLocation(Location location, Iterable<? extends File> files) throws IOException {
+ fileManager.setLocation(location, files);
+ }
+
+ @Override
+ public Iterable<? extends File> getLocation(Location location) {
+ return fileManager.getLocation(location);
+ }
+
+ }
+
+ @BeforeMethod
+ @Override
+ public void setUp() {
+ setUp(b -> b.fileManager(fm -> new MyFileManager(fm)));
+ }
+
+ public void testSnippetMemberAssignment() {
+ assertEval("java.lang.reflect.Array.get(new String[1], 0) == null");
+ assertTrue(encountered, "java.lang.reflect not encountered");
+ }
+
+}
--- a/langtools/test/jdk/jshell/JavadocTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/JavadocTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8131019 8169561
+ * @bug 8131019 8169561 8174245
* @summary Test Javadoc
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -107,4 +107,51 @@
addToClasspath(compiler.getClassDir());
}
+ public void testCollectionsMin() {
+ prepareJavaUtilZip();
+ assertJavadoc("java.util.Collections.min(|",
+ "T java.util.Collections.<T>min(java.util.Collection<? extends T> coll, java.util.Comparator<? super T> comp)\n" +
+ " min comparator\n",
+ "T java.util.Collections.<T extends Object & Comparable<? super T>>min(java.util.Collection<? extends T> coll)\n" +
+ " min comparable\n");
+ }
+
+ private void prepareJavaUtilZip() {
+ String clazz =
+ "package java.util;\n" +
+ "/**Top level." +
+ " */\n" +
+ "public class Collections {\n" +
+ " /**\n" +
+ " * min comparable\n" +
+ " */\n" +
+ " public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll) {" +
+ " return null;\n" +
+ " }\n" +
+ " /**\n" +
+ " * min comparator\n" +
+ " */\n" +
+ " public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+
+ Path srcZip = Paths.get("src.zip");
+
+ try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
+ out.putNextEntry(new JarEntry("java/util/Collections.java"));
+ out.write(clazz.getBytes());
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ try {
+ Field availableSources = getAnalysis().getClass().getDeclaredField("availableSources");
+ availableSources.setAccessible(true);
+ availableSources.set(getAnalysis(), Arrays.asList(srcZip));
+ } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
}
--- a/langtools/test/jdk/jshell/KullaTesting.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/KullaTesting.java Wed Jul 05 22:52:01 2017 +0200
@@ -213,7 +213,7 @@
ModuleFinder finder = ModuleFinder.of(modPath);
Layer parent = Layer.boot();
Configuration cf = parent.configuration()
- .resolveRequires(finder, ModuleFinder.of(), Set.of(moduleName));
+ .resolve(finder, ModuleFinder.of(), Set.of(moduleName));
ClassLoader scl = ClassLoader.getSystemClassLoader();
Layer layer = parent.defineModulesWithOneLoader(cf, scl);
ClassLoader loader = layer.findLoader(moduleName);
--- a/langtools/test/jdk/jshell/MyExecutionControl.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/MyExecutionControl.java Wed Jul 05 22:52:01 2017 +0200
@@ -29,6 +29,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,7 +79,7 @@
+ System.getProperty("path.separator")
+ System.getProperty("user.dir"));
JdiInitiator jdii = new JdiInitiator(port,
- opts, REMOTE_AGENT, true, null, TIMEOUT);
+ opts, REMOTE_AGENT, true, null, TIMEOUT, Collections.emptyMap());
VirtualMachine vm = jdii.vm();
Process process = jdii.process();
--- a/langtools/test/jdk/jshell/ReplToolTesting.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java Wed Jul 05 22:52:01 2017 +0200
@@ -72,27 +72,27 @@
final static List<String> START_UP_CMD_METHOD = Stream.<String>of()
.collect(toList());
final static List<String> PRINTING_CMD_METHOD = Stream.of(
- "| print (boolean)void",
- "| print (char)void",
- "| print (int)void",
- "| print (long)void",
- "| print (float)void",
- "| print (double)void",
- "| print (char s[])void",
- "| print (String)void",
- "| print (Object)void",
- "| println ()void",
- "| println (boolean)void",
- "| println (char)void",
- "| println (int)void",
- "| println (long)void",
- "| println (float)void",
- "| println (double)void",
- "| println (char s[])void",
- "| println (String)void",
- "| println (Object)void",
- "| printf (Locale,String,Object...)void",
- "| printf (String,Object...)void")
+ "| void print(boolean)",
+ "| void print(char)",
+ "| void print(int)",
+ "| void print(long)",
+ "| void print(float)",
+ "| void print(double)",
+ "| void print(char s[])",
+ "| void print(String)",
+ "| void print(Object)",
+ "| void println()",
+ "| void println(boolean)",
+ "| void println(char)",
+ "| void println(int)",
+ "| void println(long)",
+ "| void println(float)",
+ "| void println(double)",
+ "| void println(char s[])",
+ "| void println(String)",
+ "| void println(Object)",
+ "| void printf(java.util.Locale,String,Object...)",
+ "| void printf(String,Object...)")
.collect(toList());
final static List<String> START_UP = Collections.unmodifiableList(
Stream.concat(START_UP_IMPORTS.stream(), START_UP_METHODS.stream())
@@ -152,6 +152,7 @@
return s -> {
List<String> lines = Stream.of(s.split("\n"))
.filter(l -> !l.isEmpty())
+ .filter(l -> !l.startsWith("| ")) // error/unresolved info
.collect(Collectors.toList());
assertEquals(lines.size(), set.size(), message + " : expected: " + set.keySet() + "\ngot:\n" + lines);
for (String line : lines) {
@@ -664,7 +665,12 @@
@Override
public String toString() {
- return String.format("%s %s", name, signature);
+ int i = signature.lastIndexOf(")") + 1;
+ if (i <= 0) {
+ return String.format("%s", name);
+ } else {
+ return String.format("%s %s%s", signature.substring(i), name, signature.substring(0, i));
+ }
}
}
--- a/langtools/test/jdk/jshell/ToolReloadTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -92,8 +92,8 @@
test(false, new String[]{"--no-startup"},
a -> assertVariable(a, "int", "a"),
a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
+ a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+ a -> dropMethod(a, "/drop b", "int b()", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
a -> dropClass(a, "/dr A", "class A", "| dropped class A"),
a -> assertCommand(a, "/reload",
@@ -115,8 +115,8 @@
test(false, new String[]{"--no-startup"},
a -> assertVariable(a, "int", "a"),
a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
+ a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+ a -> dropMethod(a, "/drop b", "int b()", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
a -> dropClass(a, "/dr A", "class A", "| dropped class A"),
a -> assertCommand(a, "/reload -quiet",
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
@@ -238,8 +238,8 @@
test(false, new String[]{"--no-startup"},
a -> assertVariable(a, "int", "a"),
a -> dropVariable(a, "/drop 1", "int a = 0", "| dropped variable a"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop 2", "b ()I", "| dropped method b()"),
+ a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+ a -> dropMethod(a, "/drop 2", "int b()", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
a -> dropClass(a, "/drop 3", "class A", "| dropped class A"),
a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
@@ -255,8 +255,8 @@
test(false, new String[]{"--no-startup"},
a -> assertVariable(a, "int", "a"),
a -> dropVariable(a, "/drop a", "int a = 0", "| dropped variable a"),
- a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
- a -> dropMethod(a, "/drop b", "b ()I", "| dropped method b()"),
+ a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+ a -> dropMethod(a, "/drop b", "int b()", "| dropped method b()"),
a -> assertClass(a, "class A {}", "class", "A"),
a -> dropClass(a, "/drop A", "class A", "| dropped class A"),
a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
@@ -466,10 +466,50 @@
a -> assertCommandCheckOutput(a, "/methods print println printf",
s -> checkLineToList(s, printingMethodList)),
a -> assertCommandOutputStartsWith(a, "/methods g",
- "| g ()void"),
+ "| void g()"),
a -> assertCommandOutputStartsWith(a, "/methods f",
- "| f ()int\n" +
- "| f (int)void")
+ "| int f()\n" +
+ "| void f(int)")
+ );
+ }
+
+ @Test
+ public void testMethodsWithErrors() {
+ test(new String[]{"--no-startup"},
+ a -> assertCommand(a, "double m(int x) { return x; }",
+ "| created method m(int)"),
+ a -> assertCommand(a, "GARBAGE junk() { return TRASH; }",
+ "| created method junk(), however, it cannot be referenced until class GARBAGE, and variable TRASH are declared"),
+ a -> assertCommand(a, "int w = 5;",
+ "w ==> 5"),
+ a -> assertCommand(a, "int tyer() { return w; }",
+ "| created method tyer()"),
+ a -> assertCommand(a, "String w = \"hi\";",
+ "w ==> \"hi\""),
+ a -> assertCommand(a, "/methods",
+ "| double m(int)\n" +
+ "| GARBAGE junk()\n" +
+ "| which cannot be referenced until class GARBAGE, and variable TRASH are declared\n" +
+ "| int tyer()\n" +
+ "| which cannot be invoked until this error is corrected: \n" +
+ "| incompatible types: java.lang.String cannot be converted to int\n" +
+ "| int tyer() { return w; }\n" +
+ "| ^\n")
+ );
+ }
+
+ @Test
+ public void testTypesWithErrors() {
+ test(new String[]{"--no-startup"},
+ a -> assertCommand(a, "class C extends NONE { int x; }",
+ "| created class C, however, it cannot be referenced until class NONE is declared"),
+ a -> assertCommand(a, "class D { void m() { System.out.println(nada); } }",
+ "| created class D, however, it cannot be instantiated or its methods invoked until variable nada is declared"),
+ a -> assertCommand(a, "/types",
+ "| class C\n" +
+ "| which cannot be referenced until class NONE is declared\n" +
+ "| class D\n" +
+ "| which cannot be instantiated or its methods invoked until variable nada is declared\n")
);
}
--- a/langtools/test/tools/javac/6627362/T6627362.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/6627362/T6627362.java Wed Jul 05 22:52:01 2017 +0200
@@ -68,9 +68,9 @@
// compile and disassemble E.java, using modified Object.java,
// check for reference to System.arraycopy
File x = new File(testSrc, "x");
- String[] jcArgs = { "-d", ".", "-Xmodule:java.base",
+ String[] jcArgs = { "-d", ".", "--patch-module", "java.base=" + x.getAbsolutePath(),
new File(x, "E.java").getPath(),
- new File(x, "Object.java").getPath()};
+ new File(new File(new File(x, "java"), "lang"), "Object.java").getPath()};
compile(jcArgs);
String[] jpArgs = { "-classpath", ".", "-c", "E" };
--- a/langtools/test/tools/javac/6627362/x/Object.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2007, 2008, 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.
- */
-
-package java.lang;
-
-/*
- * Object, without clone()
- */
-public class Object {
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6627362/x/java/lang/Object.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2007, 2008, 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.
+ */
+
+package java.lang;
+
+/*
+ * Object, without clone()
+ */
+public class Object {
+}
--- a/langtools/test/tools/javac/T4093617/T4093617.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/T4093617/T4093617.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,6 +26,6 @@
* @bug 4093617
* @summary Object has no superclass
* @author Peter von der Ah\u00e9
- * @compile/module=java.base/fail/ref=T4093617.out -XDrawDiagnostics Object.java
+ * @compile/module=java.base/fail/ref=T4093617.out -XDrawDiagnostics java/lang/Object.java
*/
--- a/langtools/test/tools/javac/T4093617/java.base/Object.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-/*
- * /nodynamiccopyright/
- * See ../T4093617.java
- */
-
-package java.lang;
-
-class Object {
- Object() { super(); }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T4093617/java.base/java/lang/Object.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,10 @@
+/*
+ * /nodynamiccopyright/
+ * See ../T4093617.java
+ */
+
+package java.lang;
+
+class Object {
+ Object() { super(); }
+}
--- a/langtools/test/tools/javac/T6234077.out Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/T6234077.out Wed Jul 05 22:52:01 2017 +0200
@@ -1,2 +1,2 @@
-T6234077.java:7:8: compiler.err.class.public.should.be.in.file: Foo
+T6234077.java:7:8: compiler.err.class.public.should.be.in.file: kindname.class, Foo
1 error
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java Wed Jul 05 22:52:01 2017 +0200
@@ -107,7 +107,7 @@
// by reflective lookup, to avoid explicit references that are not available
// when running javac on JDK 8.
ignore("com/sun/tools/javac/util/JDK9Wrappers$Configuration",
- "resolveRequiresAndUsesMethod", "configurationClass");
+ "resolveAndBindMethod", "configurationClass");
ignore("com/sun/tools/javac/util/JDK9Wrappers$Layer",
"bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass");
ignore("com/sun/tools/javac/util/JDK9Wrappers$Module",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForClassTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,8 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8174027
+ * @summary error message should adapt to the corresponding top level element
+ * @compile/fail/ref=MessageForClassTest.out -XDrawDiagnostics MessageForClassTest.java
+ */
+
+public class MessageForClassTest_ {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForClassTest.out Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,2 @@
+MessageForClassTest.java:8:8: compiler.err.class.public.should.be.in.file: kindname.class, MessageForClassTest_
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForEnumTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,8 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8174027
+ * @summary error message should adapt to the corresponding top level element
+ * @compile/fail/ref=MessageForEnumTest.out -XDrawDiagnostics MessageForEnumTest.java
+ */
+
+public enum MessageForEnumTest_ {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForEnumTest.out Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,2 @@
+MessageForEnumTest.java:8:8: compiler.err.class.public.should.be.in.file: kindname.enum, MessageForEnumTest_
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForInterfaceTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,8 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8174027
+ * @summary error message should adapt to the corresponding top level element
+ * @compile/fail/ref=MessageForInterfaceTest.out -XDrawDiagnostics MessageForInterfaceTest.java
+ */
+
+public interface MessageForInterfaceTest_ {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8173955/MessageForInterfaceTest.out Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,2 @@
+MessageForInterfaceTest.java:8:8: compiler.err.class.public.should.be.in.file: kindname.interface, MessageForInterfaceTest_
+1 error
--- a/langtools/test/tools/javac/diags/Example.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/diags/Example.java Wed Jul 05 22:52:01 2017 +0200
@@ -63,6 +63,7 @@
procFiles = new ArrayList<File>();
srcPathFiles = new ArrayList<File>();
moduleSourcePathFiles = new ArrayList<File>();
+ patchModulePathFiles = new ArrayList<File>();
modulePathFiles = new ArrayList<File>();
classPathFiles = new ArrayList<File>();
additionalFiles = new ArrayList<File>();
@@ -88,6 +89,9 @@
} else if (files == srcFiles && c.getName().equals("modulesourcepath")) {
moduleSourcePathDir = c;
findFiles(c, moduleSourcePathFiles);
+ } else if (files == srcFiles && c.getName().equals("patchmodule")) {
+ patchModulePathDir = c;
+ findFiles(c, patchModulePathFiles);
} else if (files == srcFiles && c.getName().equals("additional")) {
additionalFilesDir = c;
findFiles(c, additionalFiles);
@@ -272,6 +276,16 @@
files.addAll(nonEmptySrcFiles); // srcFiles containing declarations
}
+ if (patchModulePathDir != null) {
+ for (File mod : patchModulePathDir.listFiles()) {
+ opts.add("--patch-module");
+ opts.add(mod.getName() + "=" + mod.getPath());
+ }
+ files = new ArrayList<>();
+ files.addAll(patchModulePathFiles);
+ files.addAll(nonEmptySrcFiles); // srcFiles containing declarations
+ }
+
if (additionalFiles.size() > 0) {
List<String> sOpts = Arrays.asList("-d", classesDir.getPath());
new Jsr199Compiler(verbose).run(null, null, false, sOpts, additionalFiles);
@@ -343,9 +357,11 @@
List<File> procFiles;
File srcPathDir;
File moduleSourcePathDir;
+ File patchModulePathDir;
File additionalFilesDir;
List<File> srcPathFiles;
List<File> moduleSourcePathFiles;
+ List<File> patchModulePathFiles;
List<File> modulePathFiles;
List<File> classPathFiles;
List<File> additionalFiles;
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 22:52:01 2017 +0200
@@ -5,6 +5,7 @@
compiler.err.cant.read.file # (apt.JavaCompiler?)
compiler.err.cant.select.static.class.from.param.type
compiler.err.dc.unterminated.string # cannot happen
+compiler.err.file.patched.and.msp # needs the same dir on --module-source-path and --patch-module
compiler.err.illegal.char.for.encoding
compiler.err.invalid.repeatable.annotation # should not happen
compiler.err.invalid.repeatable.annotation.invalid.value # "can't" happen
--- a/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java Wed Jul 05 22:52:01 2017 +0200
@@ -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,7 +22,7 @@
*/
// key: compiler.err.illegal.argument.for.option
-// options: --module-path doesNotExist
+// options: --module-source-path=abc*def
// run: simple
class X {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/ModuleInfoWithPatchedModuleClassoutput.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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.module-info.with.patched.module.classoutput
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/additional/module-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+module mod {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleClassoutput/patchmodule/java.compiler/javax/lang/model/element/Extra.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package javax.lang.model.element;
+
+public interface Extra {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/ModuleInfoWithPatchedModule.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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.module-info.with.patched.module.sourcepath
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/javax/lang/model/element/Extra.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package javax.lang.model.element;
+
+public interface Extra {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ModuleInfoWithPatchedModuleSourcepath/patchmodule/java.compiler/module-info.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+module java.compiler {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/Extra.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-
-// key: compiler.err.module-info.with.xmodule.sourcepath
-// options: -Xmodule:java.compiler
-
-package javax.lang.model.element;
-
-public interface Extra {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithXModuleSourcePath/module-info.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-
-module java.compiler {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/ModuleInfoWithXmoduleClasspath.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-
-// key: compiler.err.module-info.with.xmodule.classpath
-// options: -Xmodule:java.compiler
-
-package javax.lang.model.element;
-
-public interface ModuleInfoWithXModuleClasspath {}
--- a/langtools/test/tools/javac/diags/examples/ModuleInfoWithXmoduleClasspath/additional/module-info.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-
-module mod {}
--- a/langtools/test/tools/javac/diags/examples/NoSuperclass.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, 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.
- */
-
-// key: compiler.err.no.superclass
-// options: -Xmodule:java.base
-
-package java.lang;
-
-class Object {
- public Object() {
- super();
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoSuperclass/NoSuperclass.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * 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
+ * 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.no.superclass
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoSuperclass/patchmodule/java.base/java/lang/Object.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * 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
+ * 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.
+ */
+
+package java.lang;
+
+class Object {
+ public Object() {
+ super();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/TooManyPatchedModules/TooManyPatchedModules.java Wed Jul 05 22:52:01 2017 +0200
@@ -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.
+ */
+
+// key: compiler.err.too.many.patched.modules
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/TooManyPatchedModules/patchmodule/java.compiler/p/C.java Wed Jul 05 22:52:01 2017 +0200
@@ -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.
+ */
+package p;
+
+class C {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/TooManyPatchedModules/patchmodule/jdk.compiler/p/C.java Wed Jul 05 22:52:01 2017 +0200
@@ -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.
+ */
+package p;
+
+class C {}
--- a/langtools/test/tools/javac/diags/examples/XModuleWithModulePath/XModuleWithModulePath.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-// key: compiler.err.xmodule.no.module.sourcepath
-// options: -Xmodule:java.compiler --module-source-path src
-
-class XModuleWithModulePath {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/doclint/NPEDuplicateClassNamesTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,97 @@
+/*
+ * 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 8174073
+ * @summary NPE caused by link reference to class
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @library /tools/lib
+ * @build toolbox.JavacTask toolbox.TestRunner toolbox.ToolBox
+ * @run main NPEDuplicateClassNamesTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class NPEDuplicateClassNamesTest extends TestRunner {
+
+ public static void main(String... args) throws Exception {
+ NPEDuplicateClassNamesTest t = new NPEDuplicateClassNamesTest();
+ t.runTests();
+ }
+
+ private final ToolBox tb = new ToolBox();
+ private final String class1 =
+ "package com;\n" +
+ "/***/\n" +
+ "public class MyClass {}";
+ private final String class2 =
+ "package com;\n" +
+ "/**\n" +
+ " * The following link tag causes a NullPointerException: {@link Requirements}. \n" +
+ " */\n" +
+ "public class MyClass {}";
+
+ NPEDuplicateClassNamesTest() throws IOException {
+ super(System.err);
+ }
+
+ @Test
+ public void testDuplicateClassNames() throws IOException {
+ Path src = Paths.get("src");
+ Path one = src.resolve("one");
+ Path two = src.resolve("two");
+ Path classes = Paths.get("classes");
+ Files.createDirectories(classes);
+ tb.writeJavaFiles(one, class1);
+ tb.writeJavaFiles(two, class2);
+
+ List<String> expected = Arrays.asList(
+ "MyClass.java:5:8: compiler.err.duplicate.class: com.MyClass",
+ "MyClass.java:3:65: compiler.err.proc.messager: reference not found",
+ "2 errors");
+ List<String> output = new JavacTask(tb)
+ .outdir(classes)
+ .options("-XDrawDiagnostics", "-Xdoclint:all", "-XDdev")
+ .files(tb.findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ if (!Objects.equals(output, expected)) {
+ throw new IllegalStateException("incorrect output; actual=" + output + "; expected=" + expected);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8174249/T8174249a.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ *
+ * 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 8174249
+ * @summary Regression in generic method unchecked calls
+ * @compile T8174249a.java
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+class T8174249a {
+ static <T> T foo(Class<T> c, Collection<? super T> baz) {
+return null;
+ }
+
+ static void bar(String c) { }
+
+ void test() {
+ // this works
+ bar(foo(String.class, new ArrayList<String>()));
+
+ // this works with a warning
+ String s = foo(String.class, new ArrayList());
+ bar(s);
+
+ // this causes an error on JDK9 but should work
+ bar(foo(String.class, new ArrayList()));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8174249/T8174249b.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ * 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 8174249
+ * @summary Regression in generic method unchecked calls
+ * @compile T8174249b.java
+ */
+
+import java.util.*;
+
+class T8174249b {
+
+ static void cs(Collection<String> cs) {}
+
+ void test1(Collection c) {
+ cs(rawCollection((Class)null));
+ Collection<String> cs1 = rawCollection((Class)null);
+ }
+
+ void test2(Collection c) {
+ cs(rawCollection2((Class)null));
+ Collection<String> cs2 = rawCollection2((Class)null);
+ }
+
+ void test3(Collection c) {
+ cs(rawCollection3((Class)null));
+ Collection<String> cs3 = rawCollection2((Class)null);
+ }
+
+ Collection<Integer> rawCollection(Class<String> cs) { return null; }
+
+ <Z> Collection<Integer> rawCollection2(Class<Z> cs) { return null; }
+
+ <Z> Collection<Z> rawCollection3(Class<Z> cs) { return null; }
+}
--- a/langtools/test/tools/javac/lib/combo/ComboTask.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/lib/combo/ComboTask.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 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,9 +25,9 @@
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.JavacTask;
-import com.sun.source.util.TaskEvent.Kind;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.List;
import combo.ComboParameter.Resolver;
@@ -36,11 +36,18 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
+
import java.io.IOException;
import java.io.Writer;
import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -184,6 +191,28 @@
}
/**
+ * Parse, analyze, perform code generation for the sources associated with this task and finally
+ * executes them
+ */
+ public <Z> Optional<Z> execute(Function<ExecutionTask, Z> executionFunc) throws IOException {
+ Result<Iterable<? extends JavaFileObject>> generationResult = generate();
+ Iterable<? extends JavaFileObject> jfoIterable = generationResult.get();
+ if (generationResult.hasErrors()) {
+ // we have nothing else to do
+ return Optional.empty();
+ }
+ java.util.List<URL> urlList = new ArrayList<>();
+ for (JavaFileObject jfo : jfoIterable) {
+ String urlStr = jfo.toUri().toURL().toString();
+ urlStr = urlStr.substring(0, urlStr.length() - jfo.getName().length());
+ urlList.add(new URL(urlStr));
+ }
+ return Optional.of(
+ executionFunc.apply(
+ new ExecutionTask(new URLClassLoader(urlList.toArray(new URL[urlList.size()])))));
+ }
+
+ /**
* Fork a new compilation task; if possible the compilation context from previous executions is
* retained (see comments in ReusableContext as to when it's safe to do so); otherwise a brand
* new context is created.
@@ -215,6 +244,80 @@
}
/**
+ * This class represents an execution task. It allows the execution of one or more classes previously
+ * added to a given class loader. This class uses reflection to execute any given static public method
+ * in any given class. It's not restricted to the execution of the {@code main} method
+ */
+ public class ExecutionTask {
+ private ClassLoader classLoader;
+ private String methodName = "main";
+ private Class<?>[] parameterTypes = new Class<?>[]{String[].class};
+ private Object[] args = new String[0];
+ private Consumer<Throwable> handler;
+ private Class<?> c;
+
+ private ExecutionTask(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ /**
+ * Set the name of the class to be loaded.
+ */
+ public ExecutionTask withClass(String className) {
+ Assert.check(className != null, "class name value is null, impossible to proceed");
+ try {
+ c = classLoader.loadClass(className);
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
+ return this;
+ }
+
+ /**
+ * Set the name of the method to be executed along with the parameter types to
+ * reflectively obtain the method.
+ */
+ public ExecutionTask withMethod(String methodName, Class<?>... parameterTypes) {
+ this.methodName = methodName;
+ this.parameterTypes = parameterTypes;
+ return this;
+ }
+
+ /**
+ * Set the arguments to be passed to the method.
+ */
+ public ExecutionTask withArguments(Object... args) {
+ this.args = args;
+ return this;
+ }
+
+ /**
+ * Set a handler to handle any exception thrown.
+ */
+ public ExecutionTask withHandler(Consumer<Throwable> handler) {
+ this.handler = handler;
+ return this;
+ }
+
+ /**
+ * Executes the given method in the given class. Returns true if the execution was
+ * successful, false otherwise.
+ */
+ public Object run() {
+ try {
+ java.lang.reflect.Method meth = c.getMethod(methodName, parameterTypes);
+ meth.invoke(null, (Object)args);
+ return true;
+ } catch (Throwable t) {
+ if (handler != null) {
+ handler.accept(t);
+ }
+ return false;
+ }
+ }
+ }
+
+ /**
* This class is used to help clients accessing the results of a given compilation task.
* Contains several helper methods to inspect diagnostics generated during the task execution.
*/
--- a/langtools/test/tools/javac/meth/BadPolySig.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * @test
- * @bug 8168774
- * @summary Polymorhic signature method check crashes javac
- * @compile -Xmodule:java.base BadPolySig.java
- */
-
-package java.lang.invoke;
-
-class MethodHandle {
- native Object m();
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/BadPolySig/BadPolySig.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * 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 8168774
+ * @summary Polymorhic signature method check crashes javac
+ * @modules jdk.compiler
+ * @compile/module=java.base java/lang/invoke/MethodHandle.java
+ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/BadPolySig/java.base/java/lang/invoke/MethodHandle.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package java.lang.invoke;
+
+class MethodHandle {
+ native Object m();
+}
--- a/langtools/test/tools/javac/modules/AddLimitMods.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java Wed Jul 05 22:52:01 2017 +0200
@@ -293,7 +293,7 @@
}
actual = new JavacTask(tb)
- .options("-Xmodule:java.base",
+ .options("--patch-module", "java.base=" + cpSrc.toString(),
"-XDrawDiagnostics",
"--add-modules", "ALL-MODULE-PATH")
.outdir(cpOut)
--- a/langtools/test/tools/javac/modules/AddReadsTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/AddReadsTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -217,7 +217,7 @@
new JavacTask(tb)
.options("--class-path", jar.toString(),
"--add-reads", "java.base=ALL-UNNAMED",
- "-Xmodule:java.base")
+ "--patch-module", "java.base=" + src)
.outdir(classes)
.files(src.resolve("impl").resolve("Impl.java"))
.run()
@@ -237,7 +237,7 @@
new JavacTask(tb)
.options("--add-modules", "java.desktop",
"--add-reads", "java.base=java.desktop",
- "-Xmodule:java.base")
+ "--patch-module", "java.base=" + src)
.outdir(classes)
.files(findJavaFiles(src))
.run()
@@ -304,7 +304,7 @@
new JavacTask(tb)
.options("--add-reads", "m1x=ALL-UNNAMED",
- "-Xmodule:m1x",
+ "--patch-module", "m1x=" + unnamedSrc,
"--module-path", classes.toString())
.outdir(unnamedClasses)
.files(findJavaFiles(unnamedSrc))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/CompileModulePatchTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,694 @@
+/*
+ * 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
+ * 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 8173777
+ * @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.processing
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
+ * @run main CompileModulePatchTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.Elements;
+
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
+import toolbox.Task;
+import toolbox.Task.Expect;
+
+public class CompileModulePatchTest extends ModuleTestBase {
+
+ public static void main(String... args) throws Exception {
+ new CompileModulePatchTest().runTests();
+ }
+
+ @Test
+ public void testCorrectModulePatch(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + src.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.isEmpty())
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testCorrectModulePatchMultiModule(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ Path m1 = src.resolve("m1");
+ tb.writeJavaFiles(m1, "package javax.lang.model.element; public interface Extra extends Element { }");
+ Path m2 = src.resolve("m2");
+ tb.writeJavaFiles(m2, "package com.sun.source.tree; public interface Extra extends Tree { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + m1.toString(),
+ "--patch-module", "jdk.compiler=" + m2.toString(),
+ "--module-source-path", "dummy")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.isEmpty())
+ throw new Exception("expected output not found: " + log);
+
+ checkFileExists(classes, "java.compiler/javax/lang/model/element/Extra.class");
+ checkFileExists(classes, "jdk.compiler/com/sun/source/tree/Extra.class");
+ }
+
+ @Test
+ public void testCorrectModulePatchMultiModule2(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ Path m1 = src.resolve("m1");
+ tb.writeJavaFiles(m1,
+ "package javax.lang.model.element; public interface Extra extends Element { }");
+ Path m2 = src.resolve("m2");
+ tb.writeJavaFiles(m2,
+ "package com.sun.source.tree; public interface Extra extends Tree { }");
+ Path msp = base.resolve("msp");
+ Path m3 = msp.resolve("m3x");
+ tb.writeJavaFiles(m3,
+ "module m3x { }",
+ "package m3; public class Test { }");
+ Path m4 = msp.resolve("m4x");
+ tb.writeJavaFiles(m4,
+ "module m4x { }",
+ "package m4; public class Test { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + m1.toString(),
+ "--patch-module", "jdk.compiler=" + m2.toString(),
+ "--module-source-path", msp.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src, msp))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.isEmpty())
+ throw new Exception("expected output not found: " + log);
+
+ checkFileExists(classes, "java.compiler/javax/lang/model/element/Extra.class");
+ checkFileExists(classes, "jdk.compiler/com/sun/source/tree/Extra.class");
+ checkFileExists(classes, "m3x/m3/Test.class");
+ checkFileExists(classes, "m4x/m4/Test.class");
+ }
+
+ @Test
+ public void testPatchModuleModuleSourcePathConflict(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ Path m1 = src.resolve("m1x");
+ tb.writeJavaFiles(m1,
+ "module m1x { }",
+ "package m1; public class Test { }");
+ Path m2 = src.resolve("m2x");
+ tb.writeJavaFiles(m2,
+ "module m2x { }",
+ "package m2; public class Test { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("--patch-module", "m1x=" + m2.toString(),
+ "--module-source-path", src.toString(),
+ "-XDrawDiagnostics")
+ .outdir(classes)
+ .files(findJavaFiles(src.resolve("m1x").resolve("m1"),
+ src.resolve("m2x").resolve("m2")))
+ .run(Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expectedOut = Arrays.asList(
+ "Test.java:1:1: compiler.err.file.patched.and.msp: m1x, m2x",
+ "1 error"
+ );
+
+ if (!expectedOut.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testSourcePath(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element, Other { }");
+ Path srcPath = base.resolve("src-path");
+ tb.writeJavaFiles(srcPath, "package javax.lang.model.element; interface Other { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + src.toString(),
+ "-sourcepath", srcPath.toString(),
+ "-XDrawDiagnostics")
+ .outdir(classes)
+ .files(src.resolve("javax/lang/model/element/Extra.java"))
+ .run(Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expectedOut = Arrays.asList(
+ "Extra.java:1:75: compiler.err.cant.resolve: kindname.class, Other, , ",
+ "1 error"
+ );
+
+ if (!expectedOut.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testClassPath(Path base) throws Exception {
+ Path cpSrc = base.resolve("cpSrc");
+ tb.writeJavaFiles(cpSrc, "package p; public interface Other { }");
+ Path cpClasses = base.resolve("cpClasses");
+ tb.createDirectories(cpClasses);
+
+ String cpLog = new JavacTask(tb)
+ .outdir(cpClasses)
+ .files(findJavaFiles(cpSrc))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!cpLog.isEmpty())
+ throw new Exception("expected output not found: " + cpLog);
+
+ Path src = base.resolve("src");
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element, p.Other { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + src.toString(),
+ "--class-path", cpClasses.toString(),
+ "-XDrawDiagnostics")
+ .outdir(classes)
+ .files(src.resolve("javax/lang/model/element/Extra.java"))
+ .run(Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expectedOut = Arrays.asList(
+ "Extra.java:1:76: compiler.err.doesnt.exist: p",
+ "1 error"
+ );
+
+ if (!expectedOut.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testNoModuleInfoOnSourcePath(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "module java.compiler {}",
+ "package javax.lang.model.element; public interface Extra { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ List<String> log;
+ List<String> expected;
+
+ log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--patch-module", "java.compiler=" + src.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.patched.module.sourcepath",
+ "1 error");
+
+ if (!expected.equals(log))
+ throw new Exception("expected output not found: " + log);
+
+ //multi-module mode:
+ log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--patch-module", "java.compiler=" + src.toString(),
+ "--module-source-path", "dummy")
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ expected = Arrays.asList("- compiler.err.locn.module-info.not.allowed.on.patch.path: module-info.java",
+ "1 error");
+
+ if (!expected.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testNoModuleInfoInClassOutput(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path srcMod = base.resolve("src-mod");
+ tb.writeJavaFiles(srcMod,
+ "module mod {}");
+ Path classes = base.resolve("classes").resolve("java.compiler");
+ tb.createDirectories(classes);
+
+ String logMod = new JavacTask(tb)
+ .options()
+ .outdir(classes)
+ .files(findJavaFiles(srcMod))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!logMod.isEmpty())
+ throw new Exception("unexpected output found: " + logMod);
+
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "package javax.lang.model.element; public interface Extra { }");
+ tb.createDirectories(classes);
+
+ List<String> log;
+ List<String> expected;
+
+ log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--patch-module", "java.compiler=" + src.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.patched.module.classoutput",
+ "1 error");
+
+ if (!expected.equals(log))
+ throw new Exception("expected output not found: " + log);
+
+ log = new JavacTask(tb)
+ .options("-XDrawDiagnostics",
+ "--patch-module", "java.compiler=" + src.toString(),
+ "--module-source-path", "dummy")
+ .outdir(classes.getParent())
+ .files(findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ expected = Arrays.asList("- compiler.err.locn.module-info.not.allowed.on.patch.path: module-info.class",
+ "1 error");
+
+ if (!expected.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testWithModulePath(Path base) throws Exception {
+ Path modSrc = base.resolve("modSrc");
+ Path modules = base.resolve("modules");
+ new ModuleBuilder(tb, "m1")
+ .classes("package pkg1; public interface E { }")
+ .build(modSrc, modules);
+
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "package p; interface A extends pkg1.E { }");
+
+ new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-path", modules.toString(),
+ "--patch-module", "m1=" + src.toString())
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ //checks module bounds still exist
+ new ModuleBuilder(tb, "m2")
+ .classes("package pkg2; public interface D { }")
+ .build(modSrc, modules);
+
+ Path src2 = base.resolve("src2");
+ tb.writeJavaFiles(src2, "package p; interface A extends pkg2.D { }");
+
+ List<String> log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "--module-path", modules.toString(),
+ "--patch-module", "m1=" + src2.toString())
+ .files(findJavaFiles(src2))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+
+ List<String> expected = Arrays.asList("A.java:1:32: compiler.err.package.not.visible: pkg2, (compiler.misc.not.def.access.does.not.read: m1, pkg2, m2)",
+ "1 error");
+
+ if (!expected.equals(log))
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @Test
+ public void testWithUpgradeModulePath(Path base) throws Exception {
+ Path modSrc = base.resolve("modSrc");
+ Path modules = base.resolve("modules");
+ new ModuleBuilder(tb, "m1")
+ .classes("package pkg1; public interface E { }")
+ .build(modSrc, modules);
+
+ Path upgrSrc = base.resolve("upgradeSrc");
+ Path upgrade = base.resolve("upgrade");
+ new ModuleBuilder(tb, "m1")
+ .classes("package pkg1; public interface D { }")
+ .build(upgrSrc, upgrade);
+
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "package p; interface A extends pkg1.D { }");
+
+ new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("--module-path", modules.toString(),
+ "--upgrade-module-path", upgrade.toString(),
+ "--patch-module", "m1=" + src.toString())
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+ }
+
+ @Test
+ public void testUnnamedIsolation(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path sourcePath = base.resolve("source-path");
+ tb.writeJavaFiles(sourcePath, "package src; public class Src {}");
+
+ Path classPathSrc = base.resolve("class-path-src");
+ tb.writeJavaFiles(classPathSrc, "package cp; public class CP { }");
+ Path classPath = base.resolve("classPath");
+ tb.createDirectories(classPath);
+
+ String cpLog = new JavacTask(tb)
+ .outdir(classPath)
+ .files(findJavaFiles(classPathSrc))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!cpLog.isEmpty())
+ throw new Exception("expected output not found: " + cpLog);
+
+ Path modulePathSrc = base.resolve("module-path-src");
+ tb.writeJavaFiles(modulePathSrc,
+ "module m {}",
+ "package m; public class M {}");
+ Path modulePath = base.resolve("modulePath");
+ tb.createDirectories(modulePath.resolve("m"));
+
+ String modLog = new JavacTask(tb)
+ .outdir(modulePath.resolve("m"))
+ .files(findJavaFiles(modulePathSrc))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!modLog.isEmpty())
+ throw new Exception("expected output not found: " + modLog);
+
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "package m; public class Extra { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ String log = new JavacTask(tb)
+ .options("--patch-module", "m=" + sourcePath.toString(),
+ "--class-path", classPath.toString(),
+ "--source-path", sourcePath.toString(),
+ "--module-path", modulePath.toString(),
+ "--processor-path", System.getProperty("test.classes"),
+ "-XDaccessInternalAPI=true",
+ "-processor", CheckModuleContentProcessing.class.getName())
+ .outdir(classes)
+ .files(findJavaFiles(sourcePath))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.isEmpty())
+ throw new Exception("expected output not found: " + log);
+ }
+
+ @SupportedAnnotationTypes("*")
+ public static final class CheckModuleContentProcessing extends AbstractProcessor {
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ Symtab syms = Symtab.instance(((JavacProcessingEnvironment) processingEnv).getContext());
+ Elements elements = processingEnv.getElementUtils();
+ ModuleElement unnamedModule = syms.unnamedModule;
+ ModuleElement mModule = elements.getModuleElement("m");
+
+ assertNonNull("mModule found", mModule);
+ assertNonNull("src.Src from m", elements.getTypeElement(mModule, "src.Src"));
+ assertNull("cp.CP not from m", elements.getTypeElement(mModule, "cp.CP"));
+ assertNull("src.Src not from unnamed", elements.getTypeElement(unnamedModule, "src.Src"));
+ assertNonNull("cp.CP from unnamed", elements.getTypeElement(unnamedModule, "cp.CP"));
+
+ return false;
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ private static void assertNonNull(String msg, Object val) {
+ if (val == null) {
+ throw new AssertionError(msg);
+ }
+ }
+
+ private static void assertNull(String msg, Object val) {
+ if (val != null) {
+ throw new AssertionError(msg);
+ }
+ }
+ }
+
+ @Test
+ public void testSingleModeIncremental(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "package javax.lang.model.element; public interface Extra extends Element { }",
+ "package javax.lang.model.element; public interface Extra2 extends Extra { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ Thread.sleep(2000); //ensure newer timestamps on classfiles:
+
+ new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + src.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ List<String> log = new JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + src.toString(),
+ "-verbose")
+ .outdir(classes)
+ .files(findJavaFiles(src.resolve("javax/lang/model/element/Extra2.java"
+ .replace("/", src.getFileSystem().getSeparator()))))
+ .run()
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT)
+ .stream()
+ .filter(l -> l.contains("parsing"))
+ .collect(Collectors.toList());
+
+ boolean parsesExtra2 = log.stream()
+ .anyMatch(l -> l.contains("Extra2.java"));
+ boolean parsesExtra = log.stream()
+ .anyMatch(l -> l.contains("Extra.java"));
+
+ if (!parsesExtra2 || parsesExtra) {
+ throw new AssertionError("Unexpected output: " + log);
+ }
+ }
+
+ @Test
+ public void testComplexMSPAndPatch(Path base) throws Exception {
+ //note: avoiding use of java.base, as that gets special handling on some places:
+ Path src1 = base.resolve("src1");
+ Path src1ma = src1.resolve("ma");
+ tb.writeJavaFiles(src1ma,
+ "module ma { exports ma; }",
+ "package ma; public class C1 { public static void method() { } }",
+ "package ma.impl; public class C2 { }");
+ Path src1mb = src1.resolve("mb");
+ tb.writeJavaFiles(src1mb,
+ "module mb { requires ma; }",
+ "package mb.impl; public class C2 { public static void method() { } }");
+ Path src1mc = src1.resolve("mc");
+ tb.writeJavaFiles(src1mc,
+ "module mc { }");
+ Path classes1 = base.resolve("classes1");
+ tb.createDirectories(classes1);
+ tb.cleanDirectory(classes1);
+
+ new JavacTask(tb)
+ .options("--module-source-path", src1.toString())
+ .files(findJavaFiles(src1))
+ .outdir(classes1)
+ .run()
+ .writeAll();
+
+ //patching:
+ Path src2 = base.resolve("src2");
+ Path src2ma = src2.resolve("ma");
+ tb.writeJavaFiles(src2ma,
+ "package ma.impl; public class C2 { public static void extra() { ma.C1.method(); } }",
+ "package ma.impl; public class C3 { public void test() { C2.extra(); } }");
+ Path src2mb = src2.resolve("mb");
+ tb.writeJavaFiles(src2mb,
+ "package mb.impl; public class C3 { public void test() { C2.method(); ma.C1.method(); ma.impl.C2.extra(); } }");
+ Path src2mc = src2.resolve("mc");
+ tb.writeJavaFiles(src2mc,
+ "package mc.impl; public class C2 { public static void test() { } }",
+ //will require --add-reads ma:
+ "package mc.impl; public class C3 { public static void test() { ma.impl.C2.extra(); } }");
+ Path src2mt = src2.resolve("mt");
+ tb.writeJavaFiles(src2mt,
+ "module mt { requires ma; requires mb; }",
+ "package mt.impl; public class C2 { public static void test() { mb.impl.C2.method(); ma.impl.C2.extra(); } }",
+ "package mt.impl; public class C3 { public static void test() { C2.test(); mc.impl.C2.test(); } }");
+ Path classes2 = base.resolve("classes2");
+ tb.createDirectories(classes2);
+ tb.cleanDirectory(classes2);
+
+ Thread.sleep(2000); //ensure newer timestamps on classfiles:
+
+ new JavacTask(tb)
+ .options("--module-path", classes1.toString(),
+ "--patch-module", "ma=" + src2ma.toString(),
+ "--patch-module", "mb=" + src2mb.toString(),
+ "--add-exports", "ma/ma.impl=mb",
+ "--patch-module", "mc=" + src2mc.toString(),
+ "--add-reads", "mc=ma",
+ "--add-exports", "ma/ma.impl=mc",
+ "--add-exports", "ma/ma.impl=mt",
+ "--add-exports", "mb/mb.impl=mt",
+ "--add-exports", "mc/mc.impl=mt",
+ "--add-reads", "mt=mc",
+ "--module-source-path", src2.toString())
+ .outdir(classes2)
+ .files(findJavaFiles(src2))
+ .run()
+ .writeAll();
+
+ //incremental compilation (C2 mustn't be compiled, C3 must):
+ tb.writeJavaFiles(src2ma,
+ "package ma.impl; public class C3 { public void test() { ma.C1.method(); C2.extra(); } }");
+ tb.writeJavaFiles(src2mt,
+ "package mt.impl; public class C3 { public static void test() { mc.impl.C2.test(); C2.test(); } }");
+
+ List<String> log = new JavacTask(tb)
+ .options("--module-path", classes1.toString(),
+ "--patch-module", "ma=" + src2ma.toString(),
+ "--patch-module", "mb=" + src2mb.toString(),
+ "--add-exports", "ma/ma.impl=mb",
+ "--patch-module", "mc=" + src2mc.toString(),
+ "--add-reads", "mc=ma",
+ "--add-exports", "ma/ma.impl=mc",
+ "--add-exports", "ma/ma.impl=mt",
+ "--add-exports", "mb/mb.impl=mt",
+ "--add-exports", "mc/mc.impl=mt",
+ "--add-reads", "mt=mc",
+ "--module-source-path", src2.toString(),
+ "--add-modules", "mc",
+ "-verbose")
+ .outdir(classes2)
+ .files(src2ma.resolve("ma").resolve("impl").resolve("C3.java"),
+ src2mt.resolve("mt").resolve("impl").resolve("C3.java"))
+ .run()
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT)
+ .stream()
+ .filter(l -> l.contains("parsing"))
+ .collect(Collectors.toList());
+
+ boolean parsesC3 = log.stream()
+ .anyMatch(l -> l.contains("C3.java"));
+ boolean parsesC2 = log.stream()
+ .anyMatch(l -> l.contains("C2.java"));
+
+ if (!parsesC3 || parsesC2) {
+ throw new AssertionError("Unexpected output: " + log);
+ }
+ }
+
+ private void checkFileExists(Path dir, String path) {
+ Path toCheck = dir.resolve(path.replace("/", dir.getFileSystem().getSeparator()));
+
+ if (!Files.exists(toCheck)) {
+ throw new AssertionError(toCheck.toString() + " does not exist!");
+ }
+ }
+}
--- a/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -177,7 +177,7 @@
Files.createDirectories(patch);
new JavacTask(tb)
- .options("-Xmodule:java.base")
+ .options("--patch-module", "java.base=" + patchSrc.toString())
.outdir(patch)
.sourcepath(patchSrc)
.files(findJavaFiles(patchSrc))
--- a/langtools/test/tools/javac/modules/ModuleInfoTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/ModuleInfoTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -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
@@ -94,7 +94,7 @@
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
- if (!log.contains("module-info.java:1:8: compiler.err.class.public.should.be.in.file: C"))
+ if (!log.contains("module-info.java:1:8: compiler.err.class.public.should.be.in.file: kindname.class, C"))
throw new Exception("expected output not found");
}
--- a/langtools/test/tools/javac/modules/ModulePathTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/ModulePathTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -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,6 +23,7 @@
/*
* @test
+ * @bug 8142968 8174104
* @summary tests for --module-path
* @library /tools/lib
* @modules
@@ -57,7 +58,7 @@
}
@Test
- public void testNotExistsOnPath(Path base) throws Exception {
+ public void testNotExistsOnPath_noWarn(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
@@ -65,11 +66,29 @@
.options("-XDrawDiagnostics",
"--module-path", "doesNotExist")
.files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
+ .run(Task.Expect.SUCCESS)
.writeAll()
.getOutput(Task.OutputKind.DIRECT);
- if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist"))
+ if (!log.isEmpty())
+ throw new Exception("unexpected output");
+ }
+
+ @Test
+ public void testNotExistsOnPath_warn(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src, "class C { }");
+
+ String log = new JavacTask(tb, Task.Mode.CMDLINE)
+ .options("-XDrawDiagnostics",
+ "-Xlint:path",
+ "--module-path", "doesNotExist")
+ .files(findJavaFiles(src))
+ .run(Task.Expect.SUCCESS)
+ .writeAll()
+ .getOutput(Task.OutputKind.DIRECT);
+
+ if (!log.contains("- compiler.warn.path.element.not.found: doesNotExist"))
throw new Exception("expected output not found");
}
--- a/langtools/test/tools/javac/modules/PatchModulesTest.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/modules/PatchModulesTest.java Wed Jul 05 22:52:01 2017 +0200
@@ -28,7 +28,7 @@
* @library /tools/lib
* @modules
* jdk.compiler/com.sun.tools.javac.api
- * jdk.compiler/com.sun.tools.javac.file:+open
+ * jdk.compiler/com.sun.tools.javac.file
* jdk.compiler/com.sun.tools.javac.main
* @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
* @run main PatchModulesTest
@@ -38,21 +38,26 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.lang.reflect.Field;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.AbstractMap.SimpleEntry;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+import javax.tools.JavaFileManager.Location;
import javax.tools.JavaFileObject;
import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.file.Locations;
import static java.util.Arrays.asList;
@@ -115,21 +120,29 @@
void test(List<String> patches, boolean expectOK, String expect) throws Exception {
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
StringWriter sw = new StringWriter();
- try (PrintWriter pw = new PrintWriter(sw)) {
- JavacFileManager fm = tool.getStandardFileManager(null, null, null);
+ try (PrintWriter pw = new PrintWriter(sw);
+ JavacFileManager fm = tool.getStandardFileManager(null, null, null)) {
List<String> opts = patches.stream()
.map(p -> "--patch-module=" + p.replace(":", PS))
.collect(Collectors.toList());
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects("C.java");
JavacTask task = tool.getTask(pw, fm, null, opts, null, files);
- Field locationsField = BaseFileManager.class.getDeclaredField("locations");
- locationsField.setAccessible(true);
- Object locations = locationsField.get(fm);
+ Map<String, List<Location>> mod2Location =
+ StreamSupport.stream(fm.listLocationsForModules(StandardLocation.PATCH_MODULE_PATH)
+ .spliterator(),
+ false)
+ .flatMap(sl -> sl.stream())
+ .collect(Collectors.groupingBy(l -> fm.inferModuleName(l)));
- Field patchMapField = Locations.class.getDeclaredField("patchMap");
- patchMapField.setAccessible(true);
- Map<?,?> patchMap = (Map<?,?>) patchMapField.get(locations);
+ Map<String, List<String>> patchMap = mod2Location.entrySet()
+ .stream()
+ .map(e -> new SimpleEntry<>(e.getKey(), e.getValue().get(0)))
+ .map(e -> new SimpleEntry<>(e.getKey(), locationPaths(fm, e.getValue())))
+ .collect(Collectors.toMap(Entry :: getKey,
+ Entry :: getValue,
+ (v1, v2) -> {throw new IllegalStateException();},
+ TreeMap::new));
String found = patchMap.toString();
if (!found.equals(expect)) {
@@ -150,5 +163,34 @@
}
}
}
+
+ static List<String> locationPaths(StandardJavaFileManager fm, Location loc) {
+ return StreamSupport.stream(fm.getLocationAsPaths(loc).spliterator(), false)
+ .map(p -> p.toString())
+ .collect(Collectors.toList());
+ }
+
+ @Test
+ public void testPatchWithSource(Path base) throws Exception {
+ Path patch = base.resolve("patch");
+ tb.writeJavaFiles(patch, "package javax.lang.model.element; public interface Extra { }");
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ "module m { requires java.compiler; }",
+ "package test; public interface Test extends javax.lang.model.element.Extra { }");
+ Path classes = base.resolve("classes");
+ tb.createDirectories(classes);
+
+ new toolbox.JavacTask(tb)
+ .options("--patch-module", "java.compiler=" + patch.toString())
+ .outdir(classes)
+ .files(findJavaFiles(src))
+ .run()
+ .writeAll();
+
+ if (Files.exists(classes.resolve("javax"))) {
+ throw new AssertionError();
+ }
+ }
}
--- a/langtools/test/tools/javac/modules/XModuleTest.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,422 +0,0 @@
-/*
- * 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
- * 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
- * @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.processing
- * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
- * @run main XModuleTest
- */
-
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import toolbox.JavacTask;
-import toolbox.ModuleBuilder;
-import toolbox.Task;
-import toolbox.Task.Expect;
-
-public class XModuleTest extends ModuleTestBase {
-
- public static void main(String... args) throws Exception {
- new XModuleTest().runTests();
- }
-
- @Test
- public void testCorrectXModule(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- String log = new JavacTask(tb)
- .options("-Xmodule:java.compiler")
- .outdir(classes)
- .files(findJavaFiles(src))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!log.isEmpty())
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testSourcePath(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element, Other { }", "package javax.lang.model.element; interface Other { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- String log = new JavacTask(tb)
- .options("-Xmodule:java.compiler", "-sourcepath", src.toString())
- .outdir(classes)
- .files(src.resolve("javax/lang/model/element/Extra.java"))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!log.isEmpty())
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testClassPath(Path base) throws Exception {
- Path cpSrc = base.resolve("cpSrc");
- tb.writeJavaFiles(cpSrc, "package p; public interface Other { }");
- Path cpClasses = base.resolve("cpClasses");
- tb.createDirectories(cpClasses);
-
- String cpLog = new JavacTask(tb)
- .outdir(cpClasses)
- .files(findJavaFiles(cpSrc))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!cpLog.isEmpty())
- throw new Exception("expected output not found: " + cpLog);
-
- Path src = base.resolve("src");
- //note: avoiding use of java.base, as that gets special handling on some places:
- tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element, p.Other { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- List<String> log = new JavacTask(tb)
- .options("-Xmodule:java.compiler",
- "--class-path", cpClasses.toString(),
- "-XDrawDiagnostics")
- .outdir(classes)
- .files(src.resolve("javax/lang/model/element/Extra.java"))
- .run(Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expectedOut = Arrays.asList(
- "Extra.java:1:76: compiler.err.doesnt.exist: p",
- "1 error"
- );
-
- if (!expectedOut.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testNoModuleInfoOnSourcePath(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path src = base.resolve("src");
- tb.writeJavaFiles(src,
- "module java.compiler {}",
- "package javax.lang.model.element; public interface Extra { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- List<String> log = new JavacTask(tb)
- .options("-XDrawDiagnostics", "-Xmodule:java.compiler")
- .outdir(classes)
- .files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.xmodule.sourcepath",
- "1 error");
-
- if (!expected.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testNoModuleInfoInClassOutput(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path srcMod = base.resolve("src-mod");
- tb.writeJavaFiles(srcMod,
- "module mod {}");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- String logMod = new JavacTask(tb)
- .options()
- .outdir(classes)
- .files(findJavaFiles(srcMod))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!logMod.isEmpty())
- throw new Exception("unexpected output found: " + logMod);
-
- Path src = base.resolve("src");
- tb.writeJavaFiles(src,
- "package javax.lang.model.element; public interface Extra { }");
- tb.createDirectories(classes);
-
- List<String> log = new JavacTask(tb)
- .options("-XDrawDiagnostics", "-Xmodule:java.compiler")
- .outdir(classes)
- .files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList("Extra.java:1:1: compiler.err.module-info.with.xmodule.classpath",
- "1 error");
-
- if (!expected.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testModuleSourcePathXModule(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- List<String> log = new JavacTask(tb)
- .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "--module-source-path", src.toString())
- .outdir(classes)
- .files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList("- compiler.err.xmodule.no.module.sourcepath");
-
- if (!expected.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testXModuleTooMany(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- List<String> log = new JavacTask(tb, Task.Mode.CMDLINE)
- .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "-Xmodule:java.compiler")
- .outdir(classes)
- .files(findJavaFiles(src))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList("javac: option -Xmodule: can only be specified once",
- "Usage: javac <options> <source files>",
- "use --help for a list of possible options");
-
- if (!expected.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testWithModulePath(Path base) throws Exception {
- Path modSrc = base.resolve("modSrc");
- Path modules = base.resolve("modules");
- new ModuleBuilder(tb, "m1")
- .classes("package pkg1; public interface E { }")
- .build(modSrc, modules);
-
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package p; interface A extends pkg1.E { }");
-
- new JavacTask(tb, Task.Mode.CMDLINE)
- .options("--module-path", modules.toString(),
- "-Xmodule:m1")
- .files(findJavaFiles(src))
- .run()
- .writeAll();
-
- //checks module bounds still exist
- new ModuleBuilder(tb, "m2")
- .classes("package pkg2; public interface D { }")
- .build(modSrc, modules);
-
- Path src2 = base.resolve("src2");
- tb.writeJavaFiles(src2, "package p; interface A extends pkg2.D { }");
-
- List<String> log = new JavacTask(tb, Task.Mode.CMDLINE)
- .options("-XDrawDiagnostics",
- "--module-path", modules.toString(),
- "-Xmodule:m1")
- .files(findJavaFiles(src2))
- .run(Task.Expect.FAIL)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
-
- List<String> expected = Arrays.asList("A.java:1:32: compiler.err.package.not.visible: pkg2, (compiler.misc.not.def.access.does.not.read: m1, pkg2, m2)",
- "1 error");
-
- if (!expected.equals(log))
- throw new Exception("expected output not found: " + log);
- }
-
- @Test
- public void testWithUpgradeModulePath(Path base) throws Exception {
- Path modSrc = base.resolve("modSrc");
- Path modules = base.resolve("modules");
- new ModuleBuilder(tb, "m1")
- .classes("package pkg1; public interface E { }")
- .build(modSrc, modules);
-
- Path upgrSrc = base.resolve("upgradeSrc");
- Path upgrade = base.resolve("upgrade");
- new ModuleBuilder(tb, "m1")
- .classes("package pkg1; public interface D { }")
- .build(upgrSrc, upgrade);
-
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package p; interface A extends pkg1.D { }");
-
- new JavacTask(tb, Task.Mode.CMDLINE)
- .options("--module-path", modules.toString(),
- "--upgrade-module-path", upgrade.toString(),
- "-Xmodule:m1")
- .files(findJavaFiles(src))
- .run()
- .writeAll();
- }
-
- @Test
- public void testUnnamedIsolation(Path base) throws Exception {
- //note: avoiding use of java.base, as that gets special handling on some places:
- Path sourcePath = base.resolve("source-path");
- tb.writeJavaFiles(sourcePath, "package src; public class Src {}");
-
- Path classPathSrc = base.resolve("class-path-src");
- tb.writeJavaFiles(classPathSrc, "package cp; public class CP { }");
- Path classPath = base.resolve("classPath");
- tb.createDirectories(classPath);
-
- String cpLog = new JavacTask(tb)
- .outdir(classPath)
- .files(findJavaFiles(classPathSrc))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!cpLog.isEmpty())
- throw new Exception("expected output not found: " + cpLog);
-
- Path modulePathSrc = base.resolve("module-path-src");
- tb.writeJavaFiles(modulePathSrc,
- "module m {}",
- "package m; public class M {}");
- Path modulePath = base.resolve("modulePath");
- tb.createDirectories(modulePath.resolve("m"));
-
- String modLog = new JavacTask(tb)
- .outdir(modulePath.resolve("m"))
- .files(findJavaFiles(modulePathSrc))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!modLog.isEmpty())
- throw new Exception("expected output not found: " + modLog);
-
- Path src = base.resolve("src");
- tb.writeJavaFiles(src, "package m; public class Extra { }");
- Path classes = base.resolve("classes");
- tb.createDirectories(classes);
-
- String log = new JavacTask(tb)
- .options("-Xmodule:m",
- "--class-path", classPath.toString(),
- "--source-path", sourcePath.toString(),
- "--module-path", modulePath.toString(),
- "--processor-path", System.getProperty("test.classes"),
- "-XDaccessInternalAPI=true",
- "-processor", CheckModuleContentProcessing.class.getName())
- .outdir(classes)
- .files(findJavaFiles(sourcePath))
- .run()
- .writeAll()
- .getOutput(Task.OutputKind.DIRECT);
-
- if (!log.isEmpty())
- throw new Exception("expected output not found: " + log);
- }
-
- @SupportedAnnotationTypes("*")
- public static final class CheckModuleContentProcessing extends AbstractProcessor {
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- Symtab syms = Symtab.instance(((JavacProcessingEnvironment) processingEnv).getContext());
- Elements elements = processingEnv.getElementUtils();
- ModuleElement unnamedModule = syms.unnamedModule;
- ModuleElement mModule = elements.getModuleElement("m");
-
- assertNonNull("mModule found", mModule);
- assertNonNull("src.Src from m", elements.getTypeElement(mModule, "src.Src"));
- assertNull("cp.CP not from m", elements.getTypeElement(mModule, "cp.CP"));
- assertNull("src.Src not from unnamed", elements.getTypeElement(unnamedModule, "src.Src"));
- assertNonNull("cp.CP from unnamed", elements.getTypeElement(unnamedModule, "cp.CP"));
-
- return false;
- }
-
- @Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- private static void assertNonNull(String msg, Object val) {
- if (val == null) {
- throw new AssertionError(msg);
- }
- }
-
- private static void assertNull(String msg, Object val) {
- if (val != null) {
- throw new AssertionError(msg);
- }
- }
- }
-
-}
--- a/langtools/test/tools/javac/redefineObject/Object1-test.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/redefineObject/Object1-test.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,6 +27,6 @@
* @summary java.lang.Object can't be redefined without crashing javac
* @author gafter
*
- * @compile/module=java.base/fail/ref=Object1.out -XDrawDiagnostics Object1.java
+ * @compile/module=java.base/fail/ref=Object1.out -XDrawDiagnostics java/lang/Object1.java
*/
--- a/langtools/test/tools/javac/redefineObject/Object2-test.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/redefineObject/Object2-test.java Wed Jul 05 22:52:01 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,5 +27,5 @@
* @summary java.lang.Object can't be redefined without crashing javac
* @author gafter
*
- * @compile/module=java.base/fail/ref=Object2.out -XDrawDiagnostics Object2.java
+ * @compile/module=java.base/fail/ref=Object2.out -XDrawDiagnostics java/lang/Object2.java
*/
--- a/langtools/test/tools/javac/redefineObject/java.base/Object1.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*
- * /nodynamiccopyright/
- * See ../Object1-test.java
- */
-
-package java.lang;
-class Object extends Throwable {
- public final native Class getClass();
- public native int hashCode();
- public native boolean equals(Object obj);
- protected native Object clone() throws CloneNotSupportedException;
- public native String toString();
- public final native void notify();
- public final native void notifyAll();
- public final native void wait(long timeout) throws InterruptedException;
- public native final void wait(long timeout, int nanos) throws InterruptedException;
- public native final void wait() throws InterruptedException;
- protected void finalize() throws Throwable { }
-}
--- a/langtools/test/tools/javac/redefineObject/java.base/Object2.java Wed Jul 05 22:51:47 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*
- * /nodynamiccopyright/
- * See ../Object2-test.java
- */
-
-package java.lang;
-class Object implements Cloneable {
- public final native Class getClass();
- public native int hashCode();
- public native boolean equals(Object obj);
- public native Object clone() throws CloneNotSupportedException;
- public native String toString();
- public final native void notify();
- public final native void notifyAll();
- public final native void wait(long timeout) throws InterruptedException;
- public native final void wait(long timeout, int nanos) throws InterruptedException;
- public native final void wait() throws InterruptedException;
- protected void finalize() throws Throwable { }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/redefineObject/java.base/java/lang/Object1.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * /nodynamiccopyright/
+ * See ../Object1-test.java
+ */
+
+package java.lang;
+class Object extends Throwable {
+ public final native Class getClass();
+ public native int hashCode();
+ public native boolean equals(Object obj);
+ protected native Object clone() throws CloneNotSupportedException;
+ public native String toString();
+ public final native void notify();
+ public final native void notifyAll();
+ public final native void wait(long timeout) throws InterruptedException;
+ public native final void wait(long timeout, int nanos) throws InterruptedException;
+ public native final void wait() throws InterruptedException;
+ protected void finalize() throws Throwable { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/redefineObject/java.base/java/lang/Object2.java Wed Jul 05 22:52:01 2017 +0200
@@ -0,0 +1,19 @@
+/*
+ * /nodynamiccopyright/
+ * See ../Object2-test.java
+ */
+
+package java.lang;
+class Object implements Cloneable {
+ public final native Class getClass();
+ public native int hashCode();
+ public native boolean equals(Object obj);
+ public native Object clone() throws CloneNotSupportedException;
+ public native String toString();
+ public final native void notify();
+ public final native void notifyAll();
+ public final native void wait(long timeout) throws InterruptedException;
+ public native final void wait(long timeout, int nanos) throws InterruptedException;
+ public native final void wait() throws InterruptedException;
+ protected void finalize() throws Throwable { }
+}
--- a/langtools/test/tools/javac/synthesize/Main.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/javac/synthesize/Main.java Wed Jul 05 22:52:01 2017 +0200
@@ -92,12 +92,17 @@
File empty = new File("empty");
empty.mkdirs();
+ // files to compile are in a separate directory from test to avoid
+ // confusing jtreg
+ File src = new File(testSrc, "src");
+
List<String> args = new ArrayList<String>();
args.add("-classpath");
args.add("empty");
if (stdBootClassPath) {
- args.add("-Xmodule:java.base");
+ args.add("--patch-module");
+ args.add("java.base=" + testSrc.getAbsolutePath());
} else {
args.add("--system");
args.add("none");
@@ -108,9 +113,6 @@
args.add("-d");
args.add(".");
- // files to compile are in a separate directory from test to avoid
- // confusing jtreg
- File src = new File(testSrc, "src");
for (String f: files)
args.add(new File(src, f).getPath());
--- a/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Wed Jul 05 22:51:47 2017 +0200
+++ b/langtools/test/tools/jdeps/jdkinternals/RemovedJDKInternals.java Wed Jul 05 22:52:01 2017 +0200
@@ -63,7 +63,7 @@
Path sunMiscSrc = Paths.get(TEST_SRC, "patches", JDK_UNSUPPORTED);
Path patchDir = PATCHES_DIR.resolve(JDK_UNSUPPORTED);
assertTrue(CompilerUtils.compile(sunMiscSrc, patchDir,
- "-Xmodule:" + JDK_UNSUPPORTED));
+ "--patch-module", JDK_UNSUPPORTED + "=" + sunMiscSrc.toString()));
// compile com.sun.image.codec.jpeg types
Path codecSrc = Paths.get(TEST_SRC, "patches", "java.desktop");