In this paper, the authors consider limit cycle bifurcations for a kind of nonsmooth polynomial differential systems by perturbing a piecewise linear Hamiltonian system with a center at the origin and a heteroclinic loop around the origin. When the degree of perturbing polynomial terms is n(n ≥ 1), it is obtained that n limit cycles can appear near the origin and the heteroclinic loop respectively by using the first Melnikov function of piecewise near-Hamiltonian systems, and that there are at most n + [(n+1)/2] limit cycles bifurcating from the periodic annulus between the center and the heteroclinic loop up to the first order in ε. Especially, for n = 1, 2, 3 and 4, a precise result on the maximal number of zeros of the first Melnikov function is derived.