GWT problem with calling Java methods from JSNI


I tried the example from google at this page: <a href="http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=DevGuideJavaFromJavaScript" rel="nofollow">http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=DevGuideJavaFromJavaScript</a>

I want to be able to call a Java method from JSNI, but nothing happens. No errors but the methods are not called. However, I can modify the fields from my class.

Here is the code I tried:

package com.jsni.client; import com.google.gwt.core.client.EntryPoint; public class Testjsnii implements EntryPoint { String myInstanceField; static int myStaticField; void instanceFoo(String s) { System.out.println(s); } static void staticFoo(String s) { System.out.println(s); } public native void bar(Testjsnii x, String s) /*-{ this.@com.jsni.client.Testjsnii::instanceFoo(Ljava/lang/String;)(s); x.@com.jsni.client.Testjsnii::instanceFoo(Ljava/lang/String;)(s); @com.jsni.client.Testjsnii::staticFoo(Ljava/lang/String;)(s); var val = this.@com.jsni.client.Testjsnii::myInstanceField; }-*/; public void onModuleLoad() { bar(this,"Hello"); } }

It prints nothing on the console but only a waring that says:


[WARN] [testjsnii] - JSNI method '@com.jsni.client.Testjsnii::bar(Lcom/jsni/client/Testjsnii;Ljava/lang/String;)' returned > a value of type JavaScript object(1) but was declared void; it should not have returned a > value at all


I wonder what is the problem.

Thanks for the help.


You're actually running into a Chrome (10-dev) issue with the GWT DevMode plugin: <a href="http://code.google.com/p/google-web-toolkit/issues/detail?id=5778" rel="nofollow">http://code.google.com/p/google-web-toolkit/issues/detail?id=5778</a>


  • Call Java from Javascript JSNI
  • GWT: FileUpload Browse Button styling
  • How can I connect GWT to CometD/Bayeux events?
  • entrypoint file not found
  • Change GWT project to Maven Project
  • GWT listbox - how to look up item index using text?
  • How do I add MouseEvents to an AbsolutePanel?
  • gwt-exporter doesn't generate code (Java to Javascript)
  • GWT and JSNI add Javascript button into HTML panel
  • GWT 2.3 dev mode - Hosted mode JSP compilation appears to not use java 1.5 compatibility
  • Attempted to read or write protected memory with dllimport in c#
  • Polymer build not to create bundled and unbundled folder
  • where do I find the xml.dom python package for the python-2.6.0-8.9.28 and I have a suse/x86_64 vers
  • Angular2 component view does not update on value change via method
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • Read text file that is not in the main package in a runnable jar
  • Roxygen error “Skipping invalid path”
  • CakePHP ACL tutorial initDB function warnings
  • Spring Cloud Microservice Architecture Confusion
  • Transactional Create with Validation in ServiceStack Redis Client
  • Handling un-mapped Rest path
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • PHP - How to update data to MySQL when click a radio button
  • Can Jackson SerializationFeature be overridden per field or class?
  • sending/ receiving email in Java
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • SetUp method failed while running tests from teamcity
  • How to delete a row from a dynamic generate table using jquery?
  • Python: how to group similar lists together in a list of lists?
  • Proper way to use connect-multiparty with express.js?
  • Understanding cpu registers
  • how does django model after text[] in postgresql [duplicate]
  • Java static initializers and reflection
  • unknown Exception android
  • Checking variable from a different class in C#
  • Busy indicator not showing up in wpf window [duplicate]
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app