plaidgroup / plaid-lang

The Plaid Programming Language Tools
11 stars 1 forks source link

Using reflection to call methods on iterators throws an error #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I've attached a test case that will reproduce the problem. 

What is the expected output? What do you see instead?
The expected output is "1" being printed to stdout.  Instead, an error is 
thrown.

From what I've been able to glean from testing, internet searches, and Java's 
error messages, the 
problem is not specific to the Plaid interface for calling methods.  The 
iterator returned is a 
private class of whatever class is being iterated over, therefore an exception 
is thrown when 
trying to call its methods via reflection.

I think an appropriate solution would be if we get an error due to a privacy 
violation, we should 
check up the inheritance hierarchy to see if the private class inherits from a 
public class or 
interface with the method we're looking for.  This solution should solve the 
problem for iterators 
along with other similar internal classes.  This fix should be possible, but if 
it isn't we'll have to 
come up with something else.

Original issue reported on code.google.com by mhahn...@gmail.com on 18 May 2010 at 9:08

GoogleCodeExporter commented 9 years ago
I have made a fix, but I fear that it will not be sufficient in the long run, 
as I think it misses a couple corner 
cases.  Namely, if we look through the list of interfaces/superclasses and 
examine one that includes a method 
that is acceptable under primitive widening and there is a separate interface 
that better matches the signature, 
we will call the wrong method.  I will see if there is a relatively simple fix 
for this problem.

Original comment by mhahn...@gmail.com on 19 May 2010 at 7:23

GoogleCodeExporter commented 9 years ago
I added a function requiresPrimitiveWidening() that checks whether a method and 
the types of the parameters to 
the passed to the method require primitive widening.  I've modified 
PlaidJavaMethodMap to incorporate the new 
function and call the correct one accordingly.

Original comment by mhahn...@gmail.com on 19 May 2010 at 8:33