Distribution of built-in electric field in GaN/AlGaN/GaN transistor heterostructures without and with AlN layer was studied theoretically (solving the Schrodinger and Poisson equation) and experimentally (measuring contactless electroreflectance (CER) spectra and analyzing the AlGaN-related Franz-Keldysh oscillation). It is shown that the AlN layer changes very strongly the distribution of electric field in such heterostructures. This change can be very well predicted if the surface boundary conditions for self-consistent Schrodinger-Poisson calculations in GaN/AlGaN/GaN heterostructures are known. These conditions can be determined/verified by CER measurements of AlGaN-related Franz-Keldysh oscillation, which depends on the built-in electric field in AlGaN layer.