code: public static int setFinal(int modifier, boolean b) {
          if (b) {
              return (modifier | FINAL) & (~INTERFACE & ~ABSTRACT);
          }
          else {
              return modifier & ~FINAL;
          }
      }
docs: When set final, the modifier is cleared from being an interface or
  abstract.