What's illegal about it?
It's 'front end loading' a contract as opposed to the 'back ending' we often see, particularly when someone's final season of a contract is as a veteran where only 1/2 gets included in the cap.
Anyone that puts a figure on their head have to do so for the first 2 years, not one. In your example the club that took him would get away with only paying him $150K in his second year.