Skip to content

Commit 79e9d01

Browse files
committed
Print warning if adding parent folder of library to the classpath eclipse-jdt#4797
Print a warning in the trace log if the Class-Path entry in the manifest file of a third-party library includes a parent folder. This might not be forbidden but it's a dangerous practice. Contributes to: eclipse-jdt#4797
1 parent 2875481 commit 79e9d01

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,14 @@ private static void resolvedChainedLibraries(IPath jarPath, HashSet visited, Arr
986986
}
987987
continue;
988988
}
989+
if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE && calledJar.isPrefixOf(jarPath)) {
990+
// Adding parent folders is a hack that some JARs use to spare some effort,
991+
// but it may cause issues like having invalid duplicated classes in the classpath.
992+
// See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4797
993+
trace("WARN: Classpath entry " + calledFileName + " in manifest of jar file: " //$NON-NLS-1$ //$NON-NLS-2$
994+
+ jarPath.toOSString()
995+
+ " references a parent folder. This may cause issues like duplicated classes in the classpath, wrong hierarchies, etc. For more details, see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4797."); //$NON-NLS-1$
996+
}
989997
resolvedChainedLibraries(calledJar, visited, result);
990998
result.add(calledJar);
991999
}

0 commit comments

Comments
 (0)