Why is there a comment code in my own method?

Recently, I have seen many methods with the keyword "native". It seems very common that it seems to comment on the code .

public native Something Foo(arg, arg) /*-{ var foo = some.Method(arg); return foo; }-*/; 

I really do not understand what the commented part is or why it commented . For quite some time I thought this was just commented code. Now I am starting to see it in more projects (for example, in the gwt source code).

Is the comment code significant, somehow, I don't understand? I read about my native keyword , and I understand what this means and how it is used in the main sense. It's just embarrassing to see this "comment code" so often.

Can someone explain the comments. Do they really comment? Are they significant?

[Update] The question was about comments. I began to see this often enough, I thought that there was some meaning that I was missing. For example, something like annotation. I just wanted to be clear, because sections of the code that were littered with everything were commented out.

+4
source share
2 answers

Since gwt code is compiled into two separate parts: java for the server part and javascript for the client.

Comment syntax in native methods

  /*-{ some javascript code }-*/ 

is a special way to write your own javascript in gwt code.

See JSNI

+5
source

native methods are usually executed in c and are platform dependent. You could see them as links to external libraries. A comment can tell you what this method does.

+2
source

All Articles