aspose file tools*
The moose likes Java in General and the fly likes Java Compilation Error:  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Compilation Error:  "illegal start of expression:  })"" Watch "Java Compilation Error:  "illegal start of expression:  })"" New topic
Author

Java Compilation Error: "illegal start of expression: })"

Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi all,

My development team is using Hibernate Annotations on our project, and I have run into what seems to be a Windows / Linux compiler compatibility issue. Basically, whenever, we declare an array of annotations with a dangling comma as in the following example:



the class compiles without error using the following JDK:



But when we try to compile it on our integration server running the following JDK:



we get the following error:



This is really pretty annoying, because we only catch the error when we deploy to Cruise, and suffer the humilating shamefacedness that results from a red build :-(

So I have a number of questions:

1. Is this really an error? According to my readings of the JDK spec, dangling commas at the end of arrays are fine. But are they fine at the end of an array of annotations?
2. Is there some way I can either enforce an error being thrown by the Windows compiler, or, prevent an error from being thrown by the Linux compiler?

Thanks,
Darryl Staflund
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Darryl A. J. Staflund wrote:
...

...

...
1. Is this really an error? According to my readings of the JDK spec, dangling commas at the end of arrays are fine. But are they fine at the end of an array of annotations?
2. Is there some way I can either enforce an error being thrown by the Windows compiler, or, prevent an error from being thrown by the Linux compiler?


Your development and deployment versions should match (both runtime and compiler). So you should either upgrade your deployment environment to _11_b03 or downgrade your development version to _07_b06 (it is usually easier to downgrade the development machine to match the deployment machine, but an upgrade is usually a better idea, especially if you are seeing aberrant behavior, if you can convince those in charge to do so).

Only if the versions match can you determine if the difference in behavior is based on Windows vs. Linux if the behavior differences continue.


Steve
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Alas, I don't have the ability to changing JVMs on either the build server or my workstation at work (NB: We're working on a defense contract and our customer - who owns the hardware - is quite particular about these sorts of things.) But I will install 1.6.0_07 on my home workstation to see if it makes a difference. I have to be honest, I don't think it will. I expect the compiler to behave as it does at work because I think the different in compiler behaviour lies not in the particular minor release I am working with, but with the fact we're working with two JVMs designed for two different architectures (one 32-bit, the other 64-bit) and operating systems (Windows and Linux). I'll post my results though for everyone to see.

Thanks for your comment.

Darryl
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
intermediate level


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Well, I downloaded Sun Java JDK 1.6.0_07 for Windows x86 and it compiled without error.

I am pretty sure it is a bug that just hasn't been patched for the JDK release on our build server. Looking at the Java Bug Database, the JDK specification definitely allows dangling commas at the end of an annotation array. And the problem, which was first posted here:

Original Array Annotation Dangling Comma Bug Report

has officially been accepted as a Java Compiler bug here:

Java Bug ID: 6337964 ("Should ignore last comma in annotation array")

So, that's it then. There is nothing I can do since I can't modify our build server. I appreciate the responses.

Darryl Staflund
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I'll offer a half-hearted congrats, welcome to the 'Have found a bug in the JDK club'


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Compilation Error: "illegal start of expression: })"