--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java 2017-12-13 09:54:12.959055594 -0800 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java 2017-12-13 09:54:12.631055579 -0800 @@ -53,6 +53,7 @@ import com.sun.tools.javac.code.Lint; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.ModuleSymbol; +import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.comp.Modules; import com.sun.tools.javac.model.JavacElements; @@ -715,12 +716,11 @@ // TODO: Check if type already exists on source or class path? // If so, use warning message key proc.type.already.exists checkName(typename, allowUnnamedPackageInfo); - ClassSymbol existing; + boolean alreadySeen = aggregateGeneratedSourceNames.contains(Pair.of(mod, typename)) || aggregateGeneratedClassNames.contains(Pair.of(mod, typename)) || initialClassNames.contains(typename) || - ((existing = elementUtils.getTypeElement(typename)) != null && - initialInputs.contains(existing.sourcefile)); + containedInInitialInputs(typename); if (alreadySeen) { if (lint) log.warning(Warnings.ProcTypeRecreate(typename)); @@ -731,6 +731,25 @@ } } + private boolean containedInInitialInputs(String typename) { + // Name could be a type name or the name of a package-info file + JavaFileObject sourceFile = null; + + ClassSymbol existingClass = elementUtils.getTypeElement(typename); + if (existingClass != null) { + sourceFile = existingClass.sourcefile; + } else if (typename.endsWith(".package-info")) { + String targetName = typename.substring(0, typename.length() - ".package-info".length()); + PackageSymbol existingPackage = + elementUtils.getPackageElement(targetName); +// System.err.println("\t\tfound " + existingPackage + +// ", sourceFile "+ (existingPackage!= null?existingPackage.sourcefile:null)); + if (existingPackage != null) + sourceFile = existingPackage.sourcefile; + } + return (sourceFile == null) ? false : initialInputs.contains(sourceFile); + } + /** * Check to see if the file has already been opened; if so, throw * an exception, otherwise add it to the set of files.