ロギングの目的で、AspectJ の側面でスプリッテレータを監視しようとしています。しかし、それは不可能のようです。アスペクトが呼び出されることはなく、IntelliJ はアドバイスがメソッドをアドバイスしないことを教えてくれます。AspectJ 1.8.1を使用しています。
SSCCE は github にあります: https://github.com/flaviait/StreamSpliteratorAspectJExample
注釈付きのアスペクトを持つスプリッテレータ:
public class RepositorySpliterator<T> implements Spliterator<T> {
@Override
@SpliteratorWatch
public boolean tryAdvance(Consumer<? super T> action) {
...
}
}
私の側面:
@Aspect
@Component
public class SpliteratorWatchAspect {
private static final Logger logger = LoggerFactory.getLogger(SpliteratorWatchAspect.class);
@After("@annotation(spliteratorWatch)")
public void watch(JoinPoint joinPoint, SpliteratorWatch spliteratorWatch) throws Throwable {
...
}
}
最後になりましたが、注釈:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SpliteratorWatch {
}
私はこれをさまざまなコンテキストで数回実行しましたが、正常に動作します。Java 8 ストリーム API、スプリッテレータ、およびアスペクトに関する既知の問題はありますか? 多分誰かが私を助けることができます。それは素晴らしいことです!