Revision: 8803
Author: [email protected]
Date: Thu Sep 16 10:52:13 2010
Log: Add error message when non-static inner class throws NoSuchMethodException

Review at http://gwt-code-reviews.appspot.com/876801

http://code.google.com/p/google-web-toolkit/source/detail?r=8803

Modified:
 /trunk/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java Wed Aug 11 07:24:43 2010 +++ /trunk/dev/core/src/com/google/gwt/dev/shell/ModuleSpace.java Thu Sep 16 10:52:13 2010
@@ -445,6 +445,7 @@
     Throwable caught = null;
     String msg = null;
     String resultName = null;
+    Class<?> resolvedClass = null;

     Event moduleSpaceRebindAndCreate =
SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_REBIND_AND_CREATE);
@@ -455,7 +456,7 @@
       resultName = rebind(sourceName);
       moduleSpaceRebindAndCreate.addData(
"Requested Class", requestedClassName, "Result Name", resultName);
-      Class<?> resolvedClass = loadClassFromSourceName(resultName);
+      resolvedClass = loadClassFromSourceName(resultName);
       if (Modifier.isAbstract(resolvedClass.getModifiers())) {
         msg = "Deferred binding result type '" + resultName
             + "' should not be abstract";
@@ -473,9 +474,18 @@
       caught = e;
     } catch (ExceptionInInitializerError e) {
       caught = e.getException();
-    } catch (NoSuchMethodException e) {
-      msg = "Rebind result '" + resultName
-          + "' has no default (zero argument) constructors.";
+    } catch (NoSuchMethodException e) {
+      // If it is a nested class and not declared as static,
+      // then it's not accessible from outside.
+      //
+      if (resolvedClass.getEnclosingClass() != null
+          && !Modifier.isStatic(resolvedClass.getModifiers())) {
+        msg = "Rebind result '" + resultName
+        + " is a non-static inner class";
+      } else {
+        msg = "Rebind result '" + resultName
+        + "' has no default (zero argument) constructors.";
+      }
       caught = e;
     } catch (InvocationTargetException e) {
       caught = e.getTargetException();

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to