[GitHub] [lucene-solr] noblepaul commented on a change in pull request #1624: use MethodHandles in AnnotatedAPI
noblepaul commented on a change in pull request #1624: URL: https://github.com/apache/lucene-solr/pull/1624#discussion_r447736459 ## File path: solr/core/src/java/org/apache/solr/api/AnnotatedApi.java ## @@ -87,16 +83,18 @@ public EndPoint getEndPoint() { public static List getApis(Object obj) { return getApis(obj.getClass(), obj); } - public static List getApis(Class klas , Object obj) { -if (!Modifier.isPublic(klas.getModifiers())) { - throw new RuntimeException(klas.getName() + " is not public"); + public static List getApis(Class theClass , Object obj) { +Class klas = null; Review comment: how is that possible? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] noblepaul commented on a change in pull request #1624: use MethodHandles in AnnotatedAPI
noblepaul commented on a change in pull request #1624: URL: https://github.com/apache/lucene-solr/pull/1624#discussion_r447412157 ## File path: solr/core/src/java/org/apache/solr/api/AnnotatedApi.java ## @@ -87,16 +88,18 @@ public EndPoint getEndPoint() { public static List getApis(Object obj) { return getApis(obj.getClass(), obj); } - public static List getApis(Class klas , Object obj) { -if (!Modifier.isPublic(klas.getModifiers())) { - throw new RuntimeException(klas.getName() + " is not public"); + public static List getApis(Class theClass , Object obj) { +Class klas = null; +try { + klas = MethodHandles.publicLookup().accessClass(theClass); +} catch (IllegalAccessException e) { + throw new RuntimeException(klas.getName() + " is not public", e); Review comment: Thanks, everyone. I wanted to get a quick review for the implementation. Basically, I was not too sure about the idioms we normally use for `MethodHandle` based reflection code. Moreover, We are more worried about the security manager complaining and wanted to do a PoC if that problem goes away This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] noblepaul commented on a change in pull request #1624: use MethodHandles in AnnotatedAPI
noblepaul commented on a change in pull request #1624: URL: https://github.com/apache/lucene-solr/pull/1624#discussion_r447412157 ## File path: solr/core/src/java/org/apache/solr/api/AnnotatedApi.java ## @@ -87,16 +88,18 @@ public EndPoint getEndPoint() { public static List getApis(Object obj) { return getApis(obj.getClass(), obj); } - public static List getApis(Class klas , Object obj) { -if (!Modifier.isPublic(klas.getModifiers())) { - throw new RuntimeException(klas.getName() + " is not public"); + public static List getApis(Class theClass , Object obj) { +Class klas = null; +try { + klas = MethodHandles.publicLookup().accessClass(theClass); +} catch (IllegalAccessException e) { + throw new RuntimeException(klas.getName() + " is not public", e); Review comment: Thanks, everyone. I wanted to get a quick review for the implementation. Basically, I was not too sure about the idioms we normally use for `MethodHandle` based reflection code. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] noblepaul commented on a change in pull request #1624: use MethodHandles in AnnotatedAPI
noblepaul commented on a change in pull request #1624: URL: https://github.com/apache/lucene-solr/pull/1624#discussion_r446597787 ## File path: solr/core/src/java/org/apache/solr/api/AnnotatedApi.java ## @@ -306,7 +313,7 @@ void invoke(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation cmd) { } catch (InvocationTargetException ite) { log.error("Error executing command ", ite); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, ite.getCause()); - } catch (Exception e) { + } catch (Throwable e) { Review comment: `methodhandle.invoke()` throws `Throwable`. What choice do we have? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org