Return the source of the specified class which may lie in component
path.
322365
synchronized public ClassSource getClassSource( String className )
    {
        // Before triggering classpath mapping (initialization) check for
        // explicitly set class sources (e.g. generated classes).  These would
        // take priority over any found in the classpath anyway.
        ClassSource cs = (ClassSource)classSource.get( className );
        if ( cs != null )
            return cs;

        insureInitialized(); // trigger possible mapping

        cs = (ClassSource)classSource.get( className );
        if ( cs == null && compPaths != null )
            for (int i=0; i<compPaths.size() && cs==null; i++)
                cs = ((BshClassPath)compPaths.get(i)).getClassSource(className);
        return cs;
    }

    /**
        Explicitly set a class source.  This is used for generated classes, but
        could potentially be used to allow a user to override which version of
        a class from the classpath is located.
    */
    synchronized public void setClassSource( String className, ClassSource cs )
    {
        classSource.put( className, cs );
    }

    /**
        If the claspath map is not initialized, do it now.
        If component maps are not do them as well...

        Random note:
        Should this be "insure" or "ensure".  I know I've seen "ensure" used
        in the JDK source.  Here's what Webster has to say:

            Main Entry:ensure Pronunciation:in-'shur
            Function:transitive verb Inflected
            Form(s):ensured; ensuring : to make sure,
            certain, or safe : GUARANTEE synonyms ENSURE,
            INSURE, ASSURE, SECURE mean to make a thing or
            person sure. ENSURE, INSURE, and ASSURE are
            interchangeable in many contexts where they
            indicate the making certain or inevitable of an
            outcome, but INSURE sometimes stresses the
            taking of necessary measures beforehand, and
            ASSURE distinctively implies the removal of
            doubt and suspense from a person's mind. SECURE
            implies action taken to guard against attack or
            loss.
    */
    public void insureInitialized()
    {
        insureInitialized( true );
    }

    /**
        @param topPath indicates that this is the top level classpath
        component and it should send the startClassMapping message
    */
    protected synchronized void insureInitialized( boolean topPath )
    {
        // If we are the top path and haven't been initialized before
        // inform the listeners we are going to do expensive map
        if ( topPath && !mapsInitialized )
            startClassMapping();

        // initialize components
        if ( compPaths != null )
            for (int i=0; i< compPaths.size(); i++)
                ((BshClassPath)compPaths.get(i)).insureInitialized( false );

        // initialize ourself
        if ( !mapsInitialized )
            map( (URL[])path.toArray( new URL[0] ) );

        if ( topPath && !mapsInitialized )
            endClassMapping();

        mapsInitialized = true;
    }

    /**
        Get the full path including component paths.
        (component paths listed first, in order)
        Duplicate path components are removed.
    */
    protected List getFullPath()
    {
        List list = new ArrayList();
        if ( compPaths != null ) {
            for (int i=0; i<compPaths.size(); i++) {
                List l = ((BshClassPath)compPaths.get(i)).getFullPath();
                // take care to remove dups
                // wish we had an ordered set collection
                Iterator it = l.iterator();
                while ( it.hasNext() ) {
                    Object o = it.next();
                    if ( !list.contains(o) )
                        list.add( o );
                }
            }
        }
        list.addAll( path );
        return list;
    }


    /**
        Support for super import "*";
        Get the full name associated with the unqualified name in this
        classpath.  Returns either the String name or an AmbiguousName object
        encapsulating the various names.
    */
    public String getClassNameByUnqName( String name )
        throws ClassPathException
    {
        insureInitialized();
        UnqualifiedNameTable unqNameTable = getUnqualifiedNameTable();

        Object obj = unqNameTable.get( name );
        if ( obj instanceof AmbiguousName )
            throw new ClassPathException("Ambigous class names: "+
                ((AmbiguousName)obj).get() );

        return (String)obj;
    }

    /*
        Note: we could probably do away with the unqualified name table
        in favor of a second name source
    */
    private UnqualifiedNameTable getUnqualifiedNameTable() {
        if ( unqNameTable == null )
            unqNameTable = buildUnqualifiedNameTable();
        return unqNameTable;
    }

    private UnqualifiedNameTable buildUnqualifiedNameTable()
    {
        UnqualifiedNameTable unqNameTable = new UnqualifiedNameTable();

        // add component names
        if ( compPaths != null )
            for (int i=0; i<compPaths.size(); i++) {
                Set s = ((BshClassPath)compPaths.get(i)).classSource.keySet();
                Iterator it = s.iterator();
                while(it.hasNext())
                    unqNameTable.add( (String)it.next() );
            }

        // add ours
        Iterator it = classSource.keySet().iterator();
        while(it.hasNext())
            unqNameTable.add( (String)it.next() );

        return unqNameTable;
    }

    public String [] getAllNames()
    {
        insureInitialized();

        List names = new ArrayList();
        Iterator it = getPackagesSet().iterator();
        while( it.hasNext() ) {
            String pack = (String)it.next();
            names.addAll(
                removeInnerClassNames( getClassesForPackage( pack ) ) );
        }

        if ( nameCompletionIncludesUnqNames )
            names.addAll( getUnqualifiedNameTable().keySet() );

        return (String [])names.toArray(new String[0]);
    }

    /**
        call map(url) for each url in the array
    */
    synchronized void map( URL [] urls )
    {
        for(int i=0; i< urls.length; i++)
            try{
                map( urls[i] );
            } catch ( IOException e ) {
                String s = "Error constructing classpath: " +urls[i]+": "+e;
                errorWhileMapping( s );
            }
    }

    synchronized void map( URL url )
        throws IOException
    {
        if ("jrt".equals(url.getProtocol())) {
            classMapping("FileSystem: "+url );
            map( searchJrtFSForClasses( url ), new JrtClassSource(url) );
        } else  if ("jar".equals(url.getProtocol())) {
            classMapping("FileSystem: "+url );
            map( searchJarFSForClasses( url ), new JarClassSource(url) );
        } else {
            String name = url.getFile();
            File f = new File( name );

            if ( f.isDirectory() ) {
                classMapping( "Directory "+ f.toString() );
                map( traverseDirForClasses( f ), new DirClassSource(f) );
            } else if ( isArchiveFileName( name ) ) {
                classMapping("Archive: "+url );
                map( searchArchiveForClasses( url ), new JarClassSource(url) );
            } else {
                String s = "Not a classpath component: "+ name ;
                errorWhileMapping( s );
            }
        }
    }

    private void map( String [] classes, Object source ) {
        for(int i=0; i< classes.length; i++) {
            //System.out.println( classes[i] +": "+ source );
            mapClass( classes[i], source );
        }
    }

    private void mapClass( String className, Object source )
    {
        // add to package map
        String [] sa = splitClassname( className );
        String pack = sa[0];
        Set set = (Set)packageMap.get( pack );
        if ( set == null ) {
            set = new HashSet();
            packageMap.put( pack, set );
        }
        set.add( className );

        // Add to classSource map
        Object obj = classSource.get( className );
        // don't replace previously set (found earlier in classpath or
        // explicitly set via setClassSource() )
        if ( obj == null )
            classSource.put( className, source );
    }
765414
public static Class<?> classFind(String name) {
        try {
            return Class.forName(name);
        } catch (ClassNotFoundException e) {
            return findType(name).type;
        }
    }
1093136
public InputStream getResourceAsStream( String path ) {
        Object in = null;
        if ( externalClassLoader != null )
            // classloader wants no leading slash
            in = externalClassLoader.getResourceAsStream( path.substring(1) );
        if ( in == null )
            return Interpreter.class.getResourceAsStream( path );

        return (InputStream) in;
    }
322896
public static String getSourceByClass(Class<?> koanClass) {

        File file = new File(getKoanFileLocation(koanClass));
   		StringBuilder contents = new StringBuilder();
   		BufferedReader reader = null;

   		try {
   			reader = new BufferedReader(new FileReader(file));
   			String text = null;

   			while ((text = reader.readLine()) != null) {
   				contents.append(text).append(System.lineSeparator());
   			}
   		} catch (IOException e) {
   			e.printStackTrace();
   		} finally {
   			try {
   				if (reader != null) {
   					reader.close();
   				}
   			} catch (IOException e) {
   				e.printStackTrace();
   			}
   		}
   		return contents.toString();
   	}
298795
def path(self):
        ""
        if self.parent:
            return '.'.join([self.parent.path, str(self.identifier)])
        else:
            return self.identifier if self.identifier else self.__class__.__name__
188994
public File findJavaSourceFile(String soruceRootDir,Class<?> clazz)
	{
		String url = StringUtils.replace(clazz.getPackage().toString().split(" ")[1], ".",File.separator);
		String sourceFilename = soruceRootDir+url +File.separator + clazz.getSimpleName() + ".java";
		File javaSourceFile=new File(sourceFilename);
		return javaSourceFile;
	}
139109
def jarSources(target, source, env, for_signature):
    """"""
    try:
        env['JARCHDIR']
    except KeyError:
        jarchdir_set = False
    else:
        jarchdir_set = True
        jarchdir = env.subst('$JARCHDIR', target=target, source=source)
        if jarchdir:
            jarchdir = env.fs.Dir(jarchdir)
    result = []
    for src in source:
        contents = src.get_text_contents()
        if contents[:16] != "Manifest-Version":
            if jarchdir_set:
                _chdir = jarchdir
            else:
                try:
                    _chdir = src.attributes.java_classdir
                except AttributeError:
                    _chdir = None
            if _chdir:
                # If we are changing the dir with -C, then sources should
                # be relative to that directory.
                src = SCons.Subst.Literal(src.get_path(_chdir))
                result.append('-C')
                result.append(_chdir)
            result.append(src)
    return result
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);
    }
117101
@Override
  protected ClassEntry getClassEntry(String name, String pathName)
    throws ClassNotFoundException
  {
    PathImpl classFile = _classDir.lookup(pathName);
    /*
    Path classDir = classFile.getParent();
    
    if (! classDir.isDirectory())
      return null;
    */
    
    String javaName = name.replace('.', '/') + _sourceExt;
    PathImpl javaFile = _sourceDir.lookup(javaName);

    for (int i = 0; i < INNER_CLASS_SEPARATORS.length; i++) {
      char sep = INNER_CLASS_SEPARATORS[i];
      if (name.indexOf(sep) > 0) {
        String subName = name.substring(0, name.indexOf(sep));
        String subJavaName = subName.replace('.', '/') + _sourceExt;
        PathImpl subJava = _sourceDir.lookup(subJavaName);

        if (subJava.exists()) {
          javaFile = subJava;
        }
      }
    }

    synchronized (this) {
      if (_requireSource && ! javaFile.exists()) {
        boolean doRemove = true;

        if (doRemove) {
          log.finer(L.l("removing obsolete class `{0}'.", classFile.getPath()));

          try {
            classFile.remove();
          } catch (IOException e) {
            log.log(Level.WARNING, e.toString(), e);
          }

          return null;
        }
      }

      if (! classFile.canRead() && ! javaFile.canRead())
        return null;

      return new CompilingClassEntry(this, getClassLoader(),
                                     name, javaFile,
                                     classFile,
                                     getCodeSource(classFile));
    }
  }
610072
public static SqlScriptSource classPathScript(final String path) {
        String normalizedPath = path.startsWith("/") ? path : format("/%s", path);
        URL resource = ScriptResolver.class.getResource(normalizedPath);

        if (resource == null)
            throw new ScriptResolutionException(normalizedPath);

        return Sources.fromURL(resource);
    }
473651
def get_source(self, objtxt):
        """"""
        from spyder_kernels.utils.dochelpers import getsource

        obj, valid = self._eval(objtxt)
        if valid:
            return getsource(obj)
250645
public static URL findClassBase(Class clazz)
   {
      String resource = clazz.getName().replace('.', '/') + ".class";
      return findResourceBase(resource, clazz.getClassLoader());
   }
719083
def get_finder(import_path):
    """"""
    finder_class = import_string(import_path)
    if not issubclass(finder_class, BaseProcessesFinder):
        raise ImproperlyConfigured(
            'Finder "{}" is not a subclass of "{}"'.format(finder_class, BaseProcessesFinder))
    return finder_class()
269703
def load_class_by_path(taskpath):
    

    return getattr(
        importlib.import_module(
            re.sub(
                r"\.[^.]+$",
                "",
                taskpath)),
        re.sub(
            r"^.*\.",
            "",
            taskpath))
714632
public Resource findResourceForClassName(String className) {

        if (className.contains(CLOSURE_MARKER)) {
            className = className.substring(0, className.indexOf(CLOSURE_MARKER));
        }
        Resource resource = classNameToResourceCache.get(className);
        if (resource == null) {
            String classNameWithPathSeparator = className.replace(".", FILE_SEPARATOR);
            for (String pathPattern : getSearchPatternForExtension(classNameWithPathSeparator, ".groovy", ".java", ".kt")) {
                resource = resolveExceptionSafe(pathPattern);
                if (resource != null && resource.exists()) {
                    classNameToResourceCache.put(className, resource);
                    break;
                }
            }
        }
        return resource != null && resource.exists() ? resource : null;
    }
228168
def class_path(cls):
    """"""
    if cls.__module__ == '__main__':
        path = None
    else:
        path = os.path.dirname(inspect.getfile(cls))

    if not path:
        path = os.getcwd()

    return os.path.realpath(path)
579947
private static void getClassPathesFromLoader(ClassLoader cl, Map pathes) {
	if (cl instanceof URLClassLoader) _getClassPathesFromLoader((URLClassLoader) cl, pathes);
    }