<div dir="ltr">Hello Harris,<div><br></div><div style>Thank you for your answer. So it is there a way of annotating variables in Java Code, so I can see them into LLVM bytecode?</div><div style><br></div><div style>Thank you !</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 17, 2013 at 3:54 PM, Harris BAKIRAS <span dir="ltr"><<a href="mailto:h.bakiras@gmail.com" target="_blank">h.bakiras@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div><tt>Hello Alexandru,<br>
<br>
No you did nothing wrong.<br>
<br>
We are using our own data structure to describe annotations in
J3. So it is normal that you can not see your Java annotations
inside the LLVM bytecode produced.<br>
If I remember well, our implementation of annotations do not
rely on LLVM annotations.<br>
<br>
Regards,<br>
</tt>
<pre cols="72">Harris Bakiras
</pre><div><div class="h5">
On 06/17/2013 02:19 PM, Alexandru Ionut Diaconescu wrote:<br>
</div></div></div>
<blockquote type="cite"><div><div class="h5">
<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" target="_blank">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>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Best regards,</font><br style="background-color:rgb(255,255,255);color:rgb(153,153,153)">
<font style="background-color:rgb(255,255,255);color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>
</div>