There is also the possibility that the PLA determined that a cannon would be contradictory to stealth.
F22 does have a gun as does F35A but F35B and C use a pod.
In the case of the F22 It's a 20mm intended for air to air close fighting. F22 was intended as a Air dominance machine able to fight from both BVR and to turn and burn like a flanker.
In the F35 It's a 25mm chosen not as a fall back against air targets (it still can) but for Close Air Support. It's meant to stand off a little.
As I just pointed out the F4 lacked a internal gun as do a number of interceptors which was the F4s original role another was the Mig 25,
Stealth fighters are a relivtivly new concept, but the point is two fold to reduce the effectiveness of ground or surface based air denial technology and in the Air to air role to close with and engage the enemy well he is unawares. Inessence eliminate his potential to observe, orient, decide, and act against you.
Like changing all the pieces on a chess board in your favor well he is away.
For fighters however a auto cannon is a close in engagement weapon. The only reason to use it is if you and the enemy have closed in and are in a traditional dog fight. But as proven Stealthy characteristics don't nessisarily work well in a dog fight. At less then 10 Miles your radar signature mitigation is not effective. If you close to that ramge to gun someone they will know they are in a dogfight and react.
As such for a stealth or any modern fighter the gun in air to air is a last resort. Only used if everything else has been used or failed.
It's removal or omission is not entirely a foolish choice in fact the British tried to do that with Typhoon only to keep it as it balanced the weight.
The F35 was handicapped by the fact that it’s designers never expected it to face hostile 5th gens. Certainly not as the mainstay air superiority fighters.
The J20 OTOH, was designed from the ground up as a counter against the F22.
Stealth not only reduced detection range, but also lowers the kill probability of BVR missiles, which overwhelming reply on radar guidance.
As such, in a stealth vs stealth encounter, there is every chance the battle will only be decided in WVR, as the BVR engagement window is greatly reduced by shorter detection ranges and KPs are greatly reduced on already small internal missile loads.
Once in WVR, each Raptor and J20 only carry a pair of IRAAMs, so combat persistence is going to be poor without a gun.
A gun is heavy, but nowhere like cripplingly so as to require the PLAAF to forgo it with all the limitations and disadvantages that would mean.
The J20 is underpowered without the WS15, but not to the extent that a few hundred kilos for a gun and ammo would make a critical difference. Especially not for AA weapons loads.
Even if the margins are so tight, they can easily compensate by loading the J20 with a few hundred litres less fuel than full tank capacity, and either live with the shorter range, or top up after take off with tankers.
A slight range hit is a far better trade off than not having a gun.