From owner-freebsd-java Fri Mar 23 11:27: 9 2001 Delivered-To: freebsd-java@freebsd.org Received: from cypherpunks.ai (cypherpunks.ai [209.88.68.47]) by hub.freebsd.org (Postfix) with ESMTP id 17EE137B719 for ; Fri, 23 Mar 2001 11:27:05 -0800 (PST) (envelope-from jeroen@vangelderen.org) Received: from vangelderen.org (grolsch.ai [209.88.68.214]) by cypherpunks.ai (Postfix) with ESMTP id 0B1BABE; Fri, 23 Mar 2001 15:27:02 -0400 (AST) Message-ID: <3ABBA386.EB08F648@vangelderen.org> Date: Fri, 23 Mar 2001 15:27:02 -0400 From: "Jeroen C. van Gelderen" X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: Rob Furphy Cc: freebsd-java@freebsd.org Subject: Re: possible bug in port of javac References: <3ABB57F9.2090101@ox.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Rob Furphy wrote: > > Some documentation may clear up what is supposed to happen. > I started start here: > > http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#35962 > > and found > > http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#10931 > > this even describes what a 'blank final' variable is and > > "It is a compile-time error if a blank final class variable is not > definitely assigned....." > > Some more examples: > > Using Joe Shevland's example class (and Solaris VM (build > Solaris_JDK_1.2.2_05a, native threads, sunwjit) > public class test { > private final int someint; > public test() { someint = 5; } > } > > This compiles without error (I think it should). However, if you make a > change to thispublic class test { > private static final int someint; > public test() { someint = 5; } > } > > this error pops out > "Blank final variable 'someint' may not have been initialized. It must > be assigned a value in an initializer, or in every constructor" That makes sense. someint is a final class variable and hence must can only be assigned with an immediate or from within a static{} block: public class Test { private static final int someInt; static { someInt = 5; } } or public class Test { private static final int someInt = 5; } Cheers, Jeroen -- Jeroen C. van Gelderen - jeroen@vangelderen.org "A government that robs Peter to pay Paul can always depend upon the support of Paul." -- George Bernard Shaw To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message