Add code in extract.php to remove the administrator/cache/autoload_psr4.php file before loading the finalisation.php as the latter might try to use core code which depends on the former.
Testing Instructions
From Joomla 4.0.0
Install a Joomla 4.0.0 site
Replace administrator/components/com_joomlaupdate, components/com_joomlaupdate, media/com_joomlaupdate, and administrator/language/en-GB/com_joomlaupdate.* with the files from this PR.
Log into the backend
Do an md5sum of the administrator/cache/autoload_psr4.php file
Upgrade the site to Joomla 4.2 using the package built from this PR
Try to access your site's frontend
Do an md5sum of the administrator/cache/autoload_psr4.php file
From Joomla 4.1.5
Install a Joomla 4.1.5 site
Log into the backend
Do an md5sum of the administrator/cache/autoload_psr4.php file
Upgrade the site to Joomla 4.2 using the package built from this PR
Try to access your site's frontend
Do an md5sum of the administrator/cache/autoload_psr4.php file
Actual result BEFORE applying this Pull Request
The MD5 sums are identical (the autoload_psr4.php file was not removed on update).
Expected result AFTER applying this Pull Request
The MD5 sums are different (the autoload_psr4.php file was removed on update and replaced when accessing your site again).