apt and visitPackageDeclaration

Hello,

apt is indeed a powerful tool. As long as it's working as expected :P

My problem here is that I wrote a new Visitor that also checks for Package annotations. As you may already know: package annotations have to be used in a file called package-info.java which may look like this:

/**My package.

*/

@xd5.annotations.ManifestInfo(descr="A sample package")

package test1;

Using this simple file however seems to confuse apt totally. Here is all info that I get when running my processors over the package-info files:

apt Round : 1

[apt] filenames: [/home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/net/feed/rss20/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/net/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/net/feed/atom/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/anttasks/gecko/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/classloader/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/tools/jnlp/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/apt/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/classloader/jobs/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/tools/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/tools/mozilla/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/anttasks/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/anttasks/wow/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/tools/shadows/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/net/ftp/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/tools/log/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/enterprise/jsptags/package-info.java, /home/kaeto23/eclipse/Kaeto23Package/src/kaeto23/base/net/js/json/package-info.java]

[apt] options: com.sun.tools.javac.util.Options@15b2043

[apt] Set of annotations found:[xd5.annotations.ManifestInfo]

[apt] Set of Specified Declarations:[]

[apt] Set of Included Declarations: []

[apt] Factory xd5.apt.fac.ManifestInfoPF matches [xd5.annotations.ManifestInfo]

[apt] 09.10.2006 23:03:20 kaeto23.apt.DefaultAnnotationProcessor process

[apt] WARNUNG: No annotations found. So no sense to execute :/

It seems that apt finds the annotation. And also knows that the factory exists. But funnily no annotations are given to the processor.

My question: does anybody have similar experience with apt and package declarations? Class declarations are working like a charm :/

Best regards

Dirk

[2952 byte] By [DirkBWa] at [2007-10-3 6:54:49]
# 1

Answering myself: the problem is that package-info files are considered as non-existing. So they are ignored by default.

However, changing the visitor does the job. You need to have at least one real class file in the package. Changing the visitor to something like:

public void visitClassDeclaration(ClassDeclaration cd){

visitPackageDeclaration(cd.getPackage());

}

is the solution. Of course, you need to check whether the package has already been visited and scanned but this is easy to do.

DirkBWa at 2007-7-15 1:46:26 > top of Java-index,Developer Tools,Java Compiler...