• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Darryl A. J. Staflund
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
intermediate level
 
Darryl A. J. Staflund
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll offer a half-hearted congrats, welcome to the 'Have found a bug in the JDK club'
reply
    Bookmark Topic Watch Topic
  • New Topic