Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
import java.lang.annotation.Target;

/**
* Annotation to create refinements for an external library. The annotation receives the path of the
* library e.g. @ExternalRefinementsFor("java.lang.Math")
* Annotation to refine a class or interface of an external library
* e.g. `@ExternalRefinementsFor("java.lang.Math")`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface ExternalRefinementsFor {

/**
* The prefix of the external method
*
* @return
* The fully qualified name of the class or interface for which the refinements are being defined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add some examples! like "java.lang.Math"

*/
public String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
import java.lang.annotation.Target;

/**
* Annotation to create a ghost variable for a class. The annotation receives
* the type and name of
* the ghost within a string e.g. @Ghost("int size")
* Annotation to create a ghost variable for a class or interface
* e.g. `@Ghost("int size")`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Repeatable(GhostMultiple.class)
public @interface Ghost {

/**
* The type and name of the ghost variable
*/
public String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import java.lang.annotation.Target;

/**
* Annotation to allow the creation of multiple @Ghost
* Annotation to allow the creation of multiple `@Ghost` annotations in a class or interface
* e.g. `@GhostMultiple({@Ghost("int size"), @Ghost("boolean isEmpty")})`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong example right? This is just a placeholder to allow @ghost(...) @ghost(...)

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface GhostMultiple {

/**
* The array of `@Ghost` annotations to be created
*/
Ghost[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
import java.lang.annotation.Target;

/**
* Annotation to add a refinement to variables, class fields, method's parameters and method's
* return value e.g. @Refinement("x > 0") int x;
* Annotation to add a refinement to variables, class fields, method's parameters and method's return values
* e.g. `@Refinement("x > 0") int x;`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, ElementType.TYPE})
public @interface Refinement {

/**
* The refinement string
*/
public String value();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say here what are the restrictions - like logical expression, bla bla


/**
* An optional message to be included in the error message when the refinement is violated
*/
public String msg() default "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More concise: Error message when the refinement is violated (optional)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
import java.lang.annotation.Target;

/**
* Annotation to create a ghost variable for a class. The annotation receives the type and name of
* the ghost within a string e.g. @RefinementAlias("Nat(int x) {x > 0}")
* Annotation to create a refinement alias
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say what an alias means

* e.g. `@RefinementAlias("Nat(int x) { x > 0 }")`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Repeatable(RefinementAliasMultiple.class)
public @interface RefinementAlias {

/**
* The refinement alias string, which includes the name of the alias, its parameters and the refinement itself
*/
public String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import java.lang.annotation.Target;

/**
* Annotation to create a multiple Alias in a class
* Annotation to create multiple refinement aliases
* e.g. `@RefinementAliasMultiple({@RefinementAlias("Nat(int x) { x > 0 }"), @RefinementAlias("Pos(int x) { x >= 0 }")})`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again we dont want this right, its by omission

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface RefinementAliasMultiple {

/**
* The array of `@RefinementAlias` annotations to be created
*/
RefinementAlias[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation that allows the creation of ghosts or refinement aliases
* e.g. `@RefinementPredicate("ghost int size")`, `@RefinementPredicate("type Nat(int x) { x > 0 }")`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Repeatable(RefinementPredicateMultiple.class)
public @interface RefinementPredicate {

/**
* The refinement predicate string, which can define a ghost variable or a refinement alias
*/
public String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation to allow the creation of multiple `@RefinementPredicate` annotations
* e.g. `@RefinementPredicateMultiple({`@RefinementPredicate("ghost int size")`, `@RefinementPredicate("type Nat(int x) { x > 0 }")`})`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can just erase these lines

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface RefinementPredicateMultiple {

/**
* The array of `@RefinementPredicate` annotations to be created
*/
RefinementPredicate[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@
import java.lang.annotation.Target;

/**
* Annotation to create state transitions in a method. The annotation has three arguments: from : the
* state in which the object needs to be for the method to be invoked correctly to : the state in
* which the object will be after the execution of the method msg : optional custom error message to display when refinement is violated
* e.g. @StateRefinement(from="open(this)", to="closed(this)")
* Annotation to create state transitions in a method
* e.g. `@StateRefinement(from="open(this)", to="closed(this)", msg="The object needs to be open before closing")`
*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Repeatable(StateRefinementMultiple.class)
public @interface StateRefinement {

/**
* The state in which the object needs to be before calling the method
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say, logical expression, bla bla

public String from() default "";

/**
* The state in which the object will be after calling the method
*/
public String to() default "";

/**
* Optional custom error message to be included in the error message when the `from` is violated
*/
public String msg() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import java.lang.annotation.Target;

/**
* Interface to allow multiple state refinements in a method. A method can have a state refinement
* for each set of different source and destination states
* Annotation to allow the creation of multiple `@StateRefinement` annotations
* e.g. `@StateRefinementMultiple({@StateRefinement(from="open(this)", to="closed(this)"), @StateRefinement(from="closed(this)", to="open(this)")})`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again nop

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface StateRefinementMultiple {

/**
* The array of `@StateRefinement` annotations to be created
*/
StateRefinement[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
import java.lang.annotation.Target;

/**
* Annotation to create the disjoint states in which class objects can be. The annotation receives a
* list of strings representing the names of the states. e.g. @StateSet({"open", "reading",
* "closed"})
* Annotation to create the disjoint states in which class objects can be
* e.g. @StateSet({"open", "reading", "closed"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets say more like, an object will always have to be in one of these states at every point in the program, it cannot be in two multiple states of the same state set (e.g., open and close simultaneously).
To allow an object to be in multiple states at once, they should be from different state sets.

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Repeatable(StateSets.class)
public @interface StateSet {

/**
* The array of states to be created
*/
public String[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import java.lang.annotation.Target;

/**
* Interface to allow multiple StateSets in a class.
* Annotation to allow the creation of multiple `@StateSet` annotations
* e.g. `@StateSets({@StateSet({"open", "reading", "closed"}), @StateSet({"on", "off"})})`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again this is not how we use it

*
* @author catarina gamboa
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface StateSets {

/**
* The array of `@StateSet` annotations to be created
*/
StateSet[] value();
}