Revision: 10465
Author: [email protected]
Date: Wed Jul 27 07:49:34 2011
Log: Ensure that class literals whose classes are pruned yield class
names based on hashcode to maintain existing behavior for some legacy apps.
http://code.google.com/p/google-web-toolkit/source/detail?r=10465
Modified:
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java
/trunk/user/super/com/google/gwt/emul/java/lang/Class.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java Mon Jul 18
14:28:50 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/Pruner.java Wed Jul 27
07:49:34 2011
@@ -207,6 +207,9 @@
@Override
public void endVisit(JSeedIdOf x, Context ctx) {
+ if (x.getNode() instanceof JClassType) {
+ endVisit((JNameOf) x, ctx);
+ }
}
@Override
=======================================
--- /trunk/user/super/com/google/gwt/emul/java/lang/Class.java Mon Jul 18
14:28:50 2011
+++ /trunk/user/super/com/google/gwt/emul/java/lang/Class.java Wed Jul 27
07:49:34 2011
@@ -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,12 +125,19 @@
}
/**
- * 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;
+ }-*/;
+
/**
* Install class literal into seed.prototype.clazz field such that
* Object.getClass() returning this.clazz returns the literal. Also
stores
@@ -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 @@
[email protected]::___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)) {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors