river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1062134 - in /incubator/river/jtsk/trunk: build.xml src/com/sun/jini/tool/classdepend/ClassDepend.java src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java src/manifest/classdepend.mf
Date Sat, 22 Jan 2011 10:34:01 GMT
Author: peter_firmstone
Date: Sat Jan 22 10:34:01 2011
New Revision: 1062134

URL: http://svn.apache.org/viewvc?rev=1062134&view=rev
Log:
Commit changes to build classdepend.jar for dependency analysis of java classes.

Added:
    incubator/river/jtsk/trunk/src/manifest/classdepend.mf   (with props)
Modified:
    incubator/river/jtsk/trunk/build.xml
    incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDepend.java
    incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java

Modified: incubator/river/jtsk/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/build.xml?rev=1062134&r1=1062133&r2=1062134&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/build.xml (original)
+++ incubator/river/jtsk/trunk/build.xml Sat Jan 22 10:34:01 2011
@@ -593,6 +593,16 @@
             <arg value="tools.jar"/>
         </jarwrapper>
     </target>
+    
+    <target name="classdepend.jar" depends="jarwrapper.jar">
+        <delete file="${lib.dir}/classdepend.jar" quiet="true"/>
+        <jarwrapper>
+            <arg value="-manifest=${src.manifest.dir}/classdepend.mf"/>
+            <arg path="${lib.dir}/classdepend.jar"/>
+            <arg path="${lib.dir}"/>
+            <arg value="tools.jar"/>
+        </jarwrapper>
+    </target>
 
     <target name="classserver.jar" depends="jarwrapper.jar">
         <delete file="${lib.dir}/classserver.jar" quiet="true"/>

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDepend.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDepend.java?rev=1062134&r1=1062133&r2=1062134&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDepend.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDepend.java Sat Jan
22 10:34:01 2011
@@ -132,6 +132,7 @@ public class ClassDepend {
             boolean recurse = true;
 	    boolean warn = false; //supress exceptions, print to error, warn instead
 	    boolean files = false; //print class with file path separator
+            boolean graph = false; //print dependency relation ships between classes.
 	    for (int i = 0; i < args.length; i++) {
 		String arg = args[i];
 		if (arg.equals("-cp")) {
@@ -146,6 +147,10 @@ public class ClassDepend {
 		    warn = true;
 		} else if (arg.equals("-files")) {
 		    files = true;
+                } else if (arg.equals("-graph")) {
+                    graph = true;
+                } else if (arg.equals("-excljava")) {
+                    cdpb.excludePlatformClasses(true);
 		} else if (arg.startsWith("-")) {
 		    throw new IllegalArgumentException("Bad option: " + arg);
 		} else {
@@ -154,21 +159,31 @@ public class ClassDepend {
 	    }
             ClassDependParameters cdp = cdpb.build();          
 	    ClassDepend classDepend = ClassDepend.newInstance(classpath, platform, warn);
-            
-            
-	    String[] dependencies = (String[]) classDepend
+            Set result = classDepend
                     .filterClassDependencyRelationShipMap(
                     classDepend.getDependencyRelationshipMap(rootClasses, recurse),
-                    cdp)
-                    .toArray(new String[0]);
-	    Arrays.sort(dependencies);
-            int l = dependencies.length;
-	    for ( int i = 0 ; i < l ; i++) {
-                String cl = dependencies[i];
+                    cdp);
+            Iterator results = result.iterator();
+            while (results.hasNext()){
+                Object rezult = results.next();
+                if ( !(rezult instanceof ClassDependencyRelationship )) continue;
+                ClassDependencyRelationship cl = (ClassDependencyRelationship) rezult;
+                String str = cl.toString();
 		if (files) {
-		    cl = cl.replace('.', File.separatorChar).concat(".class");
+		    str = str.replace('.', File.separatorChar).concat(".class");
+                    System.out.println(str);
 		}
-		System.out.println(cl);
+		if (graph) {
+                    Set deps = cl.getProviders();
+                    Iterator itr = deps.iterator();
+                    while (itr.hasNext()){
+                        Object dep = itr.next();
+                        if ( result.contains(dep)) {
+                            System.out.println("\"" + cl + "\""+ " -> " + 
+                                "\"" + dep + "\"" + ";");
+                        }
+                    }
+                }
 	    }
 	} catch (Throwable e) {
 	    e.printStackTrace();

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java?rev=1062134&r1=1062133&r2=1062134&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java
(original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/tool/classdepend/ClassDependencyRelationship.java
Sat Jan 22 10:34:01 2011
@@ -32,14 +32,14 @@ public class ClassDependencyRelationship
     private final Set dependants;   // classes that depend upon this class.
     private final Set providers;    // classes that this class depends upon.
     private final String fullyQualifiedClassName;
+    private final int hash;
     private final boolean rootClass;
-    private volatile boolean result = false; // never set back to false, once true, true
always.
-    private volatile boolean interesting = false;
     
     ClassDependencyRelationship (String fullyQualifiedClassName, boolean rootClass){
         this.fullyQualifiedClassName = fullyQualifiedClassName;
-        dependants = Collections.synchronizedSet(new HashSet());
-        providers = Collections.synchronizedSet(new HashSet());
+        hash = 59 * 7 + (this.fullyQualifiedClassName != null ? this.fullyQualifiedClassName.hashCode()
: 0);
+        dependants = new HashSet();
+        providers = new HashSet();
         this.rootClass = rootClass;
     }
     
@@ -79,16 +79,6 @@ public class ClassDependencyRelationship
         return deps;
     }
 
-    public void addProviders(Set providers) {
-        Iterator iter = providers.iterator();
-        synchronized (this.providers){
-            this.providers.addAll(providers);
-        }
-        while (iter.hasNext()){
-            ((ClassDependencyRelationship) iter.next()).addDependant(this);
-        }
-    }
-
     /**
      * Get the classes that this class needs to function.
      * @return a Set of classes
@@ -106,8 +96,22 @@ public class ClassDependencyRelationship
         return fullyQualifiedClassName;
     }
 
+    @Override
+    public int hashCode() {
+        return hash;
+    }
+    
+    public boolean equals(Object o){
+        if ( o == null ) return false;
+        if (!(o instanceof ClassDependencyRelationship)) return false;
+        if (fullyQualifiedClassName.equals(
+                ((ClassDependencyRelationship)o).fullyQualifiedClassName))
+                return true;
+        return false;
+    }
+
     /**
-     * Is this a root dependant, that is no other classes depend on this.
+     * If this a root dependant, the class was used to discover dependencies.
      * @return true or false
      */
     public boolean isRootClass() {

Added: incubator/river/jtsk/trunk/src/manifest/classdepend.mf
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/manifest/classdepend.mf?rev=1062134&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/src/manifest/classdepend.mf (added)
+++ incubator/river/jtsk/trunk/src/manifest/classdepend.mf Sat Jan 22 10:34:01 2011
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.sun.jini.tool.classdepend.ClassDepend
+

Propchange: incubator/river/jtsk/trunk/src/manifest/classdepend.mf
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message