vmkit java annotations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

vmkit java annotations

Alexandru Ionut Diaconescu
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 list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: vmkit java annotations

Harris BAKIRAS
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 list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: vmkit java annotations

Alexandru Ionut Diaconescu
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 <[hidden email]> 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 list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
Best regards,
Alexandru Ionut Diaconescu

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: vmkit java annotations

Harris BAKIRAS
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 <[hidden email]> 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 list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
Best regards,
Alexandru Ionut Diaconescu


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: vmkit java annotations

Alexandru Ionut Diaconescu
Hello,

I am using GNU classpath-0.97.2.


On Mon, Jun 17, 2013 at 7:10 PM, Harris BAKIRAS <[hidden email]> 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 <[hidden email]> 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 list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
Best regards,
Alexandru Ionut Diaconescu




--
Best regards,
Alexandru Ionut Diaconescu

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev