You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@river.apache.org by Sim IJskes - QCG <si...@qcg.nl> on 2010/12/04 17:00:10 UTC

API and VM compatibility verification

Hello,

Is there a tool that we can use to verify API compatibility? So we can 
make sure we do not call methods that do not exist?

Gr. SIm



Re: API and VM compatibility verification

Posted by Wade Chandler <hw...@yahoo.com>.
----- Original Message ----

> From: Peter Firmstone <ji...@zeus.net.au>
> To: river-dev@incubator.apache.org
> Sent: Sun, December 5, 2010 3:56:30 PM
> Subject: Re: API and VM compatibility verification
> 
> Sim IJskes - QCG wrote:
> > On 12/05/2010 02:18 PM, Michał Kłeczek  wrote:
> >> I know we're not using Maven (yet?) but look at:
> >>  http://mojo.codehaus.org/animal-sniffer-maven-plugin
> >

https://svn.codehaus.org/mojo/tags/animal-sniffer-parent-1.5/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/ant/


They have Ant tasks too. Seems one could have some tasks to build and store the 
signature files then use the check signatures task against pre-stored signature 
files to speed up the process. 


Just peeking at the source code it looks like it is just using strict 
signatures, so the issues with type expansion, such as with the BigDecimal issue 
I mentioned, should be accounted for I believe. The only cases it looks like it 
wouldn't work in place of good code coverage and tests in a target runtime are 
when classes are loaded by name, dynamic, versus strict source code. So, it 
isn't a complete solution in itself necessarily, but that depends on the logic 
being examined really:
https://svn.codehaus.org/mojo/tags/animal-sniffer-parent-1.5/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/


Agree, it definitely looks promising.

Wade

 ==================
Wade Chandler
Software Engineer and Developer
NetBeans Dream Team Member and Contributor

http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

Re: API and VM compatibility verification

Posted by Peter Firmstone <ji...@zeus.net.au>.
Sim IJskes - QCG wrote:
> On 12/05/2010 02:18 PM, Michał Kłeczek wrote:
>> I know we're not using Maven (yet?) but look at:
>> http://mojo.codehaus.org/animal-sniffer-maven-plugin
>
> That looks really promising. Cool!
>
> Gr. Sim
>
>
Certainly does.

Cheers,

Peter.

Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 12/05/2010 02:18 PM, Michał Kłeczek wrote:
> I know we're not using Maven (yet?) but look at:
> http://mojo.codehaus.org/animal-sniffer-maven-plugin

That looks really promising. Cool!

Gr. Sim


Re: API and VM compatibility verification

Posted by Wade Chandler <hw...@yahoo.com>.
You'll have to pull the JAR files down from a Maven repository such as:
http://mvnrepository.com/artifact/org.codehaus.mojo/animal-sniffer-ant-tasks/1.5

There may be some others out there. I think 1.5 is the latest version though 
unless I'm mistaken. Look at the "This artifact depends on ..." section on that 
page to figure out other dependencies you should download as well. Looks like 
you need the base animal-sniffer package. The other dependency should be taken 
care of by the fact you're running in Ant I believe since it seems it is Ant 
itself or its API.

Wade

 ==================
Wade Chandler
Software Engineer and Developer
NetBeans Dream Team Member and Contributor


http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org



----- Original Message ----
> From: Sim IJskes - QCG <si...@qcg.nl>
> To: river-dev@incubator.apache.org
> Sent: Sun, December 5, 2010 6:02:41 PM
> Subject: Re: API and VM compatibility verification
> 
> On 12/05/2010 11:47 PM, Wade Chandler wrote:
> > They have Ant tasks, so you  don't have to worry about trying to change  the
> > underlying build  system. Too, animal-sniffer is a regular Java  library if 
>you
> > need  something more elaborate than the Ant tasks provide.  See:
> 
> I read  about this. But i could not find a download link on their website, can  
>you?
> 
> Gr. Sim
> 

Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 12/05/2010 11:47 PM, Wade Chandler wrote:
> They have Ant tasks, so you don't have to worry about trying to change  the
> underlying build system. Too, animal-sniffer is a regular Java  library if you
> need something more elaborate than the Ant tasks provide.  See:

I read about this. But i could not find a download link on their 
website, can you?

Gr. Sim

Re: API and VM compatibility verification

Posted by Wade Chandler <hw...@yahoo.com>.
----- Original Message ----

> From: Sim IJskes - QCG <si...@qcg.nl>
> To: river-dev@incubator.apache.org
> Sent: Sun, December 5, 2010 5:06:17 PM
> Subject: Re: API and VM compatibility verification
> 
> On 12/05/2010 02:18 PM, Michał Kłeczek wrote:
> > I know we're not using  Maven (yet?) but look at:
> >  http://mojo.codehaus.org/animal-sniffer-maven-plugin
> 
> I've had a change to  start maven and compile and verify the src directory, but 
>my lack of experience  with maven is limiting to say the least. Would you be 
>willing to contribute some  time to get it working?
> 
> I've build a pom.xml with a  <sourceDirectory> in the <build> (target?). Whe 
>have source in  several directories, do we collect them first in a single 
>directory, or do we  specify multiple sourceDirectories?
> 

They have Ant tasks, so you don't have to worry about trying to change  the 
underlying build system. Too, animal-sniffer is a regular Java  library if you 
need something more elaborate than the Ant tasks provide.  See:
http://mojo.codehaus.org/animal-sniffer/
http://mojo.codehaus.org/animal-sniffer/animal-sniffer-ant-tasks/index.html

Wade

 ==================
Wade Chandler
Software Engineer and Developer
NetBeans Dream Team Member and Contributor

http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 12/05/2010 02:18 PM, Michał Kłeczek wrote:
> I know we're not using Maven (yet?) but look at:
> http://mojo.codehaus.org/animal-sniffer-maven-plugin

I've had a change to start maven and compile and verify the src 
directory, but my lack of experience with maven is limiting to say the 
least. Would you be willing to contribute some time to get it working?

I've build a pom.xml with a <sourceDirectory> in the <build> (target?). 
Whe have source in several directories, do we collect them first in a 
single directory, or do we specify multiple sourceDirectories?

Gr. Sim


Re: API and VM compatibility verification

Posted by Michał Kłeczek <mi...@xpro.biz>.
I know we're not using Maven (yet?) but look at:
http://mojo.codehaus.org/animal-sniffer-maven-plugin

On Sat, Dec 4, 2010 at 5:00 PM, Sim IJskes - QCG <si...@qcg.nl> wrote:

> Hello,
>
> Is there a tool that we can use to verify API compatibility? So we can make
> sure we do not call methods that do not exist?
>
> Gr. SIm
>
>
>

Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 04-12-10 20:54, Wade Chandler wrote:
> I don't really know of any. One way would be to run binary tests against
> different JREs/JDKs. Compile with the desired JDK. Then run other things with
> the target. Depending on code coverage of the tests that would be very useful.

I've reconfigured the River-QA matrix job (it only executes the tests), 
to run on Solaris with JDK4,5,6.

The JDK1.4 used on hudson does not accept the https certificate of 
hudson.apache.org.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Den Haag: 28088397

Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 04-12-10 20:54, Wade Chandler wrote:
> I don't really know of any. One way would be to run binary tests against
> different JREs/JDKs. Compile with the desired JDK. Then run other things with
> the target. Depending on code coverage of the tests that would be very useful.

I've looked into compiling with the desired JDK. Our sourcecode level is 
1.6 for the test harness and 1.5 for the runtime. I can exclude some 
files selectively for different compilations but it doesn't look all 
that watertight to me.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Den Haag: 28088397

Re: API and VM compatibility verification

Posted by Wade Chandler <hw...@yahoo.com>.
----- Original Message ----

> From: Sim IJskes - QCG <si...@qcg.nl>
> To: "river-dev@incubator.apache.org" <ri...@incubator.apache.org>
> Sent: Sat, December 4, 2010 11:00:10 AM
> Subject: API and VM compatibility verification
> 
> Hello,
> 
> Is there a tool that we can use to verify API compatibility? So we  can make 
>sure we do not call methods that do not exist?
> 

I don't really know of any. One way would be to run binary tests against 
different JREs/JDKs. Compile with the desired JDK. Then run other things with 
the target. Depending on code coverage of the tests that would be very useful.

There are things like BigDecimal with its constructors BigDecimal(int) and 1.4.2 
not having that. When you compile source code passing an int into a BigDecimal 
constructor with 1.5+ it references that particular method signature. That will 
then not run in binary form in a 1.4.2 VM, but compiling that logic in 1.4.2 
will work in 1.5 because the int winds up expanded to the BigDecimal(double) 
call at compile time. So, without a run through of the binary logic I don't 
think a tool could just scan the sources and insure compatibility unless it 
overlooked compile time expansion as in this case and strictly looked for method 
signatures. Either way, I don't know of any tooling.

Wade

 ==================
Wade Chandler
Software Engineer and Developer
NetBeans Dream Team Member and Contributor

http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

Re: API and VM compatibility verification

Posted by Craig L Russell <cr...@oracle.com>.
The JDO project does signature checking using reflection on a jar  
file. The expected values of reflection are stored in a file that  
looks a lot like the signature of the class itself.

Here's a snippet of the signature definition file:

public interface javax.jdo.datastore.JDOConnection {
     public Object getNativeConnection();
     public void close();
}

public interface javax.jdo.datastore.Sequence {
     public String getName();
     public Object next();
     public void allocate(int additional);
     public Object current();
     public long nextValue();
     public long currentValue();
}

The code is pretty simple and can just be taken as is in source.

http://svn.apache.org/viewcvs.cgi/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/SignatureTest.java

The real work is in the file org/apache/jdo/tck/util/signature/ 
SignatureVerifier.java

Craig

On Dec 5, 2010, at 3:24 AM, Sim IJskes - QCG wrote:

> On 05-12-10 02:24, Peter Firmstone wrote:
>> Sim IJskes - QCG wrote:
>>> Is there a tool that we can use to verify API compatibility? So we  
>>> can
>>> make sure we do not call methods that do not exist?
>
>> I've been pondering bytecode analysis.
>
> I think thats the only way to do it. Compile to jars and verify  
> against API specs.
>
>> We have just such a tool, have a look at in  
>> com.sun.jini.tool.classdepend
>> It needs to be extended to include method signatures, currently it  
>> just
>
> One minor detail. It only needs to be extended.
>
> If we don't go for a complete tool, we need to make profiles. The  
> profile should contain class version range (who knows where these  
> are documented? jvms only lists until 1.2) method signatures and  
> access modifiers. Whe can read the signatures from the (runtime)  
> class files, the class version we specify manually.
> To verify we would scan all the bytecode, look for method calls and  
> verify existance and access.
>
> We would basically recreate the bytecode verifier. I haven't  
> reserarched how accessible it is in the tools.jar and how easy it  
> would be to feed it profiles. I also haven't looked at harmony,  
> which also should have a verifier.
>
> I prefer a tool ready build. :-) Don't mind debugging it.
>
> Gr. Sim
>
>
> -- 
> QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
> Quality Consultancy Group b.v., Leiderdorp, Kvk Den Haag: 28088397

Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!


Re: API and VM compatibility verification

Posted by Sim IJskes - QCG <si...@qcg.nl>.
On 05-12-10 02:24, Peter Firmstone wrote:
> Sim IJskes - QCG wrote:
>> Is there a tool that we can use to verify API compatibility? So we can
>> make sure we do not call methods that do not exist?

> I've been pondering bytecode analysis.

I think thats the only way to do it. Compile to jars and verify against 
API specs.

> We have just such a tool, have a look at in com.sun.jini.tool.classdepend
> It needs to be extended to include method signatures, currently it just

One minor detail. It only needs to be extended.

If we don't go for a complete tool, we need to make profiles. The 
profile should contain class version range (who knows where these are 
documented? jvms only lists until 1.2) method signatures and access 
modifiers. Whe can read the signatures from the (runtime) class files, 
the class version we specify manually.
To verify we would scan all the bytecode, look for method calls and 
verify existance and access.

We would basically recreate the bytecode verifier. I haven't reserarched 
how accessible it is in the tools.jar and how easy it would be to feed 
it profiles. I also haven't looked at harmony, which also should have a 
verifier.

I prefer a tool ready build. :-) Don't mind debugging it.

Gr. Sim


-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Den Haag: 28088397

Re: API and VM compatibility verification

Posted by Peter Firmstone <ji...@zeus.net.au>.
Sim IJskes - QCG wrote:
> Hello,
>
> Is there a tool that we can use to verify API compatibility? So we can 
> make sure we do not call methods that do not exist?
>
> Gr. SIm
>
>
>

I've been pondering bytecode analysis.

We have just such a tool, have a look at in com.sun.jini.tool.classdepend

It needs to be extended to include method signatures, currently it just 
finds dependant classes, although it does examine the signatures as part 
of the dependency analysis.

Cheers,

Peter.