AOP synthetic warnings after Java 8 upgrade

1,575 views
Skip to first unread message

sar...@gmail.com

unread,
Nov 5, 2014, 8:15:56 AM11/5/14
to google...@googlegroups.com
Recently after upgrading to Java 8 I've started to see warnings from guice AOP in my glassfish logs:

[2014-11-05T13:18:01.197+0100] [glassfish 4.0] [WARNING] [] [com.google.inject.internal.ProxyFactory] [tid: _ThreadID=19 _ThreadName=http-listener-1(1)] [timeMillis: 1415189881197] [levelValue: 900] [[
  Method [public com.gwtplatform.dispatch.rpc.shared.Result SendUserMessageHandler.execute(com.gwtplatform.dispatch.rpc.shared.Action) throws com.gwtplatform.dispatch.shared.ActionException] is synthetic and is being intercepted by [TransactionalInterceptor@3b17ed63]. This could indicate a bug.  The method may be intercepted twice, or may not be intercepted at all.]]

I have a custom @Transaction annotation in subclasses of AbstractActionHandler. I've modified my code and the warnings are gone, but I'm concerned that there could be other issues as well. Do you know if there are any changes in java 8 which would cause these warnings to appear? The code didn't change at all between java 7 and 8 upgrade.

My current code which excludes synthetic methods:

public class ServerModule extends AbstractModule {
   
private static final class TransactionMethodMatcher extends AbstractMatcher<Method> {
       
@Override
       
public boolean matches(final Method method) {
           
return method.isAnnotationPresent(Transaction.class) && !method.isSynthetic();
   
}

   
@Override
   
protected final void configure() {
       
final TransactionalInterceptor transactionalInterceptor = new TransactionalInterceptor();

        bindInterceptor
(Matchers.subclassesOf(AbstractActionHandler.class), new TransactionMethodMatcher(), transactionalInterceptor);
        bind
(TransactionalInterceptor.class).toInstance(transactionalInterceptor);
        requestInjection
(transactionalInterceptor);
   
}
}

Sam Berlin

unread,
Nov 5, 2014, 9:12:18 AM11/5/14
to google...@googlegroups.com
This is indeed odd, especially because your matcher explicitly says no synthetic methods.

There was a related change in Java8 where annotations now are copied to generated bridge methods,  What happens if you add && !method.isBridge() to the matcher (though that's unlikely to fix anything)?

FWIW, the code checking this is here... so it's checking for synthetic methods. Guice issue 252 has some background on this, and there's a related change in cglib to make this kind of pattern work.

Could you create an issue with a minimal test-case that reproduces the problem, and we can look into it?

Thanks!

sam




--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/5af71528-f8cb-41ae-9ac6-f09f02b955e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sar...@gmail.com

unread,
Nov 5, 2014, 1:32:34 PM11/5/14
to google...@googlegroups.com
Sorry, I should have been more clear.

I added the !method.isSynthetic() to get rid of the warnings that started appearing after upgrading to Java 8.
The same code running on Java 7 didn't match any synthetic methods, and I didn't need to filter them out.
Something in Java 8 seems to be causing the issue, and I'm not using lamdas or anything Java 8 specific.

It seems to be working fine now though with the extra synthetic check.

Colin Decker

unread,
Nov 5, 2014, 1:42:52 PM11/5/14
to google...@googlegroups.com
Yeah, Java 8 changed things so that if a bridge method is generated for a method with annotations, the annotations are copied to the bridge method. I assume that's what's going on here.

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.

Sam Berlin

unread,
Nov 5, 2014, 1:55:21 PM11/5/14
to google...@googlegroups.com
Yup, exactly.  Glad we have that warning logged!

sam

Reply all
Reply to author
Forward
0 new messages