diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml
index a2a1b9aec..9e71f56af 100644
--- a/.github/workflows/run-e2e-tests.yml
+++ b/.github/workflows/run-e2e-tests.yml
@@ -32,13 +32,19 @@ jobs:
e2e:
runs-on: ubuntu-latest
strategy:
- max-parallel: 3
+ max-parallel: 4
matrix:
- java: [ 8, 11, 17 ]
+ java: [ 8, 11, 17, 21 ]
name: End-to-end tests java${{ matrix.java }}
env:
- JAVA_VERSION: ${{ matrix.java }}
AWS_DEFAULT_REGION: eu-west-1
+
+ # If matrix.version is 21, use 17, otherwise use matrix.version
+ # This is because AspectJ does not yet support weaving with Java21; we want
+ # to test the Java21 runtime, but we can't yet use the JDK21 compiler.
+ # https://github.com/eclipse-aspectj/aspectj/issues/260#issuecomment-1815920274
+ JAVA_VERSION: ${{ (matrix.java == 21 && '17') || matrix.java }}
+ JAVA_LAMBDA_RUNTIME_VERSION: ${{ matrix.java }}
permissions:
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
contents: read
@@ -48,7 +54,8 @@ jobs:
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
- java-version: ${{ matrix.java }}
+ # See comment above on JAVA_VERSION env var
+ java-version: ${{ (matrix.java == 21 && '17') || matrix.java }}
cache: maven
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
diff --git a/README.md b/README.md
index 63ba35cc6..bdf779bfb 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,14 @@ Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless
**[📜Documentation](https://docs.powertools.aws.dev/lambda-java/)** | **[Feature request](https://github.com/aws-powertools/powertools-lambda-java/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=)** | **[🐛Bug Report](https://github.com/aws-powertools/powertools-lambda-java/issues/new?assignees=&labels=bug%2C+triage&template=bug_report.md&title=)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-aws-lambda-powertools-java/)**
+### Java Compatibility
+Powertools for AWS Lambda (Java) supports all Java version from 8 up to 21 as well as the
+[corresponding Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
+
+AspectJ does not yet support Java 21 [[1]](https://github.com/eclipse-aspectj/aspectj/issues/260), [[2]](https://github.com/eclipse-aspectj/aspectj/blob/master/docs/dist/doc/JavaVersionCompatibility.md).
+If you need to use aspects - either Powertools features leveraging aspects or other libraries - you should use the JDK 17 compiler and target either the Java 17 or Java 21
+Lambda runtimes.
+
### Installation
Powertools for AWS Lambda (Java) is available in Maven Central. You can use your favourite dependency management tool to install it
diff --git a/docs/index.md b/docs/index.md
index 92589be7c..b1b55e2d6 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -11,10 +11,18 @@ Powertools for AWS Lambda (Java) is a suite of utilities for AWS Lambda Function
Powertools for AWS Lambda is also available for [Python](https://docs.powertools.aws.dev/lambda/python/latest/){target="_blank"}, [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}, and [.NET](https://docs.powertools.aws.dev/lambda/dotnet/){target="_blank"}
-!!! tip "Looking for a quick run through of the core utilities?"
+???+ tip "Looking for a quick run through of the core utilities?"
Check out [this detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-aws-lambda-powertools-java/) with a practical example. To dive deeper,
the [Powertools for AWS Lambda (Java) workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/a7011c82-e4af-4a52-80fa-fcd61f1dacd9/en-US/introduction) is a great next step.
+???+ tip "Java Compatability"
+ Powertools for AWS Lambda (Java) supports all Java version from 8 up to 21 as well as the
+ [corresponding Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
+
+ AspectJ does not yet support Java 21 [[1]](https://github.com/eclipse-aspectj/aspectj/issues/260), [[2]](https://github.com/eclipse-aspectj/aspectj/blob/master/docs/dist/doc/JavaVersionCompatibility.md).
+ If you need to use aspects - either Powertools features leveraging aspects or other libraries - you should use the JDK 17 compiler and target either the Java 17 or Java 21
+ Lambda runtimes.
+
## Tenets
This project separates core utilities that will be available in other runtimes vs general utilities that might not be available across all runtimes.
diff --git a/powertools-e2e-tests/pom.xml b/powertools-e2e-tests/pom.xml
index 05c544641..8a0b65f32 100644
--- a/powertools-e2e-tests/pom.xml
+++ b/powertools-e2e-tests/pom.xml
@@ -31,7 +31,7 @@
1.8
1.8
10.3.0
- 2.100.0
+ 2.109.0
diff --git a/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/Infrastructure.java b/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/Infrastructure.java
index b1fab2883..11ee24b05 100644
--- a/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/Infrastructure.java
+++ b/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/Infrastructure.java
@@ -114,6 +114,7 @@ public class Infrastructure {
private final String queue;
private final String kinesisStream;
private final String largeMessagesBucket;
+ private final JavaRuntime lambdaRuntimeVersion;
private String ddbStreamsTableName;
private String functionName;
private Object cfnTemplate;
@@ -124,6 +125,7 @@ private Infrastructure(Builder builder) {
this.tracing = builder.tracing;
this.envVar = builder.environmentVariables;
this.runtime = builder.runtime;
+ this.lambdaRuntimeVersion = builder.lambdaRuntimeVersion;
this.timeout = builder.timeoutInSeconds;
this.pathToFunction = builder.pathToFunction;
this.idempotencyTable = builder.idemPotencyTable;
@@ -204,6 +206,7 @@ public void destroy() {
private Stack createStackWithLambda() {
boolean createTableForAsyncTests = false;
Stack stack = new Stack(app, stackName);
+
List packagingInstruction = Arrays.asList(
"/bin/sh",
"-c",
@@ -247,7 +250,7 @@ private Stack createStackWithLambda() {
.handler("software.amazon.lambda.powertools.e2e.Function::handleRequest")
.memorySize(1024)
.timeout(Duration.seconds(timeout))
- .runtime(runtime.getCdkRuntime())
+ .runtime(lambdaRuntimeVersion.getCdkRuntime())
.environment(envVar)
.tracing(tracing ? Tracing.ACTIVE : Tracing.DISABLED)
.build();
@@ -504,29 +507,34 @@ public static class Builder {
private String queue;
private String kinesisStream;
private String ddbStreamsTableName;
+ private JavaRuntime lambdaRuntimeVersion;
private Builder() {
- getJavaRuntime();
+ runtime = mapRuntimeVersion("JAVA_VERSION");
+ lambdaRuntimeVersion = mapRuntimeVersion("JAVA_LAMBDA_RUNTIME_VERSION");
}
- /**
- * Retrieve the java runtime to use for the lambda function.
- */
- private void getJavaRuntime() {
- String javaVersion = System.getenv("JAVA_VERSION"); // must be set in GitHub actions
+
+
+ private JavaRuntime mapRuntimeVersion(String environmentVariableName) {
+ String javaVersion = System.getenv(environmentVariableName); // must be set in GitHub actions
+ JavaRuntime ret = null;
if (javaVersion == null) {
- throw new IllegalArgumentException("JAVA_VERSION is not set");
+ throw new IllegalArgumentException("JAVA_LAMBDA_RUNTIME_VERSION is not set");
}
if (javaVersion.startsWith("8")) {
- runtime = JavaRuntime.JAVA8AL2;
+ ret = JavaRuntime.JAVA8AL2;
} else if (javaVersion.startsWith("11")) {
- runtime = JavaRuntime.JAVA11;
+ ret = JavaRuntime.JAVA11;
} else if (javaVersion.startsWith("17")) {
- runtime = JavaRuntime.JAVA17;
+ ret = JavaRuntime.JAVA17;
+ } else if (javaVersion.startsWith("21")) {
+ ret = JavaRuntime.JAVA21;
} else {
throw new IllegalArgumentException("Unsupported Java version " + javaVersion);
}
- LOG.debug("Java Version set to {}, using runtime {}", javaVersion, runtime.getRuntime());
+ LOG.debug("Java Version set to {}, using runtime variable {}", ret, javaVersion);
+ return ret;
}
public Infrastructure build() {
diff --git a/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/JavaRuntime.java b/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/JavaRuntime.java
index c50fcab84..c75682949 100644
--- a/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/JavaRuntime.java
+++ b/powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/JavaRuntime.java
@@ -20,7 +20,8 @@ public enum JavaRuntime {
JAVA8("java8", Runtime.JAVA_8, "1.8"),
JAVA8AL2("java8.al2", Runtime.JAVA_8_CORRETTO, "1.8"),
JAVA11("java11", Runtime.JAVA_11, "11"),
- JAVA17("java17", Runtime.JAVA_17, "17");
+ JAVA17("java17", Runtime.JAVA_17, "17"),
+ JAVA21("java21", Runtime.JAVA_21, "21");
private final String runtime;
private final Runtime cdkRuntime;