I went through this process, documented the process for myself to use during this process because you have to repeat it at the various major version jumps, and then created a post to share with others since I couldn't find documented steps either (at the time 2.4.1 was the latest version so that's where the notes end). You can read the post at the link below. It's work but I think it is a better option than having to recreate classes from scratch.
https://moodle.org/mod/forum/discuss.php?d=224561