Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2001 15:27:02 -0400
From:      "Jeroen C. van Gelderen" <jeroen@vangelderen.org>
To:        Rob Furphy <rfurphy@ox.com>
Cc:        freebsd-java@freebsd.org
Subject:   Re: possible bug in port of javac
Message-ID:  <3ABBA386.EB08F648@vangelderen.org>
References:  <3ABB57F9.2090101@ox.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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