avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject [RT] Attributes (possibly the ravings of a mad man!)
Date Thu, 19 Sep 2002 14:24:34 GMT
As I was going through my pile of papers I printed out to review later
(most of which I already did), I stumbled on the BCEL instructions.
When they described the class file structure, a lightbulb went off in
my head.  At the end of every Class, is space for Class Attributes,
including application specific attributes.  The same thing for the
end of every method for Method Attributes.

Instead of embedding descriptors in XML files, we can combine the
powers of BCEL and XDoclet to place all the relavant attributes
directly in the Class file!  We would first compile the classes the
normal way, then apply the XDoclet/BCEL driven filter to add the
attributes directly into the class file.

The important thing is that we would have to override the
defineClass(String name, byte[] b, int off, int len) method of the
ClassLoader to make it work.  We can offload that into a helper class
like I did for JarScanner so that we get the following info:

interface ClassDescriptor
     boolean isAvalonClass();  // has attributes
     Class getClass();         // return the defined class
     Object getDescriptor();   // will return the Type or Service
                               // descriptor

public final class AvalonClassUtil
     public static ClassDescriptor defineClass( String name,
                                                byte[] b,
                                                int offset,
                                                int length );

Or something like that.

Using BCEL to add and read attributes will make our lives easier,
although it is entirely possible to have something that will
scan the class file without BCEL (to limit the number of runtime

As an additional benefit, we can use BCEL to get rid of all the
NOP entries in the class files. :)

So am I a mad man or a genious?  (I tend to think I am tetering
on the edge between the two)


"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin

To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message