Re: [PHP3] Zend OO syntax overloading support for Java components
| From: | rubys at us dot ibm dot com | Date: | Wed, 10 Nov 1999 03:41:12 +0000 |
| Subject: | Re: [PHP3] Zend OO syntax overloading support for Java components | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6089@lists.php.net to get a copy of this message | ||
>Look cool! I haven't worked with JNI, how much overhead is there in
>creating the JVM when it's linked into PHP? It looks like it's created
>and destroyed on a script by script basis, is that correct? I'm just
>wondering what the overhead is of this vs something like Babelj
>(http://www.twmacinta.com/software/babelj/) where a simple server is
>always running and PHP simply connects to it to call java methods.
JVMs are created and destroyed on a per-process basis. For CGI's this
would be on a per script basis. For Apache, this is configurable, but when
I test with one client, all I ever get is one JVM which persists until
Apache is recycled. I'm still looking into other configuration options.
I wasn't previously aware of babelj. For comparison, here's the first
stanza of http://www.twmacinta.com/software/babelj/babelj_tests.php3.txt
converted to "ext/java" syntax:
<?
$InetAddress = new Java("java.net.InetAddress");
$localhost = $InetAddress->getByName("www.yahoo.com");
$addr = $localhost->hostAddress;
if (substr($addr, 0, 4) == "204.") {
echo "$addr - staticMethodCall Passed\n";
} else {
echo "$addr - staticMethodCall Failed\n";
}
?>
Personally, I feel this is much more natural and usable approach.
For fairness, I must note that I need to improve my overload resolution
logic in order to handle the third case. Java will not automatically
coerce "long" values into "ints". This is coming soon. (Note: on most 32
bit platforms, a C long is the same thing as a Java int, but I didn't want
to build in any such assumptions).