#If JAVA
import java.util.ArrayList;
import java.io.File;
public static Class[] getClasses(String pckgname) throws ClassNotFoundException {
ArrayList classes=new ArrayList();
File directory=null;
try {
directory=new File(Thread.currentThread().getContextClassLoader().getResource('/'+pckgname.replace('.', '/')).getFile());
} catch(NullPointerException x) {
throw new ClassNotFoundException(pckgname+" does not appear to be a valid package");
}
if(directory.exists()) {
String[] files=directory.list();
for(int i=0; i<files.length; i++) {
if(files[i].endsWith(".class")) {
classes.add(Class.forName(pckgname+'.'+files[i].substring(0, files[i].length()-6)));
}
}
} else {
throw new ClassNotFoundException(pckgname+" does not appear to be a valid package");
}
Class[] classesA=new Class[classes.size()];
classes.toArray(classesA);
return classesA;
}
#End If