Skip to content

Maintenance: Support Java 17 #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
dagrammy opened this issue May 10, 2023 · 9 comments · Fixed by #1172
Closed
1 of 2 tasks

Maintenance: Support Java 17 #1156

dagrammy opened this issue May 10, 2023 · 9 comments · Fixed by #1172
Assignees
Labels
documentation Improvements or additions to documentation maven size/S

Comments

@dagrammy
Copy link

Summary

Lambda now supports Java 17. We use the powertools, in particular SQS Large message handling.
We would like to update our projects to Java 17.

Unfortunately, this is currently not possible because of the AspectJ version used.

<aspectj.version>1.9.7</aspectj.version>

Build fails with:
[error] target level should be in '1.1'...'1.8','9'...'16' (or '5.0'..'16.0') or cldc1.1: 17

Why is this needed?

Upgrade to Java 17 not possible.

Which area does this relate to?

SQS Large Message Handling

Solution

Upgrade AspectJ to a version which supports Java 17.

At least version 1.9.8 should support it.

https://htmlpreview.github.io/?https://github.com/eclipse/org.aspectj/blob/master/docs/dist/doc/README-197.html

Acknowledgment

@jeromevdl
Copy link
Contributor

Thanks for your feedback. Would you be able to provide a pull request for this one?

@dagrammy
Copy link
Author

Hi @jeromevdl,

I could try to update the library, see if everything works and create a PR.

However, that is probably not enough.
From the aspectJ release notes of version 1.9.8 (the next one after the one used and the version that supports Java 17).

The AspectJ compiler ajc (contained in the aspectjtools library) no longer works on JDKs 8 to 10. The minimum compile-time requirement is now JDK 11 due to upstream changes in the Eclipse Java Compiler (subset of JDT Core), which AspectJ is a fork of. You can still compile to legacy target versions as low as Java 1.3 when compiling plain Java code or using plain Java ITD constructs which do not require the AspectJ runtime aspectjrt, but the compiler itself needs JDK 11+. Just like in previous AspectJ versions, both the runtime aspectjrt and the load-time weaver aspectjweaver still only require JRE 8+.

https://htmlpreview.github.io/?https://github.com/eclipse/org.aspectj/blob/master/docs/dist/doc/README-198.html

Unfortunately, I am not familiar with aspectJ and cannot assess whether this means that the powertools lib is no longer compatible with Java 8.

In addition, as far as I have seen, there are build processes running in the pipeline with Java 8, which would then no longer work.

@mriccia
Copy link
Contributor

mriccia commented Jun 1, 2023

Hello @dagrammy,

Please can you provide more details about your project configuration?
Are you using maven? If so, do you use the org.codehaus.mojo:aspectj-maven-plugin?

If the answer is yes to both, could you try to change the aspectj-maven-plugin to the dev-aspect fork of the plugin?

According to this GH issue the plugin that we currently recommend does not support Java 17, and users are encouraged to utilise the dev-aspectj plugin instead.
I will work to update the Lambda Powertools for Java documentation & examples to this new plugin.

@mriccia mriccia added documentation Improvements or additions to documentation maven size/S and removed triage labels Jun 1, 2023
@mriccia mriccia self-assigned this Jun 1, 2023
@dagrammy
Copy link
Author

dagrammy commented Jun 1, 2023

Hi @mriccia,

we are using gradle as our build tool. For gradle we are using currently the plugin id 'io.freefair.aspectj.post-compile-weaving'.

https://plugins.gradle.org/plugin/io.freefair.aspectj.post-compile-weaving

@mriccia
Copy link
Contributor

mriccia commented Jun 1, 2023

thanks for the quick reply @dagrammy.
I will create a sample project with Gradle and check if there's a way around it.

@mriccia
Copy link
Contributor

mriccia commented Jun 1, 2023

Hi again @dagrammy

I created a small example to reproduce the issue, and see the same error you noted.

It seems that the gradle plugin will automatically select the version of aspectj weaver based on the imported dependency.
However this can be overridden by adding an explicit dependency.

Please can you try the following and report back?
Add in your build.gradle, inside the dependencies the following line implementation "org.aspectj:aspectjrt:1.9.8.RC3".

For reference, here a working build.gradle file from my working example

@dagrammy
Copy link
Author

dagrammy commented Jun 2, 2023

Hi @mriccia

we already tried to use a newer version of aspectj which supports Java 17.

Iirc we got a a warning during build time (version conflict, aspect not applied or sth. like that). We deployed it anyways, but it didn't work. In our case we are using the powertools for large SQS message handling.

I cloned your reproducer, built it and the same warnings are shown.

/Users/xxx/.gradle/caches/modules-2/files-2.1/software.amazon.lambda/powertools-tracing/1.15.0/eb7eb463817546a9fce15c33b571da8f5d922630/powertools-tracing-1.15.0.jar!software/amazon/lambda/powertools/tracing/internal/LambdaTracingAspect.class [warning] advice defined in software.amazon.lambda.powertools.tracing.internal.LambdaTracingAspect has not been applied [Xlint:adviceDidNotMatch]

/Users/xxx/.gradle/caches/modules-2/files-2.1/software.amazon.lambda/powertools-metrics/1.15.0/f0eed5e48520d882538b0e8ae40264ae5bdad4b6/powertools-metrics-1.15.0.jar!software/amazon/lambda/powertools/metrics/internal/LambdaMetricsAspect.class [warning] advice defined in software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAspect has not been applied [Xlint:adviceDidNotMatch]

Did you deploy and test your example project? Is it working?

@mriccia
Copy link
Contributor

mriccia commented Jun 2, 2023

hi @dagrammy ,
I added Metrics and Logging to the example, deployed it to my AWS account and I can confirm this example repo works.

I'll check the large SQS message handling.

@mriccia
Copy link
Contributor

mriccia commented Jun 2, 2023

@dagrammy I added 2 lambda functions to the example in this commit.
The first Lambda function publishes messages to SNS using the SNS Extended Client, and the other lambda function consumes messages from SQS using the @SqsLargeMessage annotation.
There is a subscription from SNS->SQS.
All the lambdas use Java 17.

Please take a look and let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation maven size/S
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants