Ensure that class literals whose classes are pruned yield class names based on hashcode to maintain existing behavior for some legacy apps.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10465 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java b/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
index 0594d53..136f558 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
@@ -207,6 +207,9 @@
@Override
public void endVisit(JSeedIdOf x, Context ctx) {
+ if (x.getNode() instanceof JClassType) {
+ endVisit((JNameOf) x, ctx);
+ }
}
@Override
diff --git a/user/super/com/google/gwt/emul/java/lang/Class.java b/user/super/com/google/gwt/emul/java/lang/Class.java
index b2413ec..8db8ead 100644
--- a/user/super/com/google/gwt/emul/java/lang/Class.java
+++ b/user/super/com/google/gwt/emul/java/lang/Class.java
@@ -32,7 +32,7 @@
static native String asString(int number) /*-{
// for primitives, the seedId isn't a number, but a string like ' Z'
- return typeof(number) == 'number' ? "S" + (number < -1 ? -number : number): number;
+ return typeof(number) == 'number' ? "S" + (number < 0 ? -number : number) : number;
}-*/;
/**
@@ -44,7 +44,7 @@
int seedId, Class<?> componentType) {
// Initialize here to avoid method inliner
Class<T> clazz = new Class<T>();
- setName(clazz, packageName, className, seedId != -1 ? -seedId : -1);
+ setName(clazz, packageName, className, seedId != 0 ? -seedId : 0);
clazz.modifiers = ARRAY;
clazz.superclass = Object.class;
clazz.componentType = componentType;
@@ -91,7 +91,7 @@
static <T> Class<T> createForInterface(String packageName, String className) {
// Initialize here to avoid method inliner
Class<T> clazz = new Class<T>();
- setName(clazz, packageName, className, -1);
+ setName(clazz, packageName, className, 0);
clazz.modifiers = INTERFACE;
return clazz;
}
@@ -125,10 +125,17 @@
}
/**
- * null or -1 implies lack of seed function / non-instantiable type
+ * null or 0 implies lack of seed function / non-instantiable type
*/
static native boolean isInstantiable(int seedId) /*-{
- return seedId != null && typeof (seedId) == 'number' && seedId > -1;
+ return typeof (seedId) == 'number' && seedId > 0;
+ }-*/;
+
+ /**
+ * null implies pruned.
+ */
+ static native boolean isInstantiableOrPrimitive(int seedId) /*-{
+ return seedId != null && seedId != 0;
}-*/;
/**
@@ -145,7 +152,7 @@
if (seedId == 2) {
proto = String.prototype
} else {
- if (seedId > -1) {
+ if (seedId > 0) {
// Guarantees virtual method won't be pruned by using a JSNI ref
// This is required because deRPC needs to call it.
var seed = @java.lang.Class::getSeedFunction(Ljava/lang/Class;)(clazz);
@@ -167,6 +174,13 @@
proto.@java.lang.Object::___clazz = clazz;
}-*/;
+ /**
+ * The seedId parameter can take on the following values:
+ * > 0 => type is instantiable class
+ * < 0 => type is instantiable array
+ * null => type is not instantiable
+ * string => type is primitive
+ */
static void setName(Class<?> clazz, String packageName, String className,
int seedId) {
if (clazz.isClassMetadataEnabled()) {
@@ -178,7 +192,7 @@
* during application start up, before class Integer has been initialized.
*/
clazz.typeName = "Class$"
- + (seedId != -1 ? asString(seedId) : asString(clazz.hashCode()));
+ + (isInstantiableOrPrimitive(seedId) ? asString(seedId) : "" + clazz.hashCode());
}
if (isInstantiable(seedId)) {