Ira Forman

author
+ Follow
since Jan 25, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ira Forman

Let me follow-up on class-to-class transformations. There are many difference kinds of program transformations (for example, common expression elimination is one). However, I am especially interested in transformations that take a whole class and return a new class that has new property; this is a class-to-class transformation. Achieving class-to-class transformation is the way to modularize the properties that OO programers talk about (for example, persistent, atomic, and so on). This is one of the goals of AOP. This modularization may be achieved in many ways: with a new language (AspectJ), with bytecode manipulation (JBOSS does this), with metaclasses ("Putting Metaclasses to Work"), or through program generation (Chapters 7 and 8 of "Java Reflection in Action").
19 years ago
Hi,

I have casually looked at one book on C#. With that in mind, I don't believe that there are qualitative differences between Java and C# in that reflection in both is basically limited to introspection. However, I believe Java did it better in that it has class objects that are instances of the metaclass, Class. I may be wrong but I don't believe C#'s Type qualifies as a metaclass. This difference prepares Java to be extended with user defined metaclasses.

Now, let me tell why you want to have user defined metaclasses. Someday, when we all have lots of reflective code, we will want to modularize it. The metaclass allows us to modularize aspects of an application along the lines prescribed by AOP. The advantage is that this kind of modularization is achieved inside the programming language rather than with a new one or with bytecode manipulation.

Of course, the reflective API will need to be beefed up to allow one to modify classes by adding members. Appropriate control of such powerful features will be necessary. For example, adding a field to a class object is safe if the the class has neither instances nor subclasses. Adding a field to a class object that has instances is problematic. In Section 6.4 of "Java Reflection in Action", we present an example of how to structure an application so that a class object can be dynamically replaced when it has instances. This requires a combination of a special class loader and dynamic proxies.
19 years ago