Returns the class file for the given class (which has been verified to exist in the returned location),
or null if the class file could not be found (e.g. because it is contained in a Jar).
168747
public static File getClassFile(Class<?> clazz) {
    File dir = new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath());
    if (!dir.isDirectory()) return null; // class file might be contained in Jar
    File clazzFile = new File(dir, clazz.getName().replace('.', File.separatorChar) + ".class");
    return clazzFile.isFile() ? clazzFile : null;
  }
987215
public static @Nonnull Class<?> _findClass(ClassLoader cl, String name) throws ClassNotFoundException {
        synchronized (getClassLoadingLock(cl, name)) {
            return (Class) invoke(FIND_CLASS, ClassNotFoundException.class, cl, name);
        }
    }
1012402
@SuppressWarnings("unchecked")
    public static boolean findClass(String className) {
        try {
            return getClassLoader().loadClass(className) != null;
        } catch (ClassNotFoundException e) {
            return false;
        } catch (NoClassDefFoundError e) {
            return false;
        }
    }
13721
public static FileInputStream getInputStreamByClass(Class<?> koanClass) {

        FileInputStream in = null;
        try {
            in = new FileInputStream(getKoanFileLocation(koanClass));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return in;
    }
1158527
protected static Class findClass(final String className) throws ClassNotFoundException {
        try {
            return Thread.currentThread().getContextClassLoader().loadClass(className);
        } catch (ClassNotFoundException e) {
            try {
                return Class.forName(className);
            } catch (ClassNotFoundException e1) {
                return MavenCoordHelper.class.getClassLoader().loadClass(className);
            }
        }
    }
303833
private static String readClasspathResource(String filename) {
        InputStream is = CreateEntities.class.getResourceAsStream(filename);
        if (is == null) {
            throw new IllegalArgumentException(
                    "Could not find the given file '" + filename + "' in the classpath.");
        }
        
        return readContents(is);
    }
704962
@SuppressWarnings("unchecked")
  public <T> Class<T> getClass(String key)
      throws ClassNotFoundException {
    if (containsKey(key)) {
      return (Class<T>) Class.forName(get(key));
    } else {
      throw new IllegalArgumentException("Missing key " + key + ".");
    }
  }
654961
public Class<?> findClass(String className) throws ClassNotFoundException {
		Object location = classResourceLocations.get(className);
		if (location == null && this.propertiesResourceLocations.containsKey(className)) {
			String fileName = (String) propertiesResourceLocations.get(className);
			if (fileName.endsWith(".properties")) {
				//notify invoker that file is present as properties file
				return ResourceBundle.class;
			} else {
				throw new ClassNotFoundException("resource '" + fileName + "' for class '" + className + "' has incompatible format");
			}
		}
		if (className.startsWith("java.")) {
			return super.findClass(className);
		}
		if (location == null) {
			throw new ClassNotFoundException("class '" + className + "' not found in " + classpath);
		}
		String fileName = className.replace('.', '/') + ".class";

		byte[] data;
		try {
			data = getData(fileName, location);
		} catch (IOException ioe) {
			throw new NoClassDefFoundError("class '" + className + "' could not be loaded from '" + location + "' with message: " + ioe);
		}
		return defineClass(className, data, 0, data.length);
	}
28599
public static ClassLoader getClassLoader(Class<?> cls) {
        ClassLoader cl = cls.getClassLoader();
        if (cl == null) {
            cl = getClassLoader();
        }
        return cl;
    }
1126968
public Class getNewClass() throws IllegalStateException, ClassFormatError {
        if (mClass != null) {
            return mClass;
        }
        ByteArrayOutputStream data = mData;
        if (data == null) {
            throw new IllegalStateException("Class not defined yet");
        }

        byte[] bytes = data.toByteArray();

        if (DEBUG) {
            File file = new File(mName.replace('.', '/') + ".class");
            try {
                File tempDir = new File(System.getProperty("java.io.tmpdir"));
                file = new File(tempDir, file.getPath());
            } catch (SecurityException e) {
            }
            try {
                file.getParentFile().mkdirs();
                System.out.println("ClassInjector writing to " + file);
                OutputStream out = new FileOutputStream(file);
                out.write(bytes);
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        mClass = mLoader.define(mName, bytes);
        mData = null;
        return mClass;
    }
570983
public Class<?> getClass(final String key, final Class<?> defaultClass) {
    if (containsKey(key)) {
      return getClass(key);
    } else {
      return defaultClass;
    }
  }
91250
protected InputStream getClassInputStream(String classInternalName) {
        if (classInternalName == null || "".equals(classInternalName)) {
            return null;
        }

        InputStream inputStream = null;
        try {
            for (File jarFile : jarFiles) {
                ZipFile zipFile = new ZipFile(jarFile);
                ZipEntry zipEntry = zipFile.getEntry(classInternalName + ".class");
                if (zipEntry != null) {
                    InputStream zis = zipFile.getInputStream(zipEntry);
                    byte[] bytecode = toByteArray(zis);
                    if (isStreamForClass(new ByteArrayInputStream(bytecode), classInternalName)) {
                        inputStream = new ByteArrayInputStream(bytecode);
                    }
                    zis.close();
                }
                zipFile.close();

                if (inputStream != null) {
                    return inputStream;
                }
            }

            String fileName = classInternalName + ".class";
            fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
            for (File classFile : classFiles) {
                if (classFile.getName().equals(fileName)) {
                    FileInputStream fis = new FileInputStream(classFile);
                    byte[] bytecode = toByteArray(fis);
                    if (isStreamForClass(new ByteArrayInputStream(bytecode), classInternalName)) {
                        inputStream = new ByteArrayInputStream(bytecode);
                    }
                    fis.close();
                }
                if (inputStream != null) {
                    return inputStream;
                }
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return null;
    }
894890
public static File getClassFileFromDirectoryInClassPath(String className) {
		String fileName = StringSupport.replaceAll(className, ".", "/");
		fileName += ".class";
		return getFileFromDirectoryInClassPath(fileName, System.getProperty("java.class.path"));
	}
1030944
public Class<?> findClass(String className)
	{
	
		Class<?> result = null;

		// look in hash map
		result = (Class<?>) classes.get(className);
		if (result != null)
		{
			return result;
		}

		try
		{
			return findSystemClass(className);
		}
		catch (Exception e)
		{
			Debugger.printWarn(e);
		}

		try
		{
			URL resourceURL = ClassLoader.getSystemResource(className.replace(
					'.', File.separatorChar) + ".class");

			if (resourceURL == null)
				return null;

			String classPath = resourceURL.getFile();

			classPath = classPath.substring(1);

			return loadClass(className, new File(classPath));
		}
		catch (Exception e)
		{
			Debugger.printError(e);
			return null;
		}
	}
317433
def extract_class(jar, name):
    

    with jar.open(name) as entry:
        return LinkableClass(javatools.unpack_class(entry))
536706
public function findFile($class) {
		if ('\\' === $class[0]) {
			$class = substr($class, 1);
		}

		if (isset($this->classMap[$class])) {
			return $this->classMap[$class];
		}
		elseif ($this->classMapAuthoratative) {
			return false;
		}

		$classPath = $this->getClassPath($class);

		foreach ($this->prefixes as $prefix => $dirs) {
			if (0 === strpos($class, $prefix)) {
				foreach ($dirs as $dir) {
					if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
						return $dir.DIRECTORY_SEPARATOR.$classPath;
					}
				}
			}
		}

		foreach ($this->fallbackDirs as $dir) {
			if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
				return $dir.DIRECTORY_SEPARATOR.$classPath;
			}
		}

		if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {
			return $file;
		}

		return $this->classMap[$class] = false;
	}
1332552
@Override
	protected Class<?> findClass(final String name) throws ClassNotFoundException {
		log.trace("findClass:" + name);
		Class<?> clazz = findLoadedClass(name);
		if (clazz != null) {
			return clazz;
		}
		return super.findClass(name);
	}