You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by Dale E Martin <dm...@cliftonlabs.com> on 2002/03/06 22:05:49 UTC
another question about attributes.
So, having read the spec has cleared up the structure of BCEL attributes
quite a bit - I realize now why my code was bombing although I think there
could probably be a little more error checking at the time of writing so
that it bombs then, and not while reading.
On to the current "problem". What I'm trying to do is create my own type
of attribute, that a JVM I'm working on will understand and utilize. This
attribute will be completely meaningless to any other JVM so I don't want
to add it to BCEL.
Right now, org.apache.bcel.classfile.Attribute has a default access
constructor. This means I can't simply derive from Attribute and put the
newly defined class in my own package. Furthermore, if I did that, I would
need some way of "teaching" BCEL to read it back in. The obvious problem
is that it won't know my tag so it won't know how to construct my
attribute - I'll get an "Unknown" back.
Would the following approach be reasonable:
- Implement an abstract class (or interface) that is an "AttributeFactory".
This class would contain what is currently in Attribute.readAttribute() in
some method.
- Implement a concrete class "StandardAttributeFactory" that can be
instantiated by default, that uses the standard "AttributeFactory" to read
in and construct attributes from a file.
- Put in a hook somewhere so that I can pass in my own implementation of
AttributeFactory - perhaps pass it into the ClassParser somehow. To do
this I guess I'd have to add a parameter to ClassParser, and then also pass
a ClassParser to the repository? Anyways, my AttributeFactory would know
how to read my tags, and it would defer to a default implementation for
standard tags.
This approach could be taken in other areas to allow non-intrusive
extension of other aspects of the language, like the ability to add byte
codes and things like that. It would solve some problems that I face in my
current project. Of course, it would also be a fairly radical change to
BCEL and make it more slightly more complicated for "standard" usage.
Thanks,
Dale
--
Dale E. Martin, Clifton Labs, Inc.
Senior Computer Engineer
dmartin@cliftonlabs.com
http://www.cliftonlabs.com
pgp key available
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: another question about attributes - Doh! - I see part of the answer
Posted by Dale E Martin <dm...@cliftonlabs.com>.
I see there's already "addAttributeReader". But now I'm wondering about
the default access constructor?
Thanks,
Dale
--
Dale E. Martin, Clifton Labs, Inc.
Senior Computer Engineer
dmartin@cliftonlabs.com
http://www.cliftonlabs.com
pgp key available
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>