Reflection « Core Library « Java Articles

Home
Java Articles
1.Build Deploy
2.Class
3.Core Library
4.Data Types
5.Database JDBC
6.Design
7.Development
8.File Input Output
9.Graphics Desktop
10.J2EE Enterprise
11.J2ME Wireless
12.JVM
13.Language
14.Library Product
15.Network
16.Security
17.SOA Web Services
18.Test
19.Web Development
20.XML
Java Articles » Core Library » Reflection 

1. Make an EJB from any Java class with Java Reflection    javaworld.com

So for a new EJB, you need three Java classes, each of which must adhere to the EJB specification. For just one new EJB, creating three classes -- all EJB compliant -- might not be so bad. But if you're creating lots of EJBs -- perhaps from functionality you've already coded into existing classes -- a more automated solution would be beneficial.

2. Take an in-depth look at the Java Reflection API    javaworld.com

Anonymous classes Supporting anonymous classes is hard to explain and even harder to design for in a program. The challenge of supporting an anonymous class can be stated like this: "Write a program that, when given a Java object, can incorporate that object into its continuing operation." The general solution is rather difficult, but by constraining the problem, some specialized solutions can be created. There are two examples of specialized solutions to this class of problem in the 1.0 version of Java: Java applets and the command-line version of the Java interpreter.

3. Reflection in Action    today.java.net

Together with listing the contents of an arbitrary class, this article will illustrate how reflection can be used to leverage programming and push it to a higher level of abstraction. We will start from very basic examples and move forth by applying reflection within a simple application.

4. Using Java Reflection    java.sun.com

Reflection is a feature in the Java programming language. It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.

5. Prefer dynamic extension over reflection    artima.com

Performance hit from reflection doesn't matter here because the network latency is much bigger. But I would have gone for an interface or class name that has a method in it that has defined semantics.

6. Build a Reflection-based Interpreter in Java    devx.com

Thanks to the Reflection API, you can. Using the Reflection API, you can run methods dynamically. Java's support of reflection enables you to create an interpreter that executes commands interactively. This article describes a system you can use to build an interpreter into your application. It demonstrates how to build a reflection-based system that allows simple scripting of Java programs without having to install a special-purpose scripting language. It also provides a downloadable sample program. This solution can allow you to create simple control scripts for your Java programs.

7. Reflection: A new way to discover information about Java classes    ibm.com

Java Version 1.1 or later allows a Java program to discover information about the fields, methods, and constructors of loaded classes. Also, a Java program can instantiate a class and operate on the underlying objects, within security restrictions.

8. Java programming dynamics, Part 2: Introducing reflection    ibm.com

In "Java programming dynamics, Part 1," I gave you an introduction to Java programming classes and class loading. That article described some of the extensive information present in the Java binary class format. This month I cover the basics of using the Java Reflection API to access and use some of that same information at run time. To help keep things interesting even for developers who already know the basics of reflection, I'm including a look at how reflection performance compares with direct access.

9. Java programming dynamics, Part 8: Replacing reflection with code generation    ibm.com

Figure 1 shows the results of this timing test when called with loop counts ranging from 2K to 512K (tests run on an Athlon 2200+ XP system running Mandrake Linux 9.1, using Sun's 1.4.2 JVM). Here I've included both the reflection and generated code times for the second property within each test run (so the pair of times when using the Javassist code generation are first, followed by the same pair of times when using the BCEL code generation). The execution times are about the same regardless of whether Javassist or BCEL is used to generate the glue classes, which is what I'd expect to see -- but it's always good to have confirmation!

10. Java programming dynamics, Part 3: Applied reflection    ibm.com

Now that I've covered the basics of Java classes in Part 1, and the principles of the Java Reflection API in Part 2 and Part 3, the rest of this series is going to head off along the less-traveled path of bytecode manipulation. I'll start off easy in Part 4 with a look at the user-friendly Javassist library for working with binary classes. Do you want to try transforming methods, but are reluctant to start programming in bytecode? Javassist may be just the tool to suit your needs. Find out how next month.

11. Java Reflection in Action, Part 2    developer.com

Consider listing 2, which shows a fragment of java.util.Vector. One method has an interface type as a parameter, another an array, and the third a primitive. To program effectively with reflection, you must know how to introspect on classes such as Vector that have methods with such parameters.

12. Java Reflection in Action    developer.com

The getClass method is used to access an object's class at runtime. The getClass method is often used to begin reflective programming because many reflective tasks require objects representing classes. The getClass method is introduced by java.lang.Object, so any object in Java can be queried for its class1.

13. Class of the Month: The Reflection API    developer.com

Java classes are the main building blocks of a Java application. As developers, we write some classes, but we also use classes developed by others. We rely on the API listings and documentation to learn how to use these "third-party" classes effectively. That works well (at least as well as the quality of the documentation!) in development stages. Java also provides a framework for learning about classes during runtime. That framework is called Reflection and is wrapped as the java.lang.reflect package.

14. Make Use of Reflection API to Write Dynamically Pluggable Code    developer.com

The JavaBeans framework makes use of this reflection mechanism to actually plug in a bean to a container of beans or a beanbox.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.