• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

What changed in 1.5 to cause this?

 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is it that in 1.3 and 1.4 final variables that are copied to an inner class are copied after initialization but in 1.5 it suddenly moved to before initialization? This came up as a result of this thread and I'm curious to know if anyone has any ideas. I've found the Sun forums have far more arrogance than they do actual knowledge and most of the intelligent posters are from Javaranch anyway so I'm asking here.

Compiled in 1.4:



Compiled in 1.5:



EDIT: Disabled smilies.
[ December 15, 2005: Message edited by: Ken Blair ]
 
Sheriff
Posts: 26770
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have any actual knowledge about that. I looked at the "what's new in Java 5" documents and couldn't find the word "final". Perhaps it's a bug fix? I couldn't find it in the bug database (my search for "final inner" returned about 10,000 results) but anyway, it certainly sounds like an improvement to me. I remember struggling against that problem back in Java 1.3 days and having to do some horrible workaround (as I classified it then).
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could this have something to do with JSR 133, Fixing the Java Memory Model?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it definitely sounds like a JSR-133 thing. One of the major concerns there was ensuring that there was no way for some threads to observe final fields changing their values, which could occasionally happen in earlier Java versions. This is achieved by making sure those fields are initialized before any reference to the constructed oject is allowed to escape for use or abuse by any threads other than the one performing construction. Bill Pugh's page has a nice JSR-133 FAQ covering this and other issues.
[ December 15, 2005: Message edited by: Jim Yingst ]
 
Maybe he went home and went to bed. And took this tiny ad with him:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic