vmconstmemberref.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 102 行
JAVA
102 行
/**
* $Id: VmConstMemberRef.java,v 1.4 2004/02/24 08:04:15 epr Exp $
*/
package org.jnode.vm.classmgr;
/**
* Abstract entry of a constantpool describing an member (method or field) reference.
*
* @author epr
*/
public abstract class VmConstMemberRef extends VmConstObject {
private int classIndex;
private int nameTypeIndex;
private int cachedHashCode;
public VmConstMemberRef(VmCP cp, int classIndex, int nameTypeIndex) {
super(cp);
this.classIndex = classIndex;
this.nameTypeIndex = nameTypeIndex;
}
/**
* Gets the ConstClass this member constants refers to.
* @return VmConstClass
*/
public final VmConstClass getConstClass() {
return cp.getConstClass(classIndex);
}
/**
* Gets the ConstNameType this member constants refers to.
* @return VmConstNameAndType
*/
private final VmConstNameAndType getNameAndType() {
return cp.getConstNameAndType(nameTypeIndex);
}
/**
* Gets the name of the class of the members this constants refers to.
* @return String
*/
public final String getClassName() {
return getConstClass().getClassName();
}
/**
* Gets the name of the members this constants refers to.
* @return String
*/
public final String getName() {
return getNameAndType().getName();
}
/**
* Gets the type descriptor of the members this constants refers to.
* @return String
*/
public final String getSignature() {
return getNameAndType().getDescriptor();
}
/**
* Resolve the references of this constant to loaded VmXxx objects.
* @param clc
*/
protected final void doResolve(VmClassLoader clc) {
getConstClass().resolve(clc);
doResolveMember(clc);
cachedHashCode = VmMember.calcHashCode(getName(), getSignature());
}
/**
* Resolve the references of this constant to loaded VmXxx objects.
* @param clc
*/
protected abstract void doResolveMember(VmClassLoader clc);
/**
* Convert myself into a String representation
* @see java.lang.Object#toString()
* @return String
*/
public final String toString() {
String type = getClass().getName();
type = type.substring(type.lastIndexOf('.') + 1 + 2);
return type + ": " + getClassName() + "." + getName() + " [" + getSignature() + "]";
}
/**
* @see java.lang.Object#hashCode()
* @return int
*/
public final int getMemberHashCode() {
if (cachedHashCode == 0) {
cachedHashCode = VmMember.calcHashCode(getName(), getSignature());
}
return cachedHashCode;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?