Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Enable exclusion of certain reflection entries during build #897

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.function.Predicate;
import java.util.regex.Pattern;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -92,6 +94,31 @@ public Set<AotProxyDescriptor> getClassProxyDescriptors() {
}

public ReflectionDescriptor getReflectionDescriptor() {
String exclusions = System.getProperty("spring.native.reflection-exclusions");
if (exclusions != null) {
List<Pattern> patterns = new ArrayList<>();
StringTokenizer st = new StringTokenizer(exclusions,",");
while (st.hasMoreElements()) {
String nextPattern = st.nextToken();
patterns.add(Pattern.compile(nextPattern));
}
ReflectionDescriptor newRD = new ReflectionDescriptor();
List<ClassDescriptor> classDescriptors = reflectionDescriptor.getClassDescriptors();
for (ClassDescriptor cd: classDescriptors) {
boolean exclude = false;
for (Pattern p: patterns) {
if (p.matcher(cd.getName()).matches()) {
exclude = true;
System.out.println("ReflectionExclusion: excluding "+cd.getName());
break;
}
}
if (!exclude) {
newRD.add(cd);
}
}
return newRD;
}
return reflectionDescriptor;
}

Expand Down