HEAD - 317264
diff --git a/buildnotes_jdt-core.html b/buildnotes_jdt-core.html
index 8ef66b7..2be70fd 100644
--- a/buildnotes_jdt-core.html
+++ b/buildnotes_jdt-core.html
@@ -92,7 +92,9 @@
 </ul>
 
 <h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=306524">306524</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=317264">317264</a>
+Refactoring is impossible with commons.lang added to project
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=306524">306524</a>
 ASTRewriteAnalyzer uses wrong starting offset in case of comments before a node
 <br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980">150980</a>
 [API] Selecting import declaration with space in outline highlights wrong range
diff --git a/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java b/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java
index 2e82277..6c302ef 100644
--- a/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java
+++ b/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java
@@ -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
@@ -16,6 +16,7 @@
 import org.eclipse.jdt.core.IClassFile;
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.IPackageFragment;
 import org.eclipse.jdt.core.IPackageFragmentRoot;
 import org.eclipse.jdt.core.IType;
@@ -25,8 +26,11 @@
 import org.eclipse.jdt.core.search.IJavaSearchScope;
 import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
 import org.eclipse.jdt.core.search.TypeNameRequestor;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
 import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
 import org.eclipse.jdt.internal.core.Openable;
+import org.eclipse.jdt.internal.core.PackageFragment;
 import org.eclipse.jdt.internal.core.PackageFragmentRoot;
 import org.eclipse.jdt.internal.core.util.HandleFactory;
 import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject;
@@ -69,6 +73,8 @@
 	 * Cache package handles to optimize memory.
 	 */
 	private HashtableOfArrayToObject packageHandles;
+	private long complianceValue;
+	private IJavaProject lastProject;
 
 public TypeNameMatchRequestorWrapper(TypeNameMatchRequestor requestor, IJavaSearchScope scope) {
 	this.requestor = requestor;
@@ -116,7 +122,8 @@
 		// Accept match if the type has been found
 		if (type != null) {
 			// hierarchy scopes require one more check:
-			if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {
+			if ((!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type))
+					&& (!filterMatch(type))) {
 
 				// Create the match
 				final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers);
@@ -220,4 +227,56 @@
 	}
 	return null;
 }
+
+private boolean filterMatch(IJavaElement type) {
+	
+	// filter enum and assert - these keywords have been added in 
+	// latter versions of Java and hence should be filtered off 
+	// for the versions they are introduced
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=313668
+	while (type != null) {
+		if (type.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
+			String[] names = ((PackageFragment)type).names;
+			for (int i = 0, l = names.length; i < l; i++) {
+				if (isNameNewKeyword(type, names[i]))
+					return true;
+			}
+			return false;
+		}
+		if (isNameNewKeyword(type, type.getElementName())) {
+			return true;
+		}
+		type = type.getParent();
+	}
+	return false;
+}
+
+// this function is optimized to assume that there are lesser chances of enum or assert as the name
+private boolean isNameNewKeyword(IJavaElement type, String name) {
+	if (name == null) return false;
+	switch(name.length()) {
+		case 4: // length of enum
+			if (name.equals("enum")) { //$NON-NLS-1$
+				return (getProjectCompliance(type) >= ClassFileConstants.JDK1_5);
+			}
+			break;
+		case 6: // length of assert
+			if (name.equals("assert")) { //$NON-NLS-1$
+				return (getProjectCompliance(type) >= ClassFileConstants.JDK1_4);
+			}
+			break;
+	}
+	return false;
+}
+
+private long getProjectCompliance(IJavaElement type) {
+	IJavaProject proj = (IJavaProject)type.getAncestor(IJavaElement.JAVA_PROJECT);
+	if (proj != this.lastProject) {
+		String complianceStr = proj.getOption(CompilerOptions.OPTION_Source, true);
+		this.complianceValue = CompilerOptions.versionToJdkLevel(complianceStr);
+		this.lastProject = proj;
+	}
+	return this.complianceValue;
+}
+
 }
diff --git a/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index 19585d2..38b0e49 100644
--- a/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -257,6 +257,29 @@
 	return null;
 }
 
+private boolean filterMatch(SearchMatch match) {
+	
+	// filter enum and assert - these keywords have been added in 
+	// later versions of Java and hence should be filtered off 
+	// for the versions they are introduced
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=313668
+	IJavaElement element = (IJavaElement)match.getElement();	
+	if (this.options != null && this.options.sourceLevel < ClassFileConstants.JDK1_3)
+		return false;	
+	while (element != null) {
+		if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
+			String[] names = ((PackageFragment)element).names;
+			for (int i = 0, l = names.length; i < l; i++) {
+				if (isNameNewKeyword(element, names[i])) return true;
+			}
+			return false;
+		}
+		if (isNameNewKeyword(element, element.getElementName())) return true;
+		element = element.getParent();
+	}
+	return false;
+}
+
 /**
  * Query a given index for matching entries. Assumes the sender has opened the index and will close when finished.
  */
@@ -927,6 +950,14 @@
 	this.bindings.put(methodPattern, new ProblemMethodBinding(methodPattern.selector, null, ProblemReasons.NotFound));
 	return null;
 }
+
+private long getProjectCompliance(IJavaElement element) {
+	if (this.options != null) return this.options.sourceLevel;
+	IJavaProject proj = (IJavaProject)element.getAncestor(IJavaElement.JAVA_PROJECT);
+	String complianceStr = proj.getOption(CompilerOptions.OPTION_Source, true);
+	return CompilerOptions.versionToJdkLevel(complianceStr);
+}
+
 protected boolean hasAlreadyDefinedType(CompilationUnitDeclaration parsedUnit) {
 	CompilationResult result = parsedUnit.compilationResult;
 	if (result == null) return false;
@@ -935,6 +966,24 @@
 			return true;
 	return false;
 }
+
+// this function is optimized to assume that there are lesser chances of enum or assert as the name
+private boolean isNameNewKeyword(IJavaElement element, String name) {
+	if (name == null) return false;
+	switch(name.length()) {
+		case 4: // length of enum
+			if (name.equals("enum")) { //$NON-NLS-1$
+				return (getProjectCompliance(element) >= ClassFileConstants.JDK1_5);
+			}
+			return false;
+		case 6: // length of assert
+			if (name.equals("assert")) { //$NON-NLS-1$
+				return (getProjectCompliance(element) >= ClassFileConstants.JDK1_4);
+			}
+			return false;
+	}
+	return false;
+}
 /**
  * Create a new parser for the given project, as well as a lookup environment.
  */
@@ -1702,6 +1751,9 @@
 		}
 		return;
 	}
+	if (filterMatch(match)) {
+		return;
+	}
 	long start = -1;
 	if (BasicSearchEngine.VERBOSE) {
 		start = System.currentTimeMillis();