A characterization of the weakly continuous polynomials in the method of compensated compactness