[BZ-1026311] fix incremental compilation when only java classes are changed
(cherry picked from commit e4fb597163dfc9e378d0944291d054d07cff74d0)