Recently, I've seen a lot of methods with the "native" keyword. It seems very common to have, what seems like, commented out code.
public native Something Foo(arg, arg) /*-{
var foo = some.Method(arg);
return foo;
}-*/;
I don't really understand what the commented-out portion is or why it's commented out. For a good while now I've thought that this was just commented out code. I'm starting to see it in more projects now (for instance, it's in the gwt source code).
Is the commented-out code significant in some way I don't understand? I've read about the native keyword, and I understand what it means and how it's used in a basic sense. It's just confusing to see this "commented-out code" so often.
Can someone explain the comments. Are they really comments? Are they significant?
[Update] The question was about the commented out portion. I was starting to see it often enough I thought there was some significance that I was missing. Something like an annotation, for instance. I just wanted to be clear onwhy there were commented out sections of code littered all over.
Because the gwt code is compiled in two distinct part : java for the server part and javascript for the client one.
The comment syntax in native methods
/*-{ some javascript code }-*/
is a gwt specific way to write native javascript in the gwt code.
See JSNI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With