In this image released by Sony Pictures Classics, Joaquin Phoenix, left, and Parker Posey appear in a scene from "Irrational Man." (Sabrina Lantos/Sony Pictures Classics via AP)

Woody Allen has always been interested in man’s search for meaning in life — a search he clearly sees as futile. Who can forget the young woman in “Play it Again, Sam,” staring at a Jackson Pollock painting and seeing “the hideous lonely emptiness of existence, nothingness, the predicament of man forced to live in a barren, godless eternity”? That’s not even the whole quote —but it could be Allen’s mantra.

The director has also mined the themes of crime and punishment, including murder —think “Crimes and Misdemeanors” and “Match Point.” All these threads — plus, of course, love and seduction —come together in his 45th feature, “Irrational Man,” which may not be his very best recent work, but is by far not his worst, either.

As in so many Allen films, even if some parts don’t gel, others do. If “Irrational Man” falls short of late-career home runs like “Midnight in Paris” and “Blue Jasmine,” it also feels more fully realized than last year’s visually gorgeous but otherwise uneven period piece, “Magic in the Moonlight.”

As always, the casting is something any director would kill for. Here, we have Joaquin Phoenix (grizzled, slightly pot-bellied) as an existentially challenged philosophy professor, Emma Stone (utterly effervescent) as his bright-eyed student, and Parker Posey (warmly kooky) as the sex-starved academic who forms the third side of this odd triangle.

The setting is Newport, Rhode Island, and that wind-swept, seaside town looks beautiful — no surprise, given the pedigree of cinematographer Darius Khondji. It’s summer session at a small college, and Abe Lucas (Phoenix) arrives to teach philosophy. Accomplished and brilliant, he’s also known for having affairs with students and swigging often from a flask in his pocket. “That should put some Viagra into the philosophy department,” an observer says of his arrival.

Abe is precisely the sort of disgruntled, unattainable intellectual that young women can’t stay away from. That’s what happens to Jill (Stone), who’s beautiful, brilliant, kind and also an accomplished pianist (that last part may be overkill, but it’s certainly not the film’s most outlandish plot point). Bored with her clean-cut boyfriend, she finds herself drawn to her bad-boy professor, who’s “so darned interesting and different.”

Meanwhile, frustrated wife Rita (Posey) has been dreaming of bedding Abe since before his arrival, and will NOT be denied. Yet Abe’s long stretch of depression has left him with some issues in the sack.

What’s more, he’s exhibiting disturbing nihilistic tendencies. At a party, he gets hold of the family gun and plays a game of real Russian Roulette, hoping to teach some sort of metaphysical lesson.

Everything changes, though, when Abe and Jill overhear a conversation in a diner. A beleaguered mother is facing a court case that may cost her custody of her children; the judge is corrupt. If the bad judge were out of the picture, Abe reasons, wouldn’t the world be so much better? He immediately begins plotting a solution, and this dark quest fills him with a new zest for life.

Yes, it’s a leap — but Allen’s films are famous for such leaps (Time travel, anyone? People coming out of movie screens?) You either go with it or you don’t.

The same goes for Allen’s breezy mix of light and dark tones. The subject may seem too dark for comedy, the treatment (and jazzy score) too light for tragedy. But the director balances it in his own way, and as always, we can take it or leave it.

To sell the film’s escalating implausibility, of course, Allen needs strong and appealing performances. Luckily he has them: Phoenix and Posey are pitch-perfect, and as for Stone, she’s more watchable than ever. If life is indeed “a barren godless eternity,” one could do worse than spend it with this beguiling actress.

“Irrational Man,” a Sony Pictures Classics release, is rated R by the Motion Picture Association of America “for some language and sexual content.” Running time: 94 minutes. Two and a half stars out of four.

MPAA definition of R: Restricted. Under 17 requires accompanying parent or adult guardian.

Follow AP National Writer Jocelyn Noveck on Twitter at