[jboss-jira] [JBoss JIRA] (AS7-5260) Synthetic method passed in InvocationContext

David Lloyd (JIRA) jira-events at lists.jboss.org
Mon Aug 6 13:51:06 EDT 2012


    [ https://issues.jboss.org/browse/AS7-5260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12710091#comment-12710091 ] 

David Lloyd commented on AS7-5260:
----------------------------------

We've discussed a two-pronged solution to this problem.

# If the proxy extends a base class, for each bridge method, instead of creating a proxy method for it, the bridge method bytecode should be copied or inherited, as appropriate
# If the proxy implements interfaces with covariantly overridden methods (due to generics or whatever), the proxy should generate a bridge method for the overridden method that calls the most specific method

I believe this would cover all the cases.
                
> Synthetic method passed in InvocationContext
> --------------------------------------------
>
>                 Key: AS7-5260
>                 URL: https://issues.jboss.org/browse/AS7-5260
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: EE
>    Affects Versions: 7.1.1.Final, 7.1.2.Final (EAP)
>            Reporter: Thomas Woelfle
>            Assignee: David Lloyd
>              Labels: as7, hibernate_validation, interceptor
>
> We have a JEE interceptor that validates method calls using the MethodValidator from the hibernate-validator package. We are running into problems when generic methods on stateless session beans are called that have been overwritten in a subclass. The problem is that the InvocationContext passed into our interceptor references the synthetic bridge method generated by the compiler instead of the correct overwritten method. Synthetic methods are ignored by hibernate-validator (see BeanMetaDataImpl.initMethodConstraints). This results in a NullPointerException when hibernate-validator tries to validate the given synthetic bridge method.
> Code example:
> public interface CrudService<D extends PersistentElement> {
>   D elementById(long id);
> }
> @Local
> public interface AccountService extends CrudService<Account> {
>   ... some additional methods
> }
> public class AbstractCrudServiceImpl<D extends PersistentElement> implements CrudService<D> {
>   public D elementById(long id) {
>      ... do something
>   }
> }
> @Stateless
> public class AccountServiceImpl extends AbstractCrudServiceImpl<Account> implements AccountService {
>   @Override
>   public Account elementById(long id) {
>     ... a specialized implementation
>   }
> }
> public class SomeOtherSessionBean {
>   @Inject
>   private AccountService accountService;
>  
>   public void doSomething() {
>     accountService.elementById(1);
>   }
> }
> In the example code above 'SomeOtherSessionBean.doSomething()' calls the method 'elementById'. In that case the InvocationContext passed into our interceptor references the synthetic bridge method with the signature 'PersistentElement AccountServiceImpl.elementById(long)' instead of the concrete method 'Account AccountServiceImpl.elementById(long)'.
> This seems to be a bug, isn't it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list