A minor change in org.ofbiz.service.engine.StandardJavaEngine
------------------------------------------------------------- Key: OFBIZ-2948 URL: https://issues.apache.org/jira/browse/OFBIZ-2948 Project: OFBiz Issue Type: Wish Affects Versions: Release Branch 9.04 Environment: FC10 + OpenJDK 1.6 Reporter: Shi Yusen Priority: Trivial Fix For: Release Branch 9.04 Change result = m.invoke(null, dctx, context); to result = m.invoke(c.newInstance(), dctx, context); This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759155#action_12759155 ] Jacques Le Roux commented on OFBIZ-2948: ---------------------------------------- Hi Shi, It seems OK, but what it's useful for (ie what are you using it for) ? Thanks > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759186#action_12759186 ] Shi Yusen commented on OFBIZ-2948: ---------------------------------- Hi Jacques, The reason is simple, I defined several interface classes in rmi module, so the services are not written in static. To run the services, I changed the invoke sentence. For myself convenience, I wish this could be changed. My dirty mind behind? Yes, if this could be changed, I'm sure we can see more and more interface classes and less and less static methods in OFBiz.:) > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759306#action_12759306 ] Scott Gray commented on OFBIZ-2948: ----------------------------------- If the object only lives for one service call, how is that any different that using a static method? Also you should do a check to see if the method is static before creating an instance of the class. Even if this does get committed (I'm not entire convinced it should be), it shouldn't go into 9.04 > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759360#action_12759360 ] Shi Yusen commented on OFBIZ-2948: ---------------------------------- According to the java doc of invoke method: If the underlying method is static, then the specified obj argument is ignored. It may be null. > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759362#action_12759362 ] Scott Gray commented on OFBIZ-2948: ----------------------------------- You're still unnecessarily creating an instance of the class though right? i.e. for every other normal java service in OFBiz > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759373#action_12759373 ] Shi Yusen commented on OFBIZ-2948: ---------------------------------- Yes, you're right. I wrote the following at the beginning. Honestly, I don't know which way is more efficient. if (Arrays.asList(m.getAnnotations()).contains("static")) { result = m.invoke(null, dctx, context); } else { result = m.invoke(c.newInstance(), dctx, context); } > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759375#action_12759375 ] Scott Gray commented on OFBIZ-2948: ----------------------------------- Probably something like this would be best: {code} if (Modifier.isStatic(m.getModifiers()) {code} > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759387#action_12759387 ] Shi Yusen commented on OFBIZ-2948: ---------------------------------- Yes. +1. {code} if (Modifier.isStatic(m.getModifiers())) { result = m.invoke(null, dctx, context); } else { result = m.invoke(c.newInstance(), dctx, context); } {code} > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Priority: Trivial > Fix For: Release Branch 9.04 > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
In reply to this post by Nicolas Malin (Jira)
[ https://issues.apache.org/jira/browse/OFBIZ-2948?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jacques Le Roux closed OFBIZ-2948. ---------------------------------- Resolution: Fixed Fix Version/s: (was: Release Branch 9.04) SVN trunk Assignee: Jacques Le Roux Thanks Yusen, Scott, Yusen your patch in in trunk at r819281 > A minor change in org.ofbiz.service.engine.StandardJavaEngine > ------------------------------------------------------------- > > Key: OFBIZ-2948 > URL: https://issues.apache.org/jira/browse/OFBIZ-2948 > Project: OFBiz > Issue Type: Wish > Affects Versions: Release Branch 9.04 > Environment: FC10 + OpenJDK 1.6 > Reporter: Shi Yusen > Assignee: Jacques Le Roux > Priority: Trivial > Fix For: SVN trunk > > > Change > result = m.invoke(null, dctx, context); > to > result = m.invoke(c.newInstance(), dctx, context); > This change will make it possible to invoke both static method and instance method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object,%20java.lang.Object...). > I've tested this in OFBiz 9.04 and works fine. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. |
Free forum by Nabble | Edit this page |