2020import java .lang .annotation .Annotation ;
2121import java .lang .annotation .Repeatable ;
2222import java .lang .reflect .GenericArrayType ;
23+ import java .lang .reflect .Method ;
2324import java .lang .reflect .Modifier ;
2425import java .lang .reflect .ParameterizedType ;
2526import java .lang .reflect .Type ;
@@ -169,7 +170,7 @@ public static boolean isBeanProxyable(Bean<?> bean, BeanManagerImpl manager) {
169170 // note that a bridge method can be a candidate for interception in rare cases; do not discard those
170171 boolean businessMethod = !annotatedMethod .isStatic () && !annotatedMethod .isAnnotationPresent (Inject .class );
171172
172- if (businessMethod && !isInterceptorMethod (annotatedMethod )) {
173+ if (businessMethod && !isInterceptorMethod (annotatedMethod ) && ! isLambdaMethod ( annotatedMethod ) ) {
173174 annotatedMethods .add (annotatedMethod );
174175 }
175176 }
@@ -185,6 +186,14 @@ private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
185186 return false ;
186187 }
187188
189+ // Lambdas in classes will be compiled into methods declared on that given class.
190+ // The exact representation differs between javac (standard compiler) and EJC (Eclipse compiler).
191+ // We want to avoid attempting to intercept these methods - note that the detection is on a "best effort" basis.
192+ private static boolean isLambdaMethod (AnnotatedMethod <?> annotatedMethod ) {
193+ Method javaMember = annotatedMethod .getJavaMember ();
194+ return !javaMember .isBridge () && javaMember .isSynthetic ();
195+ }
196+
188197 /**
189198 * Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers. Qualifier equality rules for
190199 * annotation members are followed.
0 commit comments