Skip to content

Instantly share code, notes, and snippets.

@olafleur
Created February 1, 2016 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olafleur/16bbafe6babd7ddc5bf8 to your computer and use it in GitHub Desktop.
Save olafleur/16bbafe6babd7ddc5bf8 to your computer and use it in GitHub Desktop.
// in JavaScript
com = { acme: {} };
com.acme.Foo = function() {
this.x = 40;
this.y = 2;
};
com.acme.Foo.prototype.sum = function() { return this.x + this.y; };
// in Java
package com.acme;
@JsType(isNative = true)
class Foo {
public int x;
public int y;
public native int sum();
}
class FooMain {
public static void main() {
Foo foo = new Foo();
foo.sum(); // will return 42!
foo.x = 50;
foo.y = 5;
foo.sum(); // will return 55!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment