Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError exception in 0.10.2 #466

Open
aino-gautam opened this issue Jun 20, 2023 · 0 comments
Open

NoSuchMethodError exception in 0.10.2 #466

aino-gautam opened this issue Jun 20, 2023 · 0 comments

Comments

@aino-gautam
Copy link

Exception in thread "main" java.lang.NoSuchMethodError: org.reflections.util.FilterBuilder.excludePattern(Ljava/lang/String;)Lorg/reflections/util/FilterBuilder;
at org.reflections.scanners.Scanners$1.(Scanners.java:50)
at org.reflections.scanners.Scanners.(Scanners.java:48)
at deba.demo.ClasspathAnalyzer.getScannerArray(ClasspathAnalyzer.java:31)
at deba.demo.ClasspathAnalyzer.(ClasspathAnalyzer.java:24)
at deba.demo.ClassPathScanner.main(ClassPathScanner.java:17)

My main method class

public class ClassPathScanner {

public static void main(String[] args) {
	
	ClassLoader loader = Thread.currentThread().getContextClassLoader();
	ClasspathAnalyzer analyzer = new ClasspathAnalyzer(loader , new String[] {"org.appops", "deba.demo.test"});
	
	Reflections sstore = analyzer.getReflectStore();
	
	Set<Class<?>> classes = sstore.getTypesAnnotatedWith(TestOp.class);
	
	for (Class<?> clazz : classes) {
		Method[] m = clazz.getMethods();
		for (Method me : m) {
			Parameter[] pars = me.getParameters();
			for (Parameter par : pars) {
				System.out.println( "Found parameter name on - " + clazz.getSimpleName() + "."+ me.getName()+ "." + par.getName());
			}
			
		}
	
	}
	
	
}

}

Class that builds the Reflections Object

public class ClasspathAnalyzer {

private Reflections refStore = null ;

public ClasspathAnalyzer(ClassLoader clsloader , String[] packrefs) {
	
	ConfigurationBuilder builder = new ConfigurationBuilder() ;
	
	builder.addClassLoaders(clsloader) ;
	builder.forPackages(packrefs);
	builder.setScanners(getScannerArray());
	
	refStore = new Reflections(builder);
}

private Scanner[] getScannerArray() {
	
	Set<Scanner> scanners = new HashSet<>(Arrays.asList(Scanners.TypesAnnotated, Scanners.SubTypes,
			Scanners.FieldsAnnotated, Scanners.MethodsAnnotated, new MethodParameterNamesScanner(),
			new TypeElementsScanner(), Scanners.MethodsSignature, Scanners.MethodsParameter));

	return scanners.toArray(new Scanner[scanners.size()]);
	
}

public Reflections getReflectStore() {
	return refStore ;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant