Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when getting Currency for CurrencyCode.MRU. #63

Open
jaredfishy opened this issue Nov 8, 2019 · 1 comment
Open

Comments

@jaredfishy
Copy link

Trying to retrieve the Currency object for MRU throws a NullPointerException.

Code to recreate issue:

Currency currency = CurrencyCode.MRU.getCurrency();

@TakahikoKawasaki
Copy link
Owner

Currency.getCurrency() is a wrapper for java.util.Currency.getInstance(String). If the getInstance(String) returns null or throws an IllegalArgumentException, Currency.getCurrency() returns null.

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
$ cat TestMRUCurrency.java 
public class TestMRUCurrency
{
    public static void main(String[] args)
    {
        System.out.println(java.util.Currency.getInstance("MRU"));
    }
}
$ java TestMRUCurrency
Exception in thread "main" java.lang.IllegalArgumentException
	at java.util.Currency.getInstance(Currency.java:345)
	at java.util.Currency.getInstance(Currency.java:310)
	at TestMRUCurrency.main(TestMRUCurrency.java:5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants