You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation provides guidance for adding GraalVM support for AWS Lambda Powertools Java modules and using the modules in Lambda functions.
@@ -31,13 +25,17 @@ In order to generate the metadata reachability files for Powertools for Lambda,
31
25
32
26
2.**Generate Reachability Metadata**
33
27
- Set the `JAVA_HOME` environment variable to use GraalVM
34
-
- Run tests with `-Pgenerate-graalvm-files` profile. You can find module specific commands in the [Module-Specific Implementation](#module-specific-implementation) section
35
-
- Some tests may need to be skipped depending on the module
28
+
- Run tests with `-Pgenerate-graalvm-files` profile.
29
+
```shell
30
+
mvn -Pgenerate-graalvm-files clean test
31
+
```
36
32
37
33
3.**Validate Native Image Tests**
38
34
- Set the `JAVA_HOME` environment variable to use GraalVM
39
-
- Run tests with `-Pgraalvm-native` profile. This will build a GraalVM native image and run the JUnit tests. You can find module specific commands in the [Module-Specific Implementation](#module-specific-implementation) section
40
-
- Verify test execution in native mode
35
+
- Run tests with `-Pgraalvm-native` profile. This will build a GraalVM native image and run the JUnit tests.
36
+
```shell
37
+
mvn -Pgraalvm-native clean test
38
+
```
41
39
42
40
4.**Clean Up Metadata**
43
41
- GraalVM metadata reachability files generated in Step 2 contains references to the test scoped dependencies as well.
@@ -47,142 +45,16 @@ In order to generate the metadata reachability files for Powertools for Lambda,
47
45
- ByteBuddy
48
46
49
47
## Known Issues and Solutions
50
-
51
48
1.**Mockito Compatibility**
52
-
- Powertools uses Mockito 5.x which uses “inline mock maker” as the default. This mock maker does not play well with GraalVM. Mockito [recommends](https://github.com/mockito/mockito/releases/tag/v5.0.0) using subclass mock maker with GraalVM.
53
-
- However, subclass mock maker does not support testing static methods. Some test cases in Powertools uses inline mock maker to mock static methods. These tests have to be skipped while generating the GraalVM reachability metadata files.
54
-
- This obviously affects the coverage and possibility of missing a required entry in GRM files. At this point we are relying on community to report any missing entries and will update the GRM based on the reports.
55
-
- This issue remains open until ability of test static methods in Mockito 5.x/inline mock maker is available.
49
+
- Powertools uses Mockito 5.x which uses “inline mock maker” as the default. This mock maker does not play well with GraalVM. Mockito [recommends](https://github.com/mockito/mockito/releases/tag/v5.0.0) using subclass mock maker with GraalVM. Therefore `generate-graalvm-files` profile uses subclass mock maker instead of inline mock maker.
50
+
- Subclass mock maker does not support testing static methods. Tests have therefore been modified to use [JUnit Pioneer](https://junit-pioneer.org/docs/environment-variables/) to inject the environment variables in the scope of the test's execution.
56
51
57
52
2.**Log4j Compatibility**
58
53
- Version 2.22.1 fails with this error
59
54
```
60
55
java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
61
56
```
62
-
- This has been [fixed](https://github.com/apache/logging-log4j2/discussions/2364#discussioncomment-8950077) in Log4j 2.24.0. PT has been updated to use this version of Log4j
63
-
57
+
- This has been [fixed](https://github.com/apache/logging-log4j2/discussions/2364#discussioncomment-8950077) in Log4j 2.24.x. PT has been updated to use this version of Log4j
64
58
65
59
## Reference Implementation
66
60
Working example is available in the [examples](examples/powertools-examples-core-utilities/sam-graalvm).
67
-
68
-
## Module-Specific Implementation
69
-
Due to the Mockito issues described in the [Known Issues and Solutions](#known-issues-and-solutions) section, some tests needs to be skipped when generating the GRM files. This section shows the commands that need to be used for the modules.
Copy file name to clipboardExpand all lines: powertools-logging/src/test/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspectTest.java
0 commit comments