--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/RklYADD2uKc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/a8d098b2-2d8c-4fca-9b4f-b5a62f68f962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/RklYADD2uKc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0cwe28ORgJDUnwTZu0Ls-%2BY4RHcQ3DAVbvxkYAU9f5oQ%40mail.gmail.com.
private static Set<Class<?>> _getAllClasses() {
if (_getAllClassesCache != null) { return _getAllClassesCache; }
_getAllClassesCache = new HashSet<>();
List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
classLoadersList.add(ClasspathHelper.contextClassLoader());
classLoadersList.add(ClasspathHelper.staticClassLoader());
if (Jenkins.getInstanceOrNull() != null) {
classLoadersList.addAll(
Jenkins.getInstanceOrNull().getPluginManager().getPlugins().stream()
.map(i -> i.classLoader).collect(Collectors.toList())
);
}
try {
final Field f = ClassLoader.class.getDeclaredField("classes");
boolean oldAccessible = f.isAccessible();
f.setAccessible(true);
for (ClassLoader classLoader : classLoadersList) {
Vector<Class> classes = (Vector<Class>) f.get(classLoader);
for (Class clazz : classes) {
if (clazz.getName().toLowerCase().contains("jenkins") || clazz.getName().toLowerCase().contains("hudson")) {
_getAllClassesCache.add(clazz);
}
}
}
f.setAccessible(oldAccessible);
} catch (NoSuchFieldException | IllegalAccessException e) {
LOGGER.info("Unable to use classloader, so falling back to reflections: " + e.getMessage());
}
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setScanners(
new SubTypesScanner(
false /* don't exclude Object.class */
),
new ResourcesScanner()
)
.setUrls(
ClasspathHelper.forClassLoader(
classLoadersList.toArray(
new ClassLoader[0]
)
)
)
.filterInputsBy(
new FilterBuilder()
.includePackage("com.cloudbees")
.includePackage("hudson.model")
.includePackage("hudson.plugins")
.includePackage("io.jenkins")
.includePackage("jenkins.plugins")
.includePackage("org.jenkins")
.includePackage("org.jenkinsci")
.includePackage("org.jenkinsci.plugins.workflow.job")
)
);
_getAllClassesCache.addAll(reflections.getSubTypesOf(Object.class));
LOGGER.info(
_getAllClassesCache.stream().filter(i -> i.getName().contains("WorkflowRun")).collect(Collectors.toList()).toString()
);
LOGGER.info(
_getAllClassesCache.stream().filter(i -> i.getName().contains("CauseAction")).collect(Collectors.toList()).toString()
);
return _getAllClassesCache;
}
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/RklYADD2uKc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr38aBtCmGi%3Dhg%2BYK5J7AOADKuLQq%3DwWEP_rV8K0bzA1-w%40mail.gmail.com.