• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Something weird in JLS (or in JBuilder)

 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone!

I was looking at the Java Language Specification and wanted to test some code in JBuilder. My surprise was that what the JLS said was ok, JBuilder pointed as compile-time error (the code in JLS was an example of what is right an wrong in use of fields during initialization).

Topic in JLS:
8.3.2.3 Restrictions on the use of Fields during Initialization

Here is the code:


Can anyone tell me why JBuilder has a different result compiling the code above?

Thanks for all,
Marcos.
 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On more thing:

I am using JBuilder8 with JDK 1.4.1-b21

Thanks,
Marcos.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not tell us what Builder said, and how that differed from what you expected?
 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, let�s see...

At the point I found the code differed from what JBuilder says I�ll put //not ok for JBuilder, ok?



And what I was expecting is that JBuilder pointed ok and not ok in the same place the JLS did.

I hope this makes things clearer.

Thanks,
Marcos
 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, above, ok is said by JLS.

Marcos.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both javac from JDK 1.4.2 and Jikes both agree with the JLS. JBuilder's wrong.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is JBuilder giving any more specific error message?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Illegal forward reference on int y = x + 1; which seems correct to me as x isn't declared until further down.
Same on the use of j before declaration in
j = j + 1;
int k = j = j + 1;
int h = j++;


This is exactly where javac also barfs, so JBuilder is correct.


P.S. I'm using JB2005 Developer and JDK 1.5.0
P.P.S. Even if it were allowed it'd be extremely dirty code and reason for a serious spanking of the person that produced it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic