Mass. Gen. Laws ch. 279, § 25
(d) Upon sentencing a defendant to a qualifying term of incarceration, or prior to accepting a guilty plea for any qualifying offense listed in subsection (b), the court shall inform the defendant that a conviction or plea of guilty for such an offense implicates the habitual offender statute and that upon conviction or plea of guilty for the third or subsequent of said offenses: