db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r171351 [4/16] - in /incubator/jdo/trunk/enhancer20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/enhancer/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/enhancer/ src/java/org/apache/jdo/impl/enhancer/classfile/ src/java/org/apache/jdo/impl/enhancer/core/ src/java/org/apache/jdo/impl/enhancer/generator/ src/java/org/apache/jdo/impl/enhancer/meta/ src/java/org/apache/jdo/impl/enhancer/meta/model/ src/java/org/apache/jdo/impl/enhancer/meta/prop/ src/java/org/apache/jdo/impl/enhancer/meta/util/ src/java/org/apache/jdo/impl/enhancer/util/ test/ test/sempdept/ test/sempdept/src/ test/sempdept/src/empdept/
Date Sun, 22 May 2005 17:55:54 GMT
Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java Sun May 22 10:55:51 2005
@@ -0,0 +1,246 @@
+/*
+ * 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.Vector;
+import java.util.Stack;
+import java.util.Enumeration;
+
+/**
+ * ClassMethod models the static and non-static methods of a class within
+ * a class file.  This includes constructors and initializer code.
+ */
+public class ClassMethod extends ClassMember {
+    /* The name of the constructor code */
+    public final static String intializerName = "<init>";
+
+    /* The name of the static initializer code */
+    public final static String staticIntializerName = "<clinit>";
+
+    /* access flag bit mask - see VMConstants */
+    private int accessFlags;
+
+    /* The name of the method */
+    private ConstUtf8 methodName;
+
+    /* The type signature of the method */
+    private ConstUtf8 methodSignature;
+
+    /* The attributes associated with the field */
+    private AttributeVector methodAttributes;
+  
+  
+    /* public accessors */
+
+    /**
+     * Return the access flags for the method - see VMConstants
+     */
+    public int access() {
+        return accessFlags;
+    }
+
+    /**
+     * Update the access flags for the field - see VMConstants
+     */
+    public void setAccess(int newFlags) {
+        accessFlags = newFlags;
+    }
+
+    /**
+     * Is the method abstract?
+     */
+    public boolean isAbstract() {
+        return (accessFlags & ACCAbstract) != 0;
+    }
+
+    /**
+     * Is the method native?
+     */
+    public boolean isNative() {
+        return (accessFlags & ACCNative) != 0;
+    }
+
+    /**
+     * Return the name of the method
+     */
+    public ConstUtf8 name() {
+        return methodName;
+    }
+
+    /**
+     * Change the name of the method
+     */
+    public void changeName(ConstUtf8 name) {
+        methodName = name;
+    }
+
+    /**
+     * Return the type signature of the method
+     */
+    public ConstUtf8 signature() {
+        return methodSignature;
+    }
+
+    /**
+     * Change the type signature of the method
+     */
+    public void changeSignature(ConstUtf8 newSig) {
+        methodSignature = newSig;
+    }
+
+    /**
+     * Return the attributes associated with the method
+     */
+    public AttributeVector attributes() {
+        return methodAttributes;
+    }
+
+    /**
+     * Construct a class method object
+     */
+  
+    public ClassMethod(int accFlags, ConstUtf8 name, ConstUtf8 sig,
+                       AttributeVector methodAttrs) {
+        accessFlags = accFlags;
+        methodName = name;
+        methodSignature = sig;
+        methodAttributes = methodAttrs;
+    }
+
+    /**
+     * Returns the size of the method byteCode (if any)
+     */
+    int codeSize() {
+        CodeAttribute codeAttr = codeAttribute();
+        return (codeAttr == null) ? 0  : codeAttr.codeSize();
+    }
+
+    /**
+     * Returns the CodeAttribute associated with this method (if any)
+     */
+    public CodeAttribute codeAttribute() {
+        Enumeration e = methodAttributes.elements();
+        while (e.hasMoreElements()) {
+            ClassAttribute attr = (ClassAttribute) e.nextElement();
+            if (attr instanceof CodeAttribute)
+                return (CodeAttribute) attr;
+        }
+        return null;
+    }
+
+    /**
+     * Returns the ExceptionsAttribute associated with this method (if any)
+     */
+    //@olsen: added method
+    public ExceptionsAttribute exceptionsAttribute() {
+        Enumeration e = methodAttributes.elements();
+        while (e.hasMoreElements()) {
+            ClassAttribute attr = (ClassAttribute) e.nextElement();
+            if (attr instanceof ExceptionsAttribute)
+                return (ExceptionsAttribute) attr;
+        }
+        return null;
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ClassMethod)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ClassMethod other = (ClassMethod)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.accessFlags != other.accessFlags) {
+            msg.push(String.valueOf("accessFlags = 0x"
+                                    + Integer.toHexString(other.accessFlags)));
+            msg.push(String.valueOf("accessFlags = 0x"
+                                    + Integer.toHexString(this.accessFlags)));
+            return false;
+        }
+        if (!this.methodName.isEqual(msg, other.methodName)) {
+            msg.push(String.valueOf("methodName = "
+                                    + other.methodName));
+            msg.push(String.valueOf("methodName = "
+                                    + this.methodName));
+            return false;
+        }
+        if (!this.methodSignature.isEqual(msg, other.methodSignature)) {
+            msg.push(String.valueOf("methodSignature = "
+                                    + other.methodSignature));
+            msg.push(String.valueOf("methodSignature = "
+                                    + this.methodSignature));
+            return false;
+        }
+        if (!this.methodAttributes.isEqual(msg, other.methodAttributes)) {
+            msg.push(String.valueOf("methodAttributes = "
+                                    + other.methodAttributes));
+            msg.push(String.valueOf("methodAttributes = "
+                                    + this.methodAttributes));
+            return false;
+        }
+        return true;
+    }
+
+    //@olsen: made public
+    public void print(PrintStream out, int indent) {
+        ClassPrint.spaces(out, indent);
+        out.print("'" + methodName.asString() + "'");
+        out.print(" sig = " + methodSignature.asString());
+        out.print(" accessFlags = " + Integer.toString(accessFlags));
+        out.println(" attributes:");
+        methodAttributes.print(out, indent+2);
+    }
+
+    /* package local methods */
+
+    static ClassMethod read(DataInputStream data, ConstantPool pool) 
+        throws IOException {
+        int accessFlags = data.readUnsignedShort();
+        int nameIndex = data.readUnsignedShort();
+        int sigIndex = data.readUnsignedShort();
+        ClassMethod f = 
+            new ClassMethod(accessFlags, 
+                            (ConstUtf8) pool.constantAt(nameIndex),
+                            (ConstUtf8) pool.constantAt(sigIndex),
+                            null);
+
+        f.methodAttributes = AttributeVector.readAttributes(data, pool);
+        return f;
+    }
+
+    void write(DataOutputStream data) throws IOException {
+        CodeAttribute codeAttr = codeAttribute();
+        data.writeShort(accessFlags);
+        data.writeShort(methodName.getIndex());
+        data.writeShort(methodSignature.getIndex());
+        methodAttributes.write(data);
+    }
+}
+
+

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassPrint.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassPrint.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassPrint.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ClassPrint.java Sun May 22 10:55:51 2005
@@ -0,0 +1,34 @@
+/*
+ * 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.*;
+
+/**
+ * A really simple class with printing utilities
+ */
+
+class ClassPrint {
+    /**
+     * Print 'nspaces' spaces to the print stream
+     */
+    public static void spaces(PrintStream ps, int nspaces) {
+        while (nspaces-- > 0)
+            ps.print(' ');
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeAttribute.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeAttribute.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeAttribute.java Sun May 22 10:55:51 2005
@@ -0,0 +1,440 @@
+/*
+ * 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.util.Stack;
+import java.util.Vector;
+import java.io.*;
+
+/**
+ * Subtype of ClassAttribute which describes the "Code" attribute
+ * associated with a method.
+ */
+public class CodeAttribute extends ClassAttribute {
+    public final static String expectedAttrName = "Code";
+
+    /* The java class file contents defining this code attribute.
+       If non-null, this must be disassembled before the remaining 
+       fields of this instance may be accessed. */
+    private byte theDataBytes[];
+
+    /* The maximum number of stack entries used by this method */
+    private int maxStack;
+
+    /* The maximum number of local variables used by this method */
+    private int maxLocals;
+
+    /* The java VM byte code sequence for this method - null for native
+       and abstract methods */
+    private byte theCodeBytes[];
+
+    /* The instruction sequence for this method - initially derived from
+       the byte code array, but may later be modified */
+    private Insn theCode;
+
+    /* The exception ranges and handlers which apply to the code in this
+       method */
+    private ExceptionTable exceptionTable;
+
+    /* The attributes which apply to this method */
+    private AttributeVector codeAttributes;
+
+    /* The method environment used for decompiling this code attribute */
+    CodeEnv codeEnv;
+
+    /* public accessors */
+
+    /**
+     * Return the maximum number of stack entries used by this method
+     */
+    public int stackUsed() {
+        makeValid();
+        return maxStack;
+    }
+
+    /**
+     * Set the maximum number of stack entries used by this method
+     */
+    public void setStackUsed(int used) {
+        makeValid();
+        maxStack = used;
+    }
+
+    /**
+     * Return the maximum number of local variables used by this method
+     */
+    public int localsUsed() {
+        makeValid();
+        return maxLocals;
+    }
+
+    /**
+     * Set the maximum number of local variables used by this method
+     */
+    public void setLocalsUsed(int used) {
+        makeValid();
+        maxLocals = used;
+    }
+
+    /**
+     * Return the java VM byte code sequence for this method - null for
+     * native and abstract methods
+     */
+    public byte[] byteCodes() {
+        makeValid();
+        return theCodeBytes;
+    }
+
+    /**
+     * Return the instruction sequence for this method - initially derived
+     * from the byte code array, but may later be modified
+     */
+    public Insn theCode() {
+        makeValid();
+        if (theCode == null && codeEnv != null) {
+            buildInstructions(codeEnv);
+        }
+        return theCode;
+    }
+
+    /**
+     * Install the instruction sequence for this method - the byte code array
+     * is later updated.
+     */
+    public void setTheCode(Insn insn) {
+        makeValid();
+        if (insn != null && insn.opcode() != Insn.opc_target)
+            throw new InsnError(
+                "The initial instruction in all methods must be a target");
+        theCode = insn;
+    }
+
+    /**
+     * Return the exception ranges and handlers which apply to the code in
+     * this method.
+     */
+    public ExceptionTable exceptionHandlers() {
+        makeValid();
+        return exceptionTable;
+    }
+
+    /**
+     * Return the attributes which apply to this code
+     */
+    public AttributeVector attributes() {
+        makeValid();
+        return codeAttributes;
+    }
+
+    /**
+     * Constructs a CodeAttribute object for construction from scratch
+     */
+    public CodeAttribute(ConstUtf8 attrName,
+                         int maxStack, int maxLocals,
+                         Insn code, 
+                         ExceptionTable excTable,
+                         AttributeVector codeAttrs) {
+        this(attrName, maxStack, maxLocals, code, null, /* byteCodes */
+             excTable, codeAttrs, null /* CodeEnv */ );
+    }
+
+    /**
+     * Constructs a CodeAttribute object 
+     */
+    public CodeAttribute(ConstUtf8 attrName,
+                         int maxStack, int maxLocals,
+                         Insn code, byte[] codeBytes,
+                         ExceptionTable excTable,
+                         AttributeVector codeAttrs,
+                         CodeEnv codeEnv) {
+        super(attrName);
+        this.maxStack = maxStack;
+        this.maxLocals = maxLocals;
+        theCode = code;
+        theCodeBytes = codeBytes;
+        exceptionTable = excTable;
+        codeAttributes = codeAttrs;
+        this.codeEnv = codeEnv;
+    }
+
+    /**
+     * Constructs a CodeAttribute object for later disassembly
+     */
+    public CodeAttribute(ConstUtf8 attrName, byte[] dataBytes, CodeEnv codeEnv) {
+        super(attrName);
+        this.theDataBytes = dataBytes;
+        this.codeEnv = codeEnv;
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof CodeAttribute)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        CodeAttribute other = (CodeAttribute)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.stackUsed() != other.stackUsed()) {
+            msg.push(String.valueOf("stackUsed() = "
+                                    + other.stackUsed()));
+            msg.push(String.valueOf("stackUsed() = "
+                                    + this.stackUsed()));
+            return false;
+        }
+        if (this.localsUsed() != other.localsUsed()) {
+            msg.push(String.valueOf("localsUsed() = "
+                                    + other.localsUsed()));
+            msg.push(String.valueOf("localsUsed() = "
+                                    + this.localsUsed()));
+            return false;
+        }
+
+        // iterate over the instructions
+        Insn theCode1 = this.theCode();
+        Insn theCode2 = other.theCode();
+        while (theCode1 != null && theCode2 != null) {
+            // ignore targets (ignore line numbers)
+            if (theCode1.opcode() == Insn.opc_target) {
+                theCode1 = theCode1.next();
+                continue;
+            }
+            if (theCode2.opcode() == Insn.opc_target) {
+                theCode2 = theCode2.next();
+                continue;
+            }
+            if (!theCode1.isEqual(msg, theCode2)) {
+                msg.push("theCode()[i] = " + String.valueOf(theCode2));
+                msg.push("theCode()[i] = " + String.valueOf(theCode1));
+                return false;
+            }
+            theCode1 = theCode1.next();
+            theCode2 = theCode2.next();
+        }
+        if (theCode1 == null ^ theCode2 == null) {
+            msg.push("theCode()[i] = " + String.valueOf(theCode2));
+            msg.push("theCode()[i] = " + String.valueOf(theCode1));
+            return false;
+        }
+
+        if (!this.exceptionHandlers().isEqual(msg, other.exceptionHandlers())) {
+            msg.push(String.valueOf("exceptionHandlers() = "
+                                    + other.exceptionHandlers()));
+            msg.push(String.valueOf("exceptionHandlers() = "
+                                    + this.exceptionHandlers()));
+            return false;
+        }
+        if (!this.attributes().isEqual(msg, other.attributes())) {
+            msg.push(String.valueOf("attributes() = "
+                                    + other.attributes()));
+            msg.push(String.valueOf("attributes() = "
+                                    + this.attributes()));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    static CodeAttribute read(ConstUtf8 attrName,
+                              DataInputStream data, ConstantPool pool)
+        throws IOException {
+        int maxStack = data.readUnsignedShort();
+        int maxLocals = data.readUnsignedShort();
+        int codeLength = data.readInt();
+        byte codeBytes[] = new byte[codeLength];
+        data.readFully(codeBytes);
+        Insn code = null;
+        CodeEnv codeEnv = new CodeEnv(pool);
+
+        ExceptionTable excTable = ExceptionTable.read(data, codeEnv);
+    
+        AttributeVector codeAttrs = 
+            AttributeVector.readAttributes(data, codeEnv);
+
+        return new CodeAttribute(attrName, maxStack, maxLocals, code, codeBytes,
+                                 excTable, codeAttrs, codeEnv);
+    } 
+
+    /* This version reads the attribute into a byte array for later 
+       consumption */
+    static CodeAttribute read(ConstUtf8 attrName, int attrLength,
+                              DataInputStream data, ConstantPool pool)
+        throws IOException {
+        byte dataBytes[] = new byte[attrLength];
+        data.readFully(dataBytes);
+        return new CodeAttribute(attrName, dataBytes, new CodeEnv(pool));
+    } 
+
+    void write(DataOutputStream out) throws IOException {
+        out.writeShort(attrName().getIndex());
+        if (theDataBytes == null) {
+            buildInstructionBytes();
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            DataOutputStream tmpOut = new DataOutputStream(baos);
+            tmpOut.writeShort(maxStack);
+            tmpOut.writeShort(maxLocals);
+            tmpOut.writeInt(theCodeBytes.length);
+            tmpOut.write(theCodeBytes, 0, theCodeBytes.length);
+            exceptionTable.write(tmpOut);
+            codeAttributes.write(tmpOut);
+
+            tmpOut.flush();
+            byte tmpBytes[] = baos.toByteArray();
+            out.writeInt(tmpBytes.length);
+            out.write(tmpBytes, 0, tmpBytes.length);
+        } else {
+            out.writeInt(theDataBytes.length);
+            out.write(theDataBytes, 0, theDataBytes.length);
+        }
+    }
+
+    void print(PrintStream out, int indent) {
+        makeValid();
+        ClassPrint.spaces(out, indent);
+        out.print("Code:");
+        out.print(" max_stack = " + Integer.toString(maxStack));
+        out.print(" max_locals = " + Integer.toString(maxLocals));
+        out.println(" Exceptions:");
+        exceptionTable.print(out, indent+2);
+        ClassPrint.spaces(out, indent);
+        out.println("Code Attributes:");
+        codeAttributes.print(out, indent+2);
+
+        Insn insn = theCode();
+        if (insn != null) {
+            ClassPrint.spaces(out, indent);
+            out.println("Instructions:");
+            while (insn != null) {
+                insn.print(out, indent+2);
+                insn = insn.next();
+            }
+        }
+    }
+
+    /**
+     *  Assign offsets to instructions and return the number of bytes.
+     *  theCode must be non-null.
+     */
+    private int resolveOffsets() {
+        Insn insn = theCode;
+        int currPC = 0;
+        while (insn != null) {
+            currPC = insn.resolveOffset(currPC);
+            insn = insn.next();
+        }
+        return currPC;
+    }
+
+    int codeSize() {
+        makeValid();
+        return theCodeBytes.length;
+    }
+
+    /**
+     * Derive the instruction list from the instruction byte codes
+     */
+    private void buildInstructions(CodeEnv codeEnv) {
+        if (theCodeBytes != null) {
+            InsnReadEnv insnEnv = new InsnReadEnv(theCodeBytes, codeEnv);
+            theCode = insnEnv.getTarget(0);
+            Insn currInsn = theCode;
+
+            /* First, create instructions */
+            while (insnEnv.more()) {
+                Insn newInsn = Insn.read(insnEnv);
+                currInsn.setNext(newInsn);
+                currInsn = newInsn;
+            }
+
+            /* Now, insert targets */
+            InsnTarget targ;
+            currInsn = theCode;
+            Insn prevInsn = null;
+            while (currInsn != null) {
+                int off = currInsn.offset();
+
+                /* We always insert a target a 0 to start so ignore that one */
+                if (off > 0) {
+                    targ = codeEnv.findTarget(off);
+                    if (targ != null)
+                        prevInsn.setNext(targ);
+                }
+                prevInsn = currInsn;
+                currInsn = currInsn.next();
+            }
+
+            /* And follow up with a final target if needed */
+            targ = codeEnv.findTarget(insnEnv.currentPC());
+            if (targ != null)
+                prevInsn.setNext(targ);
+        }
+    }
+
+    /**
+     * Derive the instruction byte codes from the instruction list
+     * This should also recompute stack and variables but for now we
+     * assume that this isn't needed
+     */
+    private void buildInstructionBytes() {
+        if (theCode != null) {
+            /* Make sure instructions have correct offsets */
+            int size = resolveOffsets();
+            theCodeBytes = new byte[size];
+
+            Insn insn = theCode;
+            int index = 0;
+            while (insn != null) {
+                index = insn.store(theCodeBytes, index);
+                insn = insn.next();
+            }
+        }
+    }
+
+    /** If theDataBytes is non-null, disassemble this code attribute
+     *  from the data bytes. */
+    private void makeValid() {
+        if (theDataBytes != null) {
+            DataInputStream dis = new DataInputStream(
+		new ByteArrayInputStream(theDataBytes));
+            try {
+                maxStack = dis.readUnsignedShort();
+                maxLocals = dis.readUnsignedShort();
+                int codeLength = dis.readInt();
+                theCodeBytes = new byte[codeLength];
+                dis.readFully(theCodeBytes);
+                exceptionTable = ExceptionTable.read(dis, codeEnv);
+                codeAttributes = AttributeVector.readAttributes(dis, codeEnv);
+            } catch (java.io.IOException ioe) {
+                throw new ClassFormatError("IOException while reading code attribute");
+            }
+
+            theDataBytes = null;
+        }
+    }
+}
+

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeEnv.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeEnv.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeEnv.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/CodeEnv.java Sun May 22 10:55:51 2005
@@ -0,0 +1,54 @@
+/*
+ * 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.util.Hashtable;
+
+/**
+ * Environment in which to decode the attributes of a CodeAttribute.
+ */
+class CodeEnv {
+    /* The constant pool */
+    private ConstantPool constantPool;
+
+    /* hash table mapping byte code offset to InsnTarget */
+    private Hashtable targets = new Hashtable(7);
+
+    CodeEnv(ConstantPool constantPool) {
+        this.constantPool = constantPool;
+    }
+
+    final InsnTarget getTarget(int offset) {
+        Integer off = new Integer(offset);
+        InsnTarget targ = (InsnTarget)targets.get(off);
+        if (targ == null) {
+            targ = new InsnTarget(offset);
+            targets.put(off, targ);
+        }
+        return targ;
+    }
+
+    final InsnTarget findTarget(int offset) {
+        Integer off = new Integer(offset);
+        return (InsnTarget)targets.get(off);
+    }
+
+    final ConstantPool pool() {
+        return constantPool;
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasic.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasic.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasic.java Sun May 22 10:55:51 2005
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+/**
+ * Abstract base class of the types which represent entries in
+ * the class constant pool.
+ */
+abstract public class ConstBasic implements VMConstants {
+    /* The index of the constant entry in the constant pool */
+    protected int index = 0;
+
+    /* public accessors */
+
+    /* Get the index of this constant entry */
+    public int getIndex() { return index; }
+
+    /* Return the type of the constant entry - see VMConstants */
+    public abstract int tag();
+
+    /* package local methods */
+
+    /**
+     * Sets the index of this constant with its containing constant pool
+     */
+    void setIndex(int ind) { index = ind; }
+
+    /**
+     * Write this Constant pool entry to the output stream
+     */
+    abstract void formatData(DataOutputStream b) throws IOException;
+
+    /**
+     * Resolve integer index references to the actual constant pool
+     * entries that they represent.  This is used during class file 
+     * reading because a constant pool entry could have a forward
+     * reference to a higher numbered constant.
+     */
+    abstract void resolve(ConstantPool p);
+
+    /**
+     * Return the index of this constant in the constant pool as
+     * a decimal formatted String.
+     */
+    String indexAsString() { return Integer.toString(index); }
+
+    /**
+     * The constructor for subtypes
+     */
+    ConstBasic() {}
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstBasic)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstBasic other = (ConstBasic)obj;
+
+        return true;
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasicMemberRef.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasicMemberRef.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasicMemberRef.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstBasicMemberRef.java Sun May 22 10:55:51 2005
@@ -0,0 +1,124 @@
+/*
+ * 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;
+
+/**
+ * The abstract base class used to represent the various type of
+ * references to members (fields/methods) within the constant pool. 
+ */
+public abstract class ConstBasicMemberRef extends ConstBasic {
+    /* The name of the class on which the member is defined */
+    protected ConstClass theClassName;
+
+    /* The index of the class on which the member is defined
+     *   - used temporarily while reading from a class file */
+    protected int theClassNameIndex;
+
+    /* The name and type of the member */
+    protected ConstNameAndType theNameAndType;
+
+    /* The index of the name and type of the member
+     *   - used temporarily while reading from a class file */
+    protected int theNameAndTypeIndex;
+
+    /* public accessors */
+
+    /**
+     * Return the name of the class defining the member 
+     */
+    public ConstClass className() {
+        return theClassName;
+    }
+
+    /**
+     * Return the name and type of the member 
+     */
+    public ConstNameAndType nameAndType() {
+        return theNameAndType;
+    }
+
+    public String toString () {
+        return "className(" + theClassName.toString() + ")" +
+            " nameAndType(" + theNameAndType.toString() + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstBasicMemberRef)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstBasicMemberRef other = (ConstBasicMemberRef)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.theClassName.isEqual(msg, other.theClassName)) {
+            msg.push(String.valueOf("theClassName = "
+                                    + other.theClassName));
+            msg.push(String.valueOf("theClassName = "
+                                    + this.theClassName));
+            return false;
+        }
+        if (!this.theNameAndType.isEqual(msg, other.theNameAndType)) {
+            msg.push(String.valueOf("theNameAndType = "
+                                    + other.theNameAndType));
+            msg.push(String.valueOf("theNameAndType = "
+                                    + this.theNameAndType));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    /**
+     * Constructor for "from scratch" creation
+     */
+    ConstBasicMemberRef (ConstClass cname, ConstNameAndType NT) {
+        theClassName = cname;
+        theNameAndType = NT;
+    }
+
+    /**
+     * Constructor for reading from a class file
+     */
+    ConstBasicMemberRef (int cnameIndex, int NT_index) {
+        theClassNameIndex = cnameIndex;
+        theNameAndTypeIndex = NT_index;
+    }
+
+    void formatData (DataOutputStream b) throws IOException {
+        b.writeShort(theClassName.getIndex());
+        b.writeShort(theNameAndType.getIndex());
+    }
+    void resolve (ConstantPool p) {
+        theClassName = (ConstClass) p.constantAt(theClassNameIndex);
+        theNameAndType = (ConstNameAndType) p.constantAt(theNameAndTypeIndex);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java Sun May 22 10:55:51 2005
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+/**
+ * Class representing a class reference in the constant pool
+ */
+public class ConstClass extends ConstBasic {
+    /* The tag associated with ConstClass entries */
+    public static final int MyTag = CONSTANTClass;
+
+    /* The name of the class being referred to */
+    private ConstUtf8 theClassName;
+
+    /* The index of name of the class being referred to
+     *  - used while reading from a class file */
+    private int theClassNameIndex;
+
+    /* public accessors */
+
+    /**
+     * Return the tag for this constant
+     */
+    public int tag() { return MyTag; }
+
+    /**
+     * Return the class name
+     */
+    public ConstUtf8 className() {
+        return theClassName;
+    }
+
+    /**
+     * Return the class name in simple string form
+     */
+    public String asString() {
+        return theClassName.asString();
+    }
+
+    /**
+     * A printable representation 
+     */
+    public String toString() {
+        return "CONSTANTClass(" + indexAsString() + "): " + 
+            "className(" + theClassName.toString() + ")";
+    }
+
+    /**
+     * Change the class reference (not to be done lightly)
+     */
+    public void changeClass(ConstUtf8 newName) {
+        theClassName = newName;
+        theClassNameIndex = newName.getIndex();
+    }
+
+    /**
+     * Construct a ConstClass
+     */
+    public ConstClass(ConstUtf8 cname) {
+        theClassName = cname;
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstClass)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstClass other = (ConstClass)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.theClassName.isEqual(msg, other.theClassName)) {
+            msg.push(String.valueOf("theClassName = "
+                                    + other.theClassName));
+            msg.push(String.valueOf("theClassName = "
+                                    + this.theClassName));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstClass(int cname) {
+        theClassNameIndex = cname;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeShort(theClassName.getIndex());
+    }
+
+    static ConstClass read(DataInputStream input) throws IOException {
+        return new ConstClass(input.readUnsignedShort());
+    }
+
+    void resolve(ConstantPool p) {
+        theClassName = (ConstUtf8)p.constantAt(theClassNameIndex);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstDouble.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstDouble.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstDouble.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstDouble.java Sun May 22 10:55:51 2005
@@ -0,0 +1,110 @@
+/*
+ * 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;
+
+/**
+ * Class representing a double constant in the constant pool of a class file
+ */
+public class ConstDouble extends ConstValue {
+    /* The tag value associated with ConstDouble */
+    public static final int MyTag = CONSTANTDouble;
+
+    /* The value */
+    private double doubleValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag() {
+        return MyTag;
+    }
+
+    /**
+     * return the value associated with the entry
+     */
+    public double value() {
+        return doubleValue;
+    }
+
+    /**
+     * Return the descriptor string for the constant type.
+     */
+    public String descriptor() {
+        return "D";
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString() {
+        return "CONSTANTDouble(" + indexAsString() + "): " + 
+            "doubleValue(" + Double.toString(doubleValue) + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstDouble)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstDouble other = (ConstDouble)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.doubleValue != other.doubleValue) {
+            msg.push(String.valueOf("doubleValue = "
+                                    + other.doubleValue));
+            msg.push(String.valueOf("doubleValue = "
+                                    + this.doubleValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    /**
+     * Construct a ConstDouble object 
+     */
+    ConstDouble(double f) {
+        doubleValue = f;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeDouble(doubleValue);
+    }
+
+    static ConstDouble read(DataInputStream input) throws IOException {
+        return new ConstDouble(input.readDouble());
+    }
+
+    void resolve(ConstantPool p) { }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFieldRef.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFieldRef.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFieldRef.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFieldRef.java Sun May 22 10:55:51 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.*;
+
+/**
+ * ConstFieldRef represents a reference to a field of some class
+ * in the constant pool of a class file.
+ */
+public class ConstFieldRef extends ConstBasicMemberRef {
+    /* The tag associated with ConstFieldRef */
+    public static final int MyTag = CONSTANTFieldRef;
+
+    /* public accessors */
+    public int tag () { return MyTag; }
+
+    public String toString () {
+        return "CONSTANTFieldRef(" + indexAsString() + "): " + 
+            super.toString();
+    }
+
+    /* package local methods */
+
+    ConstFieldRef (ConstClass cname, ConstNameAndType NT) {
+        super(cname, NT);
+    }
+
+    ConstFieldRef (int cnameIndex, int NT_index) {
+        super(cnameIndex, NT_index);
+    }
+
+    static ConstFieldRef read (DataInputStream input) throws IOException {
+        int cname = input.readUnsignedShort();
+        int NT = input.readUnsignedShort();
+        return new ConstFieldRef (cname, NT);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFloat.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFloat.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFloat.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstFloat.java Sun May 22 10:55:51 2005
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+/**
+ * Class representing a float constant in the constant pool of a class file
+ */
+public class ConstFloat extends ConstValue {
+    /* The tag value associated with ConstFloat */
+    public static final int MyTag = CONSTANTFloat;
+
+    /* The value */
+    private float floatValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag() { return MyTag; }
+
+    /**
+     * return the value associated with the entry
+     */
+    public float value() {
+        return floatValue;
+    }
+
+    /**
+     * Return the descriptor string for the constant type.
+     */
+    public String descriptor() {
+        return "F";
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString() {
+        return "CONSTANTFloat(" + indexAsString() + "): " + 
+            "floatValue(" + Float.toString(floatValue) + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstFloat)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstFloat other = (ConstFloat)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.floatValue != other.floatValue) {
+            msg.push(String.valueOf("floatValue = "
+                                    + other.floatValue));
+            msg.push(String.valueOf("floatValue = "
+                                    + this.floatValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstFloat(float f) {
+        floatValue = f;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeFloat(floatValue);
+    }
+
+    static ConstFloat read(DataInputStream input) throws IOException {
+        return new ConstFloat(input.readFloat());
+    }
+
+    void resolve(ConstantPool p) { }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInteger.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInteger.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInteger.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInteger.java Sun May 22 10:55:51 2005
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+/**
+ * Class representing an integer constant in the constant pool of a class file
+ */
+public class ConstInteger extends ConstValue {
+    /* The tag value associated with ConstInteger */
+    public static final int MyTag = CONSTANTInteger;
+
+    /* The value */
+    private int intValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag() { return MyTag; }
+
+    /**
+     * return the value associated with the entry
+     */
+    public int value() {
+        return intValue;
+    }
+
+    /**
+     * Return the descriptor string for the constant type.
+     */
+    public String descriptor() {
+        return "I";
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString() {
+        return "CONSTANTInteger(" + indexAsString() + "): " + 
+            "intValue(" + Integer.toString(intValue) + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstInteger)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstInteger other = (ConstInteger)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.intValue != other.intValue) {
+            msg.push(String.valueOf("intValue = "
+                                    + other.intValue));
+            msg.push(String.valueOf("intValue = "
+                                    + this.intValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstInteger(int i) {
+        intValue = i;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeInt(intValue);
+    }
+
+    static ConstInteger read(DataInputStream input) throws IOException {
+        return new ConstInteger(input.readInt());
+    }
+
+    void resolve(ConstantPool p) { }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInterfaceMethodRef.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInterfaceMethodRef.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInterfaceMethodRef.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstInterfaceMethodRef.java Sun May 22 10:55:51 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.*;
+
+/**
+ * Class representing a reference to an interface method of some class
+ * in the constant pool of a class file.
+ */
+public class ConstInterfaceMethodRef extends ConstBasicMemberRef {
+    /* The tag value associated with ConstDouble */
+    public static final int MyTag = CONSTANTInterfaceMethodRef;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag () { return MyTag; }
+
+    /**
+     * A printable representation
+     */
+    public String toString () {
+        return "CONSTANTInterfaceMethodRef(" + indexAsString() + "): " + 
+            super.toString();
+    }
+
+    /* package local methods */
+
+    ConstInterfaceMethodRef (ConstClass cname, ConstNameAndType NT) {
+        super(cname, NT);
+    }
+
+    ConstInterfaceMethodRef (int cnameIndex, int NT_index) {
+        super(cnameIndex, NT_index);
+    }
+
+    static ConstInterfaceMethodRef read (DataInputStream input) 
+        throws IOException {
+        int cname = input.readUnsignedShort();
+        int NT = input.readUnsignedShort();
+        return new ConstInterfaceMethodRef (cname, NT);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstLong.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstLong.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstLong.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstLong.java Sun May 22 10:55:51 2005
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+/**
+ * Class representing a long constant in the constant pool of a class file
+ */
+public class ConstLong extends ConstValue {
+    /* The tag value associated with ConstLong */
+    public static final int MyTag = CONSTANTLong;
+
+    /* The value */
+    private long longValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag() { return MyTag; }
+
+    /**
+     * return the value associated with the entry
+     */
+    public long value() {
+        return longValue;
+    }
+
+    /**
+     * Return the descriptor string for the constant type.
+     */
+    public String descriptor() {
+        return "J";
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString() {
+        return "CONSTANTLong(" + indexAsString() + "): " + 
+            "longValue(" + Long.toString(longValue) + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstLong)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstLong other = (ConstLong)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (this.longValue != other.longValue) {
+            msg.push(String.valueOf("longValue = "
+                                    + other.longValue));
+            msg.push(String.valueOf("longValue = "
+                                    + this.longValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstLong(long i) {
+        longValue = i;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeLong(longValue);
+    }
+
+    static ConstLong read(DataInputStream input) throws IOException {
+        return new ConstLong(input.readLong());
+    }
+
+    void resolve(ConstantPool p) { }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstMethodRef.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstMethodRef.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstMethodRef.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstMethodRef.java Sun May 22 10:55:51 2005
@@ -0,0 +1,60 @@
+/*
+ * 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.*;
+
+/**
+ * Class representing a reference to a method of some class in the
+ * constant pool of a class file
+ */
+public class ConstMethodRef extends ConstBasicMemberRef {
+    /* The tag value associated with ConstMethodRef */
+    public static final int MyTag = CONSTANTMethodRef;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag () { return MyTag; }
+
+    /**
+     * A printable representation
+     */
+    public String toString () {
+        return "CONSTANTMethodRef(" + indexAsString() + "): " + 
+            super.toString();
+    }
+
+    /* package local methods */
+
+    ConstMethodRef (ConstClass cname, ConstNameAndType NT) {
+        super(cname, NT);
+    }
+
+    ConstMethodRef (int cnameIndex, int NT_index) {
+        super(cnameIndex, NT_index);
+    }
+
+    static ConstMethodRef read (DataInputStream input) throws IOException {
+        int cname = input.readUnsignedShort();
+        int NT = input.readUnsignedShort();
+        return new ConstMethodRef (cname, NT);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstNameAndType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstNameAndType.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstNameAndType.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstNameAndType.java Sun May 22 10:55:51 2005
@@ -0,0 +1,143 @@
+/*
+ * 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;
+
+/**
+ * Class representing a name and an associated type in the constant pool
+ * of a class file
+ */
+public class ConstNameAndType extends ConstBasic {
+    /* The tag value associated with ConstDouble */
+    public static final int MyTag = CONSTANTNameAndType;
+
+    /* The name of interest */
+    private ConstUtf8 theName;
+
+    /* The index of the name to be resolved
+     *   - used during class file reading */
+    private int theNameIndex;
+
+    /* The type signature associated with the name */
+    private ConstUtf8 typeSignature;
+
+    /* The index of the signature to be resolved
+     *   - used during class file reading */
+    private int typeSignatureIndex;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag () { return MyTag; }
+
+    /**
+     * Return the name
+     */
+    public ConstUtf8 name() {
+        return theName;
+    }
+
+    /**
+     * Return the type signature associated with the name
+     */
+    public ConstUtf8 signature() {
+        return typeSignature;
+    }
+
+    /**
+     * Modify the signature
+     */
+    public void changeSignature(ConstUtf8 newSig) {
+        typeSignature = newSig;
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString () {
+        return "CONSTANTNameAndType(" + indexAsString() + "): " + 
+            "name(" + theName.toString() + ") " +
+            " type(" + typeSignature.toString() + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstNameAndType)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstNameAndType other = (ConstNameAndType)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.theName.isEqual(msg, other.theName)) {
+            msg.push(String.valueOf("theName = "
+                                    + other.theName));
+            msg.push(String.valueOf("theName = "
+                                    + this.theName));
+            return false;
+        }
+        if (!this.typeSignature.isEqual(msg, other.typeSignature)) {
+            msg.push(String.valueOf("typeSignature = "
+                                    + other.typeSignature));
+            msg.push(String.valueOf("typeSignature = "
+                                    + this.typeSignature));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstNameAndType (ConstUtf8 n, ConstUtf8 sig) {
+        theName = n; typeSignature = sig;
+    }
+
+    ConstNameAndType (int n, int sig) {
+        theNameIndex = n; typeSignatureIndex = sig;
+    }
+
+    void formatData (DataOutputStream b) throws IOException {
+        b.writeShort(theName.getIndex());
+        b.writeShort(typeSignature.getIndex());
+    }
+
+    static ConstNameAndType read (DataInputStream input) throws IOException {
+        int cname = input.readUnsignedShort();
+        int sig = input.readUnsignedShort();
+
+        return new ConstNameAndType (cname, sig);
+    }
+
+    void resolve (ConstantPool p) {
+        theName = (ConstUtf8) p.constantAt(theNameIndex);
+        typeSignature = (ConstUtf8) p.constantAt(typeSignatureIndex);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstString.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstString.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstString.java Sun May 22 10:55:51 2005
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+/**
+ * Class representing a class specification in the constant pool
+ *
+ * ConstString strictly speaking is not a ConstantValue in the
+ * Java VM sense.  However, the compiler generates ConstantValue attributes
+ * which refer to ConstString entries.  This occurs for initialized static
+ * final String fields.  I've changed ConstString to be a ConstValue for 
+ * now as a simplification.
+ */
+public class ConstString extends ConstValue {
+    /* The tag associated with ConstClass entries */
+    public static final int MyTag = CONSTANTString;
+
+    /* The name of the class being referred to */
+    private ConstUtf8 stringValue;
+
+    /* The index of name of the class being referred to
+     *  - used while reading from a class file */
+    private int stringValueIndex;
+
+    /* public accessors */
+
+    /**
+     * Return the tag for this constant
+     */
+    public int tag() { return MyTag; }
+
+    /**
+     * Return the utf8 string calue
+     */
+    public ConstUtf8 value() {
+        return stringValue;
+    }
+
+    /**
+     * Return the descriptor string for the constant type.
+     */
+    public String descriptor() {
+        return "Ljava/lang/String;";
+    }
+
+    /**
+     * A printable representation 
+     */
+    public String toString() {
+        return "CONSTANTString(" + indexAsString() + "): " + 
+            "string(" + stringValue.asString() + ")";
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstString)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstString other = (ConstString)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.stringValue.isEqual(msg, other.stringValue)) {
+            msg.push(String.valueOf("stringValue = "
+                                    + other.stringValue));
+            msg.push(String.valueOf("stringValue = "
+                                    + this.stringValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstString(ConstUtf8 s) {
+        stringValue = s;
+    }
+
+    ConstString(int sIndex) {
+        stringValueIndex = sIndex;
+    }
+
+    void formatData(DataOutputStream b) throws IOException {
+        b.writeShort(stringValue.getIndex());
+    }
+    static ConstString read(DataInputStream input) throws IOException {
+        return new ConstString(input.readUnsignedShort());
+    }
+    void resolve(ConstantPool p) {
+        stringValue = (ConstUtf8) p.constantAt(stringValueIndex);
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUnicode.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUnicode.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUnicode.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUnicode.java Sun May 22 10:55:51 2005
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+/**
+ * Class representing a unicode string value in the constant pool
+ *
+ * Note: evidence suggests that this is no longer part of the java VM
+ * spec.
+ */
+public class ConstUnicode extends ConstBasic {
+    /* The tag associated with ConstClass entries */
+    public static final int MyTag = CONSTANTUnicode;
+ 
+    /* The unicode string of interest */
+    private String stringValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag () { return MyTag; }
+
+    /**
+     * return the value associated with the entry
+     */
+    public String asString() {
+        return stringValue;
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString () {
+        return "CONSTANTUnicode(" + indexAsString() + "): " + stringValue;
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstUnicode)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstUnicode other = (ConstUnicode)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.stringValue.equals(other.stringValue)) {
+            msg.push(String.valueOf("stringValue = "
+                                    + other.stringValue));
+            msg.push(String.valueOf("stringValue = "
+                                    + this.stringValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstUnicode (String s) {
+        stringValue = s;
+    }
+
+    void formatData (DataOutputStream b) throws IOException {
+        b.writeBytes(stringValue);
+    }
+
+    static ConstUnicode read (DataInputStream input) throws IOException {
+        int count = input.readShort(); // Is this chars or bytes?
+        StringBuffer b = new StringBuffer();
+        for (int i=0; i < count; i++) { 
+            b.append(input.readChar());
+        }
+        return new ConstUnicode (b.toString());
+    }
+
+    void resolve (ConstantPool p) {
+    }
+}

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUtf8.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUtf8.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUtf8.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstUtf8.java Sun May 22 10:55:51 2005
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+/**
+ * Class representing a utf8 string value in the constant pool
+ */
+public class ConstUtf8 extends ConstBasic {
+    /* The tag associated with ConstClass entries */
+    public static final int MyTag = CONSTANTUtf8;
+ 
+    /* The unicode string of interest */
+    private String stringValue;
+
+    /* public accessors */
+
+    /**
+     * The tag of this constant entry
+     */
+    public int tag () { return MyTag; }
+
+    /**
+     * return the value associated with the entry
+     */
+    public String asString () {
+        return stringValue;
+    }
+
+    /**
+     * A printable representation
+     */
+    public String toString () {
+        return "CONSTANTUtf8(" + indexAsString() + "): " + asString();
+    }
+
+    /**
+     * Compares this instance with another for structural equality.
+     */
+    //@olsen: added method
+    public boolean isEqual(Stack msg, Object obj) {
+        if (!(obj instanceof ConstUtf8)) {
+            msg.push("obj/obj.getClass() = "
+                     + (obj == null ? null : obj.getClass()));
+            msg.push("this.getClass() = "
+                     + this.getClass());
+            return false;
+        }
+        ConstUtf8 other = (ConstUtf8)obj;
+
+        if (!super.isEqual(msg, other)) {
+            return false;
+        }
+
+        if (!this.stringValue.equals(other.stringValue)) {
+            msg.push(String.valueOf("stringValue = "
+                                    + other.stringValue));
+            msg.push(String.valueOf("stringValue = "
+                                    + this.stringValue));
+            return false;
+        }
+        return true;
+    }
+
+    /* package local methods */
+
+    ConstUtf8 (String s) {
+        stringValue = s;
+    }
+
+    void formatData (DataOutputStream b) throws IOException {
+        b.writeUTF(stringValue);
+    }
+
+    static ConstUtf8 read (DataInputStream input) throws IOException {
+        return new ConstUtf8 (input.readUTF());
+    }
+
+    void resolve (ConstantPool p) {
+    }
+}
+
+

Added: incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstValue.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstValue.java?rev=171351&view=auto
==============================================================================
--- incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstValue.java (added)
+++ incubator/jdo/trunk/enhancer20/src/java/org/apache/jdo/impl/enhancer/classfile/ConstValue.java Sun May 22 10:55:51 2005
@@ -0,0 +1,37 @@
+/*
+ * 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.*;
+
+/**
+ * An abstract class serving as a common type for constants which
+ * can be the target of ConstantValue attributes
+ */
+
+public abstract class ConstValue extends ConstBasic {
+  /**
+   * The constructor
+   */
+  ConstValue() { }
+
+  /**
+   * Return the descriptor string for the constant type.
+   */
+  public abstract String descriptor();
+}



Mime
View raw message