Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JUnit annotation scanning during the image build #258

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public void onLoad(NativeImageConfiguration config) {
"org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor",
"org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor",
"org.junit.jupiter.engine.execution.ConditionEvaluator",
"org.junit.jupiter.engine.execution.ExecutableInvoker"
"org.junit.jupiter.engine.execution.ExecutableInvoker",
"org.junit.jupiter.params.provider.EnumSource$Mode",
};
for (String className : buildTimeInitializedClasses) {
config.initializeAtBuildTime(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
package org.graalvm.junit.platform.config.util;

import org.graalvm.junit.platform.config.core.NativeImageConfiguration;
import org.graalvm.util.GuardedAnnotationAccess;
import org.junit.platform.commons.support.AnnotationSupport;

import java.lang.annotation.Annotation;
Expand Down Expand Up @@ -96,7 +95,7 @@ private static void forEachMethod(Class<?> clazz, Consumer<Method> consumer) {
}

private static <A extends Annotation> List<A> getAnnotations(AnnotatedElement element, Class<A> annotation) {
if (GuardedAnnotationAccess.getAnnotation(annotation, Repeatable.class) != null) {
if (annotation.getAnnotation(Repeatable.class) != null) {
return AnnotationSupport.findRepeatableAnnotations(element, annotation);
} else {
Optional<A> optionalAnnotation = AnnotationSupport.findAnnotation(element, annotation);
Expand Down
14 changes: 0 additions & 14 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@
<module name="SuppressWarningsFilter" />
<module name="TreeWalker">
<module name="SuppressWarningsHolder" />
<!-- Disallows direct calls to "AnnotatedElement.get(Declared)Annotation(s)". This check can yield false positives,
i.e., it will match any ".get(Declared)Annotation(s)" calls that are not preceded by "GuardedAnnotationAccess"
since checkstyle relies only on pattern matching and it cannot determine the type of the call's receiver object. -->
<module name="RegexpSinglelineJava">
<property name="id" value="annotationAccess"/>
<metadata name="net.sf.eclipsecs.core.comment"
value="Disallow calls to AnnotatedElement.get(Declared)Annotation(s)."/>
<property name="severity" value="error"/>
<property name="format"
value="\b(?&lt;!AnnotationAccess)\.(getAnnotation|getAnnotations|getDeclaredAnnotation|getDeclaredAnnotations|isAnnotationPresent)\b"/>
<property name="message"
value="Direct calls to java.lang.reflect.AnnotatedElement.get(Declared)Annotation(s) are restricted. Use either org.graalvm.util.GuardedAnnotationAccess or org.graalvm.util.DirectAnnotationAccess methods. (Use &quot;// Checkstyle: allow direct annotation access... // Checkstyle: disallow direct annotation access&quot; to disable this check.)"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle: allow direct annotation access"/>
<property name="onCommentFormat" value="Checkstyle: disallow direct annotation access"/>
Expand Down
8 changes: 8 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ If you are using alternative build systems, see <<alternative-build-systems.adoc

[[changelog]]
== Changelog
=== Release 0.9.13

=== Gradle plugin
* Reverted a change in the `NativeImagePlugin` that removed publicly accessible constants. This should prevent breakage of external plugins.

=== JUnit testing support
* Adapted the JUnit automatic metadata registration to changes in annotation handling on newer native image versions.

=== Release 0.9.12

==== Gradle plugin
Expand Down