possible bug in port of javac

possible bug in port of javac

Post by Brian J. Slette » Sat, 24 Mar 2001 05:28:00



Quote:> I'm trying to port one of our software packages to the FreeBSD platform. It currently works
> on Win32, Solaris and Linux, and we have customer who'd like to see it run on FreeBSD.

Are you using the same version of the JDK on every platform? I'm using the Linux version of JDK1.3 under FreeBSD and it complains the same way. I'd say it is more likely to do with some versions of Java allowing it and some not, rather than something FreeBSD-specific.

Quote:> > Blank final variable 'm_maxValuesPerName' may not have been initialized. It must  be
> > assigned a value in an initializer, or in every constructor.
> Even though the constructor assigns a value to the final variable.

> I've tried adding a default constructor but that didn't fix the problem.

I assume you mean "I've tried adding a default constructor and assigned the value in it".

I did the same thing and the aforementioned error went away.

Quote:> The only solution so far has been to remove the "final" keyword from the declaration.

I'm assuming that you are trying to assign this value from a property or something. Do you need it as a final instance variable? If the same value is going to be valid for every class, try something like:

public class A {
    private static final int m_maxValuesPerName;

    static {
       m_maxValuesPerName = Integer.getInteger( "foo.maxValuesPerName", 5 ).intValue();
    }

Quote:}

Or even the more succinct:

public class A {
    private static final int m_maxValuesPerName
        = Integer.getInteger( "foo.maxValuesPerName", 5 ).intValue();

Quote:}

--
Where you stand depends on where you sit.  -- Anonymous


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Todd Eners » Sat, 24 Mar 2001 05:07:36


--------------1EED3C64C602FEB08BD11F3B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I'm trying to port one of our software packages to the FreeBSD platform.
It currently works on Win32, Solaris and Linux, and we have customer
who'd like to see it run on FreeBSD.

So, I've downloaded an built a version of the jdk from your installation
instructions. I believe that I have followed the instructions to a "t".
However the java compiler is * on the following code segment

private final int m_maxValuesPerName;

The compiler is complaining about:

Quote:> Blank final variable 'm_maxValuesPerName' may not have been initialized. It must  be assigned a value in an initializer, or in every constructor.

Even though the constructor assigns a value to the final variable.

I've tried adding a default constructor but that didn't fix the problem.

The only solution so far has been to remove the "final" keyword from the
declaration.

Have you heard of this issue?  Is there a solution?

Todd Enersen

--------------1EED3C64C602FEB08BD11F3B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello,
<p>I'm trying to port one of our software packages to the FreeBSD platform.
It currently works on Win32, Solaris and Linux, and we have customer who'd
like to see it run on FreeBSD.
<p>So, I've downloaded an built a version of the jdk from your installation
instructions. I believe that I have followed the instructions to a "t".&nbsp;
However the java compiler is * on the following code segment
<p><b>private final int m_maxValuesPerName;</b>
<p>The compiler is complaining about:
<blockquote TYPE=CITE>
<pre>Blank final variable 'm_maxValuesPerName' may not have been initialized. It must&nbsp; be assigned a value in an initializer, or in every constructor.</pre>
</blockquote>

<p><br>Even though the constructor assigns a value to the final variable.
<p>I've tried adding a default constructor but that didn't fix the problem.
<p>The only solution so far has been to remove the "final" keyword from
the declaration.
<p>Have you heard of this issue?&nbsp; Is there a solution?
<p>Todd Enersen
<br>&nbsp;
<br>&nbsp;</html>

--------------1EED3C64C602FEB08BD11F3B--


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Brian J. Slette » Sat, 24 Mar 2001 05:30:40


I *MEANT*:

I'm assuming that you are trying to assign this value from a property or
something. Do you need it as a final instance variable? If the same value is
going to be valid for every *INSTANCE*, try something like:

public class A {
    private static final int m_maxValuesPerName
        = Integer.getInteger( "foo.maxValuesPerName", 5 ).intValue();

Quote:}

Sorry.

--
I don't want to achieve immortality through my work. I want to achieve it
through not dying. -- Woody Allen


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Nate Willia » Sat, 24 Mar 2001 06:47:41


Quote:> I'm trying to port one of our software packages to the FreeBSD platform.
> It currently works on Win32, Solaris and Linux, and we have customer
> who'd like to see it run on FreeBSD.

Does it compile with the same version of the JDK on Win32, Solaris, and
Linux?

Nate


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Thomas T. Veldhous » Sat, 24 Mar 2001 11:35:34


This is a multi-part message in MIME format.

------=_NextPart_000_005A_01C0B30F.12363E40
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

When you declare something final, aren't you supposed to supply an =
initializer? I believe this is analgous to const int m_maxValuesPerName =
=3D 10 in C++.

private final int m_maxValuesPerName =3D 10;=20

I believe this is analgous to const int m_maxValuesPerName =3D 10; in =
C++.

Tom Veldhouse

  ----- Original Message -----=20
  From: Todd Enersen=20

  Sent: Thursday, March 22, 2001 2:04 PM
  Subject: possible bug in port of javac

  Hello,=20
  I'm trying to port one of our software packages to the FreeBSD =
platform. It currently works on Win32, Solaris and Linux, and we have =
customer who'd like to see it run on FreeBSD.=20

  So, I've downloaded an built a version of the jdk from your =
installation instructions. I believe that I have followed the =
instructions to a "t".  However the java compiler is * on the =
following code segment=20

  private final int m_maxValuesPerName;=20

  The compiler is complaining about:=20

Blank final variable 'm_maxValuesPerName' may not have been initialized. =
It must  be assigned a value in an initializer, or in every constructor.

  Even though the constructor assigns a value to the final variable.=20

  I've tried adding a default constructor but that didn't fix the =
problem.=20

  The only solution so far has been to remove the "final" keyword from =
the declaration.=20

  Have you heard of this issue?  Is there a solution?=20

  Todd Enersen=20
   =20
   =20

------=_NextPart_000_005A_01C0B30F.12363E40
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>When you declare something final, =
aren't you=20
supposed to supply an initializer? I believe this is analgous to const =
int=20
m_maxValuesPerName =3D 10 in C++.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><STRONG>private final int m_maxValuesPerName =3D 10;</STRONG> =
</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I believe this is analgous to =
<STRONG>const int=20
m_maxValuesPerName =3D 10;</STRONG> in C++.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Tom Veldhouse</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><A=20

<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20

Enersen</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =


</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Thursday, March 22, 2001 =
2:04=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> possible bug in port =
of=20
  javac</DIV>
  <DIV><BR></DIV>Hello,=20
  <P>I'm trying to port one of our software packages to the FreeBSD =
platform. It=20
  currently works on Win32, Solaris and Linux, and we have customer =
who'd like=20
  to see it run on FreeBSD.=20
  <P>So, I've downloaded an built a version of the jdk from your =
installation=20
  instructions. I believe that I have followed the instructions to a =
"t".&nbsp;=20
  However the java compiler is * on the following code segment=20
  <P><B>private final int m_maxValuesPerName;</B>=20
  <P>The compiler is complaining about:=20
  <BLOCKQUOTE TYPE=3D"CITE"><PRE>Blank final variable =
'm_maxValuesPerName' may not have been initialized. It must&nbsp; be =
assigned a value in an initializer, or in every =
constructor.</PRE></BLOCKQUOTE>
  <P><BR>Even though the constructor assigns a value to the final =
variable.=20
  <P>I've tried adding a default constructor but that didn't fix the =
problem.=20
  <P>The only solution so far has been to remove the "final" keyword =
from the=20
  declaration.=20
  <P>Have you heard of this issue?&nbsp; Is there a solution?=20
  <P>Todd Enersen <BR>&nbsp; <BR>&nbsp; </P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_005A_01C0B30F.12363E40--


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Joe Shevlan » Sat, 24 Mar 2001 12:59:42


This struck me as odd too, but after reading the postings I compiled a small test on Windows JDK 1.3 that seemed to allow the initialisation to occur in the constructor. Subclasses still won't be able to access/alter the variable by overriding the constructor, but it kind of goes against the meaning of 'final' to me.

I wonder did Todd add the initialisation in _every_ constructor?

e.g.

public class test {
   private final int someint;
   public test() { someint = 5; }

Quote:}

was allowed which surprised me. The FreeBSD JDK 1.1.8 allowed it also.

Regards,
Joe

-----Original Message-----

Sent: Friday, March 23, 2001 1:31 PM
To: Todd Enersen


Subject: Re: possible bug in port of javac

When you declare something final, aren't you supposed to supply an initializer? I believe this is analgous to const int m_maxValuesPerName = 10 in C++.

private final int m_maxValuesPerName = 10;

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

Tom Veldhouse


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Brian J. Slette » Sat, 24 Mar 2001 23:04:03


Quote:> When you declare something final, aren't you supposed to supply an initializer? I believe
> this is analgous to const int m_maxValuesPerName = 10 in C++.

That is how it is usually used, but it needn't be initialized at that point.

You might also initialize it either in a static block (if it is a final static) or in the constructors. The key is that it can only be assigned to once.

--

Self-discovery is useless unless I discover I am somebody else.  -- Dan Goodman


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Rob Furp » Sat, 24 Mar 2001 23:06:19


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.ht...

and found

http://java.sun.com/docs/books/jls/second_edition/html/typesValues.do...

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; }

Quote:}

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; }

Quote:}

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"

Using the latest beta java for linux
java version "1.3.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)

I do not see the error in question but I get "test.java:3: cannot assign
a value to final variable someint"
when someint is static but no error when it is not.

Rob F.


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Jeroen C. van Geldere » Sun, 25 Mar 2001 05:12:08



> 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.ht...

> and found

> http://java.sun.com/docs/books/jls/second_edition/html/typesValues.do...

> 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;
  }

Quote:}

or

public class Test {
  private static final int someInt = 5;

Quote:}

Cheers,
Jeroen
--

"A government that robs Peter to pay Paul can always depend
  upon the support of Paul."  --  George Bernard Shaw


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Jeroen C. van Geldere » Sun, 25 Mar 2001 05:12:56


Hi Todd,


> I'm trying to port one of our software packages to the FreeBSD
> platform. It currently works on Win32, Solaris and Linux, and we have
> customer who'd like to see it run on FreeBSD.

> So, I've downloaded an built a version of the jdk from your
> installation instructions. I believe that I have followed the
> instructions to a "t".  However the java compiler is * on the
> following code segment

> private final int m_maxValuesPerName;

> The compiler is complaining about:

> > Blank final variable 'm_maxValuesPerName' may not have been
> > initialized. It must  be assigned a value in an initializer,
> > or in every constructor.

This can be caused by a number of problems and since you didn't
post the code in question it is hard to say what is at fault.

Try and isolate the fault by compiling with the Jikes compiler
or with the same version of javac on a different platform as
suggested by others in this thread.

If the problem doesn't manifest itself on the alternative compiler
you have probably spotted a compiler bug. You will then have to
produce a small test case demonstrating the problem and submit it
to the compiler maintainers.

It is not unlikely that your problem is caused by a compiler bug.
Most compiler bugs I have seen manifest themselves when you use
inner classes or static{} initilizers but Javasoft doesn't really
have a track record of producing reliable code so I'd expect
anything. (To be fair, Jikes 1.13 has some analysis bugs as well.)

Quote:> Even though the constructor assigns a value to the final variable.

> I've tried adding a default constructor but that didn't fix the
> problem.

That is to be expected.

Quote:> The only solution so far has been to remove the "final" keyword from
> the declaration.

That is rather ugly.

Quote:> Have you heard of this issue?  Is there a solution?

You will have to try and pinpoint the problem or provide source
code for us to analyze. Without more details we can only speculate.

Cheers,
Jeroen
--

"A government that robs Peter to pay Paul can always depend
  upon the support of Paul."  --  George Bernard Shaw


with "unsubscribe freebsd-java" in the body of the message

 
 
 

possible bug in port of javac

Post by Todd Enerse » Sun, 25 Mar 2001 05:48:03


Jeroen (and company):

Thanks for all of your suggestions.

The code segment in question compiles under other Jdk 1.2 plaforms,
including Solaris (jdk 1.2.2_05), Win32, and Linux. It compiles with javac
or jikes under all of these platforms.

When I was porting to the FreeBSD platform, I originally tried using the
jikes (version 1.12 that came as part of my 4.2 distribution).
Unfortunately, it immediately threw up some errors which I later solved. As
it turns out, this version of jikes doesn't like relative pathnames when
given a explicit classpath. Fortunately, after reworking the classpath on
the compiler invocation, our software now compiles with jikes under the
FreeBSD platform.

However the source still fails to compile with the javac that I have built.
I'm working on developing a small test code segment. The ones I have built
so far all compile smoothly, so I know it has to be some set of complex
conditions, or perhaps the size of the class, that is causing the compiler
to fail.  I'll continue to try and get this issue resolved.

There have been many questions as to why we use the private static final
<type> invocation. Infact, we use it over 100 places in our code mainly to
introduce static final class specific constants that may need to change with
different constructors.  For example, in this instance we want to assign an
integer a constant, but have that constant vary on a class instance basis,
based on which constructor was called.

I want to give thanks to all those who have written me back. This level of
support was unexpected and very appreciated.

Regards,

Todd Enersen
Fireclick

-----Original Message-----

Of Jeroen C. van Gelderen
Sent: Friday, March 23, 2001 11:38 AM
To: Todd Enersen

Subject: Re: possible bug in port of javac

Hi Todd,


> I'm trying to port one of our software packages to the FreeBSD
> platform. It currently works on Win32, Solaris and Linux, and we have
> customer who'd like to see it run on FreeBSD.

> So, I've downloaded an built a version of the jdk from your
> installation instructions. I believe that I have followed the
> instructions to a "t".  However the java compiler is * on the
> following code segment

> private final int m_maxValuesPerName;

> The compiler is complaining about:

> > Blank final variable 'm_maxValuesPerName' may not have been
> > initialized. It must  be assigned a value in an initializer,
> > or in every constructor.

This can be caused by a number of problems and since you didn't
post the code in question it is hard to say what is at fault.

Try and isolate the fault by compiling with the Jikes compiler
or with the same version of javac on a different platform as
suggested by others in this thread.

If the problem doesn't manifest itself on the alternative compiler
you have probably spotted a compiler bug. You will then have to
produce a small test case demonstrating the problem and submit it
to the compiler maintainers.

It is not unlikely that your problem is caused by a compiler bug.
Most compiler bugs I have seen manifest themselves when you use
inner classes or static{} initilizers but Javasoft doesn't really
have a track record of producing reliable code so I'd expect
anything. (To be fair, Jikes 1.13 has some analysis bugs as well.)

> Even though the constructor assigns a value to the final variable.

> I've tried adding a default constructor but that didn't fix the
> problem.

That is to be expected.

> The only solution so far has been to remove the "final" keyword from
> the declaration.

That is rather ugly.

> Have you heard of this issue?  Is there a solution?

You will have to try and pinpoint the problem or provide source
code for us to analyze. Without more details we can only speculate.

Cheers,
Jeroen
--

"A government that robs Peter to pay Paul can always depend
  upon the support of Paul."  --  George Bernard Shaw


with "unsubscribe freebsd-java" in the body of the message

 
 
 

1. "Out of memory" in javac on Linux==compiler bug?

Excerpts from netnews.comp.os.linux.development.apps: 27-Jun-96 Re: "Out

on how
on this point:  i have 40 meg of ram and it gets used all up sometimes
by cache and then starts on the swap space.  is there anyway to control
this?  i feel that it is using the memory poorly.  i should be able to
install a small distrib on a ramdisk and still have enough mem to run it
ok!


2. fdisk

3. /dev/port BUG and possible workaround

4. DiLinux setup errors

5. Possible Bug in kernel 2.4.x: PS/2 port not detected on i440BX chipset

6. IP Masquerading with Linux and Windows 2000 Pro?

7. STROBE v1.02 (minor bug fix for sunos, ports for SCO, AIX) tcp port surveyor.

8. News on Linux...

9. Adaptec SCSI problem (possible bug)

10. Possible bug in Solaris 2.5

11. possible bug in solaris dtsession locking

12. Possible awk bug (Solaris 2.1) ?

13. possible tcsh pipe and/or redirection bug