Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Unable to set a watchpoint on final variable
Unable to set a watchpoint on final variable [message #259036] Wed, 11 March 2009 12:39 Go to next message
Eclipse UserFriend
Originally posted by: m.junk.com

Hi, there is a final variable I'd like to set a watchpoint for. This
variable is an ArrayList. The reference to the ArrayList will never
change, but the contents will. I don't see "Toggle watchpoint" anywhere.
Is it not possible to set a watchpoint on a final variable? Can I request
this feature?
Re: Unable to set a watchpoint on final variable [message #259060 is a reply to message #259036] Fri, 13 March 2009 09:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

On 3/11/2009 12:39 PM, New User wrote:
> Hi, there is a final variable I'd like to set a watchpoint for. This
> variable is an ArrayList. The reference to the ArrayList will never
> change, but the contents will. I don't see "Toggle watchpoint" anywhere.
> Is it not possible to set a watchpoint on a final variable? Can I
> request this feature?
>

I'm not sure it makes sense to have a watchpoint on a final field. A
watchpoint, by definition, is a breakpoint that is triggered by a
particular expression's value changing; but with a final field, once set
its value can't change.
Seems like you really want a breakpoint to monitor changes to the
contents of the ArrayList, which is quite different than watching the
value of the reference to the list (which can never change).

Eric
Re: Unable to set a watchpoint on final variable [message #259064 is a reply to message #259060] Fri, 13 March 2009 11:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

Eric Rizzo ha scritto:
> I'm not sure it makes sense to have a watchpoint on a final field. A
> watchpoint, by definition, is a breakpoint that is triggered by a
> particular expression's value changing; but with a final field, once set
> its value can't change.

A watchpoint might be triggered on field access in addition to field
modification. Maybe this is what is needed by "New User".

Mauro.
Re: Unable to set a watchpoint on final variable [message #259072 is a reply to message #259064] Fri, 13 March 2009 12:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: m.junk.com

Eric, I don't understand what you mean by setting a breakpoint when the
list changes. I would have to find all the places in the code when the
list changes, and that defeats the purpose of a watchpoint.

I realize that setting a watchpoint on a final variable seems
counter-intuitive, but the fact of the matter is, that's how Java works.
Most Java variables are references. When people want to "watch a
variable's changes", sometimes the reference itself changes, but most of
the time the reference stays the same and is merely accessed. Mauro
brings up a good point. If I could set a watchpoint for just when the
variable is accessed, that meet my goal.

I don't know how hard this would be, but my guess is that eclipse has the
logic "If a variable is final, don't allow watchpoints". If we could just
remove that logic, that would be great.

Thanks!
Re: Unable to set a watchpoint on final variable [message #259080 is a reply to message #259072] Fri, 13 March 2009 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mauro.molinari.cardinis.com

New User ha scritto:
> I don't know how hard this would be, but my guess is that eclipse has
> the logic "If a variable is final, don't allow watchpoints". If we
> could just remove that logic, that would be great.

Is the code where you're trying to set the breakpoint on inside a JAR or
is it in your source classpath? In the first case, maybe the JAR is
compiled without enough debug information for the debugger to let you
set a watchpoint on final fields, which AFAIK could be inlined.

This is just a guess.

Mauro.
Re: Unable to set a watchpoint on final variable [message #259089 is a reply to message #259080] Mon, 16 March 2009 06:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.domain.invalid

Mauro Molinari a écrit :
> New User ha scritto:
>> I don't know how hard this would be, but my guess is that eclipse has
>> the logic "If a variable is final, don't allow watchpoints". If we
>> could just remove that logic, that would be great.
>
> Is the code where you're trying to set the breakpoint on inside a JAR or
> is it in your source classpath? In the first case, maybe the JAR is
> compiled without enough debug information for the debugger to let you
> set a watchpoint on final fields, which AFAIK could be inlined.
>
> This is just a guess.

the bug 216098 is talking about final fields, but ask the question for
final variables.
Re: Unable to set a watchpoint on final variable [message #259093 is a reply to message #259089] Mon, 16 March 2009 16:54 Go to previous message
Eclipse UserFriend
Originally posted by: m.junk.com

Name wrote:

> Mauro Molinari a écrit :
>> New User ha scritto:
>>> I don't know how hard this would be, but my guess is that eclipse has
>>> the logic "If a variable is final, don't allow watchpoints". If we
>>> could just remove that logic, that would be great.
>>
>> Is the code where you're trying to set the breakpoint on inside a JAR or
>> is it in your source classpath? In the first case, maybe the JAR is
>> compiled without enough debug information for the debugger to let you
>> set a watchpoint on final fields, which AFAIK could be inlined.
>>
>> This is just a guess.

> the bug 216098 is talking about final fields, but ask the question for
> final variables.


The code is in my source classpath. I'm able to set watchpoints on
variables in the same method that's aren't final.
Previous Topic:Method is ambiguous error
Next Topic:Use non-standard VM as JRE - and then debug
Goto Forum:
  


Current Time: Tue Apr 29 16:53:59 EDT 2025

Powered by FUDForum. Page generated in 0.04607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top