cvs commit: jakarta-bcel/src/java/org/apache/bcel/classfile JavaClass.java

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
mdahm       2002/06/13 06:44:23

  Modified:    src/java/org/apache/bcel/classfile JavaClass.java
  Log:
  getMethod() for reflect.method
  
  Revision  Changes    Path
  1.10      +22 -3     jakarta-bcel/src/java/org/apache/bcel/classfile/JavaClass.java
  
  Index: JavaClass.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/JavaClass.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JavaClass.java	6 Jun 2002 11:35:43 -0000	1.9
  +++ JavaClass.java	13 Jun 2002 13:44:23 -0000	1.10
  @@ -59,6 +59,7 @@
   import  org.apache.bcel.util.SyntheticRepository;
   import  org.apache.bcel.util.ClassVector;
   import  org.apache.bcel.util.ClassQueue;
  +import  org.apache.bcel.generic.Type;
   
   import  java.io.*;
   import  java.util.StringTokenizer;
  @@ -396,7 +397,7 @@
     public int[] getInterfaceIndices()     { return interfaces; }    
   
     /**
  -   * @return Major number of compiler version.
  +   * @return Major number of class file version.
      */
     public int  getMajor()           { return major; }    
   
  @@ -406,7 +407,25 @@
     public Method[] getMethods()       { return methods; }    
   
     /**
  -   * @return Minor number of compiler version.
  +   * @return A org.apache.bcel.classfile.Method corresponding to
  +   * java.lang.reflect.Method if any
  +   */
  +  public Method getMethod(java.lang.reflect.Method m) {
  +    for(int i = 0; i < methods.length; i++) {
  +      Method method = methods[i];
  +
  +      if(m.getName().equals(method.getName()) &&
  +	 (m.getModifiers() == method.getModifiers()) &&
  +	 Type.getSignature(m).equals(method.getSignature())) {
  +	return method;
  +      }
  +    }
  +
  +    return null;
  +  }
  +
  +  /**
  +   * @return Minor number of class file version.
      */
     public int  getMinor()           { return minor; }
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.