aspose file tools*
The moose likes Beginning Java and the fly likes Something weird in JLS (or in JBuilder) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Something weird in JLS (or in JBuilder)" Watch "Something weird in JLS (or in JBuilder)" New topic
Author

Something weird in JLS (or in JBuilder)

Marcos R Oliveira
Ranch Hand

Joined: Apr 20, 2002
Posts: 51
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.


SCJP 1.4 - SCJP 1.6 - SCWCD in progress
Marcos R Oliveira
Ranch Hand

Joined: Apr 20, 2002
Posts: 51
On more thing:

I am using JBuilder8 with JDK 1.4.1-b21

Thanks,
Marcos.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Why not tell us what Builder said, and how that differed from what you expected?


[Jess in Action][AskingGoodQuestions]
Marcos R Oliveira
Ranch Hand

Joined: Apr 20, 2002
Posts: 51
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

Joined: Apr 20, 2002
Posts: 51
And, above, ok is said by JLS.

Marcos.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Both javac from JDK 1.4.2 and Jikes both agree with the JLS. JBuilder's wrong.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Is JBuilder giving any more specific error message?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.


42
 
 
subject: Something weird in JLS (or in JBuilder)