I found the bytecode compiled from ECJ compiler has the annotation information missing.
The source code decompiled from bytecode compiled by javac:
public class HelloWorldApp {
@GetAction("/hello")
public String sayHello() {
return "Hello World!";
}
}
The source code decompiled from bytecode compiled by ECJ:
public class HelloWorldApp {
public String sayHello() {
return "Hello World!";
}
}
So clearly the annotation @GetAction("/hello")
is missing from the bytecode compiled by ECJ (in memory compilation).
Anyone has encountered this issue before and get any clue?
Update with more information
Take a look at the following screenshot:
So it is in the ASTNode.resolveAnnotations()
methods line #797:
A) The state if ((method.tagBits & TagBits.AnnotationResolved) != 0) return annotations;
will return null
as annotations even
B) the source annotation @GetAction("/hello")
is presented because
C) the this.annotations
field is null
and
D) the if condition (method.tagBits & TagBits.AnnotationResolved) != 0
evaluates to true
Updates 2
It looks like I captured the screen too early, so once process finished, I found the annotations information get stored:
However I still can't get the annotation information from the result file. Click here to download the bytecode file generated:
Note I am using ECJ 4.4.1:
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.4.1</version>
</dependency>