< prev index next >
src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FieldOrMethod.java
Print this page
*** 29,47 ****
/**
* Super class for InvokeInstruction and FieldInstruction, since they have
* some methods in common!
*
- * @version $Id$
*/
public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
/**
* Empty constructor needed for Instruction.readInstruction.
* Not to be used otherwise.
*/
FieldOrMethod() {
}
/**
* @param index to constant pool
--- 29,47 ----
/**
* Super class for InvokeInstruction and FieldInstruction, since they have
* some methods in common!
*
*/
public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
/**
* Empty constructor needed for Instruction.readInstruction.
* Not to be used otherwise.
*/
FieldOrMethod() {
+ // no init
}
/**
* @param index to constant pool
*** 51,71 ****
}
/** @return signature of referenced method/field.
*/
! public String getSignature( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
}
/** @return name of referenced method/field.
*/
! public String getName( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
}
--- 51,71 ----
}
/** @return signature of referenced method/field.
*/
! public String getSignature(final ConstantPoolGen cpg) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
}
/** @return name of referenced method/field.
*/
! public String getName(final ConstantPoolGen cpg) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
}
*** 81,91 ****
* the {@link #getReferenceType(ConstantPoolGen)} method, which correctly distinguishes
* between class types and array types.
*
*/
@Deprecated
! public String getClassName( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
if (className.startsWith("[")) {
// Turn array classes into java.lang.Object.
--- 81,91 ----
* the {@link #getReferenceType(ConstantPoolGen)} method, which correctly distinguishes
* between class types and array types.
*
*/
@Deprecated
! public String getClassName(final ConstantPoolGen cpg) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
if (className.startsWith("[")) {
// Turn array classes into java.lang.Object.
*** 99,122 ****
* @deprecated If the instruction references an array class,
* the ObjectType returned will be invalid. Use
* getReferenceType() instead.
*/
@Deprecated
! public ObjectType getClassType( final ConstantPoolGen cpg ) {
return ObjectType.getInstance(getClassName(cpg));
}
/**
! * Return the reference type representing the class, interface,
* or array class referenced by the instruction.
* @param cpg the ConstantPoolGen used to create the instruction
* @return an ObjectType (if the referenced class type is a class
* or interface), or an ArrayType (if the referenced class
* type is an array class)
*/
! public ReferenceType getReferenceType( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
if (className.startsWith("[")) {
return (ArrayType) Type.getType(className);
--- 99,122 ----
* @deprecated If the instruction references an array class,
* the ObjectType returned will be invalid. Use
* getReferenceType() instead.
*/
@Deprecated
! public ObjectType getClassType(final ConstantPoolGen cpg) {
return ObjectType.getInstance(getClassName(cpg));
}
/**
! * Gets the reference type representing the class, interface,
* or array class referenced by the instruction.
* @param cpg the ConstantPoolGen used to create the instruction
* @return an ObjectType (if the referenced class type is a class
* or interface), or an ArrayType (if the referenced class
* type is an array class)
*/
! public ReferenceType getReferenceType(final ConstantPoolGen cpg) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
if (className.startsWith("[")) {
return (ArrayType) Type.getType(className);
*** 125,143 ****
return ObjectType.getInstance(className);
}
/**
! * Get the ObjectType of the method return or field.
*
* @return type of the referenced class/interface
* @throws ClassGenException when the field is (or method returns) an array,
*/
@Override
! public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
final ReferenceType rt = getReferenceType(cpg);
! if(rt instanceof ObjectType) {
! return (ObjectType)rt;
}
! throw new ClassGenException(rt.getSignature() + " does not represent an ObjectType");
}
}
--- 125,144 ----
return ObjectType.getInstance(className);
}
/**
! * Gets the ObjectType of the method return or field.
*
* @return type of the referenced class/interface
* @throws ClassGenException when the field is (or method returns) an array,
*/
@Override
! public ObjectType getLoadClassType(final ConstantPoolGen cpg) {
final ReferenceType rt = getReferenceType(cpg);
! if (rt instanceof ObjectType) {
! return (ObjectType) rt;
}
! throw new ClassGenException(rt.getClass().getCanonicalName() + " " +
! rt.getSignature() + " does not represent an ObjectType");
}
}
< prev index next >