### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.122 diff -u -r1.122 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 7 Jan 2010 20:18:49 -0000 1.122 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 27 Jan 2010 04:02:27 -0000 @@ -1758,8 +1758,14 @@ */ public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){ IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer); - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136, ignore class path errors from optional entries. - if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional()) + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136 + // Ignore class path errors from optional entries. + int statusCode = status.getCode(); + if ( (statusCode == IJavaModelStatusConstants.INVALID_CLASSPATH || + statusCode == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND || + statusCode == IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND || + statusCode == IJavaModelStatusConstants.INVALID_PATH) && + ((ClasspathEntry) entry).isOptional()) return JavaModelStatus.VERIFIED_OK; return status; } #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.203 diff -u -r1.203 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 21 Aug 2009 05:17:28 -0000 1.203 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 27 Jan 2010 04:02:35 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -5971,5 +5971,90 @@ this.deleteProject("P"); } } +/** + * @bug 300136:classpathentry OPTIONAL attribute not honored for var entries + * + * Test that classpath entries (CPE_LIB, CPE_CONTAINER and CPE_VARIABLE) that are marked as optional + * in the .classpath file are not reported for errors. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136" + */ +public void testBug300136() throws Exception { + boolean autoBuild = getWorkspace().isAutoBuilding(); + IWorkspaceDescription preferences = getWorkspace().getDescription(); + try { + preferences.setAutoBuilding(false); + IJavaProject project = createJavaProject("P"); + StringBuffer buffer = new StringBuffer( + "\n" + + "\n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + "" + ); + editFile( + "/P/.classpath", + buffer.toString() + ); + assertMarkers( + "Unexpected markers", + "", + project); + } finally { + preferences.setAutoBuilding(autoBuild); + deleteProject("P"); + } +} +/** + * Additional test for bug 300136 - Test that the the errors are reported when the + * optional attribute is not used. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136" + */ +public void testBug300136a() throws Exception { + boolean autoBuild = getWorkspace().isAutoBuilding(); + IWorkspaceDescription preferences = getWorkspace().getDescription(); + try { + preferences.setAutoBuilding(false); + IJavaProject project = createJavaProject("P"); + StringBuffer buffer = new StringBuffer( + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + ); + editFile( + "/P/.classpath", + buffer.toString() + ); + assertMarkers( + "Unexpected markers", + "Project \'P\' is missing required library: \'\\lib\\tmp.jar\'\n" + + "Unbound classpath container: \'org.eclipse.jdt.core.tests.model.TEST_CONTAINER\' in project \'P\'\n" + + "Unbound classpath variable: \'UNBOUND_VAR\' in project \'P\'", + project); + } finally { + preferences.setAutoBuilding(autoBuild); + deleteProject("P"); + } +} }