U.S. Secretary of State John Kerry criticized presumptive Republican presidential candidate Donald Trump on Friday, warning that isolationist policies would take a toll on the country's well-being.

"You are the most diverse class in Northeastern history. In other words, you are Donald Trump's worst nightmare," he jokingly told the 2016 graduates of Northeastern University in Boston.

While he did not mention the billionaire businessman's name again, Kerry alluded to one of Trump's signature proposals - his call to build a wall along the U.S.-Mexico border.

"We will never come out on top if we accept advice from soundbite salesmen and carnival barkers who pretend the most powerful country on Earth can remain great by looking inward and hiding behind walls at a time when technology has made that impossible to do and unwise to even attempt," said the former U.S. Senator from Massachusetts, who was the Democratic nominee for president in 2004.

Kerry has generally declined to comment on the race leading up to the Nov. 8 presidential election, though he has noted that foreign leaders have raised concerns about statements made by candidates, particularly Trump.

A spokesman told reporters on Friday that Kerry's remarks in Boston were intended to be lighthearted.

"He is not living in a bubble. He is obviously concerned about some of the tone and the effect that is having on foreign leaders," department spokesman John Kirby told a press briefing. "If you're asking me because he enjoyed a light-hearted moment with students today has he changed his calculus to more aggressively jumping into active debates ... the answer is no."

You can watch Kerry's full speech to graduates below: