frjaeger220 / google-guice

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

Binder.bindInterceptor must throws an exception (if intercepted method is final) #431

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently guice not throws any exception if intercept annotated final method:

binder.bindInterceptor(Matchers.any(),
Matchers.annotatedWith(Secure.class), new SecureInterceptor());       

Original issue reported on code.google.com by jose.ill...@gmail.com on 28 Sep 2009 at 11:41

GoogleCodeExporter commented 9 years ago
Same occurs on private methods,

This is an important BUG that avoid Guice interception, the module not binding
nothing after this occurs without throw any exception...

all looks like ALL_OK but Guice not works

Original comment by jose.ill...@gmail.com on 29 Sep 2009 at 3:15

GoogleCodeExporter commented 9 years ago
This is known and intentional.
  http://code.google.com/p/google-guice/wiki/AOP
This is necessary to allow users to use Matchers.all() on methods, which 
otherwise 
would be unusable.

But perhaps we want a way to verify that matchers are working as intended.

Original comment by limpbizkit on 29 Sep 2009 at 4:49

GoogleCodeExporter commented 9 years ago
But, as you say, I would like to check that all interceptors are working fine
(throwing an exception when final and private methods trying intercepted)

  note: if you try to enhaced a final class an exception is throw

Can you provide any mechanism to force exception?

Thank you

Original comment by jose.ill...@gmail.com on 2 Oct 2009 at 9:58

GoogleCodeExporter commented 9 years ago
It's not that we choose not to support intercepting private & final methods, we 
technically cannot. It's the 
same way that you cannot use a subclass to override these methods.

Original comment by limpbizkit on 6 Apr 2010 at 4:32

GoogleCodeExporter commented 9 years ago
Sorry for my poor English,

   I don't want intercept private or final methods (as you say, this is technically
impossible). I would like that any attempt to intercept private or final methods
throws an Exception (for example in: Binder.bindInterceptor).

If you let me, I use your words: "I want a way to verify that matchers are 
working as
intended"

Original comment by jose.ill...@gmail.com on 6 Apr 2010 at 5:36