ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank-Michael Moser <mo...@decodon.com>
Subject Re: ClassFileSet method of loading classes
Date Wed, 18 Dec 2002 13:37:22 GMT
Aaron Kelley wrote:
> So how exactly are dependencies found then?  Are dependencies only found
> when you instantiate something with the keyword "new"?  My code is
> filled with objects that are instantiated from factories or services.
> If I simply return these objects from a service to my base code will my
> base code not see this class as a dependency?  I use these objects all
> throughout the base code, so I would imagine that they would be seen as
> such.

Of course they will be seen as dependencies and found at runtime by the 
virtual machine. But inspecting the bytecode you'll find only strings.

You could try to write your custom dependency collector which would be 
aware of these strings. (I'm not sure but I think I heard about such a 
tool) But keep in mind that this cannot cover all possible cases. In 
fact you can pass any string to a Java program at runtime and try to 
load a corresponding class - a bytecode inspector could never know about 
that.

> -----Original Message-----
> From: Frank-Michael Moser [mailto:moser@decodon.com] 
> Sent: Tuesday, December 17, 2002 11:05 AM
> To: Ant Users List
> Subject: Re: ClassFileSet method of loading classes
> 
> Aaron Kelley wrote:
> 
>> 
>>MyClass myclass = MyFactory.create(MyClass.class);
>> 
>>I would think that MyClass should be seen as a dependency (given that
>>this line exists in my rootfileset).  So am I using it wrong, or is it
>>something else?
> 
> 
> When you examine at the bytecode of your (root-)class you will see that 
> writing
> 
>    MyClass.class
> 
> is totally equivalent to
> 
>    Class.forName("package-of-myclass.MyClass");
> 
> In fact, in bytecode it is coded much more near to the latter form, such
> 
> that looking the bytecode can't result in finding any dependencies to 
> MyClass.
> 
> Some time ago, when I started to use an obfuscator, I ran into this 
> obstacle, too.
> 
> Frank-Michael
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:ant-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


-- 
------------------------------------------------------------
DECODON GmbH                        phone: +49(0)3834 515231
W.-Rathenau-Str. 49a                  fax: +49(0)3834 515239
17489 Greifswald                    email: moser@decodon.com
Germany                               web:   www.decodon.com
------------------------------------------------------------


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


Mime
View raw message