#21 ✓hold
me (at andresteingress)

cyclic method calls when querying property in class invariant

Reported by me (at andresteingress) | April 12th, 2011 @ 06:43 PM | in 1.2.2

@Invariant({ balance >= 0.0 })
class Account {

   protected double balance   

   def withdraw(BigDecimal amount) {
      balance -= amount
      return amount
   }

   BigDecimal getBalance() {
      return balance
   }
}

Comments and changes to this ticket

  • me (at andresteingress)

    me (at andresteingress) April 14th, 2011 @ 11:10 AM

    • State changed from “new” to “hold”

    the problem is that getBalance() is user-defined. since it is user-defined it gets injected with a class invariant. the call in the class invariant gets compiled to getBalance() >= 0.0, so a cyclic call occurs.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

core module

Shared Ticket Bins

People watching this ticket

Pages