Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2001 15:15:56 -0500
From:      David Dagon <dagon@cc.gatech.edu>
To:        "Thomas T. Veldhouse" <veldy@veldy.net>
Cc:        Todd Enersen <tee@fireclick.com>, freebsd-java@FreeBSD.ORG
Subject:   Re: possible bug in port of javac
Message-ID:  <20010323151555.B49813@fritz.cc.gt.atl.ga.us>
In-Reply-To: <005d01c0b341$5cedac20$1d750140@cascade>; from veldy@veldy.net on Thu, Mar 22, 2001 at 08:31:27PM -0600
References:  <3ABA5AC3.CA8F09DD@fireclick.com> <005d01c0b341$5cedac20$1d750140@cascade>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 22, 2001 at 08:31:27PM -0600, Thomas T. Veldhouse wrote:

> When you declare something final, aren't you supposed to supply an
> initializer?

Java requires a value at the declaration.  For so-called "blank final"
variables, JLS s. 4.5.4, assignment comes in the instance <init>
call--the constructor.  In the old days, JDK 1.1 had a bug where you
could later change a final value.  (This was fixed for Java2
generation compilers, IIRC, and was probably patched to JDK 1.1
generation compilers as well.)

Since the observed behavior seems to interact with constructors, a
small piece of demonstration code would be useful.

> I believe this is analgous to const int m_maxValuesPerName = 10 in C++.

I think so.  Of course, differences arise when using references and
not primitives.  (Java acts as if every field in a const object
reference were declared 'mutable', while C++ is the opposite, and
requires const object fields to be declared mutable.)

Anyone have a demonstration snippet involving constructor assignment
of a blank final variable?

-- 
David Dagon               /"\                          "When cryptography
dagon@cc.gatech.edu       \ /  ASCII RIBBON CAMPAIGN    is outlawed, bayl
Collage(sic) o' Computing  X     AGAINST HTML MAIL      bhgynjf jvyy unir
Georgia Inst. o' Tech.    / \                           cevinpl."

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010323151555.B49813>