I am trying to load an class with specific url and invoke methods inside that class by passing same values to them.
Not exactly sure how to do that.
My url looks something like this: "file:/C:/Users/Retro/Desktop/best-project-2/mutants/traditional_mutants/Complex_cconvolve(Complex,Complex)/AOIS_136/FFT.class"
I tried to load class like this
package com.company.fileIterator;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
public class CallMutant {
public static void main(String[] args) throws IOException {
FolderIterator folderTestRunner = new FolderIterator();
List<String> list = folderTestRunner.getFilesPath();
URL url;
try{
url = new URL("file:///"+list.get(5));
System.out.println(url);
URLClassLoader ucl = new URLClassLoader(new URL[]{url});
Class clazz = ucl.loadClass("FFT");
Object o = clazz.newInstance();
System.out.println(o.toString());
} catch (MalformedURLException e){
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
}
}
and the main goal is to load multiple classes witch has the same name and methods.
Thanks for any help.