Warren Buffett published his annual letter on Saturday, and it came with some of the usual trimmings: sage advice and reflections on the past year's success.

Buffett told investors that Berkshire Hathaway (BRKB)made a $65.3 billion net gain in 2017 -- but "only $36 billion came from Berkshire's operations."

The rest was a gift from the new U.S. tax code.

"A large portion of our gain did not come from anything we accomplished at Berkshire," he wrote, adding that about $29 billion of that $65.3 billion gain came from changes to the tax law.

Buffett went on to extol Berkshire's investing methods. Careful decisions and an aversion to debt and speculation has gotten the firm this far -- and that's the course it'll stay on, he said.

Related: Warren Buffett is retiring from Kraft Heinz board

He noted that Berkshire didn't go on a buying "frenzy" and acquire a bunch of companies last year, mostly because there were no desirable options that came at a "sensible" purchase price.

"[P]rices for decent, but far from spectacular, businesses hit an all-time high" last year, he wrote.

"[Investing partner] Charlie [Munger] and I believe that from time to time Berkshire will have opportunities to make very large purchases," Buffett wrote. "In the meantime, we will stick with our simple guideline: The less the prudence with which others conduct their affairs, the greater the prudence with which we must conduct our own."

He also leveled criticism at what he called the "can-do" type of Wall Street CEO, who he said can be over eager to justify gobbling up another company.

"If Wall Street analysts or board members urge that brand of CEO to consider possible acquisitions, it's a bit like telling your ripening teenager to be sure to have a normal sex life," he wrote.

Buffett gave the final details of a 10-year long bet he made against hedge funds in 2007. That ended last year, and Buffett -- who bet slow, steady gains by the S&P 500 would beat out hedge funds over the decade -- won with flying colors.

All told, the S&P 500 had an overall gain of 125.8% while the group of five hedge funds -- which have never been publicly named -- gained between 2.8% and and 87.7%.

Buffett has long been highly critical of the high fees charged by hedge fund operators.

"Performance comes, performance goes. Fees never falter," he wrote.

Unlike some letters of years past, Buffett steered clear of commenting on the overall American economy, and he didn't wade into politics.

Buffett supported President Trump's Democratic rival, Hillary Clinton, during the 2016 election. And he's found himself at odds with Trump on several policy issues.

Related: Berkshire Hathaway prepares for life after Warren Buffett

Buffett,87, also avoided dropping any hints about who will take the reins at Berkshire when he retires.

Speculation about Buffett's successor has swirled for years.

Buffett declared in his 2015 annual shareholder letter that he has found the "right person," but he didn't offer any further details.

Two men are widely considered the frontrunners: Greg Abel, CEO of Berkshire Hathaway Energy Company, and Ajit Jain, executive vice president of Berkshire Hathaway's National Indemnity Company insurance subsidiary.

Buffett closed out his annual letter with a shout out for the two men, who were both elected to Berkshire's board of directors last month.

"You and I are lucky to have Ajit and Greg working for us," Buffett wrote. "Each has been with Berkshire for decades, and Berkshire's blood flows through their veins."

--CNN's Paul R. La Monica contributed to this report