jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject cvs commit: jakarta-bcel/src/java/org/apache/bcel/generic Type.java
Date Wed, 24 Apr 2002 11:01:31 GMT
mdahm       02/04/24 04:01:31

  Modified:    examples patchclass.java
               src/java/org/apache/bcel/classfile Attribute.java
                        ClassParser.java Constant.java ConstantPool.java
                        ConstantValue.java Field.java FieldOrMethod.java
                        Method.java Utility.java
               src/java/org/apache/bcel/generic Type.java
  Added:       src/java/org/apache/bcel/classfile ClassFormatException.java
  Log:
  Don\'t throw anymore Errors but exceptions
  
  Revision  Changes    Path
  1.2       +1 -2      jakarta-bcel/examples/patchclass.java
  
  Index: patchclass.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/examples/patchclass.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- patchclass.java	29 Oct 2001 20:01:10 -0000	1.1
  +++ patchclass.java	24 Apr 2002 11:01:30 -0000	1.2
  @@ -1,6 +1,5 @@
   import java.io.*;
   import org.apache.bcel.classfile.*;
  -import org.apache.bcel.Constants;
   
   /**
    * Patch all Utf8 constants in the given class file <em>file</em>.class
  @@ -8,7 +7,7 @@
    *
    * Usage: patch <oldstring> <newstring> files
    *
  - * @version $Id: patchclass.java,v 1.1 2001/10/29 20:01:10 jvanzyl Exp $
  + * @version $Id: patchclass.java,v 1.2 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
    */
   public class patchclass {
  
  
  
  1.7       +4 -5      jakarta-bcel/src/java/org/apache/bcel/classfile/Attribute.java
  
  Index: Attribute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/Attribute.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Attribute.java	11 Mar 2002 16:16:35 -0000	1.6
  +++ Attribute.java	24 Apr 2002 11:01:30 -0000	1.7
  @@ -66,7 +66,7 @@
    * <em>Synthetic</em> attributes are supported. The
    * <em>Unknown</em> attribute stands for non-standard-attributes.
    *
  - * @version $Id: Attribute.java,v 1.6 2002/03/11 16:16:35 mdahm Exp $
  + * @version $Id: Attribute.java,v 1.7 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    * @see     ConstantValue
    * @see     SourceFile
  @@ -146,12 +146,11 @@
      * @param  constant_pool Array of constants
      * @return Attribute
      * @throws  IOException
  -   * @throws  ClassFormatError
  -   * @throws InternalError
  +   * @throws  ClassFormatException
      */
     public static final Attribute readAttribute(DataInputStream file,
   						 ConstantPool constant_pool)
  -    throws IOException, ClassFormatError, InternalError
  +    throws IOException, ClassFormatException
     {
       ConstantUtf8 c;
       String       name;
  @@ -223,7 +222,7 @@
         return new StackMap(name_index, length, file, constant_pool);
   
       default: // Never reached
  -      throw new InternalError("Ooops! default case reached.");
  +      throw new IllegalStateException("Ooops! default case reached.");
       }
     }    
   
  
  
  
  1.3       +22 -22    jakarta-bcel/src/java/org/apache/bcel/classfile/ClassParser.java
  
  Index: ClassParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/ClassParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassParser.java	11 Mar 2002 16:16:35 -0000	1.2
  +++ ClassParser.java	24 Apr 2002 11:01:30 -0000	1.3
  @@ -71,7 +71,7 @@
    * JVM specification 1.0</a>. See this paper for
    * further details about the structure of a bytecode file.
    *
  - * @version $Id: ClassParser.java,v 1.2 2002/03/11 16:16:35 mdahm Exp $
  + * @version $Id: ClassParser.java,v 1.3 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public final class ClassParser {
  @@ -141,15 +141,15 @@
     /**
      * Parse the given Java class file and return an object that represents
      * the contained data, i.e., constants, methods, fields and commands.
  -   * A <em>ClassFormatError</em> is raised, if the file is not a valid
  +   * A <em>ClassFormatException</em> is raised, if the file is not a valid
      * .class file. (This does not include verification of the byte code as it
      * is performed by the java interpreter).
      *
      * @return Class object representing the parsed class file
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */  
  -  public JavaClass parse() throws IOException, ClassFormatError
  +  public JavaClass parse() throws IOException, ClassFormatException
     {
       /****************** Read headers ********************************/
       // Check magic tag of class file
  @@ -210,9 +210,9 @@
     /**
      * Read information about the attributes of the attributes of the class.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readAttributes() throws IOException, ClassFormatError
  +  private final void readAttributes() throws IOException, ClassFormatException
     {
       int attributes_count;
   
  @@ -226,9 +226,9 @@
     /**
      * Read information about the class and its super class.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readClassInfo() throws IOException, ClassFormatError
  +  private final void readClassInfo() throws IOException, ClassFormatException
     {
       access_flags = file.readUnsignedShort();
   
  @@ -240,7 +240,7 @@
   
       if(((access_flags & Constants.ACC_ABSTRACT) != 0) && 
          ((access_flags & Constants.ACC_FINAL)    != 0 ))
  -      throw new ClassFormatError("Class can't be both final and abstract");
  +      throw new ClassFormatException("Class can't be both final and abstract");
   
       class_name_index      = file.readUnsignedShort();
       superclass_name_index = file.readUnsignedShort();
  @@ -248,9 +248,9 @@
     /**
      * Read constant pool entries.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readConstantPool() throws IOException, ClassFormatError
  +  private final void readConstantPool() throws IOException, ClassFormatException
     {
       constant_pool = new ConstantPool(file);
     }    
  @@ -258,9 +258,9 @@
     /**
      * Read information about the fields of the class, i.e., its variables.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readFields() throws IOException, ClassFormatError
  +  private final void readFields() throws IOException, ClassFormatException
     {
       int fields_count;
   
  @@ -277,21 +277,21 @@
      * Check whether the header of the file is ok.
      * Of course, this has to be the first action on successive file reads.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readID() throws IOException, ClassFormatError
  +  private final void readID() throws IOException, ClassFormatException
     {
       int magic = 0xCAFEBABE;
   
       if(file.readInt() != magic)
  -      throw new ClassFormatError(file_name + " is not a Java .class file");
  +      throw new ClassFormatException(file_name + " is not a Java .class file");
     }    
     /**
      * Read information about the interfaces implemented by this class.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readInterfaces() throws IOException, ClassFormatError
  +  private final void readInterfaces() throws IOException, ClassFormatException
     {
       int interfaces_count;
   
  @@ -304,9 +304,9 @@
     /**
      * Read information about the methods of the class.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readMethods() throws IOException, ClassFormatError
  +  private final void readMethods() throws IOException, ClassFormatException
     {
       int methods_count;
   
  @@ -319,9 +319,9 @@
     /**
      * Read major and minor version of compiler which created the file.
      * @throws  IOException
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
  -  private final void readVersion() throws IOException, ClassFormatError
  +  private final void readVersion() throws IOException, ClassFormatException
     {
       minor = file.readUnsignedShort();
       major = file.readUnsignedShort();
  
  
  
  1.2       +3 -3      jakarta-bcel/src/java/org/apache/bcel/classfile/Constant.java
  
  Index: Constant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/Constant.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Constant.java	29 Oct 2001 19:59:58 -0000	1.1
  +++ Constant.java	24 Apr 2002 11:01:30 -0000	1.2
  @@ -62,7 +62,7 @@
    * in the constant pool of a class file. The classes keep closely to
    * the JVM specification.
    *
  - * @version $Id: Constant.java,v 1.1 2001/10/29 19:59:58 jvanzyl Exp $
  + * @version $Id: Constant.java,v 1.2 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public abstract class Constant implements Cloneable, Node {
  @@ -124,7 +124,7 @@
      * @return Constant object
      */
     static final Constant readConstant(DataInputStream file)
  -    throws IOException, ClassFormatError
  +    throws IOException, ClassFormatException
     {
       byte b = file.readByte(); // Read tag byte
   
  @@ -142,7 +142,7 @@
       case Constants.CONSTANT_NameAndType:        return new ConstantNameAndType(file);
       case Constants.CONSTANT_Utf8:               return new ConstantUtf8(file);
       default:                          
  -      throw new ClassFormatError("Invalid byte tag in constant pool: " + b);
  +      throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
       }
     }    
   }
  
  
  
  1.4       +12 -12    jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantPool.java
  
  Index: ConstantPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantPool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConstantPool.java	11 Mar 2002 16:16:35 -0000	1.3
  +++ ConstantPool.java	24 Apr 2002 11:01:30 -0000	1.4
  @@ -66,7 +66,7 @@
    * programatically should see <a href="../generic/ConstantPoolGen.html">
    * ConstantPoolGen</a>.
   
  - * @version $Id: ConstantPool.java,v 1.3 2002/03/11 16:16:35 mdahm Exp $
  + * @version $Id: ConstantPool.java,v 1.4 2002/04/24 11:01:30 mdahm Exp $
    * @see     Constant
    * @see     org.apache.bcel.generic.ConstantPoolGen
    * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  @@ -88,9 +88,9 @@
      *
      * @param file Input stream
      * @throws IOException
  -   * @throws ClassFormatError
  +   * @throws ClassFormatException
      */
  -  ConstantPool(DataInputStream file) throws IOException, ClassFormatError
  +  ConstantPool(DataInputStream file) throws IOException, ClassFormatException
     {
       byte tag;
   
  @@ -134,7 +134,7 @@
      * @return String representation
      */
     public String constantToString(Constant c)
  -       throws ClassFormatError  
  +       throws ClassFormatException  
     {
       String   str;
       int      i;
  @@ -210,7 +210,7 @@
      * @return String representation
      */
     public String constantToString(int index, byte tag) 
  -       throws ClassFormatError
  +       throws ClassFormatException
     {
       Constant c = getConstant(index, tag);
       return constantToString(c);
  @@ -240,7 +240,7 @@
      */
     public Constant getConstant(int index) {
       if (index >= constant_pool.length || index < 0)
  -      throw new ClassFormatError("Invalid constant pool reference: " +
  +      throw new ClassFormatException("Invalid constant pool reference: " +
   				 index + ". Constant pool size is: " +
   				 constant_pool.length);
       return constant_pool[index];
  @@ -254,22 +254,22 @@
      * @param  tag Tag of expected constant, i.e., its type
      * @return Constant value
      * @see    Constant
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
     public Constant getConstant(int index, byte tag)
  -       throws ClassFormatError
  +       throws ClassFormatException
     {
       Constant c;
   
       c = getConstant(index);
   
       if(c == null)
  -      throw new ClassFormatError("Constant pool at index " + index + " is null.");
  +      throw new ClassFormatException("Constant pool at index " + index + " is null.");
   
       if(c.getTag() == tag)
         return c;
       else
  -      throw new ClassFormatError("Expected class `" + Constants.CONSTANT_NAMES[tag] + 
  +      throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag]
+ 
   				 "' at index " + index + " and got " + c);
     }
   
  @@ -289,10 +289,10 @@
      * @return Contents of string reference
      * @see    ConstantClass
      * @see    ConstantString
  -   * @throws  ClassFormatError
  +   * @throws  ClassFormatException
      */
     public String getConstantString(int index, byte tag) 
  -       throws ClassFormatError
  +       throws ClassFormatException
     {
       Constant c;
       int    i;
  
  
  
  1.4       +5 -4      jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantValue.java
  
  Index: ConstantValue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantValue.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConstantValue.java	11 Mar 2002 17:19:49 -0000	1.3
  +++ ConstantValue.java	24 Apr 2002 11:01:30 -0000	1.4
  @@ -62,7 +62,7 @@
    * value, i.e., a default value for initializing a class field.
    * This class is instantiated by the <em>Attribute.readAttribute()</em> method.
    *
  - * @version $Id: ConstantValue.java,v 1.3 2002/03/11 17:19:49 mdahm Exp $
  + * @version $Id: ConstantValue.java,v 1.4 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    * @see     Attribute
    */
  @@ -142,8 +142,7 @@
     /**
      * @return String representation of constant value.
      */ 
  -  public final String toString() throws InternalError
  -  {
  +  public final String toString() {
       Constant c = constant_pool.getConstant(constantvalue_index);
   	
       String   buf;
  @@ -160,7 +159,9 @@
         c   = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
         buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\"";
         break;
  -    default: throw new InternalError("Type of ConstValue invalid: " + c);
  +
  +    default:
  +      throw new IllegalStateException("Type of ConstValue invalid: " + c);
       }
   
       return buf;
  
  
  
  1.2       +2 -2      jakarta-bcel/src/java/org/apache/bcel/classfile/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/Field.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Field.java	29 Oct 2001 20:00:01 -0000	1.1
  +++ Field.java	24 Apr 2002 11:01:30 -0000	1.2
  @@ -60,7 +60,7 @@
    * This class represents the field info structure, i.e., the representation 
    * for a variable in the class. See JVM specification for details.
    *
  - * @version $Id: Field.java,v 1.1 2001/10/29 20:00:01 jvanzyl Exp $
  + * @version $Id: Field.java,v 1.2 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public final class Field extends FieldOrMethod {
  @@ -77,7 +77,7 @@
      * @param file Input stream
      */
     Field(DataInputStream file, ConstantPool constant_pool)
  -       throws IOException, ClassFormatError
  +       throws IOException, ClassFormatException
     {
       super(file, constant_pool);
     }
  
  
  
  1.3       +3 -3      jakarta-bcel/src/java/org/apache/bcel/classfile/FieldOrMethod.java
  
  Index: FieldOrMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/FieldOrMethod.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FieldOrMethod.java	11 Mar 2002 16:16:35 -0000	1.2
  +++ FieldOrMethod.java	24 Apr 2002 11:01:30 -0000	1.3
  @@ -59,7 +59,7 @@
   /** 
    * Abstract super class for fields and methods.
    *
  - * @version $Id: FieldOrMethod.java,v 1.2 2002/03/11 16:16:35 mdahm Exp $
  + * @version $Id: FieldOrMethod.java,v 1.3 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node {
  @@ -84,10 +84,10 @@
      * Construct object from file stream.
      * @param file Input stream
      * @throws IOException
  -   * @throws ClassFormatError
  +   * @throws ClassFormatException
      */
     protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool)
  -    throws IOException, ClassFormatError
  +    throws IOException, ClassFormatException
     {
       this(file.readUnsignedShort(), file.readUnsignedShort(),
   	 file.readUnsignedShort(), null, constant_pool);
  
  
  
  1.3       +3 -3      jakarta-bcel/src/java/org/apache/bcel/classfile/Method.java
  
  Index: Method.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/Method.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Method.java	11 Mar 2002 16:16:35 -0000	1.2
  +++ Method.java	24 Apr 2002 11:01:30 -0000	1.3
  @@ -61,7 +61,7 @@
    * for a method in the class. See JVM specification for details.
    * A method has access flags, a name, a signature and a number of attributes.
    *
  - * @version $Id: Method.java,v 1.2 2002/03/11 16:16:35 mdahm Exp $
  + * @version $Id: Method.java,v 1.3 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public final class Method extends FieldOrMethod {
  @@ -83,10 +83,10 @@
      * Construct object from file stream.
      * @param file Input stream
      * @throws IOException
  -   * @throws ClassFormatError
  +   * @throws ClassFormatException
      */
     Method(DataInputStream file, ConstantPool constant_pool)
  -       throws IOException, ClassFormatError
  +       throws IOException, ClassFormatException
     {
       super(file, constant_pool);
     }
  
  
  
  1.5       +31 -31    jakarta-bcel/src/java/org/apache/bcel/classfile/Utility.java
  
  Index: Utility.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/Utility.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Utility.java	5 Apr 2002 08:59:39 -0000	1.4
  +++ Utility.java	24 Apr 2002 11:01:30 -0000	1.5
  @@ -63,7 +63,7 @@
   /**
    * Utility functions that do not really belong to any class in particular.
    *
  - * @version $Id: Utility.java,v 1.4 2002/04/05 08:59:39 mdahm Exp $
  + * @version $Id: Utility.java,v 1.5 2002/04/24 11:01:30 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public abstract class Utility {
  @@ -169,7 +169,7 @@
       } catch(IOException e) {
         System.out.println(buf.toString());
         e.printStackTrace();
  -      throw new ClassFormatError("Byte code error: " + e);
  +      throw new ClassFormatException("Byte code error: " + e);
       }
   
       return buf.toString();
  @@ -536,7 +536,7 @@
      * @return Byte code representation of method signature
      */
     public final static String methodTypeToSignature(String ret, String[] argv)
  -    throws ClassFormatError
  +    throws ClassFormatException
     {
       StringBuffer buf = new StringBuffer("(");
       String       str;
  @@ -546,7 +546,7 @@
   	str = getSignature(argv[i]);
   
   	if(str.endsWith("V")) // void can't be a method argument
  -	  throw new ClassFormatError("Invalid type: " + argv[i]);
  +	  throw new ClassFormatException("Invalid type: " + argv[i]);
   
   	buf.append(str);
         }
  @@ -561,10 +561,10 @@
     /**
      * @param  signature    Method signature
      * @return Array of argument types
  -   * @throws  ClassFormatError  
  +   * @throws  ClassFormatException  
      */
     public static final String[] methodSignatureArgumentTypes(String signature)
  -    throws ClassFormatError 
  +    throws ClassFormatException 
     {
       return methodSignatureArgumentTypes(signature, true);
     }    
  @@ -573,11 +573,11 @@
      * @param  signature    Method signature
      * @param chopit Shorten class names ?
      * @return Array of argument types
  -   * @throws  ClassFormatError  
  +   * @throws  ClassFormatException  
      */
     public static final String[] methodSignatureArgumentTypes(String signature,
   							    boolean chopit)
  -    throws ClassFormatError
  +    throws ClassFormatException
     {
       ArrayList vec = new ArrayList();
       int       index;
  @@ -585,7 +585,7 @@
   
       try { // Read all declarations between for `(' and `)'
         if(signature.charAt(0) != '(')
  -	throw new ClassFormatError("Invalid method signature: " + signature);
  +	throw new ClassFormatException("Invalid method signature: " + signature);
   
         index = 1; // current string position
   
  @@ -594,7 +594,7 @@
   	index += consumed_chars; // update position
         }
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
   	
       types = new String[vec.size()];
  @@ -604,10 +604,10 @@
     /**
      * @param  signature    Method signature
      * @return return type of method
  -   * @throws  ClassFormatError  
  +   * @throws  ClassFormatException  
      */
     public static final String methodSignatureReturnType(String signature)
  -       throws ClassFormatError 
  +       throws ClassFormatException 
     {
       return methodSignatureReturnType(signature, true);
     }    
  @@ -615,11 +615,11 @@
      * @param  signature    Method signature
      * @param chopit Shorten class names ?
      * @return return type of method
  -   * @throws  ClassFormatError  
  +   * @throws  ClassFormatException  
      */
     public static final String methodSignatureReturnType(String signature,
   						       boolean chopit)
  -       throws ClassFormatError
  +       throws ClassFormatException
     {
       int    index;
       String type;
  @@ -629,7 +629,7 @@
         index = signature.lastIndexOf(')') + 1; 
         type = signatureToString(signature.substring(index), chopit);
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
   
       return type;
  @@ -674,21 +674,21 @@
      * <arguments_signature>::= <argument_signature>*
      *
      * This method converts such a string into a Java type declaration like
  -   * `void main(String[])' and throws a `ClassFormatError' when the parsed 
  +   * `void main(String[])' and throws a `ClassFormatException' when the parsed 
      * type is invalid.
      *
      * @param  signature    Method signature
      * @param  name         Method name
      * @param  access       Method access rights
      * @return Java type declaration
  -   * @throws  ClassFormatError  
  +   * @throws  ClassFormatException  
      */
     public static final String methodSignatureToString(String signature,
   						     String name,
   						     String access,
   						     boolean chopit,
   						     LocalVariableTable vars)
  -    throws ClassFormatError
  +    throws ClassFormatException
     {
       StringBuffer buf = new StringBuffer("(");
       String       type;
  @@ -697,7 +697,7 @@
   
       try { // Read all declarations between for `(' and `)'
         if(signature.charAt(0) != '(')
  -	throw new ClassFormatError("Invalid method signature: " + signature);
  +	throw new ClassFormatException("Invalid method signature: " + signature);
   
         index = 1; // current string position
   
  @@ -728,7 +728,7 @@
         type = signatureToString(signature.substring(index), chopit);
   
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
   
       if(buf.length() > 1) // Tack off the extra ", "
  @@ -815,13 +815,13 @@
      * </PRE>
      *
      * This method converts this string into a Java type declaration such as
  -   * `String[]' and throws a `ClassFormatError' when the parsed type is 
  +   * `String[]' and throws a `ClassFormatException' when the parsed type is 
      * invalid.
      *
      * @param  signature  Class signature
      * @param chopit Flag that determines whether chopping is executed or not
      * @return Java type declaration
  -   * @throws ClassFormatError
  +   * @throws ClassFormatException
      */
     public static final String signatureToString(String signature,
   					       boolean chopit)
  @@ -841,7 +841,7 @@
   	int    index = signature.indexOf(';'); // Look for closing `;'
   
   	if(index < 0)
  -	  throw new ClassFormatError("Invalid signature: " + signature);
  +	  throw new ClassFormatException("Invalid signature: " + signature);
   	
   	consumed_chars = index + 1; // "Lblabla;" `L' and `;' are removed
   
  @@ -875,11 +875,11 @@
   
         case 'V' : return "void";
   
  -      default  : throw new ClassFormatError("Invalid signature: `" +
  +      default  : throw new ClassFormatException("Invalid signature: `" +
   					    signature + "'");
         }
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid signature: " + e + ":" + signature);
  +      throw new ClassFormatException("Invalid signature: " + e + ":" + signature);
       }
     }
   
  @@ -982,18 +982,18 @@
      * @see    Constants
      */
     public static final byte typeOfMethodSignature(String signature)
  -    throws ClassFormatError
  +    throws ClassFormatException
     {
       int index;
   
       try {
         if(signature.charAt(0) != '(')
  -	throw new ClassFormatError("Invalid method signature: " + signature);
  +	throw new ClassFormatException("Invalid method signature: " + signature);
   
         index = signature.lastIndexOf(')') + 1;
         return typeOfSignature(signature.substring(index));
       } catch(StringIndexOutOfBoundsException e) {
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
     }
   
  @@ -1005,7 +1005,7 @@
      * @see    Constants
      */
     public static final byte typeOfSignature(String signature)
  -    throws ClassFormatError
  +    throws ClassFormatException
     {
       try {
         switch(signature.charAt(0)) {
  @@ -1021,10 +1021,10 @@
         case 'Z' : return Constants.T_BOOLEAN;
         case 'S' : return Constants.T_SHORT;
         default:  
  -	throw new ClassFormatError("Invalid method signature: " + signature);
  +	throw new ClassFormatException("Invalid method signature: " + signature);
         }
       } catch(StringIndexOutOfBoundsException e) {
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
     }
   
  
  
  
  1.1                  jakarta-bcel/src/java/org/apache/bcel/classfile/ClassFormatException.java
  
  Index: ClassFormatException.java
  ===================================================================
  package org.apache.bcel.classfile;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache BCEL" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache BCEL", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /** 
   * Thrown when the BCEL attempts to read a class file and determines
   * that the file is malformed or otherwise cannot be interpreted as a
   * class file.
   *
   * @version $Id: ClassFormatException.java,v 1.1 2002/04/24 11:01:30 mdahm Exp $
   * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
   */
  public class ClassFormatException extends RuntimeException {
    public ClassFormatException() { super(); }
    public ClassFormatException(String s) { super(s); }
  }
  
  
  
  
  1.2       +5 -5      jakarta-bcel/src/java/org/apache/bcel/generic/Type.java
  
  Index: Type.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/Type.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Type.java	29 Oct 2001 20:00:28 -0000	1.1
  +++ Type.java	24 Apr 2002 11:01:31 -0000	1.2
  @@ -63,7 +63,7 @@
    * Abstract super class for all possible java types, namely basic types
    * such as int, object types like String and array types, e.g. int[]
    *
  - * @version $Id: Type.java,v 1.1 2001/10/29 20:00:28 jvanzyl Exp $
  + * @version $Id: Type.java,v 1.2 2002/04/24 11:01:31 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public abstract class Type {
  @@ -177,7 +177,7 @@
         int index = signature.indexOf(';'); // Look for closing `;'
   
         if(index < 0)
  -	throw new ClassFormatError("Invalid signature: " + signature);
  +	throw new ClassFormatException("Invalid signature: " + signature);
   	
         consumed_chars = index + 1; // "Lblabla;" `L' and `;' are removed
   
  @@ -197,7 +197,7 @@
         int index = signature.lastIndexOf(')') + 1;
         return getType(signature.substring(index));
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
     }
   
  @@ -213,7 +213,7 @@
   
       try { // Read all declarations between for `(' and `)'
         if(signature.charAt(0) != '(')
  -	throw new ClassFormatError("Invalid method signature: " + signature);
  +	throw new ClassFormatException("Invalid method signature: " + signature);
   
         index = 1; // current string position
   
  @@ -222,7 +222,7 @@
   	index += consumed_chars; // update position
         }
       } catch(StringIndexOutOfBoundsException e) { // Should never occur
  -      throw new ClassFormatError("Invalid method signature: " + signature);
  +      throw new ClassFormatException("Invalid method signature: " + signature);
       }
   	
       types = new Type[vec.size()];
  
  
  

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


Mime
View raw message