Calling Java methods from inner function of GWT JSNI
===

I'm using W3C Geolocation API in order to retrieve location information within GWT web application. Geolocation API is built the way that callback function gets invoked as soon as location position is retrieved. My current test code looks as follows:


	public native void getCoordinates() /*-{
		function onPositionUpdate(position) {
			var lat = position.coords.latitude;
			var lng = position.coords.longitude;
			var alt = position.coords.altitude;
			
			// not OK,- doesn't get invoked, and function execution stops at this point
            this.@com.test.GpsPanel::testMethod()();
            
            alert("Coordinates retrieved: " + lat + ";" + lng + ";" + alt);
        }
        
        function onPositionUpdateFailed(error) {
        	alert("Some error");
        }
		
        if(navigator.geolocation) {
        	// OK when invoked somewhere here
        	this.@com.test.GpsPanel::testMethod()();
        	
            navigator.geolocation.getCurrentPosition(onPositionUpdate, onPositionUpdateFailed);
        } else {
            alert("Geolocation is not available");
        }
	}-*/;

I'm trying to demonstrate that the method `testMethod` doesn't get invoked from inner method `onPositionUpdate`. Even more: no alert is shown afterwards (it does get shown when testMethod call is removed), but no warnings or errors are found in a log.

My question is: how do I reference this method from the inner function? I have feeling that `this.` is not a correct reference from the inner functions. If Java class cannot be referenced correctly, then what are the possible workarounds? Please note that I cannot pass anything else to function `onPositionUpdate()` as it's a callback function.

Thanks in advance.