summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTerry Parker2012-03-05 11:14:43 (EST)
committer Satyam Kandula2012-03-05 11:14:43 (EST)
commitd39d6a569bf3e8ad17dd21e40b44a475d8afacee (patch)
tree46ed31d7ec0959b3ccc49f05c1b169a920fefa90
parent4de8875392f1614ce3d9b4e720843df3cd1fa2b7 (diff)
downloadeclipse.jdt.core-d39d6a569bf3e8ad17dd21e40b44a475d8afacee.zip
eclipse.jdt.core-d39d6a569bf3e8ad17dd21e40b44a475d8afacee.tar.gz
eclipse.jdt.core-d39d6a569bf3e8ad17dd21e40b44a475d8afacee.tar.bz2
Fix for 372418: Another problem with inner classes referenced from jars
or class folders: "The type ... cannot be resolved"
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
index 65c3c79..0dc9550 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
@@ -7,6 +7,9 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Terry Parker <tparker@google.com>
+ * - Contribution for https://bugs.eclipse.org/bugs/show_bug.cgi?id=372418
+ * - Another problem with inner classes referenced from jars or class folders: "The type ... cannot be resolved"
*******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
@@ -271,7 +274,13 @@ private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeNam
// if an additional source file is waiting to be compiled, answer it BUT not if this is a secondary type search
// if we answer X.java & it no longer defines Y then the binary type looking for Y will think the class path is wrong
// let the recompile loop fix up dependents when the secondary type Y has been deleted from X.java
- SourceFile unit = (SourceFile) this.additionalUnits.get(qualifiedTypeName); // doesn't have file extension
+ // Only enclosing type names are present in the additional units table, so strip off inner class specifications
+ // when doing the lookup (https://bugs.eclipse.org/372418)
+ String enclosingTypeName = qualifiedTypeName;
+ int index = enclosingTypeName.indexOf('$');
+ if (index > 0)
+ enclosingTypeName = enclosingTypeName.substring(0, index);
+ SourceFile unit = (SourceFile) this.additionalUnits.get(enclosingTypeName); // doesn't have file extension
if (unit != null)
return new NameEnvironmentAnswer(unit, null /*no access restriction*/);
}