{"action":"created","comment":{"url":"https://api.github.com/repos/square/duktape-android/pulls/comments/56767951","id":56767951,"diff_hunk":"@@ -10,12 +10,60 @@ Usage\n ```java\n Duktape duktape = Duktape.create();\n try {\n-  Log.d(\"Greeting\", duktape.evaluate(\"'hello world'.toUpperCase();\"));\n+    Log.d(\"Greeting\", duktape.evaluate(\"'hello world'.toUpperCase();\"));\n } finally {\n-  duktape.close();\n+    duktape.close();\n }\n ```\n \n+## Calling Java from Javascript\n+\n+You can bind a Java object to a Javascript global, and call Java functions from Javascript!\n+Currently, the following Java types are supported for function arguments and return values:\n+\n+ * `boolean` and `Boolean`\n+ * `int` and `Integer`\n+ * `double` and `Double`\n+ * `String`\n+\n+`void` return values are also supported.\n+\n+### Example\n+\n+First, define a Java interface that declares the methods you would like to call from Javascript:\n+\n+```java\n+interface PersonInterface {\n+    String getName();\n+}\n+```\n+\n+Next, implement the interface in Java code:\n+\n+```java\n+class Person implements PersonInterface {","path":"README.md","position":37,"original_position":37,"commit_id":"db89a628f67346d46dce8bcecd255ed72a9adf1a","original_commit_id":"db89a628f67346d46dce8bcecd255ed72a9adf1a","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars.githubusercontent.com/u/133019?v=3","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"Nit: is there a more plausible example? Something to get people’s minds racing at the possibilities? \r\nOne fun option: rather than returning a constant string, you could prompt for one with `java.io.Console` ?","created_at":"2016-03-20T17:17:21Z","updated_at":"2016-03-20T17:17:21Z","html_url":"https://github.com/square/duktape-android/pull/42#discussion_r56767951","pull_request_url":"https://api.github.com/repos/square/duktape-android/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/square/duktape-android/pulls/comments/56767951"},"html":{"href":"https://github.com/square/duktape-android/pull/42#discussion_r56767951"},"pull_request":{"href":"https://api.github.com/repos/square/duktape-android/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/square/duktape-android/pulls/42","id":63496927,"html_url":"https://github.com/square/duktape-android/pull/42","diff_url":"https://github.com/square/duktape-android/pull/42.diff","patch_url":"https://github.com/square/duktape-android/pull/42.patch","issue_url":"https://api.github.com/repos/square/duktape-android/issues/42","number":42,"state":"open","locked":false,"title":"Update README with an example of calling Java.","user":{"login":"szurbrigg","id":13789594,"avatar_url":"https://avatars.githubusercontent.com/u/13789594?v=3","gravatar_id":"","url":"https://api.github.com/users/szurbrigg","html_url":"https://github.com/szurbrigg","followers_url":"https://api.github.com/users/szurbrigg/followers","following_url":"https://api.github.com/users/szurbrigg/following{/other_user}","gists_url":"https://api.github.com/users/szurbrigg/gists{/gist_id}","starred_url":"https://api.github.com/users/szurbrigg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szurbrigg/subscriptions","organizations_url":"https://api.github.com/users/szurbrigg/orgs","repos_url":"https://api.github.com/users/szurbrigg/repos","events_url":"https://api.github.com/users/szurbrigg/events{/privacy}","received_events_url":"https://api.github.com/users/szurbrigg/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-20T14:33:23Z","updated_at":"2016-03-20T17:17:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff24df873c267aa3959bcebf22736d7b1ad08e85","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/duktape-android/pulls/42/commits","review_comments_url":"https://api.github.com/repos/square/duktape-android/pulls/42/comments","review_comment_url":"https://api.github.com/repos/square/duktape-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/duktape-android/issues/42/comments","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/db89a628f67346d46dce8bcecd255ed72a9adf1a","head":{"label":"square:szurbrigg/update-readme-for-java-ffi","ref":"szurbrigg/update-readme-for-java-ffi","sha":"db89a628f67346d46dce8bcecd255ed72a9adf1a","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":41445081,"name":"duktape-android","full_name":"square/duktape-android","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/duktape-android","description":"The Duktape embeddable Javascript engine packaged for Android.","fork":false,"url":"https://api.github.com/repos/square/duktape-android","forks_url":"https://api.github.com/repos/square/duktape-android/forks","keys_url":"https://api.github.com/repos/square/duktape-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/duktape-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/duktape-android/teams","hooks_url":"https://api.github.com/repos/square/duktape-android/hooks","issue_events_url":"https://api.github.com/repos/square/duktape-android/issues/events{/number}","events_url":"https://api.github.com/repos/square/duktape-android/events","assignees_url":"https://api.github.com/repos/square/duktape-android/assignees{/user}","branches_url":"https://api.github.com/repos/square/duktape-android/branches{/branch}","tags_url":"https://api.github.com/repos/square/duktape-android/tags","blobs_url":"https://api.github.com/repos/square/duktape-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/duktape-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/duktape-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/duktape-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/{sha}","languages_url":"https://api.github.com/repos/square/duktape-android/languages","stargazers_url":"https://api.github.com/repos/square/duktape-android/stargazers","contributors_url":"https://api.github.com/repos/square/duktape-android/contributors","subscribers_url":"https://api.github.com/repos/square/duktape-android/subscribers","subscription_url":"https://api.github.com/repos/square/duktape-android/subscription","commits_url":"https://api.github.com/repos/square/duktape-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/duktape-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/duktape-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/duktape-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/duktape-android/contents/{+path}","compare_url":"https://api.github.com/repos/square/duktape-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/duktape-android/merges","archive_url":"https://api.github.com/repos/square/duktape-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/duktape-android/downloads","issues_url":"https://api.github.com/repos/square/duktape-android/issues{/number}","pulls_url":"https://api.github.com/repos/square/duktape-android/pulls{/number}","milestones_url":"https://api.github.com/repos/square/duktape-android/milestones{/number}","notifications_url":"https://api.github.com/repos/square/duktape-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/duktape-android/labels{/name}","releases_url":"https://api.github.com/repos/square/duktape-android/releases{/id}","deployments_url":"https://api.github.com/repos/square/duktape-android/deployments","created_at":"2015-08-26T19:17:25Z","updated_at":"2016-03-19T14:09:59Z","pushed_at":"2016-03-20T14:33:23Z","git_url":"git://github.com/square/duktape-android.git","ssh_url":"git@github.com:square/duktape-android.git","clone_url":"https://github.com/square/duktape-android.git","svn_url":"https://github.com/square/duktape-android","homepage":"","size":2530,"stargazers_count":257,"watchers_count":257,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":3,"forks":13,"open_issues":3,"watchers":257,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"182d3dfb951d07df8a797dcaa29f40110d0e112e","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":41445081,"name":"duktape-android","full_name":"square/duktape-android","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/duktape-android","description":"The Duktape embeddable Javascript engine packaged for Android.","fork":false,"url":"https://api.github.com/repos/square/duktape-android","forks_url":"https://api.github.com/repos/square/duktape-android/forks","keys_url":"https://api.github.com/repos/square/duktape-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/duktape-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/duktape-android/teams","hooks_url":"https://api.github.com/repos/square/duktape-android/hooks","issue_events_url":"https://api.github.com/repos/square/duktape-android/issues/events{/number}","events_url":"https://api.github.com/repos/square/duktape-android/events","assignees_url":"https://api.github.com/repos/square/duktape-android/assignees{/user}","branches_url":"https://api.github.com/repos/square/duktape-android/branches{/branch}","tags_url":"https://api.github.com/repos/square/duktape-android/tags","blobs_url":"https://api.github.com/repos/square/duktape-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/duktape-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/duktape-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/duktape-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/duktape-android/statuses/{sha}","languages_url":"https://api.github.com/repos/square/duktape-android/languages","stargazers_url":"https://api.github.com/repos/square/duktape-android/stargazers","contributors_url":"https://api.github.com/repos/square/duktape-android/contributors","subscribers_url":"https://api.github.com/repos/square/duktape-android/subscribers","subscription_url":"https://api.github.com/repos/square/duktape-android/subscription","commits_url":"https://api.github.com/repos/square/duktape-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/duktape-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/duktape-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/duktape-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/duktape-android/contents/{+path}","compare_url":"https://api.github.com/repos/square/duktape-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/duktape-android/merges","archive_url":"https://api.github.com/repos/square/duktape-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/duktape-android/downloads","issues_url":"https://api.github.com/repos/square/duktape-android/issues{/number}","pulls_url":"https://api.github.com/repos/square/duktape-android/pulls{/number}","milestones_url":"https://api.github.com/repos/square/duktape-android/milestones{/number}","notifications_url":"https://api.github.com/repos/square/duktape-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/duktape-android/labels{/name}","releases_url":"https://api.github.com/repos/square/duktape-android/releases{/id}","deployments_url":"https://api.github.com/repos/square/duktape-android/deployments","created_at":"2015-08-26T19:17:25Z","updated_at":"2016-03-19T14:09:59Z","pushed_at":"2016-03-20T14:33:23Z","git_url":"git://github.com/square/duktape-android.git","ssh_url":"git@github.com:square/duktape-android.git","clone_url":"https://github.com/square/duktape-android.git","svn_url":"https://github.com/square/duktape-android","homepage":"","size":2530,"stargazers_count":257,"watchers_count":257,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":3,"forks":13,"open_issues":3,"watchers":257,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/duktape-android/pulls/42"},"html":{"href":"https://github.com/square/duktape-android/pull/42"},"issue":{"href":"https://api.github.com/repos/square/duktape-android/issues/42"},"comments":{"href":"https://api.github.com/repos/square/duktape-android/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/square/duktape-android/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/square/duktape-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/duktape-android/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/square/duktape-android/statuses/db89a628f67346d46dce8bcecd255ed72a9adf1a"}}}}