dev-aspectj / aspectj-maven-plugin

AspectJ Maven Plugin
MIT License
48 stars 12 forks source link

Fails on JDK 17 #22

Closed krzyk closed 2 years ago

krzyk commented 3 years ago

I used this plugin on JDK 16 and it was working fine. Now I wanted to test out how my project behaves in JDK 17 and it fails on aspectj-maven-plugin with:

[INFO]
[INFO] --- aspectj-maven-plugin:1.13.M3:compile (default) @ fms ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[ERROR] Syntax error, annotations are only available if source level is 1.5 or greater

Just as if the source level was < 1.5, which is strange because it is set to 17.

This is my configuration:

             ...
           <java.version>17</java.version>
        <spring.boot.version>2.5.3</spring.boot.version>
        <aspectjtools.version>1.9.7</aspectjtools.version>
...
            <plugin>
                <groupId>dev.aspectj</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.13.M3</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <Xlint>ignore</Xlint>
                    <complianceLevel>${java.version}</complianceLevel>
                    <encoding>UTF-8</encoding>
                    <verbose>false</verbose>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>${aspectjtools.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectjtools.version}</version>
                    </dependency>
                </dependencies>
           </plugin>
kriegaex commented 3 years ago

The latest version of AspectJ is 1.9.7, supporting Java 16, see release notes.

This plugin cannot support a version higher than AspectJ itself. Besides, Java 16 is the latest Java SE release, Java 17+ are only development or preview versions. Why do you think you need Java 17 today, before it is even released? What is your use case?

krzyk commented 3 years ago

Well, normally apps start supporting future JDKs earlier, so there won't be a lag after the release.

17 will have RC in 2 weeks, there are no new commits, so it is a good time to prepare for working with it.

I wanted to test my project if it is ready for 17, but it fails early on aspectj, which is a bummer.

But if there is no aspectj right now supportin 17 then we need to wait :(

kriegaex commented 3 years ago

The AspectJ compiler is a fork of the Eclipse compiler, i.e. if AspectJ wants to support new Java features, it needs to do an ugly merge, integrate it with the AspectJ-specific compiler features, create new tests, keep existing ones passing and many more things. The lead developer of AspectJ (Andrew "Andy" Clement) is super busy with his daytime job as a development director at VMware, leading the team creating Spring Boot Native (running on GraalVM). So I did 90% of the work for 1.9.7, upgrading from Java 14 to 15+16, and also trying to keep this plugin up to date. I am still a relative newbie contributor to both projects and also have a daytime job as an agile coach. Actually, I last made money with coding 20 years ago, only doing some OSS development for fun in my sparetime. You see, AspectJ does not have big teams like Oracle, Eclipse, Apache, SpringSource etc.

When next time I feel inclined to merge in the latest changes from ECJ into AspectJ and have a running development version and also get around to upgrade this plugin to Java 17 as a consequence, I can let you know. So let us keep this issue open.

As an alternative, feel free to contribute to AspectJ and provide pull requests. 😉

BTW, which new language features are you testing presently? There does not seem to be a lot of exciting stuff.

krzyk commented 3 years ago

Actually I'm not testing new language features, I just like to be on the latest JDK :) For me records where the biggest feature, so I got it in JDK 16. I don't have much need for sealed classes but you know, latest and greatest and fastest JDK is always the current one :)

And it's the one that gets the most bugfixes and is the one that is encouraged by openjdk team.

Not to mention that for those that like LTS term (which is not that accurate for JDK as for other projects), 17 will have LTS from vendors so it is one that will stay longer, just like 11 and 8.

kriegaex commented 3 years ago

Well, LTS means "long term support", not "ASAP support". I am not in a hurry, just because you prefer to always be on the latest (pre-)release version. It is done when it is done. If you have no better reasons, please simply wait until there are news concerning AspectJ and JDK 17. Thank you.

krzyk commented 3 years ago

Sorry, I think you misunderstood me. I don't say you should give me working project, I was just explaining my reasoning why I reported it now and not later.

I frequently do it in projects so they are ready when the release of new java is ready, just this and nothing more.

kriegaex commented 3 years ago

There are snapshot versions of both AspectJ and this plugin available via Maven, both supporting Java 17-EA, see https://github.com/eclipse/org.aspectj/issues/79#issuecomment-888045708.

kriegaex commented 3 years ago

Update: AspectJ Maven Plugin 1.13 with Java 17 support has been released. You still need an AspectJ snapshot version, but no longer a snapshot for this plugin, see https://github.com/eclipse/org.aspectj/issues/79#issuecomment-888284841.