java extensions
Steven Van Loon <[email protected]> Thu, 20 Aug 2015 15:48:12 +0000
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <HE1PR03MB1017952DE68FDE7B0F4466B799660@HE1PR03MB1017.eurprd03.prod.outlook.com> |
Hi,
I'm trying to use icu4j (http://site.icu-project.org/) in a .net application using ikvm. What I need to do in java, is to add the icu jars (icu4j-55.1.jar and icu4j-localespi-55_1-20150610.jar) to the lib/ext folder and then the following (java) code will output in Afrikaans (not supported by the standard java platform):
java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG, new java.util.Locale("af", "ZA"));
System.out.println(df.format(new java.util.Date()));
icu4j works with the java extension mechanism.
What I did next, was to convert the icu4j jars to dll's using ikvm and referenced them in my application. However, I can't get the following (c#) code to do what it does in java:
java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG, new java.util.Locale("af", "ZA"));
System.Console.WriteLine(df.format(new java.util.Date()));
I keeps outputting in the default locale.
Now, is there a known way to get the locale-sensitive services to work in ikvm?
I'm using ikvm 7.2.4630.5.
What I already did:
I discovered that in the search of the DateFormat in DateFormat.getDateInstance(...), eventually, [c#]java.util.ServiceLoader.loadInstalled(typeof(java.text.spi.DateFormatProvider)) is called. When I call this method manually and iterate over it, it returns no results. When I create an instance of com.ibm.icu.impl.javaspi.text.DateFormatProviderICU (the class implementing DateFormat in the icu lib), the iterator does return something.
com.ibm.icu.impl.javaspi.text.DateFormatProviderICU dfi = new com.ibm.icu.impl.javaspi.text.DateFormatProviderICU();
ServiceLoader ldr = java.util.ServiceLoader.loadInstalled(typeof(java.text.spi.DateFormatProvider));
Iterator iter = ldr.iterator();
while(iter.hasNext())
{
java.text.spi.DateFormatProvider dfp = (java.text.spi.DateFormatProvider)iter.next();
Console.WriteLine(dfp.toString());
}
However, the code still won't output the date in Afrikaans. (Also, next message is found on stdout "Exception thrown: 'java.util.MissingResourceException' in icu4j.dll". )
I guess I can manually load a bunch of classes and maybe get it to work, however, I would think this is not the way to go.
Thanks,
Best regards,
Steven.
------------------------------------------------------------------------------