Please review the attached patch for the JDO11 RI enhancer support
for JDK1.5 classfiles.
There's an open issue whether Signature attributes have to be
supplied for augmented JDO methods that carry the type of managed
fields or the PC class as parameter or return. This patch provides
support for SignatureAttribute in the enhancer's classfile library
but does not have the changes to the enhancer's core component to
generate signatures for the JDO accessor, mutator, and jdoCopyField
methods. Once resolved, we might address this by a second patch.
Martin
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnConstOp.java
(working copy)
@@ -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)))
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMOp.java
(working copy)
@@ -474,8 +474,10 @@
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 */
+ /*new VMOp(opc_xxxunusedxxx, "xxxunusedxxx", 0, 0, "", ""),*/
+ /* 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 */
Index:
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
===================================================================
---
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
(revision 0)
+++
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
(revision 0)
@@ -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());
+ }
+}
+
Property changes on:
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SignatureAttribute.java
___________________________________________________________________
Name: svn:executable
+ *
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassAttribute.java
(working copy)
@@ -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;
Index:
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
===================================================================
---
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
(revision 329186)
+++
ri11/src/java/org/apache/jdo/impl/enhancer/classfile/SyntheticAttribute.java
(working copy)
@@ -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 */
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassFile.java
(working copy)
@@ -40,11 +40,19 @@
/[EMAIL PROTECTED] 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);
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassMethod.java
(working copy)
@@ -43,9 +43,8 @@
private ConstUtf8 methodSignature;
/* The attributes associated with the field */
- private AttributeVector methodAttributes;
+ private AttributeVector methodAttributes;
-
/* public accessors */
/**
@@ -112,6 +111,16 @@
}
/**
+ * 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;
+ }
+
+ /**
* Construct a class method object
*/
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/Insn.java
(working copy)
@@ -476,7 +476,8 @@
case opc_dreturn:
case opc_areturn:
case opc_return:
- case opc_xxxunusedxxx:
+ //@olsen: JDK1.5: support for new opcode invokedynamic
+ //case opc_xxxunusedxxx:
case opc_arraylength:
case opc_athrow:
case opc_monitorenter:
@@ -496,6 +497,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:
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ClassField.java
(working copy)
@@ -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;
-
+ /* The attributes associated with the field */
+ private AttributeVector fieldAttributes;
- /* public accessors */
+ /* public accessors */
- /**
- * Is the field transient?
- */
- public boolean isTransient() {
- return (accessFlags & ACCTransient) != 0;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
- }
+ /**
+ * Return the name of the field
+ */
+ public ConstUtf8 name() {
+ return fieldName;
+ }
- /**
- * Change the name of the field
- */
- public void changeName(ConstUtf8 name) {
- fieldName = name;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
- }
+ /**
+ * 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;
+ }
- /* package local methods */
+ /**
+ * 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;
+ }
- 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;
- }
+ /* package local methods */
- void write (DataOutputStream data) throws IOException {
- data.writeShort(accessFlags);
- data.writeShort(fieldName.getIndex());
- data.writeShort(fieldSignature.getIndex());
- fieldAttributes.write(data);
- }
+ 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 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);
- }
+ 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);
+ }
}
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/InsnSingle.java
(working copy)
@@ -254,7 +254,8 @@
case opc_dreturn:
case opc_areturn:
case opc_return:
- case opc_xxxunusedxxx:
+ //@olsen: JDK1.5: support for new opcode invokedynamic
+ //case opc_xxxunusedxxx:
case opc_arraylength:
case opc_athrow:
case opc_monitorenter:
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstClass.java
(working copy)
@@ -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() = "
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/VMConstants.java
(working copy)
@@ -25,20 +25,27 @@
*/
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 */
static final int T_BOOLEAN = 4;
@@ -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,9 @@
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_xxxunusedxxx = 186;
+ final static int opc_invokedynamic = 186;
final static int opc_new = 187;
final static int opc_newarray = 188;
final static int opc_anewarray = 189;
Index: ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
===================================================================
--- ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
(revision 329186)
+++ ri11/src/java/org/apache/jdo/impl/enhancer/classfile/ConstantPool.java
(working copy)
@@ -426,6 +426,9 @@
case CONSTANTNameAndType:
nameAndTypeTable.addElement(c);
break;
+ default:
+ throw new ClassFormatError("Don't know this constant type: " +
+ c.toString());
}
}
}