This was reproduced in JDK25, but JDK26 doesn't seem affected.
This code fails if the run is made from a different folder from which the cache was generated:
`Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();`
Attached a zip project to reproduce.
Steps to reproduce:
1.- Build with `mvn package`
2.- Run training `java -XX:AOTCacheOutput=target/app.aot -jar target/myproject.jar`
type Ctrl-C to end the program. The AOT cache will be dumped.
3.- Move to another folder `cd target`
4.- Run using AOT Cache `java -XX:AOTCache=app.aot -jar myproject.jar`
It fails with:
```
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.net.URL.getPath()" because the return value of "java.security.CodeSource.getLocation()" is null
at com.example.myproject.Main.main(Main.java:31)
```
More information on https://quarkusio.zulipchat.com/#narrow/channel/187030-users/topic/quarkus.20startup.20fails.20when.20using.20aot/near/570396715
Reproduced in different environments (see link above). On my case, a Fedora Linux running either:
```$ java -version
openjdk version "25.0.2" 2026-01-20 LTS
OpenJDK Runtime Environment Temurin-25.0.2+10 (build 25.0.2+10-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.2+10 (build 25.0.2+10-LTS, mixed mode, sharing)```
Or
```$ java -version
java version "25.0.2" 2026-01-20 LTS
Java(TM) SE Runtime Environment (build 25.0.2+10-LTS-69)
Java HotSpot(TM) 64-Bit Server VM (build 25.0.2+10-LTS-69, mixed mode, sharing)```
This code fails if the run is made from a different folder from which the cache was generated:
`Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();`
Attached a zip project to reproduce.
Steps to reproduce:
1.- Build with `mvn package`
2.- Run training `java -XX:AOTCacheOutput=target/app.aot -jar target/myproject.jar`
type Ctrl-C to end the program. The AOT cache will be dumped.
3.- Move to another folder `cd target`
4.- Run using AOT Cache `java -XX:AOTCache=app.aot -jar myproject.jar`
It fails with:
```
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.net.URL.getPath()" because the return value of "java.security.CodeSource.getLocation()" is null
at com.example.myproject.Main.main(Main.java:31)
```
More information on https://quarkusio.zulipchat.com/#narrow/channel/187030-users/topic/quarkus.20startup.20fails.20when.20using.20aot/near/570396715
Reproduced in different environments (see link above). On my case, a Fedora Linux running either:
```$ java -version
openjdk version "25.0.2" 2026-01-20 LTS
OpenJDK Runtime Environment Temurin-25.0.2+10 (build 25.0.2+10-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.2+10 (build 25.0.2+10-LTS, mixed mode, sharing)```
Or
```$ java -version
java version "25.0.2" 2026-01-20 LTS
Java(TM) SE Runtime Environment (build 25.0.2+10-LTS-69)
Java HotSpot(TM) 64-Bit Server VM (build 25.0.2+10-LTS-69, mixed mode, sharing)```