Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003748 [Quercus] feature always 11-05-09 12:52 11-07-09 17:45
Reporter PeterJ View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.2
Summary 0003748: Avoid recursive instropection of methods.
Description At the end of ...program.JavaClassDef.introspectMethods, the method calls itself recursively, first for the superclasses and then for the interfaces. This does not appear to be necessary because the line type.getMethods() already provided all of the methods from the superclasses and the interfaces. Even the code in AbstractJavaMethod.overload seems to acknowledge that the superclass and interface methods can be previously processed.

Removing this recursion would provide some performance benefit because the amount of duplicate effort would be eliminated, and the extra garbage generated by overriding the entries in _functionMap would be avoided.

In addition, it would benefit developers who are attempting to extend the existing capabilities. For example, I am attempting to provide support for another database, but I do not want to support as PHP functions some of the methods that are provided in JdbcConnectionResource. Unfortunately, overriding the method in my class and adding a @Hide annotation does not work because of the recursion in introspectMethods - the overridden methods get added as functions for my PHP class anyway.

Finally, I also noticed that the public methods on java.lang.Object are added as functions available to the PHP class. I don't think that this was intended so the attached patch includes a test to eliminate those methods.

By the way, if my logic is flawed and there is a perfectly valid reason for the recursion, then it would be nice if a comment explaining WHY THE RECURSION IS NECESSARY would appear in the code. I hate attempting to make sense of someone else's code when they have not commented on WHY they wrote the code the way they did, especially if the code in question does not make obvious sense (in the way that this recursion makes no obvious sense).
Additional Information
Attached Files  quercus_introspect_recursion.txt [^] (953 bytes) 11-05-09 12:52

- Relationships

- Notes
(0004289)
nam
11-05-09 19:23

You are right that we don't want to add java.lang.Object methods to PHP classes. However, we do want to add those methods to Java classes. So we'll need to distinguish between the two and put in the fix accordingly.
 
(0004290)
nam
11-07-09 17:34

php/0cja

Method introspection is fixed for 4.0.2, so @Hide should work as expected.
 
(0004291)
nam
11-07-09 17:45

php/4a40

java.lang.Object methods are not added to Java-backed PHP classes anymore
 

- Issue History
Date Modified Username Field Change
11-05-09 12:52 PeterJ New Issue
11-05-09 12:52 PeterJ File Added: quercus_introspect_recursion.txt
11-05-09 12:54 PeterJ Issue Monitored: PeterJ
11-05-09 19:23 nam Note Added: 0004289
11-07-09 17:34 nam Status new => assigned
11-07-09 17:34 nam Assigned To  => nam
11-07-09 17:34 nam Note Added: 0004290
11-07-09 17:45 nam Status assigned => closed
11-07-09 17:45 nam Note Added: 0004291
11-07-09 17:45 nam Resolution open => fixed
11-07-09 17:45 nam Fixed in Version  => 4.0.2


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
35 total queries executed.
28 unique queries executed.
Powered by Mantis Bugtracker