zhiqinghuang / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Closure doesn't handle private method calls properly #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If you use Lambda.of() on a private method, it will call it immediately with 
dummy arguments and a later call to closure.apply() will do nothing.

See attached JUnit test.

I am running this against the current revision (775).

Original issue reported on code.google.com by marko.to...@gmail.com on 24 Nov 2009 at 3:13

Attachments:

GoogleCodeExporter commented 8 years ago
It is definitively not possible to use the of() method on a private method. 
This is
due to a limitation of the proxy mechanism employed. I will update the wiki 
page with
this limitation.

Thank you
Mario

Original comment by mario.fu...@gmail.com on 24 Nov 2009 at 3:40

GoogleCodeExporter commented 8 years ago
I am well aware that you cannot override a private method. But I still think 
that the 
current handling is not proper. An explanatory exception should be thrown 
instead of 
strange behavior. We lost a day or two pinpointing what exactly was going on -- 
the 
problem we saw was a NullPointerException due to quite an elaborate sequence of 
events started by the immediate invocation of the private method.

Original comment by marko.to...@gmail.com on 24 Nov 2009 at 5:12

GoogleCodeExporter commented 8 years ago
I agree. I will check if it is possible to throw a more meaningful exception in 
that
case.

Original comment by mario.fu...@gmail.com on 24 Nov 2009 at 5:40

GoogleCodeExporter commented 8 years ago
Unfortunately, since it is not possible to intercept the invocation of a private
method, it is also not possible to report this wrong closure usage in a more
meaningful way.

Original comment by mario.fu...@gmail.com on 7 Feb 2010 at 11:23