1 of 5
AP, Photo by Chris Pizzello/Invision
James Marsden, left, and Jack Black, cast members in "The D Train," pose together at the premiere of the film at the Library Center Theatre during the 2015 Sundance Film Festival on Friday, Jan. 23, 2015, in Park City, Utah.

PARK CITY, Utah — Jack Black said he was drawn to 'The D Train' because he recognized the desperation of the character he plays: An outcast willing to do anything to get the most popular kid from his graduating class to attend their 20th high school reunion.

The male buddy comedy, which premiered Friday at the Sundance Film Festival, turns a different lens on the trope of the drunken one-night stand and shows how far Black's character will go to get the attention of the popular guy (James Marsden), who left their Pennsylvania hometown to become an actor in Los Angeles. Dan Landsman (Black) thinks wooing this Hollywood star back to their high school would make him the hero of the reunion.

As Landsman, Black dupes his boss, lies to his wife and ignores his son to gain favor with the handsome actor.

Black's performance is heartfelt and heartbreaking. Marsden is on point as a self-absorbed actor. But this flawed comedy comes with a strong undercurrent of sexism and homophobia.

To offer more details would tread into spoiler territory, but safe to say that had one of the lead characters been female, there would probably be little to laugh at, and perhaps no movie at all.

Written and directed by Jarrad Paul and Andrew Mogel, the film also stars Kathryn Hahn, a restrained Jeffrey Tambor, and features a breakthrough performance by Russell Posner as Landsman's teenage son.

Paul and Mogel, who've previously written studio fare, deftly handle their starry cast and venture into new territory for the genre, but they come off as bullies as much as they do brave.

Follow AP Entertainment Writer Sandy Cohen at www.twitter.com/APSandy .