Japan's age of consent seems very grey, but it does seem there are situations where she would would be recognized as legal or at least not illegal. Marriage for example seems to be one of them, where the minimum age for girls is 16 and having sexual relations with her marriage partner then would be acceptable.
The effective age of consent for most of Japan though is 16-18 depending on locality, but definitely grey areas depending on the age gap and the relationship between the male and female. 13 is the base level age of consent as laid down by their national laws, but local laws and ordinances raises it up in the vast majority of locations to 16-18. It seems the only places that retain the age of consent at 13 are apparently two low population locations populated by indigenous groups, such as the Ainu.