avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Praher <praher....@liwest.at>
Subject Re: [RT] Attributes (possibly the ravings of a mad man!)
Date Thu, 19 Sep 2002 14:51:17 GMT
great Idea!
I've been thinking about this for a long time!

some people @ develop.com had (possibly inspired by .NET Attributes) an
idea like that.
-> "Good Book: Component Development for the Java Platform from Stuard

Joshua Bloch - Mr Effective Java - leads the JCP working group on custom
META attributes - JSR 175 - they don't have any specifications right now
but at least it sounds like interesting extensions are to come up with
Java 1.5

Am Don, 2002-09-19 um 16.24 schrieb Berin Loritsch:
> 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.

BCEL and XDoclet would have been the type of combination I would have
choosen too.
But it is also important to provide a tool that, given an external
descriptor "marks the class" with the needed attributes, as declarative
definitions is not always - but in most cases - done by the developer.

> 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
> dependencies).
> As an additional benefit, we can use BCEL to get rid of all the
> NOP entries in the class files. :)
and do a little bit optimization (loop unrolling and so forth) - but
thats probably counterproductive as this is the job of the jit/hotspot.

> So am I a mad man or a genious?  (I tend to think I am tetering
> on the edge between the two)
I would say the latter one.
I look forward to reading your book - hope it arrives soon in the

> -- 
> "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>

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