You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by md...@apache.org on 2002/03/01 11:17:23 UTC

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

mdahm       02/03/01 02:17:23

  Modified:    src/java/org/apache/bcel Repository.java
  Log:
  new lookup method for Class objects
  
  Revision  Changes    Path
  1.2       +30 -1     jakarta-bcel/src/java/org/apache/bcel/Repository.java
  
  Index: Repository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/Repository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Repository.java	29 Oct 2001 19:59:57 -0000	1.1
  +++ Repository.java	1 Mar 2002 10:17:23 -0000	1.2
  @@ -68,7 +68,7 @@
    * the repository or been added with addClass() manually. This is
    * because we have to check for object identity (==).
    *
  - * @version $Id: Repository.java,v 1.1 2001/10/29 19:59:57 jvanzyl Exp $
  + * @version $Id: Repository.java,v 1.2 2002/03/01 10:17:23 mdahm Exp $
    * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A
    */
   public abstract class Repository {
  @@ -99,6 +99,35 @@
       }
   
       return clazz;
  +  }
  +
  +  /**
  +   * Try to find class source via getResourceAsStream()
  +   * @return JavaClass object for given runtime class
  +   */
  +  public static JavaClass lookupClass(Class clazz) {
  +    String class_name = clazz.getName();
  +
  +    JavaClass j_class = (JavaClass)classes.get(class_name);
  +
  +    if(j_class == null) {
  +      String name = class_name;
  +      int    i    = name.lastIndexOf('.');
  +
  +      if(i > 0)
  +	name = name.substring(i + 1);
  +
  +      try {
  +	InputStream is = clazz.getResourceAsStream(name + ".class");
  +	j_class = new ClassParser(is, class_name).parse();
  +      } catch(IOException e) {
  +	throw new RuntimeException(e.getMessage());
  +      }
  +
  +      classes.put(class_name, j_class);
  +    }
  +
  +    return j_class;
     }
   
     /** @return class file object for given Java class.
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Type.VOID is not a valid ParameterDescriptor

Posted by Andreas Schlapbach <sc...@iam.unibe.ch>.
The signature  of 'void a()' is not (V)V, took me 2 days to figure out.

So I'm proposing something like that:

for(int i=0; i<arg_types.length; i++) {
  if (Type.VOID == arg_types[i])
    throw new ClassGenException("`void' is an illegal
		ParameterDescriptor (see VM Spec. p.102)");
}

to add to the MethodGen constructor and InstructionList.createInvoke(..)

Or is this a performance problem?

Andreas

--
I think, so IAM.

Andreas Schlapbach            schlpbch@kde.org
http://www.iam.unibe.ch/~schlpbch


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>