Shawn Johnson's alleged stalker Robert O'Ryan is insane ... this according to the guy himself.
O'Ryan -- who's facing charges of felony stalking, felony commercial burglary and two misdemeanor counts of carrying a loaded firearm in his car -- plead not guilty by reason of insanity in L.A. County Superior Court.
As we previously reported, O'Ryan was arrested last year when he attempted to enter the set of "Dancing with the Stars" in an alleged effort to have an encounter with the Olympian.
During the hearing, the judge told O'Ryan -- who faces 6 years behind bars if convicted on all counts -- that if he was found to be insane, he could spend at least that amount of time in a state mental hospital.
O'Ryan's trial is scheduled to begin tomorrow -- and, as we first reported, Shawn Johnson is set to testify against him.
More Shawn Johnson
Shawn Johnson to Face Off with Alleged Stalker
Shawn Johnson's Alleged Stalker Charged
Johnson's Alleged Stalker Pleads Not Guilty
Shawn Johnson Under Tight Surveillance
ncG1vNJzZmivp6x7tbnZZ5qopV9nfXJ8jmltaGhnZMCprdanZKOnmKPAsLrSZpilpJWcsqV50q2YpaOVp3qzu8Geqa1ln6fGorqMoqWsmZ6ewbp5z6Wcmmc%3D