-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29731 from geoand/bytecode-rec-configurable-annot…
…ations Introduce a way to use custom annotations in bytecode recording
- Loading branch information
Showing
8 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...eployment/src/main/java/io/quarkus/deployment/recording/RecordingAnnotationsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
public interface RecordingAnnotationsProvider { | ||
|
||
Class<? extends Annotation> ignoredProperty(); | ||
} |
40 changes: 40 additions & 0 deletions
40
core/deployment/src/main/java/io/quarkus/deployment/recording/RecordingAnnotationsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.AccessibleObject; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.Set; | ||
|
||
import io.quarkus.runtime.annotations.IgnoreProperty; | ||
|
||
final class RecordingAnnotationsUtil { | ||
|
||
static final List<Class<? extends Annotation>> IGNORED_PROPERTY_ANNOTATIONS; | ||
|
||
static { | ||
Set<Class<? extends Annotation>> ignoredPropertyAnnotations = new HashSet<>(); | ||
ignoredPropertyAnnotations.add(IgnoreProperty.class); | ||
for (RecordingAnnotationsProvider provider : ServiceLoader.load(RecordingAnnotationsProvider.class)) { | ||
Class<? extends Annotation> ignoredProperty = provider.ignoredProperty(); | ||
if (ignoredProperty != null) { | ||
ignoredPropertyAnnotations.add(ignoredProperty); | ||
} | ||
} | ||
IGNORED_PROPERTY_ANNOTATIONS = List.copyOf(ignoredPropertyAnnotations); | ||
} | ||
|
||
private RecordingAnnotationsUtil() { | ||
} | ||
|
||
static boolean isIgnored(AccessibleObject object) { | ||
for (int i = 0; i < IGNORED_PROPERTY_ANNOTATIONS.size(); i++) { | ||
Class<? extends Annotation> annotation = IGNORED_PROPERTY_ANNOTATIONS.get(i); | ||
if (object.isAnnotationPresent(annotation)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...yment/src/test/java/io/quarkus/deployment/recording/TestRecordingAnnotationsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
public class TestRecordingAnnotationsProvider implements RecordingAnnotationsProvider { | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.METHOD, ElementType.FIELD }) | ||
public @interface TestIgnoreProperty { | ||
} | ||
|
||
@Override | ||
public Class<? extends Annotation> ignoredProperty() { | ||
return TestIgnoreProperty.class; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../resources/META-INF/services/io.quarkus.deployment.recording.RecordingAnnotationsProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.deployment.recording.TestRecordingAnnotationsProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters