@Override protected Class<?> findClass(String name) throws ClassNotFoundException { PySystemState sys = Py.getSystemState(); ClassLoader sysClassLoader = sys.getClassLoader(); if (sysClassLoader != null) { // sys.classLoader overrides this class loader! return sysClassLoader.loadClass(name); } // Search the sys.path for a .class file matching the named class. PyList path = sys.path; for (int i = 0; i < path.__len__(); i++) { byte[] buffer; PyObject entry = replacePathItem(sys, i, path); if (entry instanceof SyspathArchive) { SyspathArchive archive = (SyspathArchive) entry; buffer = getBytesFromArchive(archive, name); } else { if (!(entry instanceof PyUnicode)) { entry = entry.__str__(); } String dir = entry.toString(); buffer = getBytesFromDir(dir, name); } if (buffer != null) { definePackageForClass(name); return defineClass(name, buffer, 0, buffer.length); } } // couldn't find the .class file on sys.path throw new ClassNotFoundException(name); }