"Secret World of Alex Mack" star Larisa Oleynik got a three-year restraining order against a crazed fan who was so obsessed he changed his last name to Oleynik ... TMZ has learned.
A judge granted the order against Josh Hathaway -- a.k.a Josh Oleynik -- in L.A. County Superior Court on January 31.
In legal docs, Larisa says the harassment began in July 2012 when Josh started calling her mother nonstop, and leaving gifts for her at her mom's apartment.
Larisa says Josh wrote books and love letters for her featuring creepy passages like ... "You are very beloved by me everyday. You are very precious to me ... keep me on your wheel of love."
She also says Josh left a voicemail saying he changed his last name to Oleynik in 2010 ... to "build a relationship," and wanted to propose to her.
In Larisa's legal filing she says, "I feel that I am being stalked. I am worried he is unstable and could snap at any moment."
The judge clearly agreed ... ordering Josh to stop all contact with and stay 100 yards away from Larisa and her mom until Jan. 2016.