Fixes the problem reported in issue 1830 comment #12. 

We were always telling JDT that any binary only package was not a package.  This would work as long as JDT always called INameEnvironment.findType for a class in a binary only package.  

This patch uses ClassLoader.getResource(String) to determine if a name is a package.  This works as long as we are not asking about binary only package which only exists on the boot classpath.

Review by: scottb

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1944 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
index ea85b1e..2ff4800 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/AbstractCompiler.java
@@ -354,12 +354,17 @@
           nameEnvironmentAnswerForTypeName.put(qname, out);
           return out;
         } else {
-          ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-          if (isBinaryType(contextClassLoader, className)) {
-            URL resourceURL = contextClassLoader.getResource(className.replace(
-                '.', '/')
-                + ".class");
-            if (resourceURL != null) {
+          ClassLoader classLoader = getClassLoader();
+          URL resourceURL = classLoader.getResource(className.replace('.', '/')
+              + ".class");
+          if (resourceURL != null) {
+            /*
+             * We know that there is a .class file that matches the name that we
+             * are looking for. However, at least on OSX, this lookup is case
+             * insensitive so we need to use Class.forName to effectively verify
+             * the case.
+             */
+            if (isBinaryType(classLoader, className)) {
               byte[] classBytes = Util.readURLAsBytes(resourceURL);
               ClassFileReader cfr;
               try {
@@ -394,7 +399,8 @@
       String packageName = String.valueOf(pathChars);
       if (knownPackages.contains(packageName)) {
         return true;
-      } else if (sourceOracle.isPackage(packageName)) {
+      } else if (sourceOracle.isPackage(packageName)
+          || isPackage(getClassLoader(), packageName)) {
         // Grow our own list to spare calls into the host.
         //
         rememberPackage(packageName);
@@ -404,6 +410,10 @@
       }
     }
 
+    private ClassLoader getClassLoader() {
+      return Thread.currentThread().getContextClassLoader();
+    }
+
     private boolean isBinaryType(ClassLoader classLoader, String typeName) {
       try {
         Class.forName(typeName, false, classLoader);
@@ -417,6 +427,11 @@
       // Assume that it is not a binary type.
       return false;
     }
+
+    private boolean isPackage(ClassLoader classLoader, String packageName) {
+      String packageAsPath = packageName.replace('.', '/');
+      return classLoader.getResource(packageAsPath) != null;
+    }
   }
 
   private static final CachePolicy DEFAULT_POLICY = new CachePolicy() {