Using JSR-305 annotations (@Nonnull, @Nullable) alongside javax.annotation package annotations (@Generated, @PostConstruct) on Java 9 causes a split package problem due to the Java Platform Module System. The issue arises because both jsr305-3.0.2.jar and the JDK's java.xml.ws.annotation module contain types in the javax.annotation package. For non-modular projects, the cleanest fix is adding javax.annotation:javax.annotation-api as a class path dependency alongside jsr305, keeping both splits on the class path where they cause no issues. Alternatively, --patch-module can merge the JSR-305 JAR into the platform module, but this only works until java.xml.ws.annotation is removed from the JDK. For modular projects, no clean solution exists without creating a combined artifact or using --patch-module. Moving away from JSR-305 annotations to alternatives like SpotBugs, Eclipse, or JetBrains annotations is recommended when possible.
Sort: