Skip to content

Bump minimum JDK requirement from 8 to 11 - #259

Merged
xjusko merged 2 commits into
shrinkwrap:mainfrom
xjusko:jdk11-bump
Aug 27, 2026
Merged

xjusko merged 2 commits into
shrinkwrap:mainfrom
xjusko:jdk11-bump

Conversation

@xjusko

@xjusko xjusko commented Aug 18, 2026

Copy link
Copy Markdown
Contributor
  • Use maven.compiler.release=11 instead of source/target
  • Update enforcer to require JDK 11+ and Maven 3.6+
  • Update CI matrix to test on JDK 11, 17, 21

Closes #258

@mskacelik mskacelik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are few examples where the codebase mentions something related to need of newer JDK features (might be worth it to investigate):


Also don't forget to update README.md and CONTRIBUTING.md (for some reason they have inconsistent maven versions).

Comment thread pom.xml Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xjusko
xjusko force-pushed the jdk11-bump branch 2 times, most recently from 7fd1c43 to ca6124c Compare August 19, 2026 13:13
@mskacelik

Copy link
Copy Markdown

@xjusko
Some deprecated Java API:
image

@mskacelik

Copy link
Copy Markdown

Also @Deprecated annotation has new fields since Java 9, but I will leave that to you if you would like to fix them (e.g. since="2.0.0", forRemoval=true) or you will remove them sometime before the 2.0.0 release.

@xjusko

xjusko commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Also @Deprecated annotation has new fields since Java 9, but I will leave that to you if you would like to fix them (e.g. since="2.0.0", forRemoval=true) or you will remove them sometime before the 2.0.0 release.

@mskacelik I will look at those later. I would like to merge this and open a PR for JPMS.


@AfterEach
public void tearDown() {
// URLClassLoader.close() requires JDK7+

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so do I understand there is no need for the archiveCl.close() here? TBF, I am not even sure what URLClassLoader is...

@Override
public Enumeration<URL> getResources(final String name) throws IOException {
if (name.contains("donotchange")) {
// Collections.emptyEnumeration() requires JDK7+

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, this could have been replaced with the Collections.emptyEnumeration() (as the comment suggests), instead of the NOOP enumeration. But on the other hand this is not a blocker, since I think overall Enumeration usage is super old (Java 1.0 feature), and nobody should really use it (e.g. this should be replaced with either Iterator<URL>, Collection<?>, or List<URL>).

But that could be done later (I would imagine that we will have more of these super legacy code changes from JDK 1-8 -> JDK 11 before the 2.0.0 release).


// Here the exception should be thrown
Assertions.assertThrows(IllegalArgumentException.class, () -> archive.addPackages(true, Package.getPackage(packageName)));
Assertions.assertThrows(IllegalArgumentException.class, () -> archive.addPackages(true, ClassLoader.getSystemClassLoader().getDefinedPackage(packageName)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is solid change, if the getDefinedPackage returns a null (which I suspect it does), but I find funny that this test is pretty much testing that the JDK package utility method returns a null (i.e.

), so couldn't this test be simplified to just be:

@Test
public void testAddNonExistentPackage() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    Assertions.assertThrows(IllegalArtumentException.class, () -> archive.addPackages(true, (Package) null);
}

N.B. after checking the JIRA, Package.getPackage() was probably used to be consistent with the reproducer, but since Package.getPackage() is obsolete since JDK 9+, I think we can just have null instead.

WDYT?

@mskacelik mskacelik Aug 21, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OR it could be also testing this one:

@Override
public T addPackages(boolean recursive, String... packages) throws IllegalArgumentException {
Validate.notNullAndNoNullValues(packages, "Packages must be specified and can not container null values");
return addPackages(recursive, Filters.includeAll(), packages);
}

i.e. directly addPackages(true, "non.existent.package")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, according to this:

private T addPackages(final boolean recursive, final Filter<ArchivePath> filter, final ClassLoader cl,
final Package... packages) throws IllegalArgumentException {
Validate.notNull(filter, "Filter must be specified");
Validate.notNull(packages, "Packages must be specified");
String[] packageNames = new String[packages.length];
for (int i = 0; i < packages.length; i++) {
packageNames[i] = packages[i] == null ? null : packages[i].getName();
}
if (cl == null) {
return addPackages(recursive, filter, packageNames);
}
return addPackages(recursive, filter, cl, packageNames);
}

It seems like the Package... packages variation uses the addPackages(boolean recursive, String... packages) under the hood anyway.

@mskacelik mskacelik Aug 21, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I change my mind, I would leave the (Package) null for the parameter, I think other variations could be added later, ideally we would need to have better coverage for the test, but I think that is a different issue.

@xjusko

Comment thread pom.xml
<!-- Versioning -->
<version.com.sun.activation.javax.activation>1.2.0</version.com.sun.activation.javax.activation>

<!-- Plugin versions -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment should not have be removed

Comment thread pom.xml Outdated
<!-- Plugin versions -->
<version.maven-compiler-plugin.compilerVersion>1.8</version.maven-compiler-plugin.compilerVersion>
<version.org.codehaus.mojo.findbugs-maven-plugin>3.0.5</version.org.codehaus.mojo.findbugs-maven-plugin>
<version.com.github.spotbugs.spotbugs-maven-plugin>4.8.6.6</version.com.github.spotbugs.spotbugs-maven-plugin>

@mskacelik mskacelik Aug 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this; I missed it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking into it, I will have to use 4.10.3.0, as that is the latest version which works with Maven 3.6.3. And I would like to keep that Maven as the minimum requirement.

@mskacelik mskacelik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xjusko
xjusko merged commit d108e1a into shrinkwrap:main Aug 27, 2026
6 checks passed
fail-fast: false
matrix:
java-version: [ 8, 11, 17 ]
java-version: [ 11, 17, 21 ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update project's minimum requirement to JDK 11

3 participants