AW: Need to commonize classfile and generic packages

<[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <20020622123214.UGBS27460.mailoutvl21@[192.168.139.30]>
Hi,

what keeps you from using the appriate constructor of
ClassGen(JavaClass clazz) which will do everything
automagically.

Cheers
  Markus
> 
> Von: King Dale <[email protected]>
> Datum: 2002/06/20 Do PM 04:54:59 GMT+02:00
> An: "'[email protected]'" <[email protected]>
> Betreff: Need to commonize classfile and generic packages
> 
> While trying to do some simple tasks, I ran into several places where there
> was a lot of problems with the difference between the classfile and generic
> packages. Take the constant pool for example. In my application I was
> parsing one class file and using the information from that to generate
> another one. The one I was constructing was using a ClassGen with a
> ConstantPoolGen. The class I parsed was of course a JavaClass with a
> ConstantPool. When copying fields from the parsed class to the ClassGen I
> needed to copy the Constant object that represented the field's
> ConstantValue. I could certainly get the Constant from the ConstantPool, but
> how do I put it into the ConstantPoolGen. There is this method in
> ConstantPoolGen:
> 
> void addConstant( Constant c, ConstantPoolGen cp )
> 
> That expects a ConstantPoolGen not a ConstantPool. The first line of the
> Method calls getConstantPool so there is no reason for it to be
> ConstantPoolGen.
> 
> My first thought is that it could be split into:
> 
> void addConstant( Constant c, ConstantPool cp )
> {
> 	// Most of the logic
> }
> void addConstant( Constant c, ConstantPoolGen cp )
> {
> 	addConstant( c, cp.getConstantPool );
> }
> 
> But really that is not getting to the real issue. The real issue is that
> these two classes are closely related. They should actually both implement a
> common interface that defines those operations that are common to both. Then
> the addConstant method could simply take an object that implements that
> interface rather than the concrete class. This probably applies to the rest
> of the objects that have this dichotomy.
> 
> -- 
>  Dale King
> 
> PS. I am not subscribed and my employer is blocking www.mail-archive.com so
> if you want me to see a reply you will need to copy me via email.
> 
> 
--
berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse @berlin.de sichern!
http://webmail.berlin.de

++++++++++++++++++++++++++++++++++++++++++++++++
7 CITIES SUMMER AUCTION

Reisen Sie mit uns durch das Land der grenzenlosen Merkwürdigkeiten. Sieben Städte, zwölf Mitbringsel und noch mehr Erlebnisse. Jeden Montag und Donnerstag eine neue Episode und eine neue Auktion: http://www.BerlinOnline.de/auktion

Präsentiert von BerlinOnline und Lucky Strike Originals
++++++++++++++++++++++++++++++++++++++++++++++++
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.