Re: Re: Re: Re: getting all the interfaces for a class

Rajaraman Santhanam <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <12bafbbddee.-7554886085605887861.7782786730085820570@zohocorp.com>
True. But my need is getInterfaces on byte array of class C should return A also. Even though if not explicitly but a way to get that..

Right now, getInterfaces on class C will return an empty array where as it is of type interface A. Only way to find whether class C is of type A is by checking whether the super class is of type A.


In plain java terms, I'm looking something similar to instanceof at the byte code level.


regards,
ramanr

---- On Fri, 15 Oct 2010 17:13:38 +0530 luc peuvrier at home &lt;[email protected]&gt; wrote ---- 

 ClassReader has the following methods:
 -getClassName
 -getSuperName
 -getInterfaces
  
  ClassVisitor#visit(int
 version, int access, String name, String signature,String superName, String[] interfaces)
 Also gives these informations
 Regards
Luc

  ----- Original Message ----- 
 From: Rajaraman Santhanam 
 To: [email protected] 
 Sent: Friday, October 15, 2010 1:07 PM
 Subject: [asm] Re: Re: getting all the interfaces for a class
 

No, my need is nothing to do with loaded classes. Sorry I am not clear with my question. 

 Consider the below code implementation in the target java application.
 

   public interface A
 {
 public void a(int i);
 

 public void a1(int j);
 }

   public class B implements A
 {
        public void a(int i)
       {
             System.out.println(i);
       }
 

       public void a1(int j)

       {
             System.out.println(j);
       }
 }

   public class C extends B
 {
        public void a(int i)
       {
             System.out.println(++i);
       }

 

 }
 

 

Lets say, my need is to instrument all the methods of the classes that are of type "A". How would I know in the ClassReader level that class C is of type B &amp; A also?? 

 thanks,
 ramanr
 
---- On Fri, 15 Oct 2010 13:14:34 +0530 Rémi Forax &lt;[email protected]&gt; wrote ---- 

  Le 15/10/2010 09:23, Rajaraman Santhanam a écrit :   I would like to know the best solution to find out all the classes that implement an interface either directly or indirectly (by implementing the super interface of that interface or extending a class that implements that interface).
 

 One way is the ClassFileTransformer implementation should keep track of the interfaces extending that interface and class that implements that interface.  Any easier solution to achieve this?



There is no simple solution.

I suppose you want only loaded classes not all existing classes (whatever it means).
You can also use Instrumentation.getAllLoadedClasses()

   thanks,
 ramanr


Rémi




  
 

-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
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.