fix regression in C extension and bug in Java extension