vmconstclass.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 82 行
JAVA
82 行
/**
* $Id: VmConstClass.java,v 1.4 2004/02/24 08:04:15 epr Exp $
*/
package org.jnode.vm.classmgr;
/**
* Entry of a constantpool describing a class reference.
*
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public class VmConstClass extends VmConstObject {
/** The cp index of the name of the class */
private int nameIndex;
/** The resolved class */
private VmType vmClass;
private String name;
public VmConstClass(VmCP cp, int nameIndex) {
super(cp);
this.nameIndex = nameIndex;
}
/**
* Gets the name of the class this constant is a reference to
* @return String
*/
public String getClassName() {
if (name == null) {
name = cp.getUTF8(nameIndex).replace('/', '.');
}
return name;
}
/**
* Resolve the references of this constant to loaded VmXxx objects.
* @param clc
*/
protected void doResolve(VmClassLoader clc) {
if (vmClass == null) {
final String name = getClassName();
try {
vmClass = clc.loadClass(name, true);
} catch (ClassNotFoundException ex) {
throw (NoClassDefFoundError)new NoClassDefFoundError(name).initCause(ex);
}
}
}
/**
* Convert myself into a String representation
* @see java.lang.Object#toString()
* @return String
*/
public String toString() {
return "ConstClass: " + getClassName();
}
/**
* Returns the vmClass.
* @return VmClass
*/
public VmType getResolvedVmClass() {
if (vmClass == null) {
throw new RuntimeException("vmClass is not yet resolved");
} else {
return vmClass;
}
}
/**
* Sets the resolved vmClass. If the resolved vmClass was already set, any
* call to this method is silently ignored.
* @param vmClass The vmClass to set
*/
public void setResolvedVmClass(VmType vmClass) {
if (this.vmClass == null) {
this.vmClass = vmClass;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?