{"action":"created","comment":{"url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/comments/221783982","pull_request_review_id":160482022,"id":221783982,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTc4Mzk4Mg==","diff_hunk":"@@ -625,14 +627,143 @@ JVM_GetClassAnnotations(JNIEnv *env, jclass cls) {\n     JvmUnimplemented(\"JVM_GetClassAnnotations\");\n }\n \n+extern \"C\" {\n+    void Polyglot_java_lang_reflect_Field_Field__Ljava_lang_Class_2Ljava_lang_String_2Ljava_lang_Class_2IILjava_lang_String_2_3B (jobject, jclass, jstring, jclass, jint, jint, jstring, jbyteArray);\n+    void Polyglot_java_lang_reflect_Method_Method__Ljava_lang_Class_2Ljava_lang_String_2_3Ljava_lang_Class_2Ljava_lang_Class_2_3Ljava_lang_Class_2IILjava_lang_String_2_3B_3B_3B (jobject, jclass, jstring, jobjectArray, jclass, jobjectArray, jint, jint, jstring, jbyteArray, jbyteArray, jbyteArray);\n+}\n+\n jobjectArray\n JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly) {\n-    JvmUnimplemented(\"JVM_GetClassDeclaredMethods\");\n+    const JavaClassInfo* info = GetJavaClassInfo(ofClass);\n+    if (info) {\n+        // if primative class (int, boolean), return empty array\n+        if (JVM_IsPrimitiveClass(env, ofClass)) {\n+            return CreateJavaObjectArray(0);\n+        }\n+\n+        jclass MethodClass = env->FindClass(\"java.lang.reflect.Method\");\n+\n+        // TODO take into account publiconly argument\n+\n+        jobjectArray ret = CreateJavaObjectArray(info->num_methods);\n+\n+        JavaMethodInfo* methods = info->methods;\n+\n+        for (int i = 0; i < info->num_methods; i++) {\n+            // create new field object\n+            jobject newMethod = CreateJavaObject(MethodClass);\n+            jstring nameString = env->NewStringUTF(methods[i].name);\n+            // TODO need to get the proper values\n+            // call the method constructor\n+            Polyglot_java_lang_reflect_Method_Method__Ljava_lang_Class_2Ljava_lang_String_2_3Ljava_lang_Class_2Ljava_lang_Class_2_3Ljava_lang_Class_2IILjava_lang_String_2_3B_3B_3B(newMethod, NULL, nameString, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL);\n+            // add it to the array\n+            JVM_SetArrayElement(env, ret, i, newMethod);\n+        }\n+\n+        return ret;\n+    }\n+    return NULL;\n }\n \n jobjectArray\n JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly) {\n-    JvmUnimplemented(\"JVM_GetClassDeclaredFields\");\n+    const JavaClassInfo* info = GetJavaClassInfo(ofClass);\n+    if (info) {\n+        // if primative class (int, boolean), return empty array\n+        if (JVM_IsPrimitiveClass(env, ofClass)) {\n+            return CreateJavaObjectArray(0);\n+        }\n+\n+        jclass FieldsClass = env->FindClass(\"java.lang.reflect.Field\");\n+        // jclass ClassClass = env->FindClass(\"java.lang.Class\");\n+        // const JavaClassInfo* classInfo = GetJavaClassInfo(ClassClass);\n+        // printf(\"class size: %d\\n\", classInfo->obj_size);\n+\n+        // dw475 TODO take into account publiconly argument\n+        // dw475 TODO take super fields into account\n+\n+        // non-static and static fields\n+        jobjectArray ret = CreateJavaObjectArray(info->num_fields + info->num_static_fields);\n+\n+        JavaFieldInfo* fields = info->fields;\n+        JavaStaticFieldInfo* staticFields = info->static_fields;\n+\n+        for (int i = 0; i < info->num_fields+info->num_static_fields; i++) {\n+            // create new field object\n+            jobject newField = CreateJavaObject(FieldsClass);\n+\n+            // // using a Field Struct","path":"runtime/native/jvm.cpp","position":91,"original_position":91,"commit_id":"e8839be1dca95cb2f9e403a2ae50adcd85206dd3","original_commit_id":"e8839be1dca95cb2f9e403a2ae50adcd85206dd3","user":{"login":"dz333","id":33325177,"node_id":"MDQ6VXNlcjMzMzI1MTc3","avatar_url":"https://avatars0.githubusercontent.com/u/33325177?v=4","gravatar_id":"","url":"https://api.github.com/users/dz333","html_url":"https://github.com/dz333","followers_url":"https://api.github.com/users/dz333/followers","following_url":"https://api.github.com/users/dz333/following{/other_user}","gists_url":"https://api.github.com/users/dz333/gists{/gist_id}","starred_url":"https://api.github.com/users/dz333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dz333/subscriptions","organizations_url":"https://api.github.com/users/dz333/orgs","repos_url":"https://api.github.com/users/dz333/repos","events_url":"https://api.github.com/users/dz333/events{/privacy}","received_events_url":"https://api.github.com/users/dz333/received_events","type":"User","site_admin":false},"body":"This large commented section is to show how this would be done without calling in to Java code right?\r\nMaybe elaborate on the 'using a Field Struct' comment to make that clearer.\r\n\r\nMaybe even add an issue related to performance which says that we should do evaluations of these two approaches.","created_at":"2018-10-01T23:06:20Z","updated_at":"2018-10-01T23:35:21Z","html_url":"https://github.com/polyglot-compiler/JLang/pull/32#discussion_r221783982","pull_request_url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/comments/221783982"},"html":{"href":"https://github.com/polyglot-compiler/JLang/pull/32#discussion_r221783982"},"pull_request":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32","id":219119494,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MTE5NDk0","html_url":"https://github.com/polyglot-compiler/JLang/pull/32","diff_url":"https://github.com/polyglot-compiler/JLang/pull/32.diff","patch_url":"https://github.com/polyglot-compiler/JLang/pull/32.patch","issue_url":"https://api.github.com/repos/polyglot-compiler/JLang/issues/32","number":32,"state":"open","locked":false,"title":"Reflection additions","user":{"login":"Dan12","id":4943443,"node_id":"MDQ6VXNlcjQ5NDM0NDM=","avatar_url":"https://avatars1.githubusercontent.com/u/4943443?v=4","gravatar_id":"","url":"https://api.github.com/users/Dan12","html_url":"https://github.com/Dan12","followers_url":"https://api.github.com/users/Dan12/followers","following_url":"https://api.github.com/users/Dan12/following{/other_user}","gists_url":"https://api.github.com/users/Dan12/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan12/subscriptions","organizations_url":"https://api.github.com/users/Dan12/orgs","repos_url":"https://api.github.com/users/Dan12/repos","events_url":"https://api.github.com/users/Dan12/events{/privacy}","received_events_url":"https://api.github.com/users/Dan12/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-29T02:29:29Z","updated_at":"2018-10-01T23:35:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a3bd8e0ac8a0fe92ae568100546d51f03f582dd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32/commits","review_comments_url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32/comments","review_comment_url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/polyglot-compiler/JLang/issues/32/comments","statuses_url":"https://api.github.com/repos/polyglot-compiler/JLang/statuses/e8839be1dca95cb2f9e403a2ae50adcd85206dd3","head":{"label":"Dan12:reflection_additions","ref":"reflection_additions","sha":"e8839be1dca95cb2f9e403a2ae50adcd85206dd3","user":{"login":"Dan12","id":4943443,"node_id":"MDQ6VXNlcjQ5NDM0NDM=","avatar_url":"https://avatars1.githubusercontent.com/u/4943443?v=4","gravatar_id":"","url":"https://api.github.com/users/Dan12","html_url":"https://github.com/Dan12","followers_url":"https://api.github.com/users/Dan12/followers","following_url":"https://api.github.com/users/Dan12/following{/other_user}","gists_url":"https://api.github.com/users/Dan12/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan12/subscriptions","organizations_url":"https://api.github.com/users/Dan12/orgs","repos_url":"https://api.github.com/users/Dan12/repos","events_url":"https://api.github.com/users/Dan12/events{/privacy}","received_events_url":"https://api.github.com/users/Dan12/received_events","type":"User","site_admin":false},"repo":{"id":150814846,"node_id":"MDEwOlJlcG9zaXRvcnkxNTA4MTQ4NDY=","name":"JLang","full_name":"Dan12/JLang","private":false,"owner":{"login":"Dan12","id":4943443,"node_id":"MDQ6VXNlcjQ5NDM0NDM=","avatar_url":"https://avatars1.githubusercontent.com/u/4943443?v=4","gravatar_id":"","url":"https://api.github.com/users/Dan12","html_url":"https://github.com/Dan12","followers_url":"https://api.github.com/users/Dan12/followers","following_url":"https://api.github.com/users/Dan12/following{/other_user}","gists_url":"https://api.github.com/users/Dan12/gists{/gist_id}","starred_url":"https://api.github.com/users/Dan12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dan12/subscriptions","organizations_url":"https://api.github.com/users/Dan12/orgs","repos_url":"https://api.github.com/users/Dan12/repos","events_url":"https://api.github.com/users/Dan12/events{/privacy}","received_events_url":"https://api.github.com/users/Dan12/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Dan12/JLang","description":"JLang adds an LLVM back end to the Polyglot compiler, translating Java ASTs into LLVM IR.","fork":true,"url":"https://api.github.com/repos/Dan12/JLang","forks_url":"https://api.github.com/repos/Dan12/JLang/forks","keys_url":"https://api.github.com/repos/Dan12/JLang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dan12/JLang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dan12/JLang/teams","hooks_url":"https://api.github.com/repos/Dan12/JLang/hooks","issue_events_url":"https://api.github.com/repos/Dan12/JLang/issues/events{/number}","events_url":"https://api.github.com/repos/Dan12/JLang/events","assignees_url":"https://api.github.com/repos/Dan12/JLang/assignees{/user}","branches_url":"https://api.github.com/repos/Dan12/JLang/branches{/branch}","tags_url":"https://api.github.com/repos/Dan12/JLang/tags","blobs_url":"https://api.github.com/repos/Dan12/JLang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dan12/JLang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dan12/JLang/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dan12/JLang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dan12/JLang/statuses/{sha}","languages_url":"https://api.github.com/repos/Dan12/JLang/languages","stargazers_url":"https://api.github.com/repos/Dan12/JLang/stargazers","contributors_url":"https://api.github.com/repos/Dan12/JLang/contributors","subscribers_url":"https://api.github.com/repos/Dan12/JLang/subscribers","subscription_url":"https://api.github.com/repos/Dan12/JLang/subscription","commits_url":"https://api.github.com/repos/Dan12/JLang/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dan12/JLang/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dan12/JLang/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dan12/JLang/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dan12/JLang/contents/{+path}","compare_url":"https://api.github.com/repos/Dan12/JLang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dan12/JLang/merges","archive_url":"https://api.github.com/repos/Dan12/JLang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dan12/JLang/downloads","issues_url":"https://api.github.com/repos/Dan12/JLang/issues{/number}","pulls_url":"https://api.github.com/repos/Dan12/JLang/pulls{/number}","milestones_url":"https://api.github.com/repos/Dan12/JLang/milestones{/number}","notifications_url":"https://api.github.com/repos/Dan12/JLang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dan12/JLang/labels{/name}","releases_url":"https://api.github.com/repos/Dan12/JLang/releases{/id}","deployments_url":"https://api.github.com/repos/Dan12/JLang/deployments","created_at":"2018-09-29T02:18:10Z","updated_at":"2018-09-29T02:18:13Z","pushed_at":"2018-09-30T21:12:20Z","git_url":"git://github.com/Dan12/JLang.git","ssh_url":"git@github.com:Dan12/JLang.git","clone_url":"https://github.com/Dan12/JLang.git","svn_url":"https://github.com/Dan12/JLang","homepage":"http://polyglot-compiler.github.io/JLang/","size":147020,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"polyglot-compiler:master","ref":"master","sha":"92a9e78f7d62f2b857662604c800c5a2f0e282a8","user":{"login":"polyglot-compiler","id":7002073,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcwMDIwNzM=","avatar_url":"https://avatars1.githubusercontent.com/u/7002073?v=4","gravatar_id":"","url":"https://api.github.com/users/polyglot-compiler","html_url":"https://github.com/polyglot-compiler","followers_url":"https://api.github.com/users/polyglot-compiler/followers","following_url":"https://api.github.com/users/polyglot-compiler/following{/other_user}","gists_url":"https://api.github.com/users/polyglot-compiler/gists{/gist_id}","starred_url":"https://api.github.com/users/polyglot-compiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyglot-compiler/subscriptions","organizations_url":"https://api.github.com/users/polyglot-compiler/orgs","repos_url":"https://api.github.com/users/polyglot-compiler/repos","events_url":"https://api.github.com/users/polyglot-compiler/events{/privacy}","received_events_url":"https://api.github.com/users/polyglot-compiler/received_events","type":"Organization","site_admin":false},"repo":{"id":145621595,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU2MjE1OTU=","name":"JLang","full_name":"polyglot-compiler/JLang","private":false,"owner":{"login":"polyglot-compiler","id":7002073,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcwMDIwNzM=","avatar_url":"https://avatars1.githubusercontent.com/u/7002073?v=4","gravatar_id":"","url":"https://api.github.com/users/polyglot-compiler","html_url":"https://github.com/polyglot-compiler","followers_url":"https://api.github.com/users/polyglot-compiler/followers","following_url":"https://api.github.com/users/polyglot-compiler/following{/other_user}","gists_url":"https://api.github.com/users/polyglot-compiler/gists{/gist_id}","starred_url":"https://api.github.com/users/polyglot-compiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyglot-compiler/subscriptions","organizations_url":"https://api.github.com/users/polyglot-compiler/orgs","repos_url":"https://api.github.com/users/polyglot-compiler/repos","events_url":"https://api.github.com/users/polyglot-compiler/events{/privacy}","received_events_url":"https://api.github.com/users/polyglot-compiler/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/polyglot-compiler/JLang","description":"JLang adds an LLVM back end to the Polyglot compiler, translating Java ASTs into LLVM IR.","fork":false,"url":"https://api.github.com/repos/polyglot-compiler/JLang","forks_url":"https://api.github.com/repos/polyglot-compiler/JLang/forks","keys_url":"https://api.github.com/repos/polyglot-compiler/JLang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/polyglot-compiler/JLang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/polyglot-compiler/JLang/teams","hooks_url":"https://api.github.com/repos/polyglot-compiler/JLang/hooks","issue_events_url":"https://api.github.com/repos/polyglot-compiler/JLang/issues/events{/number}","events_url":"https://api.github.com/repos/polyglot-compiler/JLang/events","assignees_url":"https://api.github.com/repos/polyglot-compiler/JLang/assignees{/user}","branches_url":"https://api.github.com/repos/polyglot-compiler/JLang/branches{/branch}","tags_url":"https://api.github.com/repos/polyglot-compiler/JLang/tags","blobs_url":"https://api.github.com/repos/polyglot-compiler/JLang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/polyglot-compiler/JLang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/polyglot-compiler/JLang/git/refs{/sha}","trees_url":"https://api.github.com/repos/polyglot-compiler/JLang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/polyglot-compiler/JLang/statuses/{sha}","languages_url":"https://api.github.com/repos/polyglot-compiler/JLang/languages","stargazers_url":"https://api.github.com/repos/polyglot-compiler/JLang/stargazers","contributors_url":"https://api.github.com/repos/polyglot-compiler/JLang/contributors","subscribers_url":"https://api.github.com/repos/polyglot-compiler/JLang/subscribers","subscription_url":"https://api.github.com/repos/polyglot-compiler/JLang/subscription","commits_url":"https://api.github.com/repos/polyglot-compiler/JLang/commits{/sha}","git_commits_url":"https://api.github.com/repos/polyglot-compiler/JLang/git/commits{/sha}","comments_url":"https://api.github.com/repos/polyglot-compiler/JLang/comments{/number}","issue_comment_url":"https://api.github.com/repos/polyglot-compiler/JLang/issues/comments{/number}","contents_url":"https://api.github.com/repos/polyglot-compiler/JLang/contents/{+path}","compare_url":"https://api.github.com/repos/polyglot-compiler/JLang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/polyglot-compiler/JLang/merges","archive_url":"https://api.github.com/repos/polyglot-compiler/JLang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/polyglot-compiler/JLang/downloads","issues_url":"https://api.github.com/repos/polyglot-compiler/JLang/issues{/number}","pulls_url":"https://api.github.com/repos/polyglot-compiler/JLang/pulls{/number}","milestones_url":"https://api.github.com/repos/polyglot-compiler/JLang/milestones{/number}","notifications_url":"https://api.github.com/repos/polyglot-compiler/JLang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/polyglot-compiler/JLang/labels{/name}","releases_url":"https://api.github.com/repos/polyglot-compiler/JLang/releases{/id}","deployments_url":"https://api.github.com/repos/polyglot-compiler/JLang/deployments","created_at":"2018-08-21T21:29:33Z","updated_at":"2018-09-06T22:37:12Z","pushed_at":"2018-09-30T21:12:21Z","git_url":"git://github.com/polyglot-compiler/JLang.git","ssh_url":"git@github.com:polyglot-compiler/JLang.git","clone_url":"https://github.com/polyglot-compiler/JLang.git","svn_url":"https://github.com/polyglot-compiler/JLang","homepage":"http://polyglot-compiler.github.io/JLang/","size":146985,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1,"open_issues":32,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32"},"html":{"href":"https://github.com/polyglot-compiler/JLang/pull/32"},"issue":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/issues/32"},"comments":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/polyglot-compiler/JLang/statuses/e8839be1dca95cb2f9e403a2ae50adcd85206dd3"}},"author_association":"NONE"}}
{"actor":{"display_login":"dz333"}}