generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clean up reflection registrations (#997)
* fix: clean up todos around reflections registrations in OperatorSDKProcessor Signed-off-by: xstefank <xstefank122@gmail.com> * refactor: package-only visibility Signed-off-by: Chris Laprun <claprun@redhat.com> * refactor: remove now unneeded step Signed-off-by: Chris Laprun <claprun@redhat.com> --------- Signed-off-by: xstefank <xstefank122@gmail.com> Signed-off-by: Chris Laprun <claprun@redhat.com> Co-authored-by: Chris Laprun <claprun@redhat.com>
- Loading branch information
Showing
2 changed files
with
41 additions
and
70 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
38 changes: 38 additions & 0 deletions
38
...ployment/src/main/java/io/quarkiverse/operatorsdk/deployment/ReflectionRegistrations.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,38 @@ | ||
package io.quarkiverse.operatorsdk.deployment; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.jboss.jandex.DotName; | ||
|
||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem; | ||
|
||
public class ReflectionRegistrations { | ||
|
||
private static final String[] PACKAGES_IGNORED_FOR_REFLECTION = { | ||
// Vert.x | ||
"io.vertx.core.", | ||
// OkHttp3 | ||
"okhttp3.", | ||
// Okio | ||
"okio." | ||
}; | ||
|
||
static final IgnoreTypeForReflectionPredicate IGNORE_TYPE_FOR_REFLECTION_PREDICATE = new IgnoreTypeForReflectionPredicate(); | ||
|
||
private static class IgnoreTypeForReflectionPredicate implements Predicate<DotName> { | ||
|
||
@Override | ||
public boolean test(DotName dotName) { | ||
if (ReflectiveHierarchyBuildItem.DefaultIgnoreTypePredicate.INSTANCE.test(dotName)) { | ||
return true; | ||
} | ||
String name = dotName.toString(); | ||
for (String packageName : PACKAGES_IGNORED_FOR_REFLECTION) { | ||
if (name.startsWith(packageName)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |