[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: MDR doesn't work on annotated privates

adrian@jboss.org do-not-reply at jboss.com
Wed Aug 13 09:33:14 EDT 2008


"wolfc" wrote : 
  | So I don't see why you have to look at annotations on overridden methods.
A private method is considered to be non-overriddable. So I need that declaring class somewhere.

Ok, I understand now. It's not an override.

This isn't even really java since without a setAccessible() it's illegal. :-)


  |       Sub sub = new Sub();
  |       Method method = Super.class.getDeclaredMethod("doSomething");
  |       // method.setAccessible(true);
  |       method.invoke(sub); 
  | 
  | Exception in thread "main" java.lang.IllegalAccessException: Class Sub can not access a member of class Super with modifiers "private"
  | 	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
  | 	at java.lang.reflect.Method.invoke(Method.java:588)
  | 	at Sub.main(Sub.java:36)
  | 

I guess it's mitigated by the super class having to add the annotation
that allows it?

Since you don't need to setAccessible() to retrieve annotations from
the private super method then I don't think we would be introducing a security 
hole by supporting it within the MDR (this prints null).


  |       Method method = Super.class.getDeclaredMethod("doSomething");
  |       //method.setAccessible(true);
  |       System.out.println(method.getAnnotation(Inherited.class)); 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170330#4170330

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170330



More information about the jboss-dev-forums mailing list