ID: 19775
Comment by: ardo at np dot ee
Reported By: waazup at hotmail dot com
Status: Open
Bug Type: Java related
Operating System: Windows XP Pro
PHP Version: 4.3.3RC5-dev
New Comment:

I'm also experiencing ogous bug. Seems to me that Java class
doesn't set the 2d matrix in php correctly. For example:
PHP:
<?
$java = new Java("testiasi.testclass");
$prices = $java->getPrices();

/*$prices = array(
array(0, 1, 2, 3),
array(5, 6, 7, 8)
);*/

print_r($prices);
echo "<BR>";
for($a = 0; $a < count($prices); $a++)
echo "$a: " . $prices[$a][0] . "<BR>";

print_r($prices);

?>
Java:
package testiasi;
public class testclass {
public testclass() {
}

public double[][] getPrices() {
return new double[][]{
{0, 1, 2, 3},
{5, 6, 7, 8}
};
}
}

The result expected is:
Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) [1] =>
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 ) )
0: 0
1: 5
Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) [1] =>
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 ) )

But actually I get:

Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) [1] =>
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 ) )
0: 0
1: 5
Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) [1] => )

So it means that accessing the array has messed it up ..
When trying to access it some more, php.exe dies.

I'll use array of classes as a result in Java for quick hack, but a
real fix would really be appreciated. I'll look into the source code
later, but I don't believe I can find a solution.


Previous Comments:
------------------------------------------------------------------------

[2003-08-21 08:20:50] [email]sniperphp.net[/email]

The Java stuff in PHP is totally unmaintained (and still experimental
too). Maybe in PHP 5 it will actually work.


------------------------------------------------------------------------

[2003-08-21 00:48:04] waazup at hotmail dot com

Sorry feedback took so long. I'm still experiencing the same problem.
Using the latest stable build link you provided for windows. Dated
August 15th.

It's frustrating to by asked the same question 3 times. Is an attempt
being made to fix this bug, or are you just wishing it will magically
disappear?
Sorry if I appear snappy but this bug was posted almost 1 year ago.

------------------------------------------------------------------------

[2003-08-15 08:17:27] [email]sniperphp.net[/email]

Please try using this CVS snapshot:

[url]http://snaps.php.net/php4-STABLE-latest.tar.gz[/url]

For Windows:

[url]http://snaps.php.net/win32/php4-win32-STABLE-latest.zip[/url]



------------------------------------------------------------------------

[2002-11-21 02:14:26] waazup at hotmail dot com

I tried using:
[url]http://snaps.php.net/win32/php4-win32-latest.zip[/url]
Time Stamped 20-Nov-2002 23:30

I am still getting the same error as in the last post.

------------------------------------------------------------------------

[2002-11-15 02:57:11] waazup at hotmail dot com

I determined that for some reason, these latest builds don't like to
run from folders that have names that include spaces.
I created a virtual directory on WinXP point to a directory with no
spaces to get around this on issue.
After I resolved that problem, php was able to open the file but this
is the error I received using the latest build time stamped 14-Nov-2002
23:29


-------------------------------------------
CGI Error
The specified CGI application misbehaved by not returning a complete
set of HTTP headers. The headers it did return are:

imageMatrix[0][0]=20

imageMatrix[1][1]=22

2

9

21
-----------------------------------------------------

I also received a windows error that says "PHP Script Interpreter has
encountered a problem".

I have created a stripped down version of the script I am using to test
this bug. This script responds the same way as my original php script
for version 4.2.3 (note that I did not post the entire original script
just the portion that called the Java class).

Here is the stripped down script to test the bug:
<?
// Author: Peter Kroll [email]waazuphotmail.com[/email]
// This is a stripped down version of the program I am trying to run.
// I have hard coded values that are normally read in from an image.

// 3 x 3 filter
$filter[0] = array (.11, .11, .11);
$filter[1] = array (.11, .11, .11);
$filter[2] = array (.11, .11, .11);
$filterDimension = 3;

// Get information about the image (normally read in from an image)
$imageSizeX = 320;
$imageSizeY = 240;

// This for loop normally reads image pixels
for($countY = 0; $countY < $imageSizeY; $countY++)
{
for($countX = 0; $countX < $imageSizeX; $countX++)
{
// assign a default value so graphics library doesn't need to be
used
$imageMatrix[$countX][$countY] = $countY + $countX + 20;
}
}

// print some values before calling Java class
print "imageMatrix[0][0]=" . $imageMatrix[0][0] . "<BR>\n";
print "imageMatrix[1][1]=" . $imageMatrix[1][1] . "<BR>\n";

// Apply filter to image
$FilterObject = new Java("Filter");
$newImageMatrix = $FilterObject->applyFilter($filter, $filterDimension,
$imageMatrix, $imageSizeX, $imageSizeY);
$tempVal = $newImageMatrix[0][0];
print $tempVal . "<BR>\n";
$tempVal = $newImageMatrix[1][1];
print $tempVal . "<BR>\n";
$tempVal = $newImageMatrix[2][2];
print $tempVal . "<BR>\n";

?>

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/19775[/url]

--
Edit this bug report at [url]http://bugs.php.net/?id=19775&edit=1[/url]