This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 158218 - [67cat] Clean and Build not picking up changes in final static variables
Summary: [67cat] Clean and Build not picking up changes in final static variables
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker with 1 vote (vote)
Assignee: ulfzibis
URL:
Keywords:
: 159114 161171 162310 164987 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-09 18:33 UTC by nino80
Modified: 2009-07-22 16:38 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test case (source code + output + system specs) (1009 bytes, text/plain)
2009-02-09 18:37 UTC, nino80
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nino80 2009-02-09 18:33:30 UTC
1. Create a class with a public static final String
2. Create another class that accesses that variable in the static way (through class name)
3. Compile and run -> both values are same
4. Change the value of the variable
5. Clean project (verify build/ and dist/ are deleted)
6. Build and run ->

Theory: both values are same
Practice: first class picks up the change, the other keeps the old value

This is probably the result of some very low-level JVM caching of final variables, however the curious thing is that 
the .class files in build directory contain different values for the variable, while the generated .jar file in dist 
directory contains same values for the variable.

Test case and system specs are in the attachment.

Googling around also revealed http://www.netbeans.org/servlets/ReadMsg?listName=nbusers&msgNo=79463.
Comment 1 nino80 2009-02-09 18:37:47 UTC
Created attachment 76747 [details]
Test case (source code + output + system specs)
Comment 2 Jan Jancura 2009-02-17 15:35:46 UTC
Thanks for excellent bug report!
Reproducible in trunk and nb6.5.
This is not related to any issue in JDK. Netbeans has separate copy of your classfiles for "Compile on Save".
Switching off "Compile on Save" is simple worarround (Project - properties - Compiling - Compile on Save)
Comment 3 Max Sauer 2009-02-18 12:25:05 UTC
Fixed by http://hg.netbeans.org/jet-main/rev/478c5b86ab89
Comment 4 nino80 2009-02-18 15:00:50 UTC
jjancura, thanks for the workaround, switching off "compile on save" solves the problem.
Comment 5 Quality Engineering 2009-02-22 08:01:16 UTC
Integrated into 'main-golden', will be available in build *200902220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/478c5b86ab89
User: Max Sauer <msauer@netbeans.org>
Log: #158218: Clean and Build not picking up changes in final static variables
Comment 6 Jiri Prox 2009-02-25 09:27:12 UTC
*** Issue 159114 has been marked as a duplicate of this issue. ***
Comment 7 Jiri Prox 2009-03-25 17:30:37 UTC
*** Issue 161171 has been marked as a duplicate of this issue. ***
Comment 8 Jiri Prox 2009-03-31 11:24:20 UTC
*** Issue 161564 has been marked as a duplicate of this issue. ***
Comment 9 Jiri Prox 2009-04-09 14:26:44 UTC
*** Issue 162310 has been marked as a duplicate of this issue. ***
Comment 10 ulfzibis 2009-06-06 11:22:06 UTC
Using NB 6.7 RC1, CoS enabled:

1. Create class A with a public static final String AA = "Revision_1"
2. Create _main()_ class B that prints that variable, accessed in the static way (through static import)
3. Compile and run (should run B.main()) -> prints "Revision_1"
4. Change the value of the variable of class A to "Revision_2"
5. Run Project ->

Theory: prints "Revision_2"
Practice: prints "Revision_1"

6. Click on Editor Tab of class B (set focus to) -> note "scanning Tasks" in status line
7. Run Project ->

OK: prints "Revision_2"

Comment 11 Jan Lahoda 2009-06-07 10:46:30 UTC
I tried to reproduce using the attached steps to reproduce, and using my own project based on the description by
ulfzibis, but I was not able to reproduce the issue. ulfzibis, please provide standalone testcase to reproduce the
issue. Thanks.
Comment 12 Jiri Prox 2009-06-08 10:45:38 UTC
*** Issue 164987 has been marked as a duplicate of this issue. ***
Comment 13 ulfzibis 2009-06-09 15:31:56 UTC
I've tried to make the steps to reproduce simple, and "translated" the steps for reproduce using a string constant demo,
which I never tested, but it seems, that it isn't as simple as described here, so difficult project setup from Issue
161564 should be used actually.
Comment 14 David Strupl 2009-07-20 15:02:49 UTC
Sooo, is this a duplicate of #161564? If yes, let's close it as the duplicate if not: Ulf are you going to work on this
or should I assign it to someone else?
Comment 15 ulfzibis 2009-07-20 16:44:34 UTC
I would say, this is a duplicate of Issue 161564.
I'm not working on this. Assignment was not made be me. Sorry, I'm not familiar, what assignment means in detail.
Comment 16 Dusan Balek 2009-07-22 13:09:17 UTC
The original problem reported is fixed. Since the problem reported by ulfzibis is covered by issue #161564 (BTW -
ulfzibis - why have you opened two issues for the same problem?), I'm closing this one as FIXED.
Comment 17 ulfzibis 2009-07-22 16:38:47 UTC
> BTW - ulfzibis - why have you opened two issues for the same problem?

- My original problem was stated as duplicate of this which was stated as fixed.
- Later I found out, that my original problem was still reproducible, so I added different description (guessed
dependency from focusing editor tabs) to this issue and reopened it.
- jlahoda found out, that my steps were not reproducible
- I reopened my original issue, because IMO it likely was not valid duplicate from this issue, so from this time, we had
2 open issues. (maybe I should have close this issue again at same time, but I not felt authorized to do this)