You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2019/01/14 07:50:31 UTC

[GitHub] jlahoda commented on a change in pull request #1071: [NETBEANS-1728] fix for Exception encountered when break returns value

jlahoda commented on a change in pull request #1071: [NETBEANS-1728] fix for Exception encountered when break returns value
URL: https://github.com/apache/incubator-netbeans/pull/1071#discussion_r247402265
 
 

 ##########
 File path: java/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
 ##########
 @@ -1355,7 +1355,11 @@ public StatementTree getBreakContinueTarget(TreePath breakOrContinue) throws Ill
         
         switch (leaf.getKind()) {
             case BREAK:
-                return (StatementTree) ((JCTree.JCBreak) leaf).target;
+                Tree breakTarget = (Tree) ((JCTree.JCBreak) leaf).target;
+                if (breakTarget == null || !(breakTarget instanceof StatementTree)) {
+                    return null;
 
 Review comment:
   So.... this may be OK (or the only possibility) for this method, but as this is inevitably behavioraly incompatible, what about the clients? As the report is about the NPE check hint, that hint will be at least slightly broken in presence of switch expressions, won't it be?
   
   For compatibility, I don't think we can avoid the behavioral incompatibility here, but then we could:
   a) add a new method that would return Tree and deprecate this one
   b) change the return type to Tree here, which is inevitably source incompatible. Binary compatibility might be preservable through bytecode patching.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists