Reflection Api in java

The Reflection API allows Java code to examine classes and objects at run time. The new reflection classes allow you to call another class’s methods dynamically at run time. With the reflection classes, you can also examine an instance’s fields and change the fields’ contents.
Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language. With that caveat in mind, reflection is a powerful technique and can enable applications to perform operations which would otherwise be impossible.

Uses of Reflection

Extensibility Features
An application may make use of external, user-defined classes by creating instances of extensibility objects using their fully-qualified names.

Class Browsers and Visual Development Environments
A class browser needs to be able to enumerate the members of classes. Visual development environments can benefit from making use of type information available in reflection to aid the developer in writing correct code.

Debuggers and Test Tools
Debuggers need to be able to examine private members on classes. Test harnesses can make use of reflection to systematically call a discoverable set APIs defined on a class, to insure a high level of code coverage in a test suite.

Drawbacks of Reflection
Reflection is powerful, but should not be used indiscriminately. If it is possible to perform an operation without using reflection, then it is preferable to avoid using it. The following concerns should be kept in mind when accessing code via reflection.

Performance Overhead
Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which are called frequently in performance-sensitive applications.

Security Restrictions
Reflection requires a runtime permission which may not be present when running under a security manager. This is in an important consideration for code which has to run in a restricted security context, such as in an Applet.

Exposure of Internals
Since reflection allows code to perform operations that would be illegal in non-reflective code, such as accessing private fields and methods, the use of reflection can result in unexpected side-effects, which may render code dysfunctional and may destroy portability. Reflective code breaks abstractions and therefore may change behavior with upgrades of the platform.

References
http://java.sun.com/docs/books/tutorial/reflect/
http://www.javacommerce.com/displaypage.jsp?name=index.sql&id=18272

pimp it

.NET and J2EE. Status as of now and scope in future.(Updated with important note)

Big question today: What is the scope of .NET and J2EE platforms. Which one is more dominant in industry today?

I want to answer this question in this post with my viewpoint with no intentions of hurting anybody but with a sole intention of increasing the knowledge of J2EE for .NET people and .NET for the J2EE people
and being a developer in Microsoft technologies i agree my opinion may be aligned towards .NET but what i sincerely want is that through this platform i want to know the actual status of the platforms viz a viz features and invite everybody to add to my learning the new things happening in the J2EE world as well.

On Technology Front
I think that with the arrival of Mono, the only disadvantage that .NET had over J2EE platform i.e of platform independence has been resolved up to an extent. But with the introduction of WCF, WPF, Workflow Foundation, LINQ, ASP.NET MVC framework, Silverlight,ASP.NET Ajax and many such other features have only added to the popularity as well as usefulness of .NET both for programmers, designers and enterprises. With .NET 4.0 parallel programming framework, improved WCF and host of improvements along with Visual studio 2010 will be a great advantage for all..NET 4.0 will also be integrating cloud computing platforms. You will agree to the fact that coupling of IIS and SQL Server is superb in terms of performance as compared to any other options.

Today designers and developers can work together on the tool provided by Microsoft and the UI can be deployed to Web,Desktop or Mobile with an assurance of same effects.
I think JAVA have been left far behind on the technology terms as compared to .NET over past few years as I have not come across any such features being introduced in J2EE platform.

What customers want is fast development of the solution at low cost, and if we start of with .NET we can develop the solution at a very fast rate, thanks to the host of tools provided by Microsoft, and then use cloud computing to bring down the IT costs.You get .NET resources fast as well ,thanks to initiatives taken by Microsoft to teach students and the interest they are able to generate within the students community.

I believe that with the launch .NET 3.5 and onwards, there no looking back for .NET platform as it has enabled the developers to provide good quality extensible code at a fast rate to clients taking the full advantage of the latest operating systems plus giving the backward compatibility to most applications previously built on .NET platform. What more can customers ask for?

I also believe that yes J2EE is also here to stay for a long time as it also has got a big customer base but to compete with the .NET platform they need to pick up fast and offer some features which Microsoft has already done with, to at least get back into competition with .NET

Important NOTE:
I am in NO WAY attached to Microsoft except for the fact that i am a .NET developer and get excited with all the new things happening in the technology world and due to my busy schedule i am not able to keep myself updated on Java. So i started off with my little knowledge of the features i have about .NET and invite everybody here to discuss and put forward the corresponding features from J2EE platform. That’s it. It is of minimal importance for me as which of J2EE or .NET is more popular but what matters is i should know tomorrow that if i want to do something how is that possible with the help of two options and which one fits the best in that situation and what other features can we expect from both the fronts in the near future
I would request you not to comment as in way of showing down J2EE or .NET as i will delete those comments.

Constructive Comments are most welcome.

kick it on DotNetKicks.com

Shout it

pimp it

Marker interface in java

Marker interface is a interface which don’t have any mehtod.It is used to tag the implementing class based on their purpose.Marker interface is a Java interface which doesn’t actually define any fields. It is just used to “mark” Java classes which support a certain capability –the class marks itself as implementing the interface. For example, the java.lang.Cloneable interface.
In java language programming, interfaces with no methods are known as marker interfaces or tagged interface.Marker Interfaces are implemented by the classes or their super classes in order to add some functionality.Marker interfaces are understood by the JVM. The JVM takes care of how to deal with a class that implements that marker interface

Why we use marker interface.
The marker interfaces are used to provide certain functionality to classes you code. Take for instance the Cloneable interface. This interface is implemented by the JVM itself and allows copies of objects to be created without the developer having to write code for this purpose. User written marker interfaces can also be used for inheritance purposes.Marker Interfaces are used to mark the capability of a class as implementing a specific interface at run-time.

Example of marker Interface.

java,lang.Cloneable
java,io.Serializable
java.util.EventListener

pimp it