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

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
mdahm       2002/12/08 08:04:38

  Modified:    src/java/org/apache/bcel/classfile ConstantUtf8.java
                        Field.java LineNumberTable.java Method.java
               src/java/org/apache/bcel/generic ConstantPoolGen.java
                        LCMP.java LDC_W.java PUTSTATIC.java
               src/java/org/apache/bcel/util Repository.java
  Log:
  Various bug fixes
  
  Revision  Changes    Path
  1.3       +5 -1      jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantUtf8.java
  
  Index: ConstantUtf8.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/ConstantUtf8.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConstantUtf8.java	11 Mar 2002 16:16:35 -0000	1.2
  +++ ConstantUtf8.java	8 Dec 2002 16:04:37 -0000	1.3
  @@ -95,6 +95,10 @@
     public ConstantUtf8(String bytes)
     {
       super(Constants.CONSTANT_Utf8);
  +
  +    if(bytes == null)
  +      throw new IllegalArgumentException("bytes must not be null!");
  +
       this.bytes  = bytes;
     }    
   
  
  
  
  1.3       +9 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Field.java	24 Apr 2002 11:01:30 -0000	1.2
  +++ Field.java	8 Dec 2002 16:04:37 -0000	1.3
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   import  org.apache.bcel.Constants;
  +import org.apache.bcel.generic.Type;
   import java.io.*;
   
   /**
  @@ -153,5 +154,12 @@
      */
     public final Field copy(ConstantPool constant_pool) {
       return (Field)copy_(constant_pool);
  +  }
  +
  +  /**
  +   * @return type of field
  +   */
  +  public Type getType() {
  +    return Type.getReturnType(getSignature());
     }
   }
  
  
  
  1.3       +7 -1      jakarta-bcel/src/java/org/apache/bcel/classfile/LineNumberTable.java
  
  Index: LineNumberTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/classfile/LineNumberTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LineNumberTable.java	11 Mar 2002 16:16:35 -0000	1.2
  +++ LineNumberTable.java	8 Dec 2002 16:04:37 -0000	1.3
  @@ -213,6 +213,12 @@
         }
       } while(l <= r);
   
  +    /* It's possible that we did not find any valid entry for the bytecode
  +     * offset we were looking for.
  +     */
  +    if (min_index < 0)
  +      return -1;
  +
       return line_number_table[min_index].getLineNumber();
     }
   
  
  
  
  1.5       +17 -2     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Method.java	3 Jun 2002 09:06:37 -0000	1.4
  +++ Method.java	8 Dec 2002 16:04:37 -0000	1.5
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   import org.apache.bcel.Constants;
  +import org.apache.bcel.generic.Type;
   import java.io.*;
   
   /**
  @@ -86,7 +87,7 @@
      * @throws ClassFormatException
      */
     Method(DataInputStream file, ConstantPool constant_pool)
  -       throws IOException, ClassFormatException
  +    throws IOException, ClassFormatException
     {
       super(file, constant_pool);
     }
  @@ -209,5 +210,19 @@
      */
     public final Method copy(ConstantPool constant_pool) {
       return (Method)copy_(constant_pool);
  +  }
  +
  +  /**
  +   * @return return type of method
  +   */
  +  public Type getReturnType() {
  +    return Type.getReturnType(getSignature());
  +  }
  +
  +  /**
  +   * @return array of method argument types
  +   */
  +  public Type[] getArgumentTypes() {
  +    return Type.getArgumentTypes(getSignature());
     }
   }
  
  
  
  1.4       +8 -4      jakarta-bcel/src/java/org/apache/bcel/generic/ConstantPoolGen.java
  
  Index: ConstantPoolGen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/ConstantPoolGen.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConstantPoolGen.java	11 Jul 2002 19:39:04 -0000	1.3
  +++ ConstantPoolGen.java	8 Dec 2002 16:04:37 -0000	1.4
  @@ -323,11 +323,13 @@
      * @return index on success, -1 otherwise
      */
     public int lookupFloat(float n) {
  +    int bits = Float.floatToIntBits(n);
  +
       for(int i=1; i < index; i++) {
         if(constants[i] instanceof ConstantFloat) {
   	ConstantFloat c = (ConstantFloat)constants[i];
   
  -	if(c.getBytes() == n)
  +	if(Float.floatToIntBits(c.getBytes()) == bits)
   	  return i;
         }
       }
  @@ -438,11 +440,13 @@
      * @return index on success, -1 otherwise
      */
     public int lookupDouble(double n) {
  +    long bits = Double.doubleToLongBits(n);
  +
       for(int i=1; i < index; i++) {
         if(constants[i] instanceof ConstantDouble) {
   	ConstantDouble c = (ConstantDouble)constants[i];
  -
  -	if(c.getBytes() == n)
  +	
  +	if(Double.doubleToLongBits(c.getBytes()) == bits)
   	  return i;
         }
       }
  
  
  
  1.2       +12 -2     jakarta-bcel/src/java/org/apache/bcel/generic/LCMP.java
  
  Index: LCMP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/LCMP.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LCMP.java	29 Oct 2001 20:00:21 -0000	1.1
  +++ LCMP.java	8 Dec 2002 16:04:37 -0000	1.2
  @@ -62,11 +62,18 @@
    * @version $Id$
    * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
    */
  -public class LCMP extends Instruction {
  +public class LCMP extends Instruction
  +  implements TypedInstruction, StackProducer, StackConsumer
  +{
     public LCMP() {
       super(org.apache.bcel.Constants.LCMP, (short)1);
     }
   
  +  /** @return Type.LONG
  +   */
  +  public Type getType(ConstantPoolGen cp) {
  +    return Type.LONG;
  +  }
   
     /**
      * Call corresponding visitor method(s). The order is:
  @@ -77,6 +84,9 @@
      * @param v Visitor object
      */
     public void accept(Visitor v) {
  +    v.visitTypedInstruction(this);
  +    v.visitStackProducer(this);
  +    v.visitStackConsumer(this);
       v.visitLCMP(this);
     }
   }
  
  
  
  1.3       +1 -2      jakarta-bcel/src/java/org/apache/bcel/generic/LDC_W.java
  
  Index: LDC_W.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/LDC_W.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LDC_W.java	11 Apr 2002 08:59:14 -0000	1.2
  +++ LDC_W.java	8 Dec 2002 16:04:37 -0000	1.3
  @@ -84,6 +84,5 @@
       setIndex(bytes.readUnsignedShort());
       // Override just in case it has been changed
       opcode = org.apache.bcel.Constants.LDC_W;
  -    length = 3;
     }
   }
  
  
  
  1.2       +3 -3      jakarta-bcel/src/java/org/apache/bcel/generic/PUTSTATIC.java
  
  Index: PUTSTATIC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/PUTSTATIC.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PUTSTATIC.java	29 Oct 2001 20:00:25 -0000	1.1
  +++ PUTSTATIC.java	8 Dec 2002 16:04:37 -0000	1.2
  @@ -59,9 +59,9 @@
   
   /** 
    * PUTSTATIC - Put static field in class
  - * <PRE>Stack: ..., objectref, value -&gt; ...</PRE>
  + * <PRE>Stack: ..., value -&gt; ...</PRE>
    * OR
  - * <PRE>Stack: ..., objectref, value.word1, value.word2 -&gt; ...</PRE>
  + * <PRE>Stack: ..., value.word1, value.word2 -&gt; ...</PRE>
    *
    * @version $Id$
    * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  
  
  
  1.5       +2 -2      jakarta-bcel/src/java/org/apache/bcel/util/Repository.java
  
  Index: Repository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/util/Repository.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Repository.java	11 Oct 2002 20:34:47 -0000	1.4
  +++ Repository.java	8 Dec 2002 16:04:38 -0000	1.5
  @@ -59,7 +59,7 @@
   /**
    * Abstract definition of a class repository. Instances may be used
    * to load classes from different sources and may be used in the
  - * Repository.setRpeository method.
  + * Repository.setRepository method.
    *
    * @see org.apache.bcel.Repository
    * @version $Id$
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.