code: public static int endPos(JCTree tree) {
          if (tree.hasTag(BLOCK) && ((JCBlock) tree).endpos != Position.NOPOS)
              return ((JCBlock) tree).endpos;
          else if (tree.hasTag(SYNCHRONIZED))
              return endPos(((JCSynchronized) tree).body);
          else if (tree.hasTag(TRY)) {
              JCTry t = (JCTry) tree;
              return endPos((t.finalizer != null) ? t.finalizer
                            : (t.catchers.nonEmpty() ? t.catchers.last().body : t.body));
          } else
              return tree.pos;
      }
docs: The end position of given tree, if it is a block with
  defined endpos.