Principal typings for Java-like languages