Questions tagged [aspectj]

AspectJ is an aspect-oriented extension to the Java programming language that enables clean modularization of crosscutting concerns such as logging, error handling, standards enforcement and feature variations. Use this tag for questions about the programmatic use of this extension. For downloads, support, IDE integration, & documentation, see the "learn more" for this tag.

AspectJ is an Aspect-Oriented Programming (AOP) extension to Java, created by Xerox, that has as main components aspects (consisting of pointcuts and advices) and join points.

For AspectJ Eclipse integration, also see AspectJ Development Tools (AJDT); for NetBeans integration, see AspectJ in NetBeans; for IntelliJ IDEA integration, see IDEA Web Help.

Books:

Documentation:

3304 questions
15
votes
1 answer

Performance Overhead of AOP

I was wondering if there are any major performance issues with using AspectJ if it is being used to intercept every (or just most) method in an application. Of course, performance would also be affected by the advice that got executed on every…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
15
votes
3 answers

Syntax error, annotations are only available if source level is 5.0 - AspectJ in Maven

I am trying to use the aspectj-maven-plugin in a maven project. At compile time, I get: Syntax error, annotations are only available if source level is 5.0 Syntax error, annotations are only available if source level is 5.0 Syntax error, annotations…
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
15
votes
2 answers

Difference between @target and @within (Spring AOP)

Spring manual says: any join point (method execution only in Spring AOP) where the target object has an @Transactional annotation: @target(org.springframework.transaction.annotation .Transactional) any join point (method execution only in…
Steve Romanchuk
  • 153
  • 1
  • 1
  • 4
15
votes
2 answers

aspectj pointcut with annotation parameters

I am using aspectj to intercept methods that are annotated with @Profile(description="something") @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Profile { public String description() default…
user373201
  • 10,945
  • 34
  • 112
  • 168
15
votes
1 answer

JUnit tests fail when run together, but pass individually

I have a bunch of JUnit tests that all function individually. Each one is a true standalone unit test - single class under test. No contexts are required. I can run them all individually or all together either in Eclipse or via maven /…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
15
votes
2 answers

Error while compiling when using AspectJ compiler instead of Javac

I have a multi module project. The aspect is currently added to the "core" project. When doing a mvn clean install here it works. However trying to do a mvn clean install on parent project it fails with this error when compiling one of the other…
Knight Rider
  • 219
  • 1
  • 7
15
votes
5 answers

Code Analysis Tools and Inter-Type-Declarations

I have a maven project generated by Spring Roo and use several tools (checkstyle, pmd etc.) to collect information about my project. (namely I am using codehaus' sonar for this) Roo makes heavy use of AspectJ Inter Type Declarations (ITD) to…
er4z0r
  • 4,711
  • 8
  • 42
  • 62
15
votes
1 answer

How to debug delomboked code in IntelliJ?

In my Maven based project I'm using Lombok to save some boilerplate code. Furthermore I'm using a Spring Data library which uses AspectJ to get things done. Sadly, Lombok and AspectJ don't play nicely together out of the box, as the AspectJ compiler…
spa
  • 5,059
  • 1
  • 35
  • 59
14
votes
2 answers

@EnableAspectJAutoProxy does not work

I am using Spring Boot, and I would like to use AspectJ with it. The following works (of course): @Aspect @Component public class RequestMappingAspect { @Before("@annotation(org.springframework.web.bind.annotation.RequestMapping)") public…
Dante May Code
  • 11,177
  • 9
  • 49
  • 81
14
votes
2 answers

Tomcat 8, Spring Boot, @Configurable LoadTimeWeaving without -javaagent?

I'm trying to setup a @Configurable domain object(not managed by the spring container). I've got this working by adding the -javaagent:path/to/spring-instrument.jar as a JVM argument but it's not 100% clear to me whether or not this -javaagent MUST…
mjj1409
  • 3,075
  • 6
  • 28
  • 28
14
votes
2 answers

How to write an Aspect pointcut based on an annotated parameter

I'm having a bit of trouble working out how to create a pointcut that will operate on beans that have a specific annotated parameter. My eventual aim is to validate the value of the parameter before it's processed, but for the moment I just need to…
Stormcloud
  • 2,065
  • 2
  • 21
  • 41
14
votes
1 answer

aspectj-maven-plugin not covered by lifecycle in Kepler

I've just downloaded the OEPE (Kepler) and installed m2e and m2e-wtp connectors. I found out that under this path: Preferences ->Maven->Lifecycle mappings->Open workspace lifecycle mapping data there is a preconfigured xml file which says that maven…
LAC
  • 852
  • 4
  • 11
  • 31
14
votes
2 answers

AspectJ pointcut for annotated PRIVATE methods

I want to create a Pointcut for private methods that are annotated with a specific annotation. However my aspect is not triggered when the annotation is on a private method like below. @Aspect public class ServiceValidatorAspect { …
citress
  • 889
  • 3
  • 13
  • 35
14
votes
2 answers

How to configure AspectJ with Load Time Weaving without Interface

On my project, I currently use AspectJ (not just Spring AOP due to some limitation) with the weaving at the Compile Time. In order to speed up the development on Eclipse, I want to do the weaving at the Load Time. I succeed to do that but with one…
13
votes
1 answer

`Unrecognized VM option 'CMSClassUnloadingEnabled'` after switching to java 17

After changing the Java version to 17 I can't build the Gradle project. I am using Gradle 7.3.1 version and have the following line in Gradle properties: org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xms1g -Xmx4g -XX:+UseG1GC…
Wiktor Kęska
  • 411
  • 2
  • 4
  • 13