### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaModelStatus.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java,v retrieving revision 1.45 diff -u -r1.45 JavaModelStatus.java --- model/org/eclipse/jdt/internal/core/JavaModelStatus.java 1 Sep 2008 08:48:41 -0000 1.45 +++ model/org/eclipse/jdt/internal/core/JavaModelStatus.java 8 Dec 2008 06:39:00 -0000 @@ -364,15 +364,6 @@ } return Messages.bind(Messages.classpath_disabledMultipleOutputLocations, new String[] {newPath.makeRelative().toString(), projectName}); - case INCOMPATIBLE_JDK_LEVEL: - javaProject = (IJavaProject)this.elements[0]; - return Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel, new String[]{ - javaProject.getElementName(), - javaProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true), - this.path.makeRelative().toString(), - this.string, - }); - case CANNOT_RETRIEVE_ATTACHED_JAVADOC : if (this.elements != null && this.elements.length == 1) { if (this.string != null) { Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.109 diff -u -r1.109 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 28 Oct 2008 21:25:29 -0000 1.109 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 8 Dec 2008 06:39:00 -0000 @@ -1745,6 +1745,10 @@ * @return a java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine */ public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){ + return validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer); + } + + private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IPath path = entry.getPath(); @@ -1796,7 +1800,7 @@ if (description == null) description = path.makeRelative().toString(); return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path); } - IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, checkSourceAttachment, true/*referred by container*/); + IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, container, checkSourceAttachment, true/*referred by container*/); if (!containerEntryStatus.isOK()){ return containerEntryStatus; } @@ -1825,7 +1829,7 @@ } // get validation status - IJavaModelStatus status = validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/); + IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, false/*not referred by container*/); if (!status.isOK()) return status; // return deprecation status if any @@ -1847,7 +1851,15 @@ // (these entries are considered optional since the user cannot act on them) // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392 - IJavaModelStatus status = validateLibraryEntry(path, project, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg); + String containerInfo = null; + if (entryContainer != null) { + if (entryContainer instanceof UserLibraryClasspathContainer) { + containerInfo = Messages.bind(Messages.classpath_userLibraryInfo, new String[] {entryContainer.getDescription()}); + } else { + containerInfo = Messages.bind(Messages.classpath_containerInfo, new String[] {entryContainer.getDescription()}); + } + } + IJavaModelStatus status = validateLibraryEntry(path, project, containerInfo, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg); if (!status.isOK()) return status; break; @@ -1868,7 +1880,14 @@ long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true)); long prereqProjectTargetJDK = CompilerOptions.versionToJdkLevel(prereqProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true)); if (prereqProjectTargetJDK > projectTargetJDK) { - return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, project, path, CompilerOptions.versionFromJdkLevel(prereqProjectTargetJDK)); + return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, + project, path, + Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel, + new String[] { + project.getElementName(), + CompilerOptions.versionFromJdkLevel(projectTargetJDK), + path.makeRelative().toString(), + CompilerOptions.versionFromJdkLevel(prereqProjectTargetJDK)})); } } } catch (CoreException e){ @@ -1916,14 +1935,36 @@ return JavaModelStatus.VERIFIED_OK; } - private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, IPath sourceAttachment, String entryPathMsg) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816, Now we have the facility to include a container + // name in diagnostics. If the parameter ``container'' is not null, it is used to point to the library + // more fully. + private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String container, IPath sourceAttachment, String entryPathMsg) { if (path.isAbsolute() && !path.isEmpty()) { Object target = JavaModel.getTarget(path, true); if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) { long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true)); long libraryJDK = Util.getJdkLevel(target); if (libraryJDK != 0 && libraryJDK > projectTargetJDK) { - return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, project, path, CompilerOptions.versionFromJdkLevel(libraryJDK)); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, + project, path, + Messages.bind(Messages.classpath_incompatibleLibraryJDKLevelInContainer, + new String [] { + project.getElementName(), + CompilerOptions.versionFromJdkLevel(projectTargetJDK), + path.makeRelative().toString(), + container, + CompilerOptions.versionFromJdkLevel(libraryJDK)})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, + project, path, + Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel, + new String[] { + project.getElementName(), + CompilerOptions.versionFromJdkLevel(projectTargetJDK), + path.makeRelative().toString(), + CompilerOptions.versionFromJdkLevel(libraryJDK)})); + } } } if (target instanceof IResource){ @@ -1933,39 +1974,67 @@ if (sourceAttachment != null && !sourceAttachment.isEmpty() && JavaModel.getTarget(sourceAttachment, true) == null){ - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()})); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toString(), container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()})); + } } break; case IResource.FOLDER : // internal binary folder if (sourceAttachment != null && !sourceAttachment.isEmpty() && JavaModel.getTarget(sourceAttachment, true) == null){ - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()})); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toString(), container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()})); + } } } } else if (target instanceof File){ File file = JavaModel.getFile(target); if (file == null) { - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()})); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()})); + } } else if (sourceAttachment != null && !sourceAttachment.isEmpty() && JavaModel.getTarget(sourceAttachment, true) == null){ - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()})); - } + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()})); + } + } } else { boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists(); if (isExternal) { - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()})); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {path.toOSString(), container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()})); + } } else { if (entryPathMsg == null) entryPathMsg = project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString(); - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()})); + if (container!= null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {entryPathMsg, container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()})); + } } } } else { if (entryPathMsg == null) entryPathMsg = project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString(); - return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPath, new String[] {entryPathMsg, project.getElementName()})); + if (container != null) { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPathInContainer, new String[] {entryPathMsg, container})); + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPath, new String[] {entryPathMsg, project.getElementName()})); + } } return JavaModelStatus.VERIFIED_OK; } Index: model/org/eclipse/jdt/internal/core/util/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties,v retrieving revision 1.73 diff -u -r1.73 messages.properties --- model/org/eclipse/jdt/internal/core/util/messages.properties 10 Oct 2008 07:28:57 -0000 1.73 +++ model/org/eclipse/jdt/internal/core/util/messages.properties 8 Dec 2008 06:39:01 -0000 @@ -145,8 +145,10 @@ classpath_illegalContainerPath = Illegal classpath container path: ''{0}'' in project ''{1}'', must have at least one segment (containerID+hints) classpath_illegalEntryInClasspathFile = Illegal entry in ''.classpath'' of project ''{0}'' file: {1} classpath_illegalLibraryPath = Illegal path for required library: ''{0}'' in project ''{1}'' +classpath_illegalLibraryPathInContainer = Illegal path for required library: ''{0}'' in the {1} classpath_illegalLibraryArchive = Illegal type of archive for required library: ''{0}'' in project ''{1}'' classpath_illegalExternalFolder = Required library cannot denote external folder: ''{0}'' for project ''{1}'' +classpath_illegalExternalFolderInContainer = Required library cannot denote external folder: ''{0}'' in the {1} classpath_illegalProjectPath = Illegal path for required project: ''{0}'' in project ''{1}'' classpath_illegalSourceFolderPath = Illegal path for required source folder: ''{0}'' in project ''{1}'' classpath_illegalVariablePath = Illegal classpath variable path: ''{0}'' in project ''{1}'', must have at least one segment @@ -155,10 +157,14 @@ classpath_mustEndWithSlash = End exclusion filter ''{0}'' with / to fully exclude ''{1}'' classpath_unboundContainerPath = Unbound classpath container: ''{0}'' in project ''{1}'' classpath_unboundLibrary = Project ''{1}'' is missing required library: ''{0}'' +classpath_userLibraryInfo = user library ''{0}'' +classpath_containerInfo = container ''{0}'' +classpath_unboundLibraryInContainer = The {1} references non existing library ''{0}'' classpath_unboundProject = Project ''{1}'' is missing required Java project: ''{0}'' classpath_settingOutputLocationProgress = Setting output location for: ''{0}'' classpath_settingProgress = Setting classpath for: {0} -classpath_unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}'' in project ''{1}'' +classpath_unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}'' in project ''{2}'' +classpath_unboundSourceAttachmentInContainedLibrary = Invalid source attachment: ''{0}'' for required library ''{1}'' in the {2} classpath_unboundSourceFolder = Project ''{1}'' is missing required source folder: ''{0}'' classpath_unboundVariablePath = Unbound classpath variable: ''{0}'' in project ''{1}'' classpath_unknownKind = Unknown kind: ''{0}'' @@ -166,6 +172,7 @@ classpath_disabledInclusionExclusionPatterns = Inclusion or exclusion patterns are disabled in project ''{1}'', cannot selectively include or exclude from entry: ''{0}'' classpath_disabledMultipleOutputLocations = Multiple output locations are disabled in project ''{1}'', cannot associate entry: ''{0}'' with a specific output classpath_incompatibleLibraryJDKLevel = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' which requires a {3} runtime +classpath_incompatibleLibraryJDKLevelInContainer = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' (from the {3}) which requires a {4} runtime classpath_duplicateEntryExtraAttribute = Duplicate extra attribute: ''{0}'' in classpath entry ''{1}'' for project ''{2}'' classpath_deprecated_variable = Classpath variable ''{0}'' in project ''{1}'' is deprecated: {2} Index: model/org/eclipse/jdt/internal/core/util/Messages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Messages.java,v retrieving revision 1.24 diff -u -r1.24 Messages.java --- model/org/eclipse/jdt/internal/core/util/Messages.java 10 Oct 2008 07:28:57 -0000 1.24 +++ model/org/eclipse/jdt/internal/core/util/Messages.java 8 Dec 2008 06:39:01 -0000 @@ -149,8 +149,10 @@ public static String classpath_illegalContainerPath; public static String classpath_illegalEntryInClasspathFile; public static String classpath_illegalLibraryPath; + public static String classpath_illegalLibraryPathInContainer; public static String classpath_illegalLibraryArchive; public static String classpath_illegalExternalFolder; + public static String classpath_illegalExternalFolderInContainer; public static String classpath_illegalProjectPath; public static String classpath_illegalSourceFolderPath; public static String classpath_illegalVariablePath; @@ -159,10 +161,14 @@ public static String classpath_mustEndWithSlash; public static String classpath_unboundContainerPath; public static String classpath_unboundLibrary; + public static String classpath_userLibraryInfo; + public static String classpath_containerInfo; + public static String classpath_unboundLibraryInContainer; public static String classpath_unboundProject; public static String classpath_settingOutputLocationProgress; public static String classpath_settingProgress; public static String classpath_unboundSourceAttachment; + public static String classpath_unboundSourceAttachmentInContainedLibrary; public static String classpath_unboundSourceFolder; public static String classpath_unboundVariablePath; public static String classpath_unknownKind; @@ -170,6 +176,7 @@ public static String classpath_disabledInclusionExclusionPatterns; public static String classpath_disabledMultipleOutputLocations; public static String classpath_incompatibleLibraryJDKLevel; + public static String classpath_incompatibleLibraryJDKLevelInContainer; public static String classpath_duplicateEntryExtraAttribute; public static String classpath_deprecated_variable; public static String file_notFound; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v retrieving revision 1.193 diff -u -r1.193 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 28 Oct 2008 21:25:36 -0000 1.193 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 8 Dec 2008 06:39:06 -0000 @@ -40,6 +40,9 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentDescription; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jdt.core.ClasspathContainerInitializer; import org.eclipse.jdt.core.IAccessRule; import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathContainer; @@ -59,6 +62,7 @@ import org.eclipse.jdt.internal.core.ClasspathEntry; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.JavaProject; +import org.eclipse.jdt.internal.core.UserLibraryClasspathContainer; import org.eclipse.team.core.RepositoryProvider; public class ClasspathTests extends ModifyingResourceTests { @@ -160,6 +164,238 @@ return result; } +/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816: Misleading problem text for missing jar in user + * library. We now mention the container name in this and related diagnostics so the context and connection is clearer. + * The bunch of tests with names of the form test232816*() test several paths in the function + * org.eclipse.jdt.internal.core.ClasspathEntry.validateLibraryEntry(IPath, IJavaProject, String, IPath, String) + * with the sole objective of eliciting the various messages under the different conditions (internal/external, + * file/folder, problem with library/sources etc). The tests probably make not much sense other than to trigger + * errors. + */ + +public void test232816() throws Exception { + + IJavaProject p = null; + try { + p = createJavaProject("P"); + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path(getExternalResourcePath("libjar.jar")), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about missing library", + "The container \'container/default\' references non existing library \'" + getExternalResourcePath("libjar.jar") + "'", + status); + } finally { + deleteProject("P"); + } +} + + +public void test232816a() throws Exception { + + IJavaProject p = null; + try { + p = createJavaProject("P"); + addExternalLibrary(p, getExternalResourcePath("lib1.jar"), new String[0], + new String[] { + "META-INF/MANIFEST.MF", + "Manifest-Version: 1.0\n" + + "Class-Path: lib2.jar\n", + }, + JavaCore.VERSION_1_4); + refreshExternalArchives(p); + + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path(getExternalResourcePath("lib1.jar")), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about source attachment", + "Invalid source attachment: '/P0/SBlah' for required library \'" + getExternalResourcePath("lib1.jar") + "' in the container 'container/default'", + status); + } finally { + deleteProject("P"); + deleteExternalResource("lib1.jar"); + } +} + +public void test232816b() throws Exception { + + try { + IJavaProject p = createJavaProject("Project"); + // Create new user library "SomeUserLibrary" + ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID); + String libraryName = "SomeUserLibrary"; + IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID); + UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName); + initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion); + + // Modify user library + IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID); + String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"SomeUserLibrary"; + StringBuffer propertyValue = new StringBuffer("\r\n\r\n\r\n\r\n"); + preferences.put(propertyName, propertyValue.toString()); + preferences.flush(); + + + IClasspathEntry[] entries = p.getRawClasspath(); + int length = entries.length; + System.arraycopy(entries, 0, entries = new IClasspathEntry[length+1], 0, length); + entries[length] = JavaCore.newContainerEntry(containerSuggestion.getPath()); + p.setRawClasspath(entries, null); + + assertMarkers("Failed to find marker", "The user library 'SomeUserLibrary' references non existing library \'" + getExternalResourcePath("idontexistthereforeiamnot.jar") + "'", p); + } finally { + deleteProject("Project"); + } +} + + +public void test232816c() throws CoreException { + + IJavaProject p = null; + try { + + p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0"); + + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about missing library", + "The container 'container/default' references non existing library 'JUNK'", + status); + + } finally { + deleteProject ("P0"); + } +} + + +public void test232816d() throws CoreException { + + IJavaProject p = null; + try { + + p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0"); + + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path("/P0/src0"), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about source attachment", + "Invalid source attachment: '/P0/SBlah' for required library '/P0/src0' in the container 'container/default'", + status); + + } finally { + deleteProject ("P0"); + } +} + +public void test232816e() throws CoreException { + + IJavaProject p = null; + try { + + p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0"); + createFile("/P0/src0/X.class", ""); + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path("/P0/src0/X.class"), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about source attachment", + "Invalid source attachment: '/P0/SBlah' for required library '/P0/src0/X.class' in the container 'container/default'", + status); + + } finally { + deleteProject ("P0"); + } +} + +public void test232816f() throws Exception { + + IJavaProject p = null; + try { + p = createJavaProject("P"); + + p.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4); + p.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.WARNING); + + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(getExternalJCLPath("1.5"), new Path("/P0/SBlah"), new Path("/P0"))}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + assertStatus( + "should have complained about jdk level mismatch", + "Incompatible .class files version in required binaries. Project 'P' is targeting a 1.4 runtime, but is compiled against \'" + getExternalJCLPath("1.5").makeRelative() + "' (from the container 'container/default') which requires a 1.5 runtime", + status); + } finally { + deleteProject("P"); + } +} + + /* * Ensures that adding a library entry for an existing external library folder doesn't generate a marker */ @@ -2341,7 +2577,7 @@ setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"))}); assertMarkers( "Unexpected markers", - "Project \'P\' is missing required library: \'"+ getExternalPath() + "nonExisting.jar\'", + "The container 'Test container' references non existing library \'" + getExternalPath() + "nonExisting.jar\'", p); } finally { deleteProject("P");