If you can take UnionPay, you can swipe your card directly, but UnionPay will automatically change it into Japanese yen, but there is no conversion fee.
If you bring master and visa, it depends on the currency supported by your credit card. Generally, it is RMB and USD. In other words, your credit card has a US dollar account and a RMB account. In Japan, you use a US dollar account to swipe your card. You can deposit US dollars directly in China, or you can deposit RMB to purchase foreign exchange and exchange it for US dollars for repayment.