[jboss-user] [JBoss AOP] - Re: Problem with annotation in test case AnnotatedSecureRunA

rachmatowicz@jboss.com do-not-reply at jboss.com
Thu Mar 27 11:23:22 EDT 2008

Hello Kabir

I spoke with Shelly on the phone, but i'll reply here.

My doclets are aimed at producing analysis reports of test suites based on javadoc processing of new tags (@functionUnderTest, @unitUnderTest, etc.). In the course of producing such reports, the doclet does some processing of annotations embedded in the test cases: for example, looking for @Test which can be used to differentiate test methods from non-test methods. 

When I run the doclet against the AS 4.2.2 testsuite as is, using JDK 5, I get the exception:
  [javadoc] /home/nrla/jboss-4.2.2.GA-src/testsuite/src/main/org/jboss/test/aop/bean/AnnotatedSecureRunAsPOJO.java:52: incompatible types
  [javadoc] found   : org.jboss.aspects.security.Unchecked
  [javadoc] required: java.lang.annotation.Annotation
  [javadoc]    @Unchecked
  [javadoc]     ^
  [javadoc] Adding non-annotated testsuite JBossTestSuite in package org.jboss.test
  [javadoc] javadoc: error - In doclet class org.jboss.testsuitetool.doclets.secrisks.SecurityRisksDoclet,  method start has thrown an exception java.lang.reflect.InvocationTargetException
  [javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl
  [javadoc]     at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46)
  [javadoc]     at org.jboss.testsuitetool.Utilities.isAnnotatedTestSuite(Unknown Source)
  [javadoc]     at org.jboss.testsuitetool.Utilities.constructTestSuiteDocsList(Unknown Source)
  [javadoc]     at org.jboss.testsuitetool.doclets.secrisks.SecurityRisksDoclet.start(SecurityRisksDoclet.java:90)
  [javadoc]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [javadoc]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:585)
  [javadoc]     at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
  [javadoc]     at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
  [javadoc]     at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
  [javadoc]     at com.sun.tools.javadoc.Start.begin(Start.java:128)
  [javadoc]     at com.sun.tools.javadoc.Main.execute(Main.java:41)
  [javadoc]     at com.sun.tools.javadoc.Main.main(Main.java:31)
  [javadoc] 1 error
  [javadoc] 7 warnings

In order to try and find out what was causing this problem, I removed the annotations in the offending test case. Then the doclet did not encounter the exception. I have tested my doclet on annotated test cases I wrote and have never seen this error there.

So, in order to further investigate, I had a look at the annotations which were causing the problem. I noticed that the annotations did not have the familiar @interface keyword, but only interface. So I replaced interface with @interface and tried to recompile. My understanding of annotations is limited, and this may have been the way annotations were defined in earlier releases of JDK. I was just guessing. 

When I tried to recompile my changes using JDK 5, I got the error:
    ==  Executing 'most' in module 'aspects'...
Overriding previous definition of reference to xdoclet.task.classpath
    [mkdir] Created dir: /home/nrla/jboss-4.2.2.GA-src/aspects/output/etc
     [copy] Copying 4 files to /home/nrla/jboss-4.2.2.GA-src/aspects/output/etc
    [mkdir] Created dir: /home/nrla/jboss-4.2.2.GA-src/aspects/output/classes
    [javac] Compiling 193 source files to /home/nrla/jboss-4.2.2.GA-src/aspects/output/classes
/home/nrla/jboss-4.2.2.GA-src/aspects/src/main/org/jboss/aspects/security/RunAs.java:30: annotations are not supported in -source 1.4
(try -source 1.5 to enable annotations)
public @interface RunAs 
1 error
/home/nrla/jboss-4.2.2.GA-src/aspects/build.xml:194: Compile failed; see the compiler error output for details.
Total time: 1 minute 26 seconds
[nrla at crossover1 build]$ java -version
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)

So this is where I am. All I know is that javadoc complains about these annotations, but I don't know (i) if the change from interface to @interface for these annotations is correct, nor (ii) whether tinkering around with the source level restrictions is something I should be  even thinking about. That's why I have asked for advice.

If you need further info, please don't hesitate.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139335#4139335

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139335

More information about the jboss-user mailing list