Cheech & Chong's Up in Smoke

Anthony "Man" Stoner,[4] a jobless, marijuana-smoking drummer who is told to either get a job by sundown or be sent off to military school by his parents. Anthony leaves the house in a 1967 Volkswagen Beetle convertible (which had his father's Rolls Royce radiator grille on the front), a car which is subsequently left smoking on the side of the road. Anthony is picked up while hitchhiking by the equally enthusiastic smoker Pedro de Pacas. The license plate reads MUF DVR ("Muff Diver"). They share a large joint, which Man says is made with "mostly Maui wowie" and "Labrador" (essentially dog feces, as his dog, a Labrador Retriever, had eaten his stash). Police find their car parked on a traffic median with them in it, discover that they are clearly stoned and arrest them. At trial, the pair are released on a technicality after Anthony discovers that the judge is drinking vodka.
In an attempt to procure marijuana, they visit Pedro's cousin Strawberry, a Vietnam War veteran. They narrowly escape a police raid on Strawberry's house while Strawberry has a flashback and thinks the police are the Viet Cong, but are soon deported to Tijuana, by the INS (la migra), along with Pedro's relatives, who actually called the INS on themselves, so they could get a free ride to a wedding in Tijuana. In order to get back to the United States they arrange to pick up a vehicle from Pedro's uncle's upholstery shop, but arrive at the wrong address, a disguised marijuana processing plant. They end up unknowingly involved in a plot to smuggle a van constructed completely out of "fiberweed" (hardened THC resin derived from marijuana - a play on the word fiberglass) from Mexico to Los Angeles, with an inept police narcotics unit, led by the overly zealous Sgt. Stedenko (Stacy Keach) hot on their heels. At the Mexican-American border, they almost get arrested but attention is diverted to a group of nuns (Man had thrown away his joint, in order to not be caught by the border patrol, which fell into the nuns' car by accident). The duo then narrowly cross the border into America and pass Stedenko who is giving an interview to a newswoman. Stedenko then finds out from his unit that they apprehended the wrong group and they begin to chase after Pedro and Man. They don't get far, however, after one of Stedenko's men accidentally shoots one of the tires to the car they were in.
Along the way, Pedro and Man pick up two women, who convince them to perform at a Battle of the Bands contest at the Roxy Theatre. Pedro and Man tell the women they need marijuana; the women convince them to see Gloriaâa police dispatcher who sells drugs being held as evidence. Gloria informs the women she can't sell them any drugs as the police destroyed the evidence they were holding, but there should be some in stock soon as the police were searching all over town for a huge stashâwhich the police do not realize is currently sitting in the police station parking lot. They narrowly avoid another arrest, at one point, after being pulled over by a police motorcyclist, but the officer gets high from the burning "fiberweed" emanating from the van's exhaust, and lets them go after asking for a hot dog one of them was eating.
When they arrive at the venue, most of the bands that are performing are negatively received by the audience. One of the women gives Man what she believes is an "upper", though, upon seeing his reaction to the drug, which was causing him to feel out of it, she checks her pills and says "I think I fucked up," indicating that she gave him the wrong drugs. Later, the duo's band, Alice Bowie, Ay Les Voy ("Here I come to you" in Spanish), wins the contest and a recording contract, with a performance of their song, Earache My Eye, despite a rough start to their performance; they win after everyone, including the cops, get stoned due to a large amount of marijuana smoke from the burning van being funneled into the venue.
The film concludes with Pedro and Man driving in the former's car and dreaming how their future career will pay off. Man then lights a small portion of hash and gives some to Pedro. However, it falls into his lap, causing him to panic and swerve the car while trying to put it out; Man attempts to put the hash out with his beer. During the scuffle, the car swerves down the road and smoke billows out the windows over the end credits.

Question: How does Anthony avoid being sent to jail?
Answer: He discovers that the judge was intoxicated.