Question about Sequence API

21 views
Skip to first unread message

Rachel Tzoref

unread,
Aug 4, 2020, 11:10:21 AM8/4/20
to randoop-d...@googlegroups.com, Saurabh Sinha
Dear Randoop developers,

We're using Randoop API in a project at IBM Research, and have several questions. We'll appreciate your responses.
  • Can Randoop parse Java code into a Sequence object? The Sequence 'parse' method accepts a list of statements in a specific Randoop-defined format, is there a way to read Java code directly?
  • Can you point us to documentation for the Randoop-defined format for various types of statements, if such exists? The manual gives examples only for method and constructor calls.
  • From looking at the Statement parsing code, the format seems to require only actual variables as parameters for method and constructor calls. Is this indeed the case? If so then I assume we will need to transform the input source code by adding auxiliary variables to hold method/constructor calls or other expressions when they are given as parameters to a method/constructor. Is this correct?

Regards,
Rachel Tzoref-Brill, Ph.D.
Software Quality Technologies
IBM Research - Haifa
Tel: 972-4-829-6236    rac...@il.ibm.com

Michael Ernst

unread,
Aug 4, 2020, 11:30:02 AM8/4/20
to randoop-developers, Saurabh Sinha
> Can Randoop parse Java code into a Sequence object? The Sequence 'parse' method accepts a list of statements in a specific Randoop-defined format, is there a way to read Java code directly?

There is not currently a way to do this.  You could likely implement it yourself.
Note that a sequence represents straight-line code (with some other limitations noted below).  If you want to parse arbitrary Java code, you would need to extend Randoop's representation of code.


> Can you point us to documentation for the Randoop-defined format for various types of statements, if such exists? The manual gives examples only for method and constructor calls.

I think you don't mean the Randoop manual, but the Randoop Developer manual, here: https://randoop.github.io/randoop/manual/dev.html#creating_sequence
The Javadoc gives details about the format and more examples:
https://randoop.github.io/randoop/api/randoop/sequence/Sequence.html#parse(java.util.List)
That Javadoc links to other Javadoc, and eventually some of it refers you to code.


> From looking at the Statement parsing code, the format seems to require only actual variables as parameters for method and constructor calls. Is this indeed the case? If so then I assume we will need to transform the input source code by adding auxiliary variables to hold method/constructor calls or other expressions when they are given as parameters to a method/constructor. Is this correct?

Yes.  In a Randoop-generated test, every statement is one of:
 * a call to a void method, or
 * an assignment to a variable.  The right-hand side is a primitive or a single operation on previously-defined variables.

The Sequence data structure is designed to represent this structure.

I hope this helps.  Good luck with using Randoop in your project.  Let us know if you have further questions.

                    -Mike

--
You received this message because you are subscribed to the Google Groups "Randoop Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to randoop-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/randoop-developers/OF80B97B9A.34D7CEC7-ONC22585BA.003F7E13-C22585BA.00434312%40notes.na.collabserv.com.

Rachel Tzoref

unread,
Aug 9, 2020, 6:42:27 AM8/9/20
to Randoop Developers
Thank you for your answers. One more question: from reverse engineering the code, i get that the expected format for field get operation is as follows:

var0 = FieldGet : className.<get>(fieldName) :

However there is no place to provide the identifier that holds the class object. What does Randoop do in case there are several objects of type className created in the sequence? How will it determine from which of them to take the value of fieldName?
To unsubscribe from this group and stop receiving emails from it, send an email to randoop-developers+unsub...@googlegroups.com.

Rachel Tzoref

unread,
Aug 9, 2020, 1:50:21 PM8/9/20
to Randoop Developers
A second question: a statement of type InitializedArrayCreation expects to receive variables for all its cells. Is there a way to parse an array creation that does not perform an explicit initialization, e.g.:

byte[] array = new byte[256];
someMethodCall(array);

Rachel Tzoref

unread,
Aug 10, 2020, 5:46:43 AM8/10/20
to Randoop Developers
Please ignore my question about FieldGet. I realized that while the field was accessed by the object identifier, it was actually a static field, and that's why Randoop didn't accept the identifier as an inVar. Thanks and my apologies.


On Sunday, 9 August 2020 13:42:27 UTC+3, Rachel Tzoref wrote:

Michael Ernst

unread,
Aug 12, 2020, 8:28:05 PM8/12/20
to randoop-developers
Sorry for my delay in responding.

If you have figured out things that ought to be in the documentation, we would gratefully accept a pull request that improves the documentation.

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to randoop-develop...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Randoop Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to randoop-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/randoop-developers/4ffc24d3-7c15-442b-ab87-2cd6fc22d9cfo%40googlegroups.com.

Michael Ernst

unread,
Aug 12, 2020, 8:30:50 PM8/12/20
to randoop-developers
Randoop doesn't currently have a way to create uninitialized arrays.  If your code creates an array and later fills it in, you could create the array with default values:
byte[] array = new byte[] { 0, 0, [253 more zeroes], 0 };

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to randoop-develop...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Randoop Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to randoop-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/randoop-developers/0d860966-c965-48c3-9a36-5a274cb881ebo%40googlegroups.com.

Rachel Tzoref

unread,
Aug 17, 2020, 2:35:48 PM8/17/20
to randoop-d...@googlegroups.com
Thank you! that is indeed what I did.

I have another question: is there a way to parse generic types appearing in code sequences? I have a method that receives a generic collection of type A, and I get from Randoop the following parsing error when parsing its signature: 'Class java.util.Collection<A> is not on classpath while parsing <method signature>'. Class A itself is on the classpath. When I erase the generic type information from the method signature, I get another error that the argument is not assignable from the corresponding variable (a linked list that also doesn't contain the generic type information). I couldn't locate in the code special support for generics.

Reply all
Reply to author
Forward
0 new messages