An ally with a convenient set of islands just north of Japan might help.
China won't necessarily hit the military. Japan is a sitting duck. We'd need Russia back on side to protect Japan.
Taiwan might be sacrificed as Ukraine is.
What a terrible scenario.
Militarily it isn't. If you're talking about attack from ballistic missiles, perhaps. If we're talking about an invasion, not a chance. Not one. Nil. Zero.
Currently, China doesn't have the amphibious capabilities to invade Taiwan, let alone cross the Sea of the Japan in the numbers required to take Japan.
The JSDF has a relatively large blue-water navy, a strong air force and more than capable troops. They have a capable ABM system to protect from attack.
That's before talking about the US 7th Fleet. China might try to marginalise Japan politically and whatnot, but they are more than capable of holding their own.