Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:56:19+00:00 2026-06-14T14:56:19+00:00

I am going to file this as a bug report, but I wanted to

  • 0

I am going to file this as a bug report, but I wanted to check if someone here can see something wrong with what I am doing.

When you expose an instance method from a GWT class through JSNI, this works as expected in JavaScript. Since we are cross compiling Java, I would instead expect this to be bound to the instance automatically. For example:

package com.test;
class Foo {

    public void instanceFunction() {
        this.otherFunction() // will cause an error when called from JSNI!
    }

    public void otherFunction() {
        // does some stuff
    }

    public native JavaScriptObject getInstanceFunction() /*-{
        return this.@com.test.Foo::instanceFunction();
    }-*/;

}

Currently the workaround is to bind the function yourself (not very portable):

    public native JavaScriptObject getInstanceFunction() /*-{
        return this.@com.test.Foo::instanceFunction().bind(this);
    }-*/;

This can also be seen as preference, some may prefer that the functions remain unbound. I would say the current functionality is unintuitave and unnecessary. I cannot imagine a use case for having an unbound this directly in Java code. Also, some browsers do not implement bind(1), so my workaround is not robust.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:56:20+00:00Added an answer on June 14, 2026 at 2:56 pm

    If you want a portable bind, it’s as easy as:

    var that = this;
    return $entry(function() {
       return that.@com.test.Foo::instanceFunction()();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was going to file a bug against GCC, but then realized that if
Before I have the audacity to file a bug report, I thought I'd check
This bug is befuddling to me, but here goes: I was trying to set
I want to convert vb this code <?php // Where the file is going
So I have a simple setup going here where I load up a file
Hi I know that this error which I'm going to show can't be fixed
Note: Visual Studio 2010 SP1 / MSBuild 4.0 I'm going crazy over this bug,
I can't figure out what's going on here. Where does the 8 below come
UPDATE: See my answer to this question first. This appears to be a bug.
I have no idea what's going on here. I'm using R2006b. Any chance someone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.