commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Longman" <glong...@intelligentworks.com>
Subject Re: [Hivemind] [PATCH] ClassFab/MethodFab patch for
Date Fri, 26 Mar 2004 19:15:25 GMT
> One caveat: I don't think removeAbstractClassModifier() is needed. It can
just be assumed (ClassFab
> exists to create concrete classes, not abstract classes), with the logic
rolled into createClass().
>

Sure.  I forgot to add in my last that the patch represents a hackish
solution I made so I could get past the problem.

Geoff
----- Original Message -----
From: "Howard M. Lewis Ship" <hlshiplists@comcast.net>
To: "'Jakarta Commons Developers List'" <commons-dev@jakarta.apache.org>
Sent: Friday, March 26, 2004 1:17 PM
Subject: RE: [Hivemind] [PATCH] ClassFab/MethodFab patch for


> This is cool. I think this is a good change.
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components
> http://howardlewisship.com
>
>
> > -----Original Message-----
> > From: Geoff Longman [mailto:glongman@intelligentworks.com]
> > Sent: Friday, March 26, 2004 11:45 AM
> > To: Jakarta Commons Developers List
> > Subject: [Hivemind] [PATCH] ClassFab/MethodFab patch for
> >
> >
> > Ran into a problem creating an interceptor method that calls another
> > interceptor method that has not been added yet.
> >
> > Javassist's compiler doesn't like that. Fortunately,
> > Javassist  provides a
> > workaround.
> > One needs to add both the methods as abstract, then set the
> > bodies on them.
> > Lastly, because adding an abstract method to a CtClass make the class
> > abstract, one must be able to reset the class modifier to public (non
> > abstract).
> >
> > Attached is are patches for the following classes:
> >
> > ClassFab:
> >
> > adds a method signature removeAbstractClassModifier() for removing an
> > abstract modifier from the class
> >
> > MethodFab:
> >
> > adds a setBody() method, so you can set the method body after
> > creating the
> > method
> >
> > ClassFabImpl:
> >
> > calling addMethod with a null body will still add the method,
> > but with an
> > abstract modifier.
> > has an impementation of removeAbstractClassModifier
> >
> > MethodFabImpl
> >
> > has an implementation of setBody()
> >
> >
> > example:
> >
> > ClassFab classFab = fClassFactory.newClass(... blah .. blah ..);
> >
> > MethodFab method1 = classFab.addMethod(
> >         Modifier.PUBLIC,
> >         "methodA",
> >         Void.TYPE,
> >         new Class[] { },
> >         new Class[] { },
> >         null);
> >
> > MethodFab method2 = classFab.addMethod(
> >         Modifier.PUBLIC,
> >         "methodB",
> >         Void.TYPE,
> >         new Class[] { },
> >         new Class[] { },
> >         null);
> >
> > method1.setBody( .. stuff that calls method2 ..);
> > method2.setBody( .. stuff ..);
> >
> > ClassFab.removeAbstractClassModifier() ;
> >
> > Class resultClass = classFab.createClass();
> >
> >
> >
> > Geoff
> >
> > offrey Longman
> > Intelligent Works Inc.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message