Semantics of JClassType.isDefaultInstantiable() now actually match the Javadoc.  GWTRunnerGenerator now deals better with nested classes.

Review by: spoon


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@3470 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/typeinfo/JRealClassType.java b/dev/core/src/com/google/gwt/core/ext/typeinfo/JRealClassType.java
index 13329a8..955146f 100644
--- a/dev/core/src/com/google/gwt/core/ext/typeinfo/JRealClassType.java
+++ b/dev/core/src/com/google/gwt/core/ext/typeinfo/JRealClassType.java
@@ -294,7 +294,13 @@
    *         <code>false</code> otherwise
    */
   public boolean isDefaultInstantiable() {
-    if (isInterface() != null) {
+    if (isInterface() != null || isAbstract()) {
+      return false;
+    }
+    if (isMemberType() && !isStatic()) {
+      return false;
+    }
+    if (isLocalType()) {
       return false;
     }
     if (getConstructors().length == 0) {
diff --git a/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java b/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
index 19a2d59..b4ed8af 100644
--- a/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
+++ b/user/src/com/google/gwt/junit/rebind/GWTRunnerGenerator.java
@@ -43,6 +43,11 @@
 
   private static final String GWT_RUNNER_NAME = GWTRunner.class.getName();
 
+  private static String getPackagePrefix(JClassType classType) {
+    String name = classType.getPackage().getName();
+    return (name.length() == 0) ? name : (name + '.');
+  }
+
   /**
    * Create a new type that satisfies the rebind request.
    */
@@ -81,7 +86,7 @@
 
     // Get the stub class name, and see if its source file exists.
     //
-    String generatedClass = requestedClass.getSimpleSourceName() + "Impl";
+    String generatedClass = requestedClass.getName().replace('.', '_') + "Impl";
     String packageName = requestedClass.getPackage().getName();
     String qualifiedStubClassName = packageName + "." + generatedClass;
 
@@ -89,7 +94,7 @@
         generatedClass, GWT_RUNNER_NAME);
 
     if (sourceWriter != null) {
-      JClassType[] allTestTypes = getAllTestTypes(context.getTypeOracle());
+      JClassType[] allTestTypes = getAllPossibleTestTypes(context.getTypeOracle());
       Set<String> testClasses = getTestTypesForModule(logger, moduleName,
           allTestTypes);
       writeCreateNewTestCaseMethod(testClasses, sourceWriter);
@@ -99,7 +104,7 @@
     return qualifiedStubClassName;
   }
 
-  private JClassType[] getAllTestTypes(TypeOracle typeOracle) {
+  private JClassType[] getAllPossibleTestTypes(TypeOracle typeOracle) {
     JClassType gwtTestType = typeOracle.findType(GWTTestCase.class.getName());
     if (gwtTestType != null) {
       return gwtTestType.getSubtypes();
@@ -133,7 +138,8 @@
         continue;
       }
 
-      String className = classType.getQualifiedSourceName();
+      String className = getPackagePrefix(classType)
+          + classType.getName().replace('.', '$');
 
       try {
         Class<?> testClass = Class.forName(className);
@@ -150,7 +156,7 @@
             e);
         continue;
       }
-      testClasses.add(className);
+      testClasses.add(classType.getQualifiedSourceName());
     }
     return testClasses;
   }