<div dir="ltr"><div><div><div><div><div>Hello everyone,<br><br></div>I am able to work very well with annotations in C/C++, by using __attribute__((annotate("MYANNOTATION"))) static int a; . Inside the LLVM bytecode I have @llvm.global.annotations and @llvm.var.annotation. <br>
<br></div>However, I was trying to test annotations also in Java, with VMKit. These are the commands that I run:<br><br>javac -Xlint -g -O Main.java<br>../Release+Asserts/bin/vmjc Main<br>../Release+Asserts/bin/j3 Main<br>
../../llvm_new/Release+Asserts/bin/llvm-dis < Main.bc > Main_assembly<br><br></div>My small program is :<br><br>import java.lang.annotation.ElementType;<br>import java.lang.annotation.Retention;<br>import java.lang.annotation.RetentionPolicy;<br>
import java.lang.annotation.Target;<br>import java.lang.reflect.Method;<br><br>@Target(ElementType.METHOD)<br>@Retention(RetentionPolicy.RUNTIME)<br>@interface Red {<br> String info() default "";<br>}<br><br>
<br>class Annotated {<br> @Red(info = "AWESOME")<br> public void foo(String myParam) {<br> System.out.println("This is " + myParam);<br> }<br>}<br><br><br>class TestAnnotationParser {<br>
public void parse(Class clazz) throws Exception {<br> Method[] methods = clazz.getMethods();<br><br><br><br> for (Method method : methods) {<br> if (method.isAnnotationPresent(Red.class)) {<br> Red test = method.getAnnotation(Red.class);<br>
String info = <a href="http://test.info">test.info</a>();<br><br> if ("AWESOME".equals(info)) {<br> System.out.println("info is awesome!");<br> // try to invoke the method with param<br>
method.invoke(<br> Annotated.class.newInstance(), <br> info<br> );<br> }<br> }<br> }<br>}<br><br><br>}<br><br><br>public class Main {<br>
public static void main(String[] args) throws Exception {<br> TestAnnotationParser parser = new TestAnnotationParser();<br> parser.parse(Annotated.class);<br> }<br>}<br><br><br></div>However, I cannot find the annotations in the bytecode. It is something that I did wrong?<br>
<br></div>Thank you in advance !<br><div><div><br></div></div></div>