[LLVMdev] vmkit java annotations

Alexandru Ionut Diaconescu alexandruionutdiaconescu at gmail.com
Mon Jun 17 10:13:12 PDT 2013


Hello,

I am using GNU classpath-0.97.2.


On Mon, Jun 17, 2013 at 7:10 PM, Harris BAKIRAS <h.bakiras at gmail.com> wrote:

>  What classpath implementation are you using ? GNUClasspath or OpenJDK ?
>
> Harris Bakiras
>
> On 06/17/2013 03:57 PM, Alexandru Ionut Diaconescu wrote:
>
> Hello Harris,
>
>  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?
>
>  Thank you !
>
>
> On Mon, Jun 17, 2013 at 3:54 PM, Harris BAKIRAS <h.bakiras at gmail.com>wrote:
>
>>  Hello Alexandru,
>>
>> No you did nothing wrong.
>>
>> 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.
>> If I remember well, our implementation of annotations do not rely on LLVM
>> annotations.
>>
>> Regards,
>>
>> Harris Bakiras
>>
>>  On 06/17/2013 02:19 PM, Alexandru Ionut Diaconescu wrote:
>>
>>     Hello everyone,
>>
>>  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.
>>
>>  However, I was trying to test annotations also in Java, with VMKit.
>> These are the commands that I run:
>>
>> javac -Xlint -g -O Main.java
>> ../Release+Asserts/bin/vmjc Main
>> ../Release+Asserts/bin/j3 Main
>> ../../llvm_new/Release+Asserts/bin/llvm-dis < Main.bc > Main_assembly
>>
>>  My small program is :
>>
>> import java.lang.annotation.ElementType;
>> import java.lang.annotation.Retention;
>> import java.lang.annotation.RetentionPolicy;
>> import java.lang.annotation.Target;
>> import java.lang.reflect.Method;
>>
>> @Target(ElementType.METHOD)
>> @Retention(RetentionPolicy.RUNTIME)
>> @interface Red {
>>     String info() default "";
>> }
>>
>>
>> class Annotated {
>>     @Red(info = "AWESOME")
>>     public void foo(String myParam) {
>>         System.out.println("This is " + myParam);
>>     }
>> }
>>
>>
>> class TestAnnotationParser {
>>     public void parse(Class clazz) throws Exception {
>>         Method[] methods = clazz.getMethods();
>>
>>
>>
>>     for (Method method : methods) {
>>         if (method.isAnnotationPresent(Red.class)) {
>>             Red test = method.getAnnotation(Red.class);
>>             String info = test.info();
>>
>>             if ("AWESOME".equals(info)) {
>>                  System.out.println("info is awesome!");
>>                  // try to invoke the method with param
>>                  method.invoke(
>>                     Annotated.class.newInstance(),
>>                     info
>>                  );
>>             }
>>         }
>>     }
>> }
>>
>>
>> }
>>
>>
>> public class Main {
>>     public static void main(String[] args) throws Exception {
>>         TestAnnotationParser parser = new TestAnnotationParser();
>>         parser.parse(Annotated.class);
>>     }
>> }
>>
>>
>>  However, I cannot find the annotations in the bytecode. It is something
>> that I did wrong?
>>
>>  Thank you in advance !
>>
>>
>>
>>  _______________________________________________
>> LLVM Developers mailing listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>>
>
>
>  --
> Best regards,
> Alexandru Ionut Diaconescu
>
>
>


-- 
Best regards,
Alexandru Ionut Diaconescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130617/5d843142/attachment.html>


More information about the llvm-dev mailing list