|
From: <php...@li...> - 2007-10-22 07:13:40
|
Hi,
> class I get a "No such mehtod" exceptions on very simple methods.
You can use
echo java_inspect ($javaObject);
to list the public methods.
> public String report() {
> $model = new JavaClass("py.model.Collapse");
> echo (String) $model->report();
> PHP Fatal error: Uncaught [o(Exception):"java.lang.Exception: Invoke
> failed: [c(Collapse)]->report. Cause: java.lang.NoSuchMethodException:
> report().
It's a misunderstanding. Unlike other languages which have a meta object protocol the Java
language doesn't allow methods for classes (the so called "class methods" are only procedures
bound to that type, you can't override them).
> Looks like almost exactly the same code in both cases. It looks like
No, it is a misunderstanding. The procedure java("typeName") returns a type, while new
Java("typeName") returns an instance. The new JavaClass("typeName") is the low-level interface
used by the java() procedure.
> Any suggestion would be greatly appreciated. .
Use
java("typeName")->staticProcedureName()
to call Java procedures belonging to "typeName". Use
$obj = new Java("typeName");
$obj->methodName()
to call methods.
Regards,
Jost Boekemeier
__________________________________ Ihre erste Baustelle? Wissenswertes für Bastler und Hobby Handwerker. www.yahoo.de/clever
|