You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2012/09/20 22:16:07 UTC

svn commit: r1388194 - /accumulo/trunk/test/compat/diffAPI.pl

Author: kturner
Date: Thu Sep 20 20:16:07 2012
New Revision: 1388194

URL: http://svn.apache.org/viewvc?rev=1388194&view=rev
Log:
ACCUMULO-765 updated diffAPI.pl to show which methods are deprecated

Modified:
    accumulo/trunk/test/compat/diffAPI.pl

Modified: accumulo/trunk/test/compat/diffAPI.pl
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/compat/diffAPI.pl?rev=1388194&r1=1388193&r2=1388194&view=diff
==============================================================================
--- accumulo/trunk/test/compat/diffAPI.pl (original)
+++ accumulo/trunk/test/compat/diffAPI.pl Thu Sep 20 20:16:07 2012
@@ -15,6 +15,60 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+sub trim($)
+{
+	my $string = shift;
+	$string =~ s/^\s+//;
+	$string =~ s/\s+$//;
+	return $string;
+}
+
+sub getDeprecated {
+        my($jar, $class) = @_;
+        
+	open(JAVAP, "javap -verbose -public -classpath '$jar' '$class'|");
+
+        my $lastMethod = "";
+        my %deprecated;
+
+        while(<JAVAP>){
+		chomp();
+                if(/^public\s/){
+                        $lastMethod = $_;
+                }
+                if(/Deprecated\:\strue/){
+			$lastMethod =~ s/\s+/ /g;
+                        $deprecated{$lastMethod}="true";
+                }
+        }
+
+        close(JAVAP);
+
+        return %deprecated;
+}
+
+sub annotateDeprecated {
+        my($jar, $class, $deprecated, $outFile) = @_;
+	open(JAVAP, "javap -public -classpath '$jar' '$class'|");
+	open(OUT, ">$outFile");
+	my @javapOut =  <JAVAP>;
+	@javapOut = sort(@javapOut);
+
+	for my $line (@javapOut){
+		my $trimLine = trim($line);
+		chomp($line);
+		$trimLine =~ s/\s+/ /g;
+		if($deprecated->{$trimLine}){
+			print OUT "$line DEPRECATED\n";
+		}else{
+			print OUT "$line\n";
+		}
+	}
+
+	close(JAVAP);
+	close(OUT);
+	
+}
 
 if(scalar(@ARGV) != 2){
 	print "Usage : diffAPI.pl <core jar 1> <core jar 2>\n";
@@ -24,7 +78,7 @@ if(scalar(@ARGV) != 2){
 $jar1 = $ARGV[0];
 $jar2 = $ARGV[1];
 
-$gtCmd = 'egrep "accumulo/core/client/.*class|accumulo/core/data/.*class" | grep -v accumulo/core/client/impl | grep -v  accumulo/core/data/thrift | tr / .';
+$gtCmd = 'egrep "accumulo/core/client/.*class|accumulo/core/data/.*class" | grep -v accumulo/core/client/impl | grep -v  accumulo/core/data/thrift | egrep -v "Impl.*class$" | tr / .';
 
 @classes1 = `jar tf $jar1 | $gtCmd`;
 @classes2 = `jar tf $jar2 | $gtCmd`;
@@ -35,12 +89,14 @@ mkdir("diffWorkDir/jar2");
 
 for $class (@classes1){
 	$class = substr($class, 0, length($class) - 7);
-	system("javap -classpath $jar1 $class | sort > diffWorkDir/jar1/$class");
+	%deprecated = getDeprecated($jar1, $class);
+	annotateDeprecated($jar1, $class, \%deprecated, "diffWorkDir/jar1/$class");
 }
 
 for $class (@classes2){
 	$class = substr($class, 0, length($class) - 7);
-	system("javap -classpath $jar2 $class | sort > diffWorkDir/jar2/$class");
+	%deprecated = getDeprecated($jar2, $class);
+	annotateDeprecated($jar2, $class, \%deprecated, "diffWorkDir/jar2/$class");
 }
 
 system("diff -u diffWorkDir/jar1 diffWorkDir/jar2");