classlister.java

来自「derby database source code.good for you.」· Java 代码 · 共 732 行 · 第 1/2 页

JAVA
732
字号
                }                catch (IOException ioe)                {                    if (beVerbose)                    {                        pwOut.println("IOException loading ZipFile or creating InputStream " +                            " from it");                        pwOut.println(ioe);                    }                }                else if (hash instanceof File)                {                    File file = new File((File)hash, className.replace('/', File.separatorChar));                    if (beVerbose)                    {                        pwOut.println("looking to load file: " + file.getName());                    }                    if (file.exists())                    {                        if (beVerbose)                        {                            pwOut.println(" found it!");                        }                        try                        {                            FileInputStream fis = new FileInputStream(file);                            return new BufferedInputStream(fis, 8192);                        }                        catch (IOException ioe)                        {                            if (beVerbose)                            {                                pwOut.println("IOException creating FileInputStream");                                pwOut.println(ioe);                                return null;                            }                        }                    }                }            }            //        }        // could not find it        if (beVerbose)        {            pwOut.println("returing null on purpose");        }        return null;    }	protected void findDependencies(String className) throws IOException {		indent++;		try {		if (className.startsWith("java.") && skipJava)		{			pwOut.println("Skipping JAVA " + className);			return;		}		if (className.startsWith("javax.") && skipJavax)		{			//System.out.println("Skipping JAVAX " + className);		    return;		}                if (className.startsWith("sun.") && skipSun)                {                        //System.out.println("Skipping Sun " + className);                    return;                }		if (className.startsWith("org.") && skipOrg)		{		    // Allow opensource org.apache.derby classes                    if (!className.startsWith("org.apache.derby")) 		    {			//System.out.println("Skipping org " + className);			return;		    }		}		if (className.startsWith("com.informix.") && skipInformix)		{			//System.out.println("Skipping Informix " + className);		    return;		}		if (className.startsWith("com.ibm.mobileservices.") && skipDB2e)		{			//System.out.println("Skipping DB2e " + className);		    return;		}		if (className.startsWith("common.") && skipDB2)		{			//System.out.println("Skipping DB2 common " + className);		    return;		}        if (ignoreWebLogic)        {            if (className.startsWith("weblogic."))			{                return;			}        }		if (db2jtools || db2jdrda) {			// for tools skip classes that are part of the db2j product api			// they should be pulled in from cs.jar or any client.jar			if (				   className.startsWith("org.apache.derby.authentication.")				|| className.startsWith("org.apache.derby.catalog.")				|| className.startsWith("org.apache.derby.iapi.db.")				|| className.startsWith("org.apache.derby.diag.")				|| className.startsWith("org.apache.derby.jdbc.")				|| className.startsWith("org.apache.derby.vti.")				)			{				return;			}		}		// drda explicitly brings in some database engine classes.		// they must be picke dup from cs.jar and not put in		// the network server jar.		if (db2jdrda) {			if (				   className.startsWith("org.apache.derby.impl.sql")				|| className.startsWith("org.apache.derby.impl.jdbc")				|| className.startsWith("org.apache.derby.impl.services")				|| className.startsWith("org.apache.derby.iapi.")				)			{				return;			}		}		// already seen class		if (foundClasses.get(className) != null)			return;		if (verbose) {			for (int i =0; i < indent; i++)			{				System.out.print(".");			}			System.out.println(className);		}		/*			org.apache.derby.iapi.reference.ClassName &			RegisteredFormatIds has a list of all registered classes, If we pull this in then			we will pull in the complete set of classes. So we add this to our list but don't			dependency check it.		*/		boolean dontCheckDependencies = false;		/*		if (className.equals("org.apache.derby.iapi.reference.ClassName") ||			className.equals("org.apache.derby.iapi.services.io.RegisteredFormatIds")) {			dontCheckDependencies = true;		}		*/        try        {			Hashtable localHashtable = null;						if (keepDependencyHistory) {				localHashtable = (Hashtable) masterClassList.get(className);				if (localHashtable == null)				{					localHashtable = new Hashtable();					masterClassList.put(className, localHashtable);				}			}		    foundClasses.put(className, "class");			if (dontCheckDependencies)				return;			String fileName = "/" + className.replace('.', '/') + ".class";			InputStream is = locateClass(fileName, false);			if (is == null) {				pwOut.println("**error** Got NULL when looking for fileName = " + fileName);				if (!keepRolling)				{					System.exit(1);				}				else				{					errorCount++;				}			}			//byte[] classData = new byte[is.available()];			//is.read(classData);			ClassInvestigator ch = ClassInvestigator.load(is);			is.close();		    for (Enumeration e = ch/*.getClassInfo()*/.referencedClasses(); e.hasMoreElements(); ) {			    String x = (String) e.nextElement();				// skip microsoft classes				if (x.startsWith("com.ms."))				{					continue;				}				if (!org.apache.derby.iapi.services.sanity.SanityManager.DEBUG) {					if (x.indexOf("SanityManager") != -1) {						boolean printSanityWarning = true;						int ld = className.lastIndexOf(".");						if (ld != -1) {							if (className.lastIndexOf("T_") == ld + 1)								printSanityWarning = false;							else if (className.lastIndexOf("T_") == ld + 1)								printSanityWarning = false;							else if (className.lastIndexOf("D_") == ld + 1)								printSanityWarning = false;							else if (className.lastIndexOf("TEST_") == ld + 1)								printSanityWarning = false;							else if (className.endsWith("SanityManager"))								printSanityWarning = false;						}						if (printSanityWarning)							System.out.println("SANITY >>> " + fileName);					}				}				if (keepDependencyHistory && (localHashtable.get(x) == null))				{											localHashtable.put(x, "class");				}			    findDependencies(x);            }		}         catch (NullPointerException npe)		{			pwOut.println("**error** Got NullPointerException in findDependencies when looking up ");			pwOut.println(className);						npe.printStackTrace();			if (!keepRolling)			{				System.exit(1);			}			errorCount++;		}		// look for properties only with cloudscape code ...		if (!isCloudscapeCode(className))			return;		String packageName = className.substring(0, className.lastIndexOf('.') + 1);		for (int i = 0; i < propFiles.length; i++) {			String fileName = "/" + packageName.replace('.', '/') + propFiles[i];			if (foundClasses.get(fileName) != null)				continue;			InputStream is = getClass().getResourceAsStream(fileName);			if (is == null)				continue;			is.close();			foundClasses.put(fileName.substring(1), "file");		}} finally {		indent--;	}	}	protected boolean isCloudscapeCode(String name) {		return name.startsWith("com.ibm.db2j.") ||		       name.startsWith("com.ihost.cs.") ||		       name.startsWith("db2j.") ||		       name.startsWith("org.apache.derby");	}	protected void showAllItems()	{		Enumeration e = masterClassList.keys();		pwOut.println("------------Printing all dependents--------------");		while (e.hasMoreElements())		{			String kid = (String) e.nextElement();			pwOut.println(kid );			Hashtable scoreboard = new Hashtable();			Hashtable grandkids = (Hashtable) masterClassList.get(kid);			unrollHashtable("", grandkids, scoreboard, 1);		}	}	protected void showAllItemsOneLevel()	{		pwOut.println("Showing all dependencies");		pwOut.println("One level only");		pwOut.println("-----------------------------------");				Enumeration e = masterClassList.keys();		while (e.hasMoreElements())		{			String key = (String) e.nextElement();			pwOut.println(key);			Hashtable h = (Hashtable) masterClassList.get(key);			Enumeration e2 = h.keys();			Hashtable h2 = new Hashtable();			while (e2.hasMoreElements())			{				String key2 = (String) e2.nextElement();				pwOut.println("\t" + key2);			}		}	}	protected void unrollHashtable( String parent, Hashtable current, Hashtable scoreboard, int indentLevel)	{		String indentString = "  ";		Enumeration e = current.keys();		String key = null; 		while (e.hasMoreElements())		{			key = (String) e.nextElement();			if (key.equals(parent))			{				continue;			}			pwOut.print(indentLevel + ":");			Integer value = (Integer) scoreboard.get(key);			if (value != null )			{				for (int i = 0; i < indentLevel; i++)				{					pwOut.print(indentString);				}				pwOut.println(key + "*****REPEATED class back at level " + value + "****");				return;			}			for (int i = 0; i < indentLevel; i++)			{				pwOut.print(indentString);			}			pwOut.println(key);			Hashtable currentsChildren = (Hashtable) masterClassList.get(key);	scoreboard.put(key, new Integer(indentLevel));			unrollHashtable(key, currentsChildren, scoreboard, (indentLevel+1));			scoreboard.put(key, new Integer(indentLevel));					}	}			}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?