public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hannes at helma dot at" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libgcj/23182] New: instanceof sometimes fails if compiled with -findirect-dispatch Date: Mon, 01 Aug 2005 15:50:00 -0000 [thread overview] Message-ID: <20050801155040.23182.hannes@helma.at> (raw) I'm compiling Rhino 1.5R5 <ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_5R5.zip> with the following command: gcj --main=org.mozilla.javascript.tools.shell.Main -findirect-dispatch js.jar -o rhino The resulting Rhino JavaScript shell throws exceptions on some String functions: js> "foo".charAt(0); js: "<stdin>", line 1: Primitive type expected (had java.lang.String instead) The code that throws the exception is in class src/org/mozilla/javascript/ScriptRuntime.java, static method toString(Object) at line 522: public static String toString(Object val) { for (;;) { if (val == null) return "null"; if (val instanceof Scriptable) { val = ((Scriptable) val).getDefaultValue(StringClass); if (val != Undefined.instance && val instanceof Scriptable) { throw errorWithClassName("msg.primitive.expected", val); } continue; } ... The val argument first refers to an instance of org.mozilla.javascript.NativeString, so instanceof Scriptable rightly evaluates to true. However, after the assignment val refers to an instance of java.lang.String, yet the second instanceof Scriptable still evaluates to true, and the exception is thrown. The String class actually looks ok (i.e. it doesn't contain Scriptable in the array returned by Class.getInterfaces(), so I guess this might be a caching bug in the implementation of instanceof. This only happens if the code is compiled with -findirect-dispatch. It still exists in gcj (GCC) 4.0.1 20050701 (prerelease), so chances are it is still present in the final 4.0.1 release. -- Summary: instanceof sometimes fails if compiled with -findirect- dispatch Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libgcj AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hannes at helma dot at CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23182
next reply other threads:[~2005-08-01 15:50 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-08-01 15:50 hannes at helma dot at [this message] 2005-08-23 16:05 ` [Bug libgcj/23182] " tromey at gcc dot gnu dot org 2005-08-23 20:48 ` tromey at gcc dot gnu dot org 2005-08-30 21:02 ` fitzsim at redhat dot com 2005-09-05 16:06 ` aph at gcc dot gnu dot org 2005-09-05 16:15 ` tromey at gcc dot gnu dot org 2005-09-05 17:40 ` fitzsim at redhat dot com 2005-09-05 18:55 ` fitzsim at redhat dot com 2005-09-08 14:09 ` aph at gcc dot gnu dot org 2005-09-09 0:34 ` green at redhat dot com 2005-09-09 16:04 ` cvs-commit at gcc dot gnu dot org 2005-09-22 17:43 ` mckinlay at redhat dot com 2005-09-30 15:54 ` cvs-commit at gcc dot gnu dot org 2005-09-30 16:17 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20050801155040.23182.hannes@helma.at \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).