Archive for the ‘Java’ Category
What is a Java annotation?
October 15, 2012
Leave a comment
Ahhh… always had this question.
Consider the class below:
In this class, @ManagedBean
and @SessionScope
are annotations.
An annotation is nothing but a markup. That’s all….
But aren’t annotations interfaces? That’s what Google says.
So yes they are interfaces… Sun merely picked an interface cause developers at that time were aware of interfaces. Note that some annotations take affect at compile time and some at runtime (dictated by the retention policy of that annotation). So this is what happens when an annotation is encountered….
- An annotation is always processed by the respective container… this container could be a Spring container (if it is a Spring annotation), JSF container (if it is a JSF annotation), Hibernate container (if it is a Hibernate annotation) and so on. And Java itself if it is a Java annotation.
- The container has something called as an annotation processor. This processor scans the code before it runs. So it is the annotation processor does the actions associated with the annotation. The annotation processor has all the intelligence. So if you have two annotations on a class and the annotation processor expects one to be before the other, you will get an error (not sure if it is runtime or compilation time.)
Categories: Java
Java Generics.
March 12, 2012
Leave a comment
Awesome tutorial on Java Generics….
http://thegreyblog.blogspot.com/2011/03/java-generics-tutorial-part-i-basics.html
Categories: Java, Programming
Core Java Understanding.
November 7, 2011
Leave a comment
There are three main things in Java.
- The JVM: This is the Java Virtual Machine. Now the deal is that this is an abstract concept.
- The JRE: This is the actual implementation of the JVM. You thus have a JRE for Windows, Linux, Mac etc.
- The JDK: This is the JRE + other stuff needed to program in Java. For instance, there is the Java Complier, the Debugger, the Profiler etc.
Categories: Java, Programming