In the classical period of Western music the only generally legitimate ways a composer would appropriate another composer’s music would be to “transcribe” it for different instrumentation, or to write variations on that composer’s theme. Sometimes variations would be called a “rhapsody on the theme” or a “fantasia on the theme,” etc. The use of the other person’s musical theme was explicitly mentioned.
This was quite a common practice, and some great works of the Western tradition originated in this way. For instance, Sergei Rachmaninov’s Rhapsody on a Theme of Paganini (1934) is one of many sets of variations on the 24th “Caprice for Solo Violin,” the last in a set of works written by Niccolò Paganini between 1802 and 1817. (Paganini’s Caprice is itself a kind of brief set of variations on the theme.)
Hilary Hahn plays Paganini Caprice #24
This classical practice influenced the development of jazz, and has parallels with the practice in jazz of improvising on standard themes.
See also: transcription