{"action":"created","issue":{"url":"https://api.github.com/repos/Samsung/GearVRf/issues/33","labels_url":"https://api.github.com/repos/Samsung/GearVRf/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/Samsung/GearVRf/issues/33/comments","events_url":"https://api.github.com/repos/Samsung/GearVRf/issues/33/events","html_url":"https://github.com/Samsung/GearVRf/pull/33","id":71754695,"number":33,"title":"Introduce class Preconditions and restructure some parameter checks in G...","user":{"login":"chenchao1407","id":9201145,"avatar_url":"https://avatars.githubusercontent.com/u/9201145?v=3","gravatar_id":"","url":"https://api.github.com/users/chenchao1407","html_url":"https://github.com/chenchao1407","followers_url":"https://api.github.com/users/chenchao1407/followers","following_url":"https://api.github.com/users/chenchao1407/following{/other_user}","gists_url":"https://api.github.com/users/chenchao1407/gists{/gist_id}","starred_url":"https://api.github.com/users/chenchao1407/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenchao1407/subscriptions","organizations_url":"https://api.github.com/users/chenchao1407/orgs","repos_url":"https://api.github.com/users/chenchao1407/repos","events_url":"https://api.github.com/users/chenchao1407/events{/privacy}","received_events_url":"https://api.github.com/users/chenchao1407/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-04-29T01:40:45Z","updated_at":"2015-05-01T00:35:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Samsung/GearVRf/pulls/33","html_url":"https://github.com/Samsung/GearVRf/pull/33","diff_url":"https://github.com/Samsung/GearVRf/pull/33.diff","patch_url":"https://github.com/Samsung/GearVRf/pull/33.patch"},"body":"...VRMesh, GVRMaterial, and GVRCameraRig\r\n\r\nOne of our goal is to provide Java side exception as possible as we can while in the illegal states.\r\nPreviously I impelment a GVRJniException class which can simulate Java stack trace and throw a JNI crash finally.I am thinking if we should avoid using this class as possible as we can. So for the readability and further robustness in GVRF, I want to introduce the class Preconditions and provide some convenient pre-condition check at Java level so that we can avoid using GVRJniException when crash happens in JNI side.\r\n\r\nBut I think the use of Preconditions may need to be very careful since unnecessary checks will eventually turn out to be a significant overhead. For example, in GVRMaterial and GVRCameraRig I finally decided to only add NaN check in setFloat is because only in the case of single float parameter may need NaN as a special flag to inform Java that an illegal state happens. Corresponsively, in the case of float vector/array, we can simply return null pointer back from JNI to Java as an illegal state identifier. I mean, we probably can't check all illegal states using Preconditions. But in necessary cases, I think we'd better make use of it and in the future extend it in a proper way.\r\n\r\n\r\nGearVRf-DCO-1.0-Signed-off-by: Chao Chen\r\nc.chen@samsung.com"},"comment":{"url":"https://api.github.com/repos/Samsung/GearVRf/issues/comments/98008805","html_url":"https://github.com/Samsung/GearVRf/pull/33#issuecomment-98008805","issue_url":"https://api.github.com/repos/Samsung/GearVRf/issues/33","id":98008805,"user":{"login":"JonShemitz","id":11304782,"avatar_url":"https://avatars.githubusercontent.com/u/11304782?v=3","gravatar_id":"","url":"https://api.github.com/users/JonShemitz","html_url":"https://github.com/JonShemitz","followers_url":"https://api.github.com/users/JonShemitz/followers","following_url":"https://api.github.com/users/JonShemitz/following{/other_user}","gists_url":"https://api.github.com/users/JonShemitz/gists{/gist_id}","starred_url":"https://api.github.com/users/JonShemitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonShemitz/subscriptions","organizations_url":"https://api.github.com/users/JonShemitz/orgs","repos_url":"https://api.github.com/users/JonShemitz/repos","events_url":"https://api.github.com/users/JonShemitz/events{/privacy}","received_events_url":"https://api.github.com/users/JonShemitz/received_events","type":"User","site_admin":false},"created_at":"2015-05-01T00:35:26Z","updated_at":"2015-05-01T00:35:26Z","body":"This looks fine, to me. We just need to validate it. @dknaan - could you perhaps do that? I'm in the middle of What's Wrong With This JNI Code ..."}}