Solution (source code)

= Solution

Choose the $z$-axis along the <cylinder> and the origin at its midpoint, so $x^2+y^2\leq b^2$ and $-a\leq z\leq a$. <Reflection symmetry> puts the <centroid> at the origin and makes all products of inertia zero. The <mass> is
$$
\boxed{m=2\pi\rho ab^2.}
$$
Cylindrical integration gives $\int_A\rho x^2\,dV=\int_A\rho y^2\,dV=mb^2/4$, while the uniform height coordinate has $\int_A\rho z^2\,dV=ma^2/3$. Consequently
$$
\boxed{J_G=m\operatorname{diag}\left(\frac{b^2}4+\frac{a^2}3,\ \frac{b^2}4+\frac{a^2}3,\ \frac{b^2}2\right).}
$$
The two equal transverse entries reflect the <rotational symmetry> about the <cylinder> axis.