Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

cyclic method calls when querying property in class invariant

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

   protected double balance   

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

   BigDecimal getBalance() {
      return balance
   }
}

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

State: hold
Milestone: 1.2.2

Activity

  1. me (at andresteingress)
    me (at andresteingress)
    • 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.

    April 14th, 2011 @ 11:10 AM

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.