In the current optical lithography processes for semiconductor manufacturing, differently shaped illumination sources have been widely used for the need of stringent critical dimension control. This paper proposes a technique for in situ measurement of lens aberrations with generalized formulations of odd and even aberration sensitivities suitable for arbitrarily shaped illumination sources. With a set of Zernike orders, these aberration sensitivities can be treated as a set of analytical kernels which succeed in constructing a sensitivity function space. The analytical kernels reveal the physical essence of partially coherent imaging systems by taking into account the interaction between the wavefront aberration and the illumination source, and take the advantage of realizing a linear and analytical relationship between the Zernike coefficients to be measured and the measurable physical signals. A variety of mainstream illumination sources with spatially variable intensity distributions were input into the PROLITH for the simulation work, which demonstrates and confirms that the generalized formulations are suitable for measuring lens aberrations up to a high order Zernike coefficient under different types of source distributions. The technique is simple to implement and will have potential applications in the in-line monitoring of imaging quality of current lithographic tools.