supers.java

来自「java 到c的转换程序的原代码.对喜欢C程序而不懂JAVA程序的人很有帮助」· Java 代码 · 共 66 行

JAVA
66
字号
//  Supers.java -- operations involving superclassespackage toba.translator;import toba.classfile.*;import java.io.*;import java.util.*;public class Supers {private static ClassData previous;	// last class loaded//  load(k) -- load and link superclasses of ClassData k////  sets k.superclass, and all method tables (and those of all ancestors)////  It is assumed that previously seen classes can be reused,//  allowing caching.public static void load(ClassData k)    throws ClassNotFoundException, IOException{    ClassData kp;    String sname;    sname = k.supername;		// name of superclass    if (k.superclass == null && sname != null) {    	// there is a superclass and it has not been linked in	for (kp = previous; kp != null; kp = kp.superclass)	    if (kp.name.equals(sname))		break;	if (kp != null)	    k.superclass = kp;		// found in existing chain	else {	    // not found; find and load superclass from file            ClassFile cf = ClassFile.find (sname);	    k.superclass = ClassData.forStream (null, cf, false);//            System.out.println (sname + " from " + cf.dir);            /* Resulting class has to have the right name. */            if (! sname.equals (k.superclass.name)) {                throw new ClassNotFoundException (sname);            }	    load(k.superclass);		// load superclass's superclasses	}    }    k.state = ClassData.RES_SUPERCLASSES;    k.buildTables();			// fill in method table    IHash.mark(null, k);			// mark interfaces    previous = k;			// remember class just loaded}    } // class Supers

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?