One exception on the length issue is the "C" target stuff. The longer "target" upper will fit the full size standard lower. A few factory parts interchange directly, for instance .357 sig barrels drop into .40 guns and vice versa, but the disconnector (the part that doubles as the take down tab, and also pulls the barrel down during cycling) is, I believe pretty much different from one frame size to the next, and one length to the next. The reason is that they use the same recoil spring in similar sized pistols, but the disconnector is a different length (as stated above) to compensate for different blowback force. Note: a 9mm spring will be the same part number as a .40 spring.
There are, however, drop in barrels for .40 to 9mm, but the angle/length (?) on the disconnector makes them a little less reliable. Light loads occasionally won't cycle the action vigorously enough to not occasionally jam. You use the 9mm mags due to the width of the feed ramps. In short, you can drop in a barrel, 9mm mag, and shoot 9mm this way. Pretty sure that your suggested conversion won't work, but I have been wrong before. I think the extractor should be the same. The diameter of the rim groove is nearly identical on 9mm and .40 that's why they use the same shell plate in reloading. (The groove is deeper on .40)
One other thing to note is that the .22 conversion kits share between 9mm and .40, so I might suspect you could swap the entire upper. Once you have the "barrel, slide and dust cover" you almost have a whole upper, anyhow. The way I am looking at it, the reason it won't work, is that the grooves in the barrel for the disconnector are in a different spot, and the reason they (I think) would work for a whole slide assembly of the same length/frame size is that the slide itself is different to line everything up again.
The drop in barrel is kind of a sure thing, though, and Glocks are very forgiving of different loads, so if a gun was to like going to less power, Glock would be it.
Oh, I should note; You have to get the AFTERMARKET CONVERSION 9mm barrel. A glock barrel WON'T go in. I have .357 sig factory barrels for both my .40 glocks, but the 9mm WON'T FIT the .40 slide (I tried it and wished I hadn't it was hard to get back apart)
Guess this doesn't get you your longer upper, though. I don't know if they still do it, but there was a company offering these conversion barrels years ago in Shotgun News and you could order them extended and ported.
Now I'm curious. I think I'm going to try and find the 9mm drop in.