Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.code_intelligence.jazzer.mutation.annotation.NotNull;
import com.code_intelligence.jazzer.mutation.annotation.WithLength;
import com.code_intelligence.jazzer.mutation.utils.IgnoreRecursiveConflicts;
import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint;
import java.lang.annotation.Annotation;
import java.lang.annotation.Inherited;
Expand Down Expand Up @@ -578,6 +579,9 @@ private static Annotation[] checkExtraAnnotations(
.collect(Collectors.toCollection(HashSet::new));
for (Annotation annotation : extraAnnotations) {
boolean added = existingAnnotationTypes.add(annotation.annotationType());
if (annotation.annotationType().isAnnotationPresent(IgnoreRecursiveConflicts.class)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the entire purpose of this function seems to be checking for the recursive conflict maybe we can exit early in the first lines of this function if IgnoreRecursiveConflicts.class is set?

continue;
}
require(added, annotation + " already directly present on " + base);
}
return extraAnnotations;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2025 Code Intelligence GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.code_intelligence.jazzer.mutation.utils;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* A meta-annotation to turn off the check in {@code checkExtraAnnotations} that throws if some
* annotation is present multiple times on a type. This allows annotations like e.g.
* {@code @DictionaryProvider} to be propagated down the type hierarchy and accumulated along the
* way.
*
* <p>E.g. {@code @A("data1") List<@A("data2") String> arg} - the String mutator will can make use
* of {@code @A("data1")} and {@code @A("data2")}, but the List mutator can only see
* {@code @A("data1")}.
*/
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Documented
public @interface IgnoreRecursiveConflicts {}