### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java,v retrieving revision 1.57 diff -u -r1.57 ClasspathDirectory.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 19 Aug 2010 06:26:31 -0000 1.57 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 30 Aug 2010 15:20:34 -0000 @@ -86,7 +86,7 @@ return true; return false; } -public List fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) { +public List fetchLinkedJars(FileSystem.ClasspathProblemReporter problemReporter) { return null; } public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v retrieving revision 1.52 diff -u -r1.52 ClasspathJar.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 21 Jul 2009 19:54:06 -0000 1.52 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 30 Aug 2010 15:20:34 -0000 @@ -43,7 +43,7 @@ this.closeZipFileAtEnd = closeZipFileAtEnd; } -public List fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) { +public List fetchLinkedJars(FileSystem.ClasspathProblemReporter problemReporter) { // expected to be called once only - if multiple calls desired, consider // using a cache InputStream inputStream = null; Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v retrieving revision 1.55 diff -u -r1.55 FileSystem.java --- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 21 Feb 2010 03:35:52 -0000 1.55 +++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 30 Aug 2010 15:20:34 -0000 @@ -13,9 +13,11 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.eclipse.jdt.core.compiler.CharOperation; @@ -40,7 +42,7 @@ * @return a list of the jar file names defined in the Class-Path * section of the jar file manifest if any */ - List fetchLinkedJars(ClasspathSectionProblemReporter problemReporter); + List fetchLinkedJars(ClasspathProblemReporter problemReporter); /** * This method resets the environment. The resulting state is equivalent to * a new name environment without creating a new object. @@ -68,9 +70,10 @@ */ void initialize() throws IOException; } - public interface ClasspathSectionProblemReporter { + public interface ClasspathProblemReporter { void invalidClasspathSection(String jarFilePath); void multipleClasspathSections(String jarFilePath); + void nestedClasspath(String classpathOne, String classpathTwo); } /** @@ -103,14 +106,20 @@ Classpath[] classpaths; Set knownFileNames; + private ClasspathProblemReporter problemReporter; /* classPathNames is a collection is Strings representing the full path of each class path initialFileNames is a collection is Strings, the trailing '.java' will be removed if its not already. */ public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { + this(classpathNames, initialFileNames, encoding, null); +} + +public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, ClasspathProblemReporter problemReporter) { final int classpathSize = classpathNames.length; this.classpaths = new Classpath[classpathSize]; + this.problemReporter = problemReporter; int counter = 0; for (int i = 0; i < classpathSize; i++) { Classpath classpath = getClasspath(classpathNames[i], encoding, null); @@ -126,10 +135,11 @@ } initializeKnownFileNames(initialFileNames); } -protected FileSystem(Classpath[] paths, String[] initialFileNames) { +protected FileSystem(Classpath[] paths, String[] initialFileNames, ClasspathProblemReporter problemReporter) { final int length = paths.length; int counter = 0; this.classpaths = new FileSystem.Classpath[length]; + this.problemReporter = problemReporter; for (int i = 0; i < length; i++) { final Classpath classpath = paths[i]; try { @@ -145,6 +155,9 @@ } initializeKnownFileNames(initialFileNames); } +protected FileSystem(Classpath[] paths, String[] initialFileNames) { + this(paths, initialFileNames, null); +} public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { return getClasspath(classpathName, encoding, false, accessRuleSet, null); } @@ -185,7 +198,24 @@ this.knownFileNames = new HashSet(0); return; } + if (this.problemReporter == null) { + this.problemReporter = new ClasspathProblemReporter() { + public void nestedClasspath(String classpathOne, String classpathTwo) { + System.err.println("Nested classpath " + classpathOne + " and " + classpathTwo); //$NON-NLS-1$ //$NON-NLS-2$ + } + public void multipleClasspathSections(String jarFilePath) { + System.err.println("Multiple classpath sections in " + jarFilePath); //$NON-NLS-1$ + } + public void invalidClasspathSection(String jarFilePath) { + System.err.println("Invalid classpath section in " + jarFilePath); //$NON-NLS-1$ + } + }; + } + this.knownFileNames = new HashSet(initialFileNames.length * 2); + + Map conflictingClasspath = new HashMap(); + for (int i = initialFileNames.length; --i >= 0;) { File compilationUnitFile = new File(initialFileNames[i]); char[] fileName = null; @@ -204,16 +234,19 @@ for (int j = 0, max = this.classpaths.length; j < max; j++) { char[] matchCandidate = this.classpaths[j].normalizedPath(); if (this.classpaths[j] instanceof ClasspathDirectory && - CharOperation.prefixEquals(matchCandidate, fileName) && - (matchingPathName == null || - matchCandidate.length < matchingPathName.length)) { - matchingPathName = matchCandidate; + CharOperation.prefixEquals(matchCandidate, fileName)) { + this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchCandidate.length, fileName.length))); + if (matchingPathName != null && matchingPathName.length != matchCandidate.length) { + if (!conflictingClasspath.containsKey(matchCandidate)) { + conflictingClasspath.put(matchCandidate, matchingPathName); + this.problemReporter.nestedClasspath(new String(matchCandidate), new String(matchingPathName)); + } + } + matchingPathName = matchCandidate; } } if (matchingPathName == null) { this.knownFileNames.add(new String(fileName)); // leave as is... - } else { - this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchingPathName.length, fileName.length))); } matchingPathName = null; } Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.353 diff -u -r1.353 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 25 Apr 2010 20:10:08 -0000 1.353 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 30 Aug 2010 15:20:34 -0000 @@ -62,6 +62,7 @@ import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.IProblemFactory; import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath; +import org.eclipse.jdt.internal.compiler.batch.FileSystem.ClasspathProblemReporter; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.env.AccessRestriction; import org.eclipse.jdt.internal.compiler.env.AccessRule; @@ -1329,6 +1330,7 @@ private PrintWriter err; ArrayList extraProblems; + ClasspathProblemReporter problemReporter = null; public final static String bundleName = "org.eclipse.jdt.internal.compiler.batch.messages"; //$NON-NLS-1$ // two uses: recognize 'none' in options; code the singleton none // for the '-d none' option (wherever it may be found) @@ -1452,6 +1454,17 @@ public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished, Map customDefaultOptions, CompilationProgress compilationProgress) { this.initialize(outWriter, errWriter, systemExitWhenFinished, customDefaultOptions, compilationProgress); this.relocalize(); + this.problemReporter = new FileSystem.ClasspathProblemReporter() { + public void invalidClasspathSection(String jarFilePath) { + addPendingErrors(bind("configure.invalidClasspathSection", jarFilePath)); //$NON-NLS-1$ + } + public void multipleClasspathSections(String jarFilePath) { + addPendingErrors(bind("configure.multipleClasspathSections", jarFilePath)); //$NON-NLS-1$ + } + public void nestedClasspath(String classpathOne, String classpathTwo) { + Main.this.logger.logWarning(bind("configure.nestedClasspathEntries", classpathOne, classpathTwo)); //$NON-NLS-1$ + } + }; } public void addExtraProblems(CategorizedProblem problem) { @@ -2935,7 +2948,7 @@ } public FileSystem getLibraryAccess() { - return new FileSystem(this.checkedClasspaths, this.filenames); + return new FileSystem(this.checkedClasspaths, this.filenames, this.problemReporter); } /* @@ -3011,22 +3024,13 @@ } ArrayList result = new ArrayList(); HashMap knownNames = new HashMap(); - FileSystem.ClasspathSectionProblemReporter problemReporter = - new FileSystem.ClasspathSectionProblemReporter() { - public void invalidClasspathSection(String jarFilePath) { - addPendingErrors(bind("configure.invalidClasspathSection", jarFilePath)); //$NON-NLS-1$ - } - public void multipleClasspathSections(String jarFilePath) { - addPendingErrors(bind("configure.multipleClasspathSections", jarFilePath)); //$NON-NLS-1$ - } - }; while (! classpaths.isEmpty()) { Classpath current = (Classpath) classpaths.remove(0); String currentPath = current.getPath(); if (knownNames.get(currentPath) == null) { knownNames.put(currentPath, current); result.add(current); - List linkedJars = current.fetchLinkedJars(problemReporter); + List linkedJars = current.fetchLinkedJars(this.problemReporter); if (linkedJars != null) { classpaths.addAll(0, linkedJars); } Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v retrieving revision 1.918 diff -u -r1.918 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 25 Aug 2010 10:53:58 -0000 1.918 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 30 Aug 2010 15:20:34 -0000 @@ -95,6 +95,7 @@ configure.incompatibleComplianceForCldcTarget=Target level ''{0}'' is incompatible with compliance level ''{1}''. A compliance level ''1.4''or lower is required configure.invalidClasspathSection = invalid Class-Path header in manifest of jar file: {0} configure.multipleClasspathSections = multiple Class-Path headers in manifest of jar file: {0} +configure.nestedClasspathEntries = Nested classpath entries found: {0} and {1} configure.missingwarningspropertiesfile=properties file {0} does not exist configure.ioexceptionwarningspropertiesfile=An IOException occurred while reading the properties file {0} configure.multipleencodings=Multiple encoding specified: {1}. The default encoding has been set to {0} #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.210 diff -u -r1.210 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 25 Aug 2010 11:11:58 -0000 1.210 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 30 Aug 2010 15:20:44 -0000 @@ -11789,4 +11789,58 @@ System.setProperty("user.dir", javaUserDir); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=322789 +public void test322789() throws IOException { + final String javaClassspath = System.getProperty("java.class.path"); + final String javaUserDir = System.getProperty("user.dir"); + try { + + File outputDir = new File(OUTPUT_DIR); + File srcDir = new File(outputDir, "src"); + srcDir.mkdirs(); + + System.setProperty("user.dir", OUTPUT_DIR); + System.setProperty("java.class.path", srcDir.getCanonicalPath()+";"+outputDir.getCanonicalPath()); + char[] srcPath = srcDir.getCanonicalPath().toCharArray(); + char[] outputPath = outputDir.getCanonicalPath().toCharArray(); + if (File.separatorChar == '\\') { + CharOperation.replace(srcPath, '\\', '/'); + CharOperation.replace(outputPath, '\\', '/'); + } + + this.runConformTest( + new String[] { + "src/p/AbstractJavaSourceClassLoader.java", + "package p;\n" + + "public abstract class AbstractJavaSourceClassLoader {\n" + + " public interface ProtectionDomainFactory {}\n" + + "}\n", + "src/p/" + PACKAGE_INFO_NAME + ".java", + "/* \n" + + " * Package information : p \n" + + " */ \n" + + "package p;\n", + }, + "\"" + OUTPUT_DIR + File.separator + "src" + File.separator + "p" + File.separator + "AbstractJavaSourceClassLoader.java\"" + + " \"" + OUTPUT_DIR + File.separator + "src" + File.separator + "p" + File.separator + PACKAGE_INFO_NAME + ".java\"" + + " -1.5 -g -preserveAllLocals" + + " -proceedOnError -referenceInfo" + + " -d \"" + OUTPUT_DIR + "\"", + "Nested classpath entries found: "+ new String(outputPath) +"/ and "+ new String(srcPath) +"/\r\n", + "", + true); + final String userDir = System.getProperty("user.dir"); + File f = new File(userDir, "p" + File.separator + "AbstractJavaSourceClassLoader.java"); + if (!Util.delete(f)) { + System.out.println("Could not delete AbstractJavaSourceClassLoader.java"); + } + f = new File(userDir, "p" + File.separator + "package-info.java"); + if (!Util.delete(f)) { + System.out.println("Could not delete package-info.java"); + } + } finally { + System.setProperty("java.class.path", javaClassspath); + System.setProperty("user.dir", javaUserDir); + } +} }