From: <php...@li...> - 2007-05-22 17:47:53
|
I'm finally upgrading my PHP code from Java Bridge 3.0.7 to 4.0.7, and the biggest change that I think I need to do is start using java_values() to convert Java objects into their PHP equivalents. I've converted over a small fraction of my code using java_values(), and it's working fine, but I'm dreading this migration process.... hunting down every little Java object that used to be cast into PHP automatically and then explicitly coverting it. Is this absolutely necessary? Can I turn on some option so the Bridge can continue to do it for me automatically? Thanks for your help, Jonathan Abbett =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Jonathan Abbett Children's Hospital Informatics Program 1 Autumn Street, Fifth Floor Boston, MA 02215 617-355-8334 jon...@ch... http://www.chip.org |
From: <php...@li...> - 2007-05-23 08:53:47
|
Hi Jonathan, how does the code look like? Why is the cast necessary, anyway? The zend engine automatically converts a Java object into a PHP object. Regards, Jost Boekemeier __________________________________ Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever |
From: <php...@li...> - 2007-05-25 14:17:22
|
I've isolated the problem a bit more. This works properly: $string =3D new Java('java.lang.String', 'abc'); // prints 'abc' echo $string; These echoes, however, do not: $string =3D new Java('java.lang.String', 'abc'); echo "This is my $string" . "\n"; echo "This is my " . $string . "\n"; echo $string " is my string" . "\n"; The result I see is: This is my Object id #30 This is my Object id #30 Object id #30 is my string The result is similar with other object types. Echoing just a boolean object gives [[o:Boolean]:"true"], but concatenating it with a string gives "Object id #1 is my boolean". Thanks for your help, Jonathan System Details: Java Bridge 4.0.7 Apache/2.0.55 (Win32) PHP/5.1.6 =20 > -----Original Message----- > From: php...@li...=20 > [mailto:php...@li...]=20 > On Behalf Of php...@li... > Sent: Wednesday, May 23, 2007 4:54 AM > To: php...@li... > Subject: Re: [Php-java-bridge-users] java_values? >=20 > Hi Jonathan, >=20 > how does the code look like?=20 >=20 > Why is the cast necessary, anyway? The zend engine > automatically converts a Java object into a PHP > object. >=20 >=20 > Regards, > Jost Boekemeier >=20 >=20 |
From: <php...@li...> - 2007-05-26 10:41:57
|
Hi Jonathan, the bug described below has been fixed in PHP version 5.2.0 and above. (I am not sure, but I think PHP 5.1.6 contains the same fix). Please use this version instead. > These echoes, however, do not: > > $string = new Java('java.lang.String', 'abc'); > echo "This is my $string" . "\n"; > echo "This is my " . $string . "\n"; > echo $string " is my string" . "\n"; > > The result I see is: > > This is my Object id #30 > This is my Object id #30 > Object id #30 is my string Yes, that was a known bug in the PHP engine. It appeared in all PHP 5 versions from 5.0.0 to 5.1.5. > The result is similar with other object types. > Echoing just a boolean > object gives [[o:Boolean]:"true"], but concatenating > it with a string > gives "Object id #1 is my boolean". It should display: [[o:Boolean]:"true"] is my boolean. If you don't want to upgrade to PHP 5.2.x or at least 5.1.6, please use the "java.so" or "php_java.dll" from the php-java-bridge-legacy download. It contains a piece of C code which works around this problem. Regards, Jost Boekemeier __________________________________ Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever |
From: <php...@li...> - 2007-05-29 15:14:03
|
I just upgraded to 5.2.2, and have confirmed that the problem is fixed. Thanks!=20 > -----Original Message----- > From: php...@li...=20 > [mailto:php...@li...]=20 > On Behalf Of php...@li... > Sent: Saturday, May 26, 2007 6:42 AM > To: php...@li... > Subject: Re: [Php-java-bridge-users] java_values? >=20 > Hi Jonathan, >=20 > the bug described below has been fixed in PHP version > 5.2.0 and above. (I am not sure, but I think PHP 5.1.6 > contains the same fix). >=20 > Please use this version instead. >=20 >=20 > > These echoes, however, do not: > >=20 > > $string =3D new Java('java.lang.String', 'abc'); > > echo "This is my $string" . "\n"; > > echo "This is my " . $string . "\n"; > > echo $string " is my string" . "\n"; > >=20 > > The result I see is: > >=20 > > This is my Object id #30 > > This is my Object id #30 > > Object id #30 is my string >=20 > Yes, that was a known bug in the PHP engine. It > appeared in all PHP 5 versions from 5.0.0 to 5.1.5. >=20 >=20 > > The result is similar with other object types.=20 > > Echoing just a boolean > > object gives [[o:Boolean]:"true"], but concatenating > > it with a string > > gives "Object id #1 is my boolean". >=20 > It should display: [[o:Boolean]:"true"] is my boolean. >=20 > If you don't want to upgrade to PHP 5.2.x or at least > 5.1.6, please use the "java.so" or "php_java.dll" from > the php-java-bridge-legacy download. It contains a > piece of C code which works around this problem. >=20 >=20 > Regards, > Jost Boekemeier |
From: <php...@li...> - 2007-05-29 18:10:24
|
With strings, that is. Is it expected behavior that Integers, Floats, Doubles, and Longs need to be converted with java_values() before being used in a PHP context? For example, $integer =3D new Java('java.lang.Integer', 123); // displays [[o:Integer]:"123"] echo $integer; // displays notice "could not be converted to int" and 'not equal' if ($integer =3D=3D 123) echo 'equal'; else echo 'not equal'; // displays 123 echo java_values($integer); // displays 'equal' if (java_values($integer) =3D=3D 123) echo 'equal'; else echo 'not equal'; =20 Thanks for your help, Jonathan Abbett > -----Original Message----- > From: php...@li...=20 > [mailto:php...@li...]=20 > On Behalf Of php...@li... > Sent: Tuesday, May 29, 2007 11:14 AM > To: php...@li... > Subject: Re: [Php-java-bridge-users] java_values? >=20 > I just upgraded to 5.2.2, and have confirmed that the problem=20 > is fixed. > Thanks!=20 >=20 >=20 > > -----Original Message----- > > From: php...@li...=20 > > [mailto:php...@li...]=20 > > On Behalf Of php...@li... > > Sent: Saturday, May 26, 2007 6:42 AM > > To: php...@li... > > Subject: Re: [Php-java-bridge-users] java_values? > >=20 > > Hi Jonathan, > >=20 > > the bug described below has been fixed in PHP version > > 5.2.0 and above. (I am not sure, but I think PHP 5.1.6 > > contains the same fix). > >=20 > > Please use this version instead. > >=20 > >=20 > > > These echoes, however, do not: > > >=20 > > > $string =3D new Java('java.lang.String', 'abc'); > > > echo "This is my $string" . "\n"; > > > echo "This is my " . $string . "\n"; > > > echo $string " is my string" . "\n"; > > >=20 > > > The result I see is: > > >=20 > > > This is my Object id #30 > > > This is my Object id #30 > > > Object id #30 is my string > >=20 > > Yes, that was a known bug in the PHP engine. It > > appeared in all PHP 5 versions from 5.0.0 to 5.1.5. > >=20 > >=20 > > > The result is similar with other object types.=20 > > > Echoing just a boolean > > > object gives [[o:Boolean]:"true"], but concatenating > > > it with a string > > > gives "Object id #1 is my boolean". > >=20 > > It should display: [[o:Boolean]:"true"] is my boolean. > >=20 > > If you don't want to upgrade to PHP 5.2.x or at least > > 5.1.6, please use the "java.so" or "php_java.dll" from > > the php-java-bridge-legacy download. It contains a > > piece of C code which works around this problem. > >=20 > >=20 > > Regards, > > Jost Boekemeier >=20 >=20 > -------------------------------------------------------------- > ----------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users >=20 >=20 |
From: <php...@li...> - 2007-05-31 07:22:38
|
Hi, > Is it expected behavior that > Integers, Floats, > Doubles, and Longs need to be converted with > java_values() before being > used in a PHP context? not that I know of. The PHP/Java Bridge protocol shouldn't touch integral types(integer, boolean, ...). BTW: The bridge doesn't convert anything. A java.lang.String and a java.lang.Integer is not converted (unless you use the deprecated php 4 java.so). What you probably mean is: How are objects displayed? The standard procedure is ObjectToString(Object ob), see JavaBridge.java, which displays all objects as [o(Type):StringRepresentation]. The only exception is the String type, there exists a method ObjectToString(String ob) which displays the object as "StringRepresentation". We could remove the ObjectToString(String o) and modify ObjectToString(Object o) so that o->toString() is called for any object. But you need to convince me that such a behaviour is useful. :) > $integer = new Java('java.lang.Integer', 123); > // displays [[o:Integer]:"123"] Well Integer is an object, not primitive type. Isn't it possible to pull the integer value from the above Integer object and display that? For example: echo $Integer->getIntValue(); should display 123. > // displays notice "could not be converted to int" > if ($integer == 123) echo 'equal'; else That's why I'd like to keep the current behaviour. Your $integer is a java object, not a primitive type. Displaying it as "123" will make the debugging process more difficult. However, you are probably upgrading from PHP4, where autoconversion was the default behavour. There is a protocol header option. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2007-05-31 15:44:09
|
After upgrading from 3.0.7 to 4.0.7, it looks like I can't use foreach() over a HashSet. It implements Collection, so in theory, it should work (it used to), but a NoSuchMethodException is thrown over a call to "getIterator". HashSet has an iterator() method (like all Collections), so I'm curious why the Bridge is attempting to call getIterator() on my behalf. Exception pasted below. Thanks for your help, Jonathan [[o:Exception]:"java.lang.Exception: Invoke failed: [[o:HashSet]]->getIterator. Cause: java.lang.NoSuchMethodException: getIterator(). Candidates: [] Responsible VM: 1.5.0_08@http://java.sun.com/" at: #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1106) #-4 php.java.bridge.Request.handleRequest(Request.java:342) #-3 php.java.bridge.Request.handleRequests(Request.java:388) #0 http://localhost:8080/JavaBridge/java/Java.inc(151): java_ThrowExceptionProxyFactory->getProxy(50, true) #1 http://localhost:8080/JavaBridge/java/Java.inc(304): java_Arg->getResult(true) #2 http://localhost:8080/JavaBridge/java/Java.inc(310): java_Client->getWrappedResult(true) #3 http://localhost:8080/JavaBridge/java/Java.inc(489): java_Client->getResult() #4 http://localhost:8080/JavaBridge/java/Java.inc(735): java_Client->invokeMethod(49, 'getIterator', Array) #5 http://localhost:8080/JavaBridge/java/Java.inc(853): java_JavaProxy->__call('getIterator', Array) #6 http://localhost:8080/JavaBridge/java/Java.inc(886): Java->__call('getIterator', Array) #7 C:\deploy\merged\php-client\IndivoAPI.class.php(974): JavaObject->getIterator() #8 C:\deploy\merged\php-client\IndivoAPI.class.php(932): IndivoAPI->updateDocument('d961ccb2-a7ca-4...', 'usr4038835@indi...', 'usr4038835@indi...', Object(java_InternalJavaObject), 'urn:org:indivo:...', '0597a897-d50f-4...') #9 C:\websites\indivo\phplib\personal.function.php(298): IndivoAPI->updateDocumentWithObject('d961ccb2-a7ca-4...', 'usr4038835@indi...', 'Sample User', 'patient', 'usr4038835@indi...', Object(java_InternalJavaObject), 'urn:org:indivo:...', '0597a897-d50f-4...') #10 [internal function]: saveDemographics(Array) #11 C:\websites\indivo\phplib\xajax_0.2.4\xajax.inc.php(997): call_user_func_array('saveDemographic...', Array) #12 C:\websites\indivo\phplib\xajax_0.2.4\xajax.inc.php(656): xajax->_callFunction('saveDemographic...', Array) #13 C:\websites\indivo\viewer.php(19): xajax->processRequests(true) #14 {main}] |
From: <php...@li...> - 2007-05-31 18:01:20
|
Hi Jonathan, > Java->__call('getIterator', Array) this sounds like a bug in Java.inc. The bridge shouln't pass getIterator to the back end. I have created two tickets: * PR1729089 Iterator not working anymore * PR1729086 Header option to enable backward compatibility not working We will check these issues asap. Thank you very much for the bug reports! Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever |
From: <php...@li...> - 2007-06-02 12:25:58
|
Hi, > > Java->__call('getIterator', Array) > > this sounds like a bug in Java.inc. The bridge > shouln't pass getIterator to the back end. the problem appears to be a workaround / debug code for an earlier version of the zend engine. Please edit your Java.inc and remove the lines marked with a - class JavaObject extends Java { function Java() { $delegate = $this->__delegate = java_create(func_get_args(), true); $this->__java = $delegate->__java; $this->__client = $delegate->__client; } - function getIterator() { - $args = func_get_args(); return $this->__call("getIterator", $args); - } - function offsetExists($idx) { - $args = func_get_args(); return $this->__call("offsetExists", $args); - } - function offsetGet($idx) { - $args = func_get_args(); return $this->__call("offsetGet", $args); - } - function offsetSet($idx, $val) { - $args = func_get_args(); return $this->__call("offsetSet", $args); - } - function offsetUnset($idx) { - $args = func_get_args(); return $this->__call("offsetUnset", $args); - } } class java_class extends JavaObject { I have added a JavaBridge.jar at the end of your ticket which containes an updated Java.inc in the META-INF/ folder. This jar file also recognizes the system property php.java.bridge.ext_java_compatibility When the option is set to true, the bridge destroys the object identity for String, Long, Integer, Float, Double, Collection, Boolean. You can set the option in php/java/bridge/global.properties or as a VM parameter, for example: export JAVA_OPTS="-Dphp.java.bridge.ext_java_compatibility=true" export JAVA_HOME=/opt/jdk1.6 /opt/apache-tomcat6/bin/catalina.sh start or java -Dphp.java.bridge.ext_java_compatility=true -jar JavaBridge.jar SERVLET_LOCAL:8080 Regards, Jost Boekemeier __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever |
From: <php...@li...> - 2007-05-31 18:02:17
|
Hi, => http://sourceforge.net/tracker/index.php?func=detail&aid=1729086&group_id=117793&atid=679233 __________________________________ Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever |