diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 71b4bcaf..2d9f8e48 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 diff --git a/.github/workflows/dropStaging.yml b/.github/workflows/dropStaging.yml index dd930de1..7836d736 100644 --- a/.github/workflows/dropStaging.yml +++ b/.github/workflows/dropStaging.yml @@ -17,13 +17,15 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Setup JDK and Maven - name: Set up JDK 9 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: 9 + distribution: 'zulu' + java-version: 17 + cache: 'maven' server-id: sonatype-nexus-staging server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central diff --git a/.github/workflows/jacoco.yml b/.github/workflows/jacoco.yml index fd384fc6..9661e777 100644 --- a/.github/workflows/jacoco.yml +++ b/.github/workflows/jacoco.yml @@ -13,20 +13,15 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - - name: Set up JDK 16 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: - java-version: 16 + distribution: 'zulu' + java-version: 17 + cache: 'maven' - - name: Cache .m2 - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven - name: Prepare mvnw run: chmod +x ./mvnw diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3e3739c..718bbf49 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,15 +11,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v1 - - - name: Cache .m2 - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven + uses: actions/checkout@v4 # Get GPG private key into GPG - name: Import GPG Owner Trust @@ -29,9 +21,11 @@ jobs: # Setup JDK and Maven - name: Set up JDK 17 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'zulu' java-version: 17 + cache: 'maven' server-id: sonatype-nexus-staging server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central diff --git a/integrationtest/java16/pom.xml b/integrationtest/java16/pom.xml index 0e86bce7..9c9e9b22 100644 --- a/integrationtest/java16/pom.xml +++ b/integrationtest/java16/pom.xml @@ -42,7 +42,7 @@ [3.0.4,) - 9 + 16 false diff --git a/integrationtest/java17/pom.xml b/integrationtest/java17/pom.xml index 8dac5b51..a5c9c710 100644 --- a/integrationtest/java17/pom.xml +++ b/integrationtest/java17/pom.xml @@ -42,7 +42,7 @@ [3.0.4,) - 9 + 17 false @@ -64,8 +64,8 @@ maven-compiler-plugin - 16 - 16 + 17 + 17 diff --git a/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java b/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java index c97fe934..c78b9c17 100644 --- a/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java +++ b/integrationtest/java17/src/test/java/io/toolisticon/aptk/tools/wrapper/Java17Tests.java @@ -15,14 +15,14 @@ public class Java17Tests { @Test public void test_sealedClassesFeature_unsealed() { - Cute.unitTest().when().passInElement().fromClass(Java17Tests.class).intoUnitTest((processingEnvironment, element) -> { + Cute.unitTest().when((processingEnvironment) -> { try { ToolingProvider.setTooling(processingEnvironment); - TypeElementWrapper elementWrapper = TypeElementWrapper.wrap(element); + TypeElementWrapper elementWrapper = TypeElementWrapper.getByClass(Java17Tests.class).get(); MatcherAssert.assertThat(elementWrapper.getPermittedSubclasses(), Matchers.empty()); - MatcherAssert.assertThat(element.getPermittedSubclasses(), Matchers.empty()); + MatcherAssert.assertThat(elementWrapper.unwrap().getPermittedSubclasses(), Matchers.empty()); } finally { ToolingProvider.clearTooling(); @@ -33,18 +33,16 @@ public void test_sealedClassesFeature_unsealed() { } - static final class AllowedClass extends SealedClass { } @PassIn - static sealed class SealedClass permits AllowedClass{ + static sealed class SealedClass permits AllowedClass { } - @Test public void test_sealedClassesFeature_sealed() { Cute.unitTest().when().passInElement().fromClass(SealedClass.class).intoUnitTest((processingEnvironment, element) -> { @@ -53,8 +51,8 @@ public void test_sealedClassesFeature_sealed() { TypeElementWrapper elementWrapper = TypeElementWrapper.wrap(element); - MatcherAssert.assertThat(elementWrapper.getPermittedSubclasses().stream().map(e -> e.getQualifiedName()).collect(Collectors.toSet()), Matchers.contains(SealedClass.class.getCanonicalName())); - MatcherAssert.assertThat(element.getPermittedSubclasses().stream().map(e -> e.toString()).collect(Collectors.toSet()), , Matchers.contains(SealedClass.class.getCanonicalName())); + MatcherAssert.assertThat(elementWrapper.getPermittedSubclasses().stream().map(e -> e.getQualifiedName()).collect(Collectors.toSet()), Matchers.contains(AllowedClass.class.getCanonicalName())); + MatcherAssert.assertThat(element.getPermittedSubclasses().stream().map(e -> e.toString()).collect(Collectors.toSet()), Matchers.contains(AllowedClass.class.getCanonicalName())); } finally { ToolingProvider.clearTooling(); diff --git a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java index b1070720..dffc6504 100644 --- a/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java +++ b/tools/src/main/java/io/toolisticon/aptk/tools/wrapper/TypeElementWrapper.java @@ -288,7 +288,7 @@ public List getRecordComponents() { public List getPermittedSubclasses() { // must make sure that method exists, otherwise return the default value - if (hasMethod(TYPE_ELEMENT_CLASS_NAME, "getPermittedSubclasses")) { + if (!hasMethod(TYPE_ELEMENT_CLASS_NAME, "getPermittedSubclasses")) { // TODO MUST CHECK WHAT SHOULD BE RETURNED FOR NON SEALED CLASSES! return Collections.EMPTY_LIST; }