- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
dupcheck
Mon, 2010-11-15, 14:58
Did you ever want to dump Java 5 signatures from existing classfiles? Did you ever want to find duplicate methods/fields in a classfile?
Probably not, but for those 2 other people who want to do that, I wrote this awesome tool:
dupcheck [-d|-p] /path/to/Foo.class
-d Find duplicate methods/fields-p Print raw information in classfiles (member descriptors and Java 5 signatures).
It saves a lot of time when chasing pesky bugs like #3973, #3828, #2754, especially when they're regressions (the exit code is non-zero when duplicates are found, so it can work with git bisect). It always annoyed me that javap does not understand 'Signature' attributes, so I added the functionality to look at them.
Here's how it looks:
dragos@dragos-imac scala (master) $ dupcheck -p build/quick/classes/library/scala/Function1.class class scala.Function1 extends java.lang.Object with scala.ScalaObject { <T1:Ljava/lang/Object;R:Ljava/lang/Object;>Ljava/lang/Object;Lscala/ScalaObject;
public abstract def apply: (Ljava.lang.Object;)Ljava.lang.Object; (TT1;)TR; public abstract def toString: ()Ljava.lang.String; public abstract def compose: (Lscala.Function1;)Lscala.Function1; <A:Ljava/lang/Object;>(Lscala/Function1<TA;TT1;>;)Lscala/Function1<TA;TR;>; public abstract def andThen: (Lscala.Function1;)Lscala.Function1; <A:Ljava/lang/Object;>(Lscala/Function1<TR;TA;>;)Lscala/Function1<TT1;TA;>; public abstract def unlift: (Lscala.Predef$$less$colon$less;)Lscala.PartialFunction; <R1:Ljava/lang/Object;>(Lscala/Predef$$less$colon$less<TR;Lscala/Option<TR1;>;>;)Lscala/PartialFunction<TT1;TR1;>; public abstract def apply$mcVI$sp: (I)V..
I know it can be improved tremendously, so I put it up on github. You can check it out or download pre-built binaries at https://github.com/dragos/dupcheck.
One idea was to add a combinator parser for Java 5 signatures and beautify them (right now they are printed as raw strings). Then support for EnclosingMethod and InnerClasses.
iulian
--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Probably not, but for those 2 other people who want to do that, I wrote this awesome tool:
dupcheck [-d|-p] /path/to/Foo.class
-d Find duplicate methods/fields-p Print raw information in classfiles (member descriptors and Java 5 signatures).
It saves a lot of time when chasing pesky bugs like #3973, #3828, #2754, especially when they're regressions (the exit code is non-zero when duplicates are found, so it can work with git bisect). It always annoyed me that javap does not understand 'Signature' attributes, so I added the functionality to look at them.
Here's how it looks:
dragos@dragos-imac scala (master) $ dupcheck -p build/quick/classes/library/scala/Function1.class class scala.Function1 extends java.lang.Object with scala.ScalaObject { <T1:Ljava/lang/Object;R:Ljava/lang/Object;>Ljava/lang/Object;Lscala/ScalaObject;
public abstract def apply: (Ljava.lang.Object;)Ljava.lang.Object; (TT1;)TR; public abstract def toString: ()Ljava.lang.String; public abstract def compose: (Lscala.Function1;)Lscala.Function1; <A:Ljava/lang/Object;>(Lscala/Function1<TA;TT1;>;)Lscala/Function1<TA;TR;>; public abstract def andThen: (Lscala.Function1;)Lscala.Function1; <A:Ljava/lang/Object;>(Lscala/Function1<TR;TA;>;)Lscala/Function1<TT1;TA;>; public abstract def unlift: (Lscala.Predef$$less$colon$less;)Lscala.PartialFunction; <R1:Ljava/lang/Object;>(Lscala/Predef$$less$colon$less<TR;Lscala/Option<TR1;>;>;)Lscala/PartialFunction<TT1;TR1;>; public abstract def apply$mcVI$sp: (I)V..
I know it can be improved tremendously, so I put it up on github. You can check it out or download pre-built binaries at https://github.com/dragos/dupcheck.
One idea was to add a combinator parser for Java 5 signatures and beautify them (right now they are printed as raw strings). Then support for EnclosingMethod and InnerClasses.
iulian
--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Sun, 2010-11-21, 19:57
#1
Re: dupcheck
Iulian,
dupcheck works great.
I also tried the ASM standalone verifier
("CheckClassAdapter") for the same purpose but it overlooks checking for
dup-methods. However, recently the Maxine VM project made available "Yet another
offline Java bytecode verifier"
http://blogs.sun.com/dns/entry/yet_another_offline_java_bytecode
that is definitely worth trying (but I
haven't tried it yet).
Miguel
Sun, 2010-11-21, 20:17
#2
Re: dupcheck
On Sun, Nov 21, 2010 at 07:44:21PM +0100, Miguel Garcia wrote:
> I also tried the ASM standalone verifier ("CheckClassAdapter") for the
> same purpose but it overlooks checking for dup-methods. However,
> recently the Maxine VM project made available "Yet another offline
> Java bytecode verifier"
>
> http://blogs.sun.com/dns/entry/yet_another_offline_java_bytecode
>
> that is definitely worth trying (but I haven't tried it yet).
I've been using it. It's great. Here's a (not fancy) wrapper script
you might find useful.
#!/bin/bash
#
# Usage: $0
export JUNIT4_CP=/soft/jar/junit-4.8.1.jar
DIR=`pwd`
PKG=$1
SCALACP=`/scala/inst/29/bin/scala -nocompdaemon -e 'println(System.getProperty("java.class.path"))'`
ANTCP=`ant -diagnostics | grep ant.core.lib | cut -d' ' -f 2`
OPTS="-Xmx4g -XX:MaxPermSize=512M"
CP="$SCALACP:$ANTCP:$CP:$DIR"
MAXOPTS="-verbose=true"
cd $MAXINE_HOME
echo bin/max -cp/a:"$CP" -J/p"$OPTS" verify $MAXOPTS ^$PKG.
bin/max -cp/a:"$CP" -J/p"$OPTS" verify $MAXOPTS ^$PKG.