Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Something weird in JLS (or in JBuilder)

 
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.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is JBuilder giving any more specific error message?
 
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
Boost this thread!