From: Chapman Flack <chap@anastigmatix.net>
To: Christoph Berg <myon@debian.org>
To: pgsql-pkg-debian@postgresql.org
Subject: Re: PL/Java 1.5.1_BETA2
Date: Mon, 17 Sep 2018 21:45:42 -0400
Message-ID: <5BA058C6.8010807@anastigmatix.net> (raw)
In-Reply-To: <20180917144716.GF27331@msg.df7cb.de>
References: <5B96B226.2080803@anastigmatix.net>
<20180915203221.GA19015@msg.df7cb.de>
<5B9D73A2.2090402@anastigmatix.net>
<20180916201808.GA30681@msg.df7cb.de>
<20180916202733.GB30681@msg.df7cb.de>
<5B9ED559.5080208@anastigmatix.net>
<20180917144716.GF27331@msg.df7cb.de>
On 09/17/18 10:47, Christoph Berg wrote:
> Re: Chapman Flack 2018-09-17 <5B9ED559.5080208@anastigmatix.net>
>> computedPath = replacement + computedPath.slice(plen);
>> to
>> computedPath = new java.lang.String(replacement + computedPath.slice(plen));
>
> ClassCastException: sun.org.mozilla.javascript.NativeJavaObject cannot be cast to java.lang.String
I have no words. :)
One more (less intuitive) thing might be worth trying:
computedPath = String(replacement + computedPath.slice(plen));
Would you have time to try it that way? I can't make the exception
happen here, even with an Oracle jdk7 that is installed.
Correction ... I can make it happen (prior to this change) in an
icedtea-6 build installed here, with a dubious version of the
Rhino-to-JSR223 adapter jar.
And the change above to String(...) does seem to fix it (without
breaking any of the other versions I can test).
I was first guessing the issue would be the change of the bundled
JavaScript implementation from Rhino in jdk6/7 to Nashorn in jdk8.
But in both cases there is also an adapter layer so that the Java
JSR223 API is the same whether Rhino or Nashorn is underneath. And
the pre-jdk8 OpenJDK builds seem to have ended up with an older,
incomplete version of the Rhino adapter (rhino-js-engine.jar) than
what was in the Oracle builds, and it doesn't handle all of the data
type conversions as it should.
Apparently it will correctly convert a JavaScript String to a Java
String. Apparently it does *not* know what to do with a JavaScript
wrapper of an actual Java string. :) And it seems Rhino has a
clever object, this ConsString, that is an implementation detail of
a JavaScript string created efficiently by concatenation, and of
course the adapter doesn't know what to do with that either.
So using that to construct a brand new ordinary JavaScript String
seems to be the one way to get a successful conversion.
-Chap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-pkg-debian@postgresql.org
Cc: chap@anastigmatix.net, myon@debian.org
Subject: Re: PL/Java 1.5.1_BETA2
In-Reply-To: <5BA058C6.8010807@anastigmatix.net>
References: <5B96B226.2080803@anastigmatix.net> <20180915203221.GA19015@msg.df7cb.de> <5B9D73A2.2090402@anastigmatix.net> <20180916201808.GA30681@msg.df7cb.de> <20180916202733.GB30681@msg.df7cb.de> <5B9ED559.5080208@anastigmatix.net> <20180917144716.GF27331@msg.df7cb.de> <5BA058C6.8010807@anastigmatix.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox