Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: JDK 1.4.2 javac compiler bug with final local variables?

Reply
Thread Tools

Re: JDK 1.4.2 javac compiler bug with final local variables?

 
 
Jon Skeet
Guest
Posts: n/a
 
      07-03-2003
xarax <> wrote:
> Anyone notice this problem with the JDK 1.4.2. javac?
>
> I get an error message about the final variable
> may have already been assigned. This compiled
> fine just last week with 1.4.1 javac from Sun.
>
> It happens for some, but not all final local
> variables. The source code has *NOT* changed
> from last week. The only change is the new
> javac compiler for Sun JDK 1.4.2.
>
> The source code is correct. Has this been reported?


Could you give a short but complete example which demonstrates the
problem?

--
Jon Skeet - <>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
 
xarax
Guest
Posts: n/a
 
      07-03-2003
Jon Skeet <> wrote in message news:< >...
> xarax <> wrote:
> > Anyone notice this problem with the JDK 1.4.2. javac?
> >
> > I get an error message about the final variable
> > may have already been assigned. This compiled
> > fine just last week with 1.4.1 javac from Sun.
> >
> > It happens for some, but not all final local
> > variables. The source code has *NOT* changed
> > from last week. The only change is the new
> > javac compiler for Sun JDK 1.4.2.
> >
> > The source code is correct. Has this been reported?

>
> Could you give a short but complete example which demonstrates the
> problem?


===================================
public void fubar()
{
final int xx;
int jj;

jj = 0;
while(0 != jj)
{
final int nn;

nn = jj+1;
}

if(0 < jj)
{
xx = 1;
}
else
{
xx = 2;
}
}
===================================

removing either "final" qualifier circumvents
the problem. the compiler complains about the
assigned to "xx". it appears that the "final"
qualifier within the while() loop is somehow
confusing the compiler.
 
Reply With Quote
 
 
 
 
Jon Skeet
Guest
Posts: n/a
 
      07-03-2003
xarax <> wrote:

<snip>

> removing either "final" qualifier circumvents
> the problem. the compiler complains about the
> assigned to "xx". it appears that the "final"
> qualifier within the while() loop is somehow
> confusing the compiler.


Not on my box - which 1.4.2 are you using? Here's the compete code of
the test program which compiles on my 1.4.2 installation:

public class Test
{
public void fubar()
{
final int xx;
int jj;

jj = 0;
while(0 != jj)
{
final int nn;

nn = jj+1;
}

if(0 < jj)
{
xx = 1;
}
else
{
xx = 2;
}
}
}

--
Jon Skeet - <>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
 
Reply With Quote
 
xarax
Guest
Posts: n/a
 
      07-03-2003
David Zimmerman <> wrote in message news:<>...
> xarax wrote:
> > Jon Skeet <> wrote in message news:< >...
> >
> >>xarax <> wrote:
> >>
> >>>Anyone notice this problem with the JDK 1.4.2. javac?
> >>>
> >>>I get an error message about the final variable
> >>>may have already been assigned. This compiled
> >>>fine just last week with 1.4.1 javac from Sun.
> >>>
> >>
> >>Could you give a short but complete example which demonstrates the
> >>problem?

> >
> >
> > ===================================
> > public void fubar()
> > {
> > final int xx;
> > int jj;
> >
> > jj = 0;
> > while(0 != jj)
> > {
> > final int nn;
> >
> > nn = jj+1;
> > }
> >
> > if(0 < jj)
> > {
> > xx = 1;
> > }
> > else
> > {
> > xx = 2;
> > }
> > }

>
> Perhaps he's complaining about nn gettingassigned more than once. That
> while loop might run more than once.


The message clearly indicates "xx" is the problem. The message
appears for each assignment to "xx". When I remove either "final"
qualifier, it compiles fine.

The "final" within the loop simply means that the variable
can only be assigned once per pass.

This is Sun JDK 1.4.2 installed on WindowsME.
 
Reply With Quote
 
Erwin Molendyk
Guest
Posts: n/a
 
      07-04-2003
"xarax" <> wrote in message
news: om...
> Jon Skeet <> wrote in message

news:< >...
> > Could you give a short but complete example which demonstrates the
> > problem?

>
> ===================================
> public void fubar()

...snip...
> }
> }
> ===================================
>
> removing either "final" qualifier circumvents
> the problem. the compiler complains about the
> assigned to "xx". it appears that the "final"
> qualifier within the while() loop is somehow
> confusing the compiler.


The code compiles fine over here, using Java 1.4.2-b28
Maybe something is wrong with your config, or maybe you are using a beta of
1.4.2?

Cheers,
Erwin


 
Reply With Quote
 
xarax
Guest
Posts: n/a
 
      07-04-2003
Jon Skeet <> wrote in message news:< >...
> xarax <> wrote:
> > This is Sun JDK 1.4.2 installed on WindowsME.

>
> *Which* 1.4.2 though? Final, or a beta?
>
> Has anyone else seen this *not* compile?


The final (pun?) 1.4.2 JDK.

I was using 1.4.1-02 prior to installing 1.4.2, so
maybe the windoze installation screwed up something
(like mixing different levels javac runtime class
libraries?). If it's not something obvious on my end,
then I'll have to wait until someone else can
recreate the bug.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK Miss Michelle. Heigardt Java 8 04-09-2011 07:20 PM
Compiler Bug?? (javac 1.6.0_0-internal) Marc van Dongen Java 12 12-28-2008 09:48 PM
jdk 1.4.2 javac and java.endorsed dirs Frank Fredstone Java 0 06-22-2006 12:54 AM
Are javac -target and -source arguments broken in JDK 1.5 ? Dean Schulze Java 7 02-28-2006 06:28 PM
Sun JDK 1.4.2 javac compiler bug xarax Java 1 07-02-2003 05:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57