Closed krzyk closed 1 year ago
Please explain your use case. What in Java 19 is not working with AspectJ 1.9.9.1? Why do you need the AspectJ compiler to create Java 19 class files or the weaver to read them? Other than preview or incubating language features, there is nothing new in Java 19. Please explain, which features you are using and why. I wish to understand your impediment.
I have a project using dev.aspectj:aspectj-maven-plugin and I switched the project to compile for Java 19 and it fails with:
[INFO] --- aspectj-maven-plugin:1.13.1:compile (default) @ fms ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[ERROR] unrecognized single argument: "-19"
<unknown source file>:<no line information>
[ERROR] no sources specified
<unknown source file>:<no line information>
So my use case is that I want to be able to compile with 19 as the target.
My config for the plugin is:
<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>19</source>
<target>19</target>
<Xlint>ignore</Xlint>
<complianceLevel>19</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<sources>
<source>
<basedir>src/main/java/com/example</basedir>
</source>
</sources>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.9.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.9.1</version>
</dependency>
</dependencies>
</plugin>
I assumed it is the issue with aspectj part - hence reported it here.
Of course I know that AspectJ does not support Java 19 yet, because the upstream Eclipse Java compiler just released its Java 19 version a few days ago. I am working and do not have lots of cycles to work on AspectJ in my spare time, but eventually I will add Java 19 support. Anyway, you did not answer my questions. Please read again and reply accordingly. Thank you. At the moment, your issue description is simply a feature request without any explained reason or benefit.
The sole benefit is support current Java version. And yes it is a feature request. Not sure what you want to see here - what I want to use from Java 19? I want to use the latest security fixes, new classes/methods added, test out preview features. Java 18 has been obsoleted by 19 release so if a project wants to stay current (e.g. regarding security updates), it needs to upgrade.
You can use all security fixes by compiling to compliance level 18 or lower while using JDK 19. If you want to test Java preview features, you can also do so without AspectJ for the time being.
What I wanted to find out is if you use AspectJ in any commercial environment and are somehow compelled to upgrade to the new preview language features. Obviously, you are not. You did not give any example of which Java 19 feature you urgently need to work with in AspectJ.
Maybe you can imagine that product maintainers prioritise raised issues. If you want me to prioritise this one, you need to give me a better reason than you simply wishing to play with the new preview features. Otherwise, maybe fixing bugs gets prioritised over upgrading JDK compatibility, given the very limited size of my time budget, not to mention Andy's which is even smaller (basically zero in his case).
I have a first Java 19 development version of AspectJ, mostly untested. I just quickly compiled an example for JEP 405: Record Patterns (Preview), which worked nicely.
At snapshot repository https://oss.sonatype.org/content/repositories/snapshots, you find version 1.9.10-SNAPSHOT
of AspectJ runtime, weaver, matcher and compiler (tools). If you use dev.aspectj:aspectj-maven-plugin:1.13.1
and define a plugin dependency on the org.aspectj:aspectjtools:1.9.10-SNAPSHOT
and use <enablePreview>true</enablePreview>
, you should be good to go for a first test. You might also need to deactivate Maven Compiler Plugin (MCP) default executions like this, if your MCP version is not capable of building Java 19 code:
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
I am not sure if I will have more time this weekend to add proper tests to the AspectJ build, so you might bump into bugs. @krzyk, you asked for this feature somehwat cheekily without giving any good reason for me to invest time, other than "I want to play with Java 19". Now I am expecting you to test as much as possible and provide feedback, making this worthwhile for me and also helping yourself to get what you want.
@mdeinum, following up on our e-mails, I am also asking you to give it a spin.
Works for my usecase. I use loadtime weaving and compile using Java19 with preview features enabled. Although I don't use them in this part of the project. I now get the expected behavior and no more ASM errors!.
Thanks for tagging me, I was just about to write you an answer to the email (it worked compiling to Java18 as well as I don't use any preview features in this section).
Thanks for your feedback, @mdeinum. I am happy it works for you.
Yes, most people should have the same use case: They want to use the latest JDK (more conservative ones maybe the latest LTS) due to security fixes, but it does not necessarily mean that they need to use the latest Java language features, especially not preview ones or even incubating ones. Of course they want to try them, but they would never use them in business or widely used OSS projects, because a preview feature compiled by Java n
will no longer work in Java n+1
, not even if the same feature is in the next stage of preview or even final. They will have to recompile.
Anyway, maybe I can add some testing infrastructure to AspectJ and release 1.9.10 soon, even though I am not promising anything. On weekends this can depend not only on how long it takes to write the code, but also on things like weather or whoever of my friends calls me to meet up spontaneously. Sometimes even I have a bit of private life. 😁
FYI, I could in principle release a new version of AspectJ, which will be 1.9.19 (not 1.9.10) in order to sync the minor-minor (1.9.x) version to the Java release in the future for users to more easily recognise the latest supported Java version of AspectJ. 1.19 would be even nicer, but minor versions (1.x) require an Eclipse review which I do not have time for.
Anyway, what is blocking the release? There are upstream issues with ECJ, the Eclipse Java Compiler with regard to preview feature implementation. I noticed those problems while creating simple smoke tests for AspectJ:
I could either release AspectJ with known issues or wait for the upstream problems to be fixed. Let's see if someone from the resource-starved JDT Core team can take time to fix this anytime soon. They are really busy, juggling many balls at once.
I have decided to no longer delay the 1.9.19 (Java 19) release and rather mention the open ECJ bugs in the release notes instead. I have added tests also for the buggy compiler features, but deactivated them for now. We can always activate them after the bugs will have bveen fixed.
Is this missing java 19?
Please add support for JDK 19.
Thank you very much.