Skip to content

Commit

Permalink
Adds multi-release logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Jan 19, 2022
1 parent f1fd2d4 commit 669e7ab
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class RecordsHelper {

private RecordsHelper() {}

public static boolean isRecord(Class<?> type) {
return type.isRecord();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class SealedClassesHelper {

private SealedClassesHelper() {}

public static boolean isSealed(Class<?> type) {
return type.isSealed();
}
}
8 changes: 4 additions & 4 deletions equalsverifier-aggregator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
</executiondata>
<structure name="EqualsVerifier: internal coverage">
<classfiles>
<fileset dir="${project.basedir}/..">
<include name="*/target/classes/**/*.class"/>
<fileset dir="${project.basedir}/../equalsverifier-core/target/classes">
<include name="**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
Expand All @@ -82,8 +82,8 @@
</executiondata>
<structure name="EqualsVerifier: external coverage">
<classfiles>
<fileset dir="${project.basedir}/..">
<include name="*/target/test-classes/nl/jqno/equalsverifier/coverage/*.class"/>
<fileset dir="${project.basedir}/../equalsverifier-test-core/target/test-classes/nl/jqno/equalsverifier/coverage">
<include name="*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static nl.jqno.equalsverifier.internal.util.Rethrow.rethrow;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Set;
import java.util.function.Predicate;
Expand Down Expand Up @@ -53,11 +52,7 @@ public Class<T> getType() {
* @return true if T is a Java Record.
*/
public boolean isRecord() {
Class<?> record = Util.classForName("java.lang.Record");
if (record == null) {
return false;
}
return record.isAssignableFrom(type);
return RecordsHelper.isRecord(type);
}

/**
Expand All @@ -66,18 +61,7 @@ public boolean isRecord() {
* @return true if T is a sealed class
*/
public boolean isSealed() {
int version = Integer.parseInt(System.getProperty("java.version").replaceAll("[.-].*", ""));
if (version >= 17) {
try {
Class<?> clazz = Util.classForName("java.lang.Class");
Method isSealed = clazz.getDeclaredMethod("isSealed");
Object result = isSealed.invoke(type);
return result == null ? false : (Boolean) result;
} catch (ReflectiveOperationException | SecurityException e) {
return false;
}
}
return false;
return SealedClassesHelper.isSealed(type);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class RecordsHelper {

private RecordsHelper() {}

public static boolean isRecord(Class<?> type) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.jqno.equalsverifier.internal.reflection;

public final class SealedClassesHelper {

private SealedClassesHelper() {}

public static boolean isSealed(Class<?> type) {
return false;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<argline.experimental></argline.experimental>
<argline.full>${argline.module} ${argline.preview} ${argline.experimental}</argline.full>

<analysis.jacoco.threshold>0.94</analysis.jacoco.threshold>
<analysis.jacoco.threshold>0.97</analysis.jacoco.threshold>

<checkstyle.version>9.2.1</checkstyle.version> <!-- Property for Checkstyle's regression CI - see issue 216 -->
<checkstyle.maven.version>3.1.2</checkstyle.maven.version>
Expand Down

0 comments on commit 669e7ab

Please sign in to comment.