> James CE Johnson wrote:
>> I think I'm trying to reinvent what you did :-) I may be able to use
>> your analyzer directly.
>
> Suppose there was the APL at the beginning of the file...
>
>> What I want to do is start at a particular object in
>> our model tier and find all of the classes that use that. Then all of
>> the classes that use those. And so on and so fort. It should
>> eventually terminate at our view tier. If it doesn't then we've
>> managed to orphan something.
>
> Watch out for the traps. The analyzer doesn't do a real flow
> analysis, therefore you could have orphaned classes without
> really noting it (instances created only by unreachable code).
> Furthermore, object instances may be created through reflection.
> I tried to solve this by adding all subclasses but I already
> found that something goes amiss, perhaps because the optimizer
> inlines stuff or omits no-op code.
Yea, I don't expect to have something that'll perfectly find all orphans.
If it'll just give me a handful of starting points I'll be much further
along than I am.
Using your code I've narrowed this:
Class foo = Synthetic.class;
down to a getstatic opcode.
>From that I've used this code:
ConstantCP ccp =
(ConstantCP) cp.getConstant((hi << 8) + lo);
String className =
cp.constantToString(ccp.getClassIndex(),
Constants.CONSTANT_Class
);
ConstantNameAndType cnt =
(ConstantNameAndType) cp.getConstant(ccp.getNameAndTypeIndex());
System.err.println("+>"+cnt.getName(cp));
System.err.println("+>"+cnt.getSignature(cp));
System.err.println(">>"+Utility.signatureToString(cnt.getSignature(cp))+"<<");
Which tells me:
+>class$org$apache$bcel$classfile$Synthetic
+>Ljava/lang/Class;
>>Class<<
I'm stumpped at converting 'class$org$apache$bcel$classfile$Synthetic' to
an actual class name. I'm sure there's something magic on Utility that
I've just not found yet. (After all, I'd barely heard of bcel before this
morning...)
>
> J.Pietschmann
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]