Neseek77 / gwt-ent

Automatically exported from code.google.com/p/gwt-ent
2 stars 1 forks source link

"this$static is undefined" javascript error from compiled code (GWT 2.1) #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
  Hi guys.

 Our team have been using GWT ENT in our enterprise project for months 
now. Before this, non reflectable nature of the compiled code was causing 
long lasting subtle problems. This one has surely solved all of them 
single-handedly. Thanks to you guys :).

 Well, I ran into a problem so I need someone's help. When I updated a
compiler from GWT 2.0.3 to GWT 2.1 RC1. It didn't work. After some homework,
I end up a piece of code that behaves differently in on-browser. 

 Is there any workaround for this now? GWT 2.1 has some sweet 
feature we cannot miss.

What steps will reproduce the problem?

 The code below compiles with both 2.0 and 2.1, works fine in dev-mode,
but GWT 2.1 seems to spit a non-worky Javascript code on browser.

----- CODE ----
ReflectSample.java

---
package org.example.reflect.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.gwtent.reflection.client.ClassType;
import com.gwtent.reflection.client.Constructor;
import com.gwtent.reflection.client.TypeOracle;

public class ReflectSample implements EntryPoint {
    public void onModuleLoad() {
        ClassType classType = TypeOracle.Instance.getClassType( Entity.class);
        Constructor constructor = classType.findConstructor();
        Object e = constructor.newInstance();

        final Label label=new Label();
        label.setText( ((Entity)e).getName());
        RootPanel.get("container").add( label);
    }
}

Entity.java:

---
import com.gwtent.reflection.client.Reflectable;

@Reflectable
public class Entity {

    String name;

    public Entity() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

----- CODE ----

What is the expected output? What do you see instead?

 We got a following Javascript error on Firefox 3.6.  
it's compiled with a "DETAIL" style option.

----- ERROR ----
Error: this$static is undefined
Line: 3397

        function java_util_AbstractHashMap_$get__Ljava_util_AbstractHashMap_2Ljava_lang_Object_2Ljava_lang_Object_2(this$static, key){
==>          return key == 
null?this$static.java_util_AbstractHashMap_nullSlot:key != null && 
key.java_lang_Object_castableTypeMap$ && 
!!key.java_lang_Object_castableTypeMap$[1]?this$static.java_util_AbstractHashMap
_stringMap[$intern_231 + 
com_google_gwt_lang_Cast_dynamicCast__Ljava_lang_Object_2ILjava_lang_Object_2(ke
y, 
1)]:java_util_AbstractHashMap_$getHashValue__Ljava_util_AbstractHashMap_2Ljava_l
ang_Object_2ILjava_lang_Object_2(this$static, key, 
~~com_google_gwt_core_client_JavaScriptObject_hashCode_1_1devirtual$__Ljava_lang
_Object_2I(key));
        }
----- ERROR ----

What version of the product are you using? On what operating system?

GWT 2.1.0 RC1 via Eclipse 3.5 with Google Plugin for Eclipse
GWT-ENT 1.0.0-RC1
FireFox 3.6.11

Please provide any additional information below.

  We also encountered TypeOracleImpl_typeMap missing error in much complecated code. 
But the cause of it also seems to be the error above.

Thanks in advance!

Original issue reported on code.google.com by hyamamot...@gmail.com on 28 Oct 2010 at 9:16

GoogleCodeExporter commented 9 years ago
Thank you very much, I'm facing the same problem as well. I think GWT changed 
the way how to generate code, the worse thing is it's working in DevMode. 

My project need this been fixed before continue as well, I will working on this 
and will let you know the result. Sorry for the inconvenience, hope you can 
find the solution before me :)

Original comment by JamesLuo...@gmail.com on 28 Oct 2010 at 11:26

GoogleCodeExporter commented 9 years ago
I think this is a GWT compiler bug, I logged a issue for them any way, you can 
find it here: http://code.google.com/p/google-web-toolkit/issues/detail?id=5505

My temporary solution is create a new package in your project and named it 
"com.gwtent.client.reflection.impl", and put the file I attached in, that 
should fix your problem.

I noticed our new GWTENT didn't have this problem, if you only using 
"Reflection" in GWTENT, you can upgrade to this version, only problem is all 
package name are changed. the donwload link: 
http://gwt-ent.googlecode.com/svn/trunk/gwtent/target/gwtent.jar, and remember 
change your inherited module to "<inherits 
name="com.gwtent.reflection.Reflection"/>"

Original comment by JamesLuo...@gmail.com on 29 Oct 2010 at 12:21

Attachments:

GoogleCodeExporter commented 9 years ago
 Al'right, the main problem has gone! There were still a couple of things I had to change and patch the GWT and our code base to compiles them right. Those were mainly from the compiler's handling of generics generated by gwt-ent and from broken GWT 2.1 RC1 compiler. Avoiding them was pretty easy, tho. Link: http://code.google.com/p/gwt-ent/issues/detail?id=35 . I'll file a bug for GWT when I recreate any test case for them.

Environment:
  GWT2.1 RC1
  GWT ENT (svn trunk 20100907) no patch with "Reflection" module

Thanko-!

Original comment by hyamamot...@gmail.com on 30 Oct 2010 at 2:06