+act #3532: Add ask support for Java API (backport)

(cherry picked from commit 5e3dcaa)