Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v retrieving revision 1.55 diff -u -r1.55 StaticImportTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 20 Nov 2006 14:17:13 -0000 1.55 +++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 16 May 2007 19:28:07 -0000 @@ -1872,4 +1872,30 @@ "The local variable i may not have been initialized\n" + "----------\n"); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=187329 + public void test050() { + this.runConformTest( + new String[] { + "p/A.java", + "package p;\n" + + "import static p.B.bar3;\n" + + "public class A { int a = bar3; }" , + "p/B.java", + "package p;\n" + + "import static p.Util.someStaticMethod;\n" + + "public class B {\n" + + " static final int bar = someStaticMethod();\n" + + " static final int bar2 = someStaticMethod();\n" + + " static final int bar3 = someStaticMethod();\n" + + "}" , + "p/C.java", + "package p;\n" + + "import static p.B.bar;\n" + + "public class C { int c = bar; }" , + "p/Util.java", + "package p;\n" + + "class Util { static int someStaticMethod() { return 0; } }" + }, + ""); + } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v retrieving revision 1.108 diff -u -r1.108 CompilationUnitScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 27 Apr 2007 15:51:38 -0000 1.108 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 16 May 2007 19:28:08 -0000 @@ -293,6 +293,9 @@ if (referenceContext.imports == null) { this.typeOrPackageCache = new HashtableOfObject(1); return; + } else if (this.typeOrPackageCache != null) { + // can be called when a field constant is resolved before static imports + return; } // collect the top level type names if a single type import exists Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.306 diff -u -r1.306 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 14 May 2007 16:47:46 -0000 1.306 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 May 2007 19:28:08 -0000 @@ -1877,6 +1877,7 @@ // at this point the scope is a compilation unit scope & need to check for imported static methods CompilationUnitScope unitScope = (CompilationUnitScope) scope; + unitScope.faultInImports(); // field constants can cause static imports to be accessed before they're resolved ImportBinding[] imports = unitScope.imports; if (imports != null) { ObjectVector visible = null;