>This argument that the technology will soon be supplanted
You're not wrong in criticizing new-flavor thinking. The USAF for example was way too quick to switch to no-guns/all-missiles in the runup to the Vietnam war.
Yet...
Whether missile-to-missile or dogfighting, there has been little real top-tier peers air-to-air combat, so even wrt guns vs missiles the tea leaves don't tell us that much. And missiles in the 70s vs missiles in the 2010s are not the same thing at all. Having Wild Weasels walk all over Iraqi and Lybian air defenses is not guarantee that they would do the same against an enemy fielding top-end SAMs with well-trained and motivated troops.
You could also make the case that we are currently investing heavily in, very costly, last-war technology. Bit like producing a massive fleet of pre-Dreadnought cruisers in 1890s. Or mass-procuring battleships in the years running up to WW2.
To me, it's a toss up whether gen 5 fighters are going to be useful in a hypothetical top-tier peer war (West vs China, not West vs Russia, btw). They may be . They may end up being totally besides the point however. Not least because China is so far away from Western power centers that jet fighters won't be too involved in non-peripheral combat zones unless they're carrier-based (with the F35 not being known for having a particularly long range).
What's certain is that right now, the F35 is in the unpleasant position of being costly, unfit for purpose and presented as the only game in town.
For now, we are only dealing with 3rd rate opponents who don't have credible air superiority/defense components. China is not in a position to challenge the West, yet. And Russia won't have the industrial capacity to do much in a serious conventional war.
We have time, for now.
My take: a) punish - hard - Lockeed by dumping its contract b) fire the military procurement folk that promoted taking so many development risks on a jack-of-all-trades airframe c) maintain R&D and training and keep the budgetary oomph to contain China, should the need arise d) engage with China to ease it into its role as future superpower while constraining its behavior to acceptable (ex: Spratley's) e) shift to designing gen 6 fighters and autonomous AA drones and design and field limited but varied 5.5 fighter designs, specialized to their roles and users.
In the 2030-2040s we may or may not have to actively counteract China to contain it. Hopefully not. But investing massively in a plane that will be 30-40 years old at that point - even it that plane worked - is the opposite of hedging our bets and being able to flexibly respond to Chinese challenges. All the while signalling to China that we are willing to bleed our budgets to develop a system that only has one credible opponent justifying it - them - thus fueling any paranoia they may have.