db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mz...@apache.org
Subject svn commit: r332591 - /incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/
Date Fri, 11 Nov 2005 16:25:36 GMT
Author: mzaun
Date: Fri Nov 11 08:25:28 2005
New Revision: 332591

URL: http://svn.apache.org/viewcvs?rev=332591&view=rev
Log:
JDO-195 Added enhancer support for JDK1.5 classfiles

Added:
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
  (with props)
Modified:
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
    incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
Fri Nov 11 08:25:28 2005
@@ -80,6 +80,13 @@
         String attrName = attrName8.asString();
         int attrLength = data.readInt();
 
+        //@olsen: The attributes predefined by the VM Spec as appearing
+        // in the attributes table of a ClassFile, ClassMethod, or
+        // ClassField structure are: SourceFile, ConstantValue, Code,
+        // Exceptions, InnerClasses, EnclosingMethod, Synthetic, Signature,
+        // and Deprecated.
+        //^olsen: to support InnerClasses, EnclosingMethod, and Deprecated
+
         if (attrName.equals(CodeAttribute.expectedAttrName)) {
             /* The old style code attribute reader uses more memory and
                cpu when the instructions don't need to be examined than the
@@ -104,11 +111,19 @@
         else if (attrName.equals(AnnotatedClassAttribute.expectedAttrName)) {
             attr = AnnotatedClassAttribute.read(attrName8, data, pool);
         }
+        //@olsen: fix 4467428, added support for synthetic code attribute
+        else if (attrName.equals(SyntheticAttribute.expectedAttrName)) {
+            attr = SyntheticAttribute.read(attrName8, data, pool);
+        }
+        //@olsen: JDK1.5: added support for signature attribute
+        else if (attrName.equals(SignatureAttribute.expectedAttrName)) {
+            attr = SignatureAttribute.read(attrName8, data, pool);
+        }
         else {
             /* Unrecognized method attribute */
             byte attrBytes[] = new byte[attrLength];
             data.readFully(attrBytes);
-            attr = new GenericAttribute (attrName8, attrBytes);
+            attr = new GenericAttribute(attrName8, attrBytes);
         }
 
         return attr;
@@ -126,6 +141,10 @@
         String attrName = attrName8.asString();
         int attrLength = data.readInt();
 
+        //@olsen: The attributes predefined by the VM Spec as
+        // appearing in the Code attribute of a method: LineNumberTable
+        // and LocalVariableTable
+
         if (attrName.equals(LineNumberTableAttribute.expectedAttrName)) {
             attr = LineNumberTableAttribute.read(attrName8, data, env);
         }
@@ -135,15 +154,11 @@
         else if (attrName.equals(AnnotatedMethodAttribute.expectedAttrName)) {
             attr = AnnotatedMethodAttribute.read(attrName8, data, env);
         }
-        //@olsen: fix 4467428, added support for synthetic code attribute
-        else if (attrName.equals(SyntheticAttribute.expectedAttrName)) {
-            attr = SyntheticAttribute.read(attrName8, data, env.pool());
-        }
         else {
             /* Unrecognized method attribute */
             byte attrBytes[] = new byte[attrLength];
             data.readFully(attrBytes);
-            attr = new GenericAttribute (attrName8, attrBytes);
+            attr = new GenericAttribute(attrName8, attrBytes);
         }
 
         return attr;

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
Fri Nov 11 08:25:28 2005
@@ -23,120 +23,128 @@
  * ClassField models the static and non-static fields of a class within
  * a class file.
  */
-
 final public class ClassField extends ClassMember {
-  /* access flag bit mask - see VMConstants */
-  private int accessFlags;
+    /* access flag bit mask - see VMConstants */
+    private int accessFlags;
 
-  /* The name of the field */
-  private ConstUtf8 fieldName;
+    /* The name of the field */
+    private ConstUtf8 fieldName;
 
-  /* The type signature of the field */
-  private ConstUtf8 fieldSignature;
+    /* The type signature of the field */
+    private ConstUtf8 fieldSignature;
 
-  /* The attributes associated with the field */
-  private AttributeVector fieldAttributes;
-  
-
-  /* public accessors */
-
-  /**
-   * Is the field transient?
-   */
-  public boolean isTransient() {
-    return (accessFlags & ACCTransient) != 0;
-  }
-
-  /**
-   * Return the access flags for the field - see VMConstants
-   */
-  public int access() {
-    return accessFlags;
-  }
-
-  /**
-   * Update the access flags for the field - see VMConstants
-   */
-  public void setAccess(int newFlags) {
-    accessFlags = newFlags;
-  }
-
-  /**
-   * Return the name of the field
-   */
-  public ConstUtf8 name() {
-    return fieldName;
-  }
-
-  /**
-   * Change the name of the field
-   */
-  public void changeName(ConstUtf8 name) {
-    fieldName = name;
-  }
-
-  /**
-   * Return the type signature of the field
-   */
-  public ConstUtf8 signature() {
-    return fieldSignature;
-  }
-
-  /**
-   * Change the type signature of the field
-   */
-  public void changeSignature(ConstUtf8 newSig) {
-    fieldSignature = newSig;
-  }
-
-  /**
-   * Return the attributes associated with the field
-   */
-  public AttributeVector attributes() {
-    return fieldAttributes;
-  }
-
-  /**
-   * Construct a class field object
-   */
-  public ClassField(int accFlags, ConstUtf8 name, ConstUtf8 sig,
-                    AttributeVector field_attrs) {
-    accessFlags = accFlags;
-    fieldName = name;
-    fieldSignature = sig;
-    fieldAttributes = field_attrs;
-  }
-
-  /* package local methods */
-
-  static ClassField read(DataInputStream data, ConstantPool pool) 
-    throws IOException {
-    ClassField f = null;
-    int accessFlags = data.readUnsignedShort();
-    int name_index = data.readUnsignedShort();
-    int sig_index = data.readUnsignedShort();
-    AttributeVector fieldAttribs = AttributeVector.readAttributes(data, pool);
-    f = new ClassField(accessFlags, 
-		       (ConstUtf8) pool.constantAt(name_index),
-		       (ConstUtf8) pool.constantAt(sig_index),
-		       fieldAttribs);
-    return f;
-  }
-
-  void write (DataOutputStream data) throws IOException {
-    data.writeShort(accessFlags);
-    data.writeShort(fieldName.getIndex());
-    data.writeShort(fieldSignature.getIndex());
-    fieldAttributes.write(data);
-  }
-
-  void print(PrintStream out, int indent) {
-    ClassPrint.spaces(out, indent);
-    out.print("'" + fieldName.asString() + "'");
-    out.print(" sig = " + fieldSignature.asString());
-    out.print(" access_flags = " + Integer.toString(accessFlags));
-    out.println(" attributes:");
-    fieldAttributes.print(out, indent+2);
-  }
+    /* The attributes associated with the field */
+    private AttributeVector fieldAttributes;  
+
+    /* public accessors */
+
+    /**
+     * Is the field transient?
+     */
+    public boolean isTransient() {
+        return (accessFlags & ACCTransient) != 0;
+    }
+
+    /**
+     * Return the access flags for the field - see VMConstants
+     */
+    public int access() {
+        return accessFlags;
+    }
+
+    /**
+     * Update the access flags for the field - see VMConstants
+     */
+    public void setAccess(int newFlags) {
+        accessFlags = newFlags;
+    }
+
+    /**
+     * Return the name of the field
+     */
+    public ConstUtf8 name() {
+        return fieldName;
+    }
+
+    /**
+     * Change the name of the field
+     */
+    public void changeName(ConstUtf8 name) {
+        fieldName = name;
+    }
+
+    /**
+     * Return the type signature of the field
+     */
+    public ConstUtf8 signature() {
+        return fieldSignature;
+    }
+
+    /**
+     * Change the type signature of the field
+     */
+    public void changeSignature(ConstUtf8 newSig) {
+        fieldSignature = newSig;
+    }
+
+    /**
+     * Return the attributes associated with the field
+     */
+    public AttributeVector attributes() {
+        return fieldAttributes;
+    }
+
+    /**
+     * Returns the SignatureAttribute, if there's any, for this field.
+     */
+    //@olsen: JDK1.5: added field
+    public SignatureAttribute getSignatureAttribute() {
+        final String name = SignatureAttribute.expectedAttrName;
+        final ClassAttribute attr = fieldAttributes.findAttribute(name);
+        return (SignatureAttribute)attr;
+    }
+
+    /**
+     * Construct a class field object
+     */
+    public ClassField(int accFlags, ConstUtf8 name, ConstUtf8 sig,
+                      AttributeVector field_attrs) {
+        accessFlags = accFlags;
+        fieldName = name;
+        fieldSignature = sig;
+        fieldAttributes = field_attrs;
+    }
+
+    /* package local methods */
+
+    static ClassField read(DataInputStream data, ConstantPool pool) 
+        throws IOException {
+        ClassField f = null;
+        int accessFlags = data.readUnsignedShort();
+        int name_index = data.readUnsignedShort();
+        int sig_index = data.readUnsignedShort();
+        AttributeVector fieldAttribs = AttributeVector.readAttributes(data, pool);
+        f = new ClassField(accessFlags, 
+                           (ConstUtf8) pool.constantAt(name_index),
+                           (ConstUtf8) pool.constantAt(sig_index),
+                           fieldAttribs);
+        return f;
+    }
+
+    void write (DataOutputStream data) throws IOException {
+        data.writeShort(accessFlags);
+        data.writeShort(fieldName.getIndex());
+        data.writeShort(fieldSignature.getIndex());
+        fieldAttributes.write(data);
+    }
+    
+    void print(PrintStream out, int indent) {
+        ClassPrint.spaces(out, indent);
+        out.print("'" + fieldName.asString() + "'");
+        out.print(" sig = " + fieldSignature.asString());
+        out.print(" access_flags = " + Integer.toString(accessFlags));
+        out.println(" attributes:");
+        fieldAttributes.print(out, indent+2);
+    }
 }
 

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
Fri Nov 11 08:25:28 2005
@@ -40,11 +40,19 @@
     
     /*@craig added more flexible version checking.
      */
-    public static final short[] [] jdkMajorMinorVersions = new short[][] {
+    public static final short[][] jdkMajorMinorVersions = new short[][] {
+        //@olsen: JDK1.5: support for classfile version 49.0
+	// JDK 1.0.2:  [45.0 .. 45.3]
+	// JDK 1.1:    [45.0 .. 45.65535]
+	// JDK 1.2:    [45.0 .. 46.0]
+	// JDK 1.3:    [45.0 .. 47.0]
+	// JDK 1.4:    [45.0 .. 48.0]
+	// JDK 1.5:    [45.0 .. 49.0]
         new short[] {45,3}, // jdk 1.1
         new short[] {46,0}, // jdk 1.2
         new short[] {47,0}, // jdk 1.3
-        new short[] {48,0}  // jdk 1.4
+        new short[] {48,0}, // jdk 1.4
+        new short[] {49,0}  // jdk 1.5
     };
     public static final List jdkVersions = 
         convertMajorMinorVersions(jdkMajorMinorVersions);
@@ -116,8 +124,6 @@
 
     /* public accessors */
 
-
-
     /**
      * Return the constant pool for the class file
      */
@@ -160,7 +166,6 @@
         return (accessFlags & ACCAbstract) != 0;
     }
 
-
     /**
      * Set the access flags for the class - see VMConstants
      */
@@ -290,11 +295,20 @@
     }
 
     /**
+     * Returns the SignatureAttribute, if there's any, for this class.
+     */
+    //@olsen: JDK1.5: added method
+    public SignatureAttribute getSignatureAttribute() {
+        final String name = SignatureAttribute.expectedAttrName;
+        final ClassAttribute attr = classAttributes.findAttribute(name);
+        return (SignatureAttribute)attr;
+    }
+
+    /**
      * Returns the class name in user ('.' delimited) form.
      */
     //@olsen: moved from ClassControl to ClassFile
-    public String userClassName()
-    {
+    public String userClassName() {
         return userClassFromVMClass(classNameString());
     }
   
@@ -302,8 +316,7 @@
      * Returns the class name in user ('.' delimited) form.
      */
     //@olsen: moved from ClassControl to ClassFile
-    static public String userClassFromVMClass(String vmName)
-    {
+    static public String userClassFromVMClass(String vmName) {
         return vmName.replace('/', '.');
     }
   
@@ -311,8 +324,7 @@
      * Returns the class name in VM ('/' delimited) form.
      */
     //@olsen: moved from ClassControl to ClassFile
-    static public String vmClassFromUserClass(String userName)
-    {
+    static public String vmClassFromUserClass(String userName) {
         return userName.replace('.', '/');
     }
   
@@ -384,9 +396,6 @@
             throw new ClassFormatError("IOException during reading: " + 
                                        e.getMessage());
         }
-        //@olsen: added println() for debugging
-        //System.out.println("ClassFile(): new class = " + 
-        //thisClassName.asString());
     }
 
     /**
@@ -395,16 +404,12 @@
     public ClassFile(String cname, String supername) {
         thisClassName = constantPool.addClass(cname);
         superClassName = constantPool.addClass(supername);
-        //@olsen: added println() for debugging
-        //System.out.println("ClassFile(): new bare class file = " + 
-        //thisClassName);
     }
 
     /**
      * Write the Class file to the data output stream
      */
-    public
-    void write (DataOutputStream buff) throws IOException {
+    public void write (DataOutputStream buff) throws IOException {
         buff.writeInt(magic);
         buff.writeShort(minorVersion);
         buff.writeShort(majorVersion);

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
Fri Nov 11 08:25:28 2005
@@ -43,8 +43,7 @@
     private ConstUtf8 methodSignature;
 
     /* The attributes associated with the field */
-    private AttributeVector methodAttributes;
-  
+    private AttributeVector methodAttributes;  
   
     /* public accessors */
 
@@ -109,6 +108,16 @@
      */
     public AttributeVector attributes() {
         return methodAttributes;
+    }
+
+    /**
+     * Returns the SignatureAttribute, if there's any, for this method.
+     */
+    //@olsen: JDK1.5: added method
+    public SignatureAttribute getSignatureAttribute() {
+        final String name = SignatureAttribute.expectedAttrName;
+        final ClassAttribute attr = methodAttributes.findAttribute(name);
+        return (SignatureAttribute)attr;
     }
 
     /**

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
Fri Nov 11 08:25:28 2005
@@ -23,7 +23,8 @@
 /**
  * Class representing a class reference in the constant pool
  */
-public class ConstClass extends ConstBasic {
+//@olsen: JDK1.5: extend ConstValue to allow for class refs as constants
+public class ConstClass extends ConstValue {
     /* The tag associated with ConstClass entries */
     public static final int MyTag = CONSTANTClass;
 
@@ -49,6 +50,15 @@
     }
 
     /**
+     * Return the descriptor string for the constant type.
+     */
+    //@olsen: added method
+    public String descriptor() {
+        String cname = asString();
+        return (cname.startsWith("[") ? cname : "L" + cname + ";");
+    }
+
+    /**
      * Return the class name in simple string form
      */
     public String asString() {
@@ -81,7 +91,7 @@
     /**
      * Compares this instance with another for structural equality.
      */
-    //@olsen: added method
+    //@olsen: JDK1.5: added method
     public boolean isEqual(Stack msg, Object obj) {
         if (!(obj instanceof ConstClass)) {
             msg.push("obj/obj.getClass() = "

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
Fri Nov 11 08:25:28 2005
@@ -426,6 +426,9 @@
             case CONSTANTNameAndType:
                 nameAndTypeTable.addElement(c);
                 break;
+            default:
+                throw new ClassFormatError("Don't know this constant type: " +
+                                           c.toString());
             }
         }
     }

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java (original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java Fri
Nov 11 08:25:28 2005
@@ -476,7 +476,6 @@
         case opc_dreturn:
         case opc_areturn:
         case opc_return:
-        case opc_xxxunusedxxx:
         case opc_arraylength:
         case opc_athrow:
         case opc_monitorenter:
@@ -496,6 +495,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+        //@olsen: JDK1.5: support for new opcode invokedynamic
+        case opc_invokedynamic:
         case opc_new:
         case opc_anewarray:
         case opc_checkcast:

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
Fri Nov 11 08:25:28 2005
@@ -48,6 +48,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+            /* @olsen: JDK1.5: support for new opcode invokedynamic */
+        case opc_invokedynamic:
             /* handle interface invoke too */
         case opc_invokeinterface:
         {
@@ -79,6 +81,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+            /* @olsen: JDK1.5: support for new opcode invokedynamic */
+        case opc_invokedynamic:
             /* handle interface invoke too */
         case opc_invokeinterface:
         {
@@ -106,6 +110,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+            /* @olsen: JDK1.5: support for new opcode invokedynamic */
+        case opc_invokedynamic:
             /* handle interface invoke too */
         case opc_invokeinterface:
         {
@@ -127,6 +133,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+            /* @olsen: JDK1.5: support for new opcode invokedynamic */
+        case opc_invokedynamic:
             /* handle interface invoke too */
         case opc_invokeinterface:
         {
@@ -279,6 +287,8 @@
         case opc_invokevirtual:
         case opc_invokespecial:
         case opc_invokestatic:
+            /* @olsen: JDK1.5: support for new opcode invokedynamic */
+        case opc_invokedynamic:
             /* ConstMethodRef */
             if (operand == null ||
                 (! (operand instanceof ConstMethodRef)))

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
Fri Nov 11 08:25:28 2005
@@ -254,7 +254,6 @@
         case opc_dreturn:
         case opc_areturn:
         case opc_return:
-        case opc_xxxunusedxxx:
         case opc_arraylength:
         case opc_athrow:
         case opc_monitorenter:

Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java?rev=332591&view=auto
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
(added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
Fri Nov 11 08:25:28 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.impl.enhancer.classfile;
+
+import java.io.*;
+import java.util.Stack;
+
+/**
+ * A SignatureAttribute is a fixed-length attribute in the attributes table
+ * of ClassFile, ClassField, and ClassMethod structures.  A signature is a
+ * string representing the generic type of a field or method, or generic
+ * type information for a class declaration.
+ */
+public class SignatureAttribute extends ClassAttribute {
+    /* The expected name of this attribute */
+    public static final String expectedAttrName = "Signature";
+
+    /* The signature constant */
+    private ConstUtf8 signature;
+
+    /* public accessors */
+
+    public ConstUtf8 signature() {
+        return signature;
+    }
+
+    /** 
+     * Construct a signature attribute
+     */
+    public SignatureAttribute(ConstUtf8 attrName, ConstUtf8 sig) {
+        super(attrName);
+        signature = sig;
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof SignatureAttribute)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        SignatureAttribute other = (SignatureAttribute)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.signature.isEqual(msg, other.signature)) {
+            msg.push("signature = " + other.signature);
+            msg.push("signature = " + this.signature);
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    static SignatureAttribute read(ConstUtf8 attrName,
+                                   DataInputStream data, ConstantPool pool)
+        throws IOException {
+        int index = 0;
+        index = data.readUnsignedShort();
+
+        return new SignatureAttribute(attrName,
+                                      (ConstUtf8)pool.constantAt(index));
+    }
+
+    void write(DataOutputStream out) throws IOException {
+        out.writeShort(attrName().getIndex());
+        out.writeInt(2);
+        out.writeShort(signature.getIndex());
+    }
+
+    void print(PrintStream out, int indent) {
+        ClassPrint.spaces(out, indent);
+        out.println("Signature: " + signature.toString());
+    }
+}
+

Propchange: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
Fri Nov 11 08:25:28 2005
@@ -26,7 +26,15 @@
  * A SyntheticAttribute is a fixed-length attribute in the attributes table
  * of ClassFile, ClassField, and ClassMethod structures.  A class member
  * that does not appear in the source code must be marked using a
- * SyntheticAttribute. 
+ * SyntheticAttribute, or else it must have its ACC_SYNTHETIC bit set. The
+ * only exceptions to this requirement are for default constructors and the
+ * class initialization method.
+ *
+ * The SyntheticAttribute has the following format:
+ *     Synthetic_attribute {
+ *         u2 attribute_name_index;
+ *         u4 attribute_length;
+ *     }
  */
 public class SyntheticAttribute extends ClassAttribute {
     /* The expected name of this attribute */
@@ -37,7 +45,6 @@
      */
     public SyntheticAttribute(ConstUtf8 attrName) {
         super(attrName);
-        //System.out.println("new SyntheticAttribute()");
     }
 
     /* package local methods */

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
(original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
Fri Nov 11 08:25:28 2005
@@ -25,19 +25,26 @@
  */
 public interface VMConstants {
     /* Access types */
-    static final int ACCPublic        = 0x0001;
-    static final int ACCPrivate       = 0x0002;
-    static final int ACCProtected     = 0x0004;
-    static final int ACCStatic        = 0x0008;
-    static final int ACCFinal         = 0x0010;
-    static final int ACCSuper         = 0x0020;   /* For Class file */
-    static final int ACCSynchronized  = 0x0020;   /* For methods    */
-    static final int ACCVolatile      = 0x0040;
-    static final int ACCTransient     = 0x0080;
-    static final int ACCNative        = 0x0100;
-    static final int ACCInterface     = 0x0200;
-    static final int ACCAbstract      = 0x0400;
-
+    //@olsen: JDK1.5: support for new flags: ACCVarargs, ACCBridge,
+    // ACCEnum, and ACCAnnotation
+    static final int ACCPublic        = 0x0001;  // class, field, method
+    static final int ACCPrivate       = 0x0002;  // field, method
+    static final int ACCProtected     = 0x0004;  // field, method
+    static final int ACCStatic        = 0x0008;  // field, method
+    static final int ACCFinal         = 0x0010;  // class, field, method
+    static final int ACCSuper         = 0x0020;  // class
+    static final int ACCSynchronized  = 0x0020;  // method
+    static final int ACCVolatile      = 0x0040;  // field
+    static final int ACCBridge        = 0x0040;  // method
+    static final int ACCTransient     = 0x0080;  // field
+    static final int ACCVarargs       = 0x0080;  // method
+    static final int ACCNative        = 0x0100;  // method
+    static final int ACCInterface     = 0x0200;  // class
+    static final int ACCAbstract      = 0x0400;  // class, method
+    static final int ACCStrict        = 0x0800;  // method
+    static final int ACCSynthetic     = 0x1000;  // class, field, method
+    static final int ACCAnnotation    = 0x2000;  // class
+    static final int ACCEnum          = 0x4000;  // class, field
 
     /* Primitive Types */
     /* These correspond to the values used by newarray */
@@ -74,8 +81,6 @@
     static final int CONSTANTInterfaceMethodRef = 11;
     static final int CONSTANTNameAndType = 12;
 
-
-
     /* Java VM opcodes */
     final static int opc_nop = 0;
     final static int opc_aconst_null = 1;
@@ -263,7 +268,8 @@
     final static int opc_invokespecial = 183;
     final static int opc_invokestatic = 184;
     final static int opc_invokeinterface = 185;
-    final static int opc_xxxunusedxxx = 186;
+    //@olsen: JDK1.5: support for new opcode invokedynamic
+    final static int opc_invokedynamic = 186;
     final static int opc_new = 187;
     final static int opc_newarray = 188;
     final static int opc_anewarray = 189;

Modified: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java?rev=332591&r1=332590&r2=332591&view=diff
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java (original)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java Fri
Nov 11 08:25:28 2005
@@ -474,8 +474,9 @@
         new VMOp(opc_invokestatic, "invokestatic", -1, -1, "?", "?"),
         /* idxbyte1, idxbyte2, nargs, rsvd | ..., objectref, [args] => ... */
         new VMOp(opc_invokeinterface, "invokeinterface", -1, -1, "A?", "?"),
-        /* */
-        new VMOp(opc_xxxunusedxxx, "xxxunusedxxx", 0, 0, "", ""),
+	/* @olsen: JDK1.5: support for new opcode invokedynamic */
+        /* idxbyte1, idxbyte2 | ..., objectref, [args] => ... */
+        new VMOp(opc_invokedynamic, "invokedynamic", -1, -1, "A?", "?"),
         /* idxbyte1, idxbyte2 | ... => ..., objectref */
         new VMOp(opc_new, "new", 0, 1, "", "A"),
         /* atype | ..., size => ..., result */



Mime
View raw message