Browse Source

Add the ability to change the signature of a constant pool methodref entry.

This is useful for JDK5 to 1.4 mapping, e.g.
java.lang.String.clone()Ljava.lang.String; -> java.lang.String.clone()Ljava.lang.Object;


git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@250 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
tags/rel_3_17_1_ga
adrian 18 years ago
parent
commit
efa62f09d0
1 changed files with 57 additions and 0 deletions
  1. 57
    0
      src/main/javassist/bytecode/ConstPool.java

+ 57
- 0
src/main/javassist/bytecode/ConstPool.java View File

@@ -361,6 +361,28 @@ public final class ConstPool {
}
}

/**
* Changed the Utf8Info of the <code>name_index</code> field of the
* <code>CONSTANT_NameAndType_info</code> structure
* indirectly specified by the given index.
*
* @param index an index to a <code>CONSTANT_Methodref_info</code>.
* @param string the new Utf8 string
*/
public void setMethodrefType(int index, String string) {
MethodrefInfo minfo = (MethodrefInfo)getItem(index);
if (minfo == null)
throw new IllegalArgumentException("Not a Methodref_info " + index);
else {
NameAndTypeInfo n
= (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
if(n == null)
throw new IllegalStateException("Unable to find NameAndTypeInfo " + index);
else
setUtf8Info(n.typeDescriptor, string);
}
}

/**
* Reads the <code>class_index</code> field of the
* <code>CONSTANT_InterfaceMethodref_info</code> structure
@@ -443,6 +465,29 @@ public final class ConstPool {
return getUtf8Info(n.typeDescriptor);
}
}
/**
* Changed the Utf8Info of the <code>name_index</code> field of the
* <code>CONSTANT_NameAndType_info</code> structure
* indirectly specified by the given index.
*
* @param index an index to a <code>CONSTANT_Methodref_info</code>.
* @param string the new Utf8 string
*/
public void setInterfaceMethodrefType(int index, String string) {
InterfaceMethodrefInfo minfo = (InterfaceMethodrefInfo)getItem(index);
if (minfo == null)
throw new IllegalArgumentException("Not an InterfaceMethodref_info " + index);
else {
NameAndTypeInfo n
= (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
if(n == null)
throw new IllegalStateException("Unable to find NameAndTypeInfo " + index);
else
setUtf8Info(n.typeDescriptor, string);
}
}

/**
* Reads <code>CONSTANT_Integer_info</code>, <code>_Float_info</code>,
* <code>_Long_info</code>, <code>_Double_info</code>, or
@@ -537,6 +582,18 @@ public final class ConstPool {
return utf.string;
}

/**
* Sets <code>CONSTANT_utf8_info</code> structure
* at the given index.
*
* @param index the index
* @param string the string specified by this entry.
*/
public void setUtf8Info(int index, String string) {
Utf8Info utf = (Utf8Info)getItem(index);
utf.string = string;
}

/**
* Determines whether <code>CONSTANT_Methodref_info</code>
* structure at the given index represents the constructor

Loading…
Cancel
Save