Mantis - Quercus
Viewing Issue Advanced Details
1404 major always 10-11-06 11:32 05-01-07 21:52
dberry  
nam  
normal  
closed 3.0.21  
fixed  
none    
none 3.1.1  
0001404: Problem using Java Objects within Quercus
This example shows that the iterator() method of an ArrayList object is not accessible via Quercus

Here is the test:
============================
<?php
// This is a test to find out what is causing problems with the xmldata
?>

<html>
<head>
</head>

<body>
<?php
// get instance of Java class java.lang.System in PHP
$system = new Java('java.lang.System');

// demonstrate property access
echo 'Java version=' . $system->getProperty('java.version') . '
';
echo 'Java vendor=' . $system->getProperty('java.vendor') . '
';
echo 'OS=' . $system->getProperty('os.name') . ' ' .
             $system->getProperty('os.version') . ' on ' .
             $system->getProperty('os.arch') . '
';

// java.util.Date example
$formatter = new Java('java.text.SimpleDateFormat',
                      "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");

echo $formatter->format(new Java('java.util.Date'));

$arr = new Java('java.util.ArrayList');
$arr->add('One');
$arr->add('Two');
$arr->add('Three');

$iter = $arr->iterator();
while($iter->hasNext()){
    $str = $iter->next();
    echo $str;
}


?></body>
</html>
==============================
here is the result:
==============================
java.lang.IllegalAccessException: Class com.caucho.quercus.env.JavaMethod
can not access a member of class java.util.AbstractList$Itr with modifiers
"public"
    at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
    at java.lang.reflect.Method.invoke(Method.java:578)
    at com.caucho.quercus.env.JavaMethod.invoke(JavaMethod.java:100)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:529)
    at com.caucho.quercus.env.JavaInvoker.call(JavaInvoker.java:536)
    at com.caucho.quercus.program.JavaClassDef.callMethod(JavaClassDef.java:440)
    at com.caucho.quercus.env.JavaValue.callMethod(JavaValue.java:197)
    at com.caucho.quercus.env.Var.callMethod(Var.java:851)
    at _quercus._testJavaExt__php.execute(usr/local/resin/deploy/_ear_platform/webapps/platform/testJavaExt.php:33)
    at com.caucho.quercus.page.QuercusPage.executeTop(QuercusPage.java:122)
    at com.caucho.quercus.servlet.QuercusServlet.service(QuercusServlet.java:244)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
    at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
    at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:209)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:274)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511)
    at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:516)
    at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
    at java.lang.Thread.run(Thread.java:613)


Notes
(0001890)
nam   
05-01-07 21:52   
php/069a

fixed in 3.1.1, I believe Java 6 fixes this longstanding issue with the JDK.