[kaffe] gnu.java.nio.charset.iconv.IconvCharset cannot be used
Guilhem Lavaux
guilhem at kaffe.org
Fri Jun 3 23:04:36 PDT 2005
Hi Ito,
Could you add (*env)->ExceptionDescribe(env) at the point where there is
a failed assertion. It should work now in any case. I guess that
FindClass returns NULL because it cannot find RawData* but we must
check.
Regards,
Guilhem.
On Sat, 2005-06-04 at 08:33 +0900, Ito Kazumitsu wrote:
> Hi,
>
> ChangeLog says:
>
> 2005-05-30 Helmer Kraemer <hkraemer at freenet.de>
>
> * libraries/javalib/kaffe/lang/AppClassLoader.java,
> libraries/javalib/kaffe/lang/PrimordialClassLoader.java,
> libraries/clib/native/PrimordialClassLoader.c: removed. Loading classes is
> now handled completely by ClassLoader / VMClassLoader.
> ...
> * libraries/javalib/META-INF/services/java.nio.charset.spi.CharsetProvider:
> removed, as iconv is treated specially by java.nio.charset.Charset
>
> The removal of META-INF/... is OK for me because I prefer using my own
> CharsetProvider wrapping gnu.java.nio.charset.iconv.IconvProvider.
>
> But the following simple program dumps core. This problem did not occur
> when kaffe.lang.*ClassLoader was used.
>
> bash-2.05b$ cat TestCharsetProviderMain.java
> import java.nio.charset.*;
> import java.nio.charset.spi.*;
> public final class TestCharsetProviderMain
> {
> public static void main(String[] args) throws Exception
> {
> Class c = Class.forName("gnu.java.nio.charset.iconv.IconvProvider", true,
> Thread.currentThread().getContextClassLoader());
> System.out.println(c);
> System.out.flush();
> CharsetProvider p = (CharsetProvider)(c.newInstance());
> System.out.println(p);
> System.out.flush();
> System.out.println(p.charsetForName(args[0]));
> }
> }
> bash-2.05b$ kaffe TestCharsetProviderMain EUC-JP
> class gnu.java.nio.charset.iconv.IconvProvider
> gnu.java.nio.charset.iconv.IconvProvider at 8408c3c
> charsetForName EUC-JP
> IconvMetaData gnu.java.nio.charset.iconv.IconvMetaData at 844cebc
> trying new IconvCharset(info)
> Assertion failed: (cls != NULL), function createRawData, file gnu_java_nio_charset_iconv_IconvEncoder.c, line 192.
> Abort trap (core dumped)
>
> Please note that some files are modified for debugging purpose:
>
> --- gnu/java/nio/charset/iconv/IconvProvider.java.orig Sat Apr 23 18:54:27 2005
> +++ gnu/java/nio/charset/iconv/IconvProvider.java Fri Jun 3 07:34:02 2005
> @@ -62,7 +62,7 @@
> }
> }
>
> - private IconvProvider()
> + public IconvProvider()
> {
> IconvMetaData.setup();
> }
> @@ -88,13 +88,23 @@
> {
> try
> {
> + System.out.println("charsetForName " + charsetName);
> + System.out.flush();
> IconvMetaData info = IconvMetaData.get(charsetName);
> + System.out.println("IconvMetaData " + info);
> + System.out.flush();
>
> // Try anyway if the set isn't found.
> if (info == null)
> info = new IconvMetaData(charsetName, 2.0f, 2.0f, 2.0f, 2.0f,
> new String[] { }, charsetName);
> - return new IconvCharset(info);
> + System.out.println("trying new IconvCharset(info)");
> + System.out.flush();
> + Charset cs = new IconvCharset(info);
> + System.out.println("new IconvCharset(info) " + cs);
> + System.out.flush();
> + return cs;
> + // return new IconvCharset(info);
> }
> catch (IllegalArgumentException e)
> {
>
>
> Note: Without changing private IconvProvider() to public IconvProvider(),
> an instance of this class cannot be created newInstance().
>
> --- libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c.~1.3.~ Fri May 20 23:46:49 2005
> +++ libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c Sat Jun 4 07:04:23 2005
> @@ -79,6 +79,7 @@
> if (infid == NULL || outfid == NULL)
> {
> cls = (*env)->GetObjectClass (env, obj);
> + assert (cls != NULL);
> infid = (*env)->GetFieldID (env, cls, "inremaining", "I");
> assert (infid != 0);
> outfid = (*env)->GetFieldID (env, cls, "outremaining", "I");
> @@ -183,10 +184,12 @@
>
> #ifdef POINTERS_ARE_64BIT
> cls = (*env)->FindClass (env, "gnu/classpath/RawData64");
> + assert (cls != NULL);
> method = (*env)->GetMethodID (env, cls, "<init>", "(J)V");
> data = (*env)->NewObject (env, cls, method, (jlong) ptr);
> #else
> cls = (*env)->FindClass (env, "gnu/classpath/RawData32");
> + assert (cls != NULL);
> method = (*env)->GetMethodID (env, cls, "<init>", "(I)V");
> data = (*env)->NewObject (env, cls, method, (jint) ptr);
> #endif
>
>
> Note: "assert (cls != NULL)" is also written in lookupClassMethod
> in kaffe/kaffevm/support.c. Without inserting "assert (cls != NULL)"
> here, the failure will be checked there.
>
>
> _______________________________________________
> kaffe mailing list
> kaffe at kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
More information about the kaffe
mailing list