This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Seems NetBeans compiler doesn't like it when an annotation is placed before package in package-info.java. This is the error I get: "annotation type not applicable to this kind of declaration" From: @SequenceGenerator(name = "seqId", sequenceName = "SEQ_ID", allocationSize = 1) package com.something.something.everything.nothing.whatever; import javax.persistence.SequenceGenerator;
Sorry, but it appears that the SequenceGenerator has specified "@Target(value={TYPE,METHOD,FIELD})". I.e. it cannot be applied to packages and the error is correct.
Well, let me just say that this was working in NetBeans < 7.0. Also, take a look here: http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/reference/en/html_single/index.html Also, the spec: http://java.sun.com/docs/books/jls/third_edition/html/packages.html Lets be frank, the spec is not crystal clear on this BUT javac compiles fine. The fact that the annotation target is not PACKAGE seems to be irrelevant in the case of package-info.java since it is NOT a standard java class but a synthetic interface. Please don't easily dismiss this.
(In reply to comment #2) > Well, let me just say that this was working in NetBeans < 7.0. Yes, there was a bug in NetBeans < 7.0 and javac before JDK7. The annotations were not properly validated, so some errors were incorrectly missing. > > Also, take a look here: > > http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/reference/en/html_single/index.html I see its marked with "3.1 beta 9". If I take a look at e.g.: http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/ it no longer proposes to put this annotation on packages. > > Also, the spec: > > http://java.sun.com/docs/books/jls/third_edition/html/packages.html > > Lets be frank, the spec is not crystal clear on this BUT javac compiles fine. I think that the javadoc for the java.lang.annotation.Target is quite clear ("If such a meta-annotation is present, the compiler will enforce the specified usage restriction."). This program would be rejected by any recent JDK7 javac, AFAIK. > > The fact that the annotation target is not PACKAGE seems to be irrelevant in > the case of package-info.java since it is NOT a standard java class but a > synthetic interface. Sorry, I do not follow. The annotations in package-info.java clearly apply to whole package, and so should have ElementType.PACKAGE. > > Please don't easily dismiss this. I am sorry, but the error is correct according to the specifications, and so there is basically nothing that could be done on NetBeans level.
Thank you for your explication, good stuff. However, I'd like to point out that the language used in the spec is fuzzy at best. Just look at the wide spread usage of my case... even Hibernate proposed this... 5/5