Friday, September 15, 2017

Re: Data class in JsInterop


What is this all for ? What am I missing? 

You have defined a non-native JsType which means you want to make JsClass usable by external JavaScript (Js that should call into your "Java" code). Thus GWT generates all the code it needs to satisfy Java semantics. Because you have marked the constructor as @JsIgnore the resulting constructor function is obfuscated, only the fields a, b are not obfuscated because they are public and not marked with @JsIgnore. So your JS output contains  

function a3i_g$(a_0_g$, b_0_g$) { //constructor function is obfuscated because of @JsIgnore
 Ezf_g$(); // object initialization (super constructors, static fields / initializer blocks)
 i_g$.call(this); // object initialization (super constructors, static fields / initializer blocks)
 this.$init_1758_g$(); // object initialization (super constructors, static fields / initializer blocks)
 this.a = a_0_g$;  // this.a is not obfuscated
 this.b = b_0_g$;  // this.b is not obfuscated
}


If you don't want that but instead use existing JavaScript through Java then you have to use isNative = true as Vassilis showed.

-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment