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.

Bug 152562 - Javac require non API classes (annotations) in order to compile dependent module
Summary: Javac require non API classes (annotations) in order to compile dependent module
Alias: None
Product: apisupport
Classification: Unclassified
Component: Harness (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jesse Glick
Depends on:
Reported: 2008-11-06 17:31 UTC by Petr Hejl
Modified: 2011-05-04 15:50 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:

sample project (8.84 KB, application/x-gzip)
2008-11-24 14:43 UTC, Petr Hejl
Test case as suite project (13.36 KB, application/x-compressed)
2008-11-24 17:45 UTC, Jesse Glick

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Hejl 2008-11-06 17:31:09 UTC
As reported in issue 137437 the javac reports that it require non API annotations in order to compile. The module using
API only annotations can't be compiled. The actual use case is mentioned in the issue 137437.

Could this be workarounded on our side/reported to javac?

The message is:
Compiling 19 source files to /home/sickboy/workspace/netbeans-experimental/server/build/classes
warning: Cannot find annotation method 'when()' in type 'javax.annotation.Nonnull': class file for
javax.annotation.Nonnull not found
An exception has occurred in the compiler (1.6.0_10). Please file a bug at the Java Developer Connection
(  after checking the Bug Parade for duplicates. Include your program and the
following diagnostic in your report.  Thank you.$CompletionFailure: class file for javax.annotation.meta.When not found
/home/sickboy/workspace/netbeans-experimental/nbbuild/templates/common.xml:146: Compile failed; see the compiler error
output for details.
BUILD FAILED (total time: 0 seconds)
Comment 1 Jesse Glick 2008-11-19 01:47:57 UTC
Do you know of a simple way to reproduce this? I created three j2seproject's containing (respectively):

package a;
public @interface A {}

package b;
public @interface B {}

package c;
public class C {}

I placed A on the classpath of B, and B (but not A) on the classpath of C. then compiled without complaint (using
JDK 6u10).
Comment 2 Petr Hejl 2008-11-24 14:40:48 UTC
Looks like there is a problem with enum value. Attaching project that fails. When enum is commented out (and thus sample
is reduced to the case you tested) it is compiled without any problem.
Comment 3 Petr Hejl 2008-11-24 14:43:54 UTC
Created attachment 74083 [details]
sample project
Comment 4 Jesse Glick 2008-11-24 16:41:04 UTC
Well your project compiles, but only because it is part of one project. As separate projects, finally I can reproduce:

package a;
public @interface A {
    E e();
    enum E {V1, V2}

package b;
public @interface B {}

package c;
public class C {}
Comment 5 Jesse Glick 2008-11-24 17:25:27 UTC
Added this test case to an existing javac bug report.
Comment 6 Jesse Glick 2008-11-24 17:45:58 UTC
Created attachment 74095 [details]
Test case as suite project
Comment 7 Jesse Glick 2008-11-24 18:05:49 UTC
Working around javac bug in core-main #92fb570474d8.
Comment 8 Quality Engineering 2008-11-25 05:09:52 UTC
Integrated into 'main-golden', will be available in build *200811250201* on (upload may still be in progress)
User: Jesse Glick <>
Log: #152562: workaround for javac bug 6550655.
When an annotation is in a private package, need to at least compile against any enumerations it mentions,
or references to a public class using the annotation will abort the compiler.
Working around compiler bug by always including enumeration classes in public package JARs, even if they are from private packages.
Comment 9 Jesse Glick 2009-01-22 19:23:44 UTC
See related issue #157320 about Javadoc execution.
Comment 10 Jesse Glick 2011-05-04 15:50:54 UTC
You still get e.g.:

Compiling 24 source files to .../
org/netbeans/api/annotations/common/CheckForNull.class(org/netbeans/api/annotations/common:CheckForNull.class): warning: Cannot find annotation method 'when()' in type 'javax.annotation.Nonnull': class file for javax.annotation.Nonnull not found
org/netbeans/api/annotations/common/NonNull.class(org/netbeans/api/annotations/common:NonNull.class): warning: Cannot find annotation method 'when()' in type 'javax.annotation.Nonnull'

This is because there are annotations in the CP which are themselved annotated with meta-annotations not in the CP. Fortunately this only seems to cause a warning, not a compiler crash as with the missing enum classes.

The only workaround in the Ant harness would be to include annotation classes (as well as enums) in the public package JARs, which seems dangerous - e.g. NB code using @javax.annotation.Nonnull directly would incorrectly compile.

Does not affect Maven-based NBM projects, in which compilation uses the original module JARs (ignoring public packages) and the check for invalid impl class dependencies is done separately.