Package org.apache.kato.jvmti.javaruntime.model

Examples of org.apache.kato.jvmti.javaruntime.model.JClass


   */
  private JClass nreadClass() throws IOException {
    long id = variablesIn.getStreamPosition();
    id--; // Class id/ImagePointer

    JClass c = model.getClass(id);

    // Prevent reference loops (check if this class is partly filled in)
    if (c.classSig != null)
      return c;

    int modifiers = variablesIn.readInt();
    c.modifiers = (short) modifiers;
    log.log(Level.FINEST, "mods " + modifiers + " " + c.modifiers);
    String name = readUTFString(variablesIn);
    String sourceFile = readUTFString(variablesIn);
    String genSig = readUTFString(variablesIn);

    // TODO move this to C implementation
    if (sourceFile.equals("NoSource")) {
      if (!(name.indexOf("[")>-1)&&name.indexOf("L")>-1){
        sourceFile = name.substring(name.lastIndexOf("/")+1, name.indexOf(";")); // Small attempt to extend number of sourcefiles reported to Eclipse
      }
    }
    c.classSig = name;
    c.classid = id;
    c.sourceFile = sourceFile;

    if (variablesIn.readByte() == CJVMTI_METHOD) {
      int num = variablesIn.readInt();
      for (int i = 0; i < num; i++) {
        nmethodDetails(c);
      }
    } else {
      throw new IOException();
    }

    if (variablesIn.readByte() == CJVMTI_CLASS_INSTANCE_FIELDS) {
      instanceFieldDetails(c);
    } else {
      throw new IOException();
    }

    int numStaticFields = 0;
    if (variablesIn.readByte() == CJVMTI_CLASS_STATIC_FIELDS) {
      numStaticFields = nstaticFieldDetails(c);
    } else {
      throw new IOException();
    }

    long supC = 0;
    if (variablesIn.readByte() == CJVMTI_SUPERCLASS_FIELDS) {
      supC = variablesIn.readLong();
    } else {
      throw new IOException();
    }

    long interfaceClasses[];
    if (variablesIn.readByte() == CJVMTI_CLASS_INTERFACES) {
      int numInterfaces = variablesIn.readInt();
      interfaceClasses = new long[numInterfaces];
      for (int i = 0; i < interfaceClasses.length; i++) {
        interfaceClasses[i] = variablesIn.readLong();
      }
    } else {
      throw new IOException();
    }

    if (!(variablesIn.readByte() == CJVMTI_CLASS_STATIC_FIELDS)) {
      throw new IOException();
    }

    long refs[] = new long[numStaticFields];
    for (int i = 0; i < numStaticFields; i++) {
      refs[i] = variablesIn.readLong();
    }

    long classLoaderRef = 0;
    if (variablesIn.readByte() == CJVMTI_CLASSLOADERS) {
      classLoaderRef = variablesIn.readLong();
    } else {
      throw new IOException();
    }

    c.superClassID = supC;
    if (supC != CJVMTI_NULL_OBJECT) {
      c.superclass = nreadClass(supC);
    }

    // Read static field references
    for (JField fl : (List<JField>) c.getDeclaredFields()) {
      if (fl.staticField) {
        fl.staticValue = nreadReference(refs[fl.index]);
      }
    }
    log.log(Level.FINEST, "num interf: " + interfaceClasses.length + " "
        + c.classSig);
    // Follow interface references
    for (long interfaceRef : interfaceClasses) {
      JClass interfaceC = nreadClass(interfaceRef);
      c.addInterface(interfaceC);
    }

    {
      JClassLoader jcl = nreadClassLoader(classLoaderRef);
View Full Code Here


    long objectID = variablesIn.getStreamPosition() - 1;
    long classRef = variablesIn.readLong();
    int numInstanceFields = variablesIn.readInt();
    long offset = variablesIn.getStreamPosition();
    // log.log(Level.FINEST,"objectID " + Long.toHexString(objectID));
    JClass c = nreadClass(classRef);
    log.log(Level.FINEST, "Obj id " + Long.toHexString(objectID));
    JObject obj = model.getObject(classRef, objectID);

    if (obj.isVisited())
      return obj; // Prevent reference loop
    obj.setVisited(true);

    // Calculate how many instance fields the reader can see on the class hierarchy
    int instanceFieldCount = 0;
    JClass superClass = c;
    while (superClass != null) {
      for (JField jf : (List<JField>) superClass.getDeclaredFields()) {
        if (!jf.staticField)
          instanceFieldCount++;
      }
      superClass = model.getClass(superClass.superClassID);
    }

    // Check they match the dump files recoard
    if (numInstanceFields != instanceFieldCount) {
      log.log(Level.FINEST, "Non-matching " + numInstanceFields
          + " found " + instanceFieldCount);
      System.exit(0);
    }

    // Now read in all the references
    long instanceRefs[] = new long[instanceFieldCount];
    variablesIn.seek(offset);
    int countUp = 0;
    while (countUp < instanceFieldCount) {
      instanceRefs[countUp] = variablesIn.readLong();
      countUp++;
    }
    offset = variablesIn.getStreamPosition();


    // Follow the references grabbing the correct jfield for the hierarchy of classes
    int fieldCount = 0;
    int fieldOffset;
    fieldOffset = 0;
    superClass = c;
    while (superClass != null) {
      for (JField jf : (List<JField>) superClass.getDeclaredFields()) {
        if (!jf.staticField) {
          fieldCount++;
          if (instanceRefs[fieldOffset +jf.index] == 0x9999999999999999L){
            log.fine("Error, unwritten reference");
          }
View Full Code Here

      case CJVMTI_OBJECT_ARRAY:
        long classType = variablesIn.readLong();
        length = variablesIn.readInt();
        long currentReadPos = variablesIn.getStreamPosition();
        log.log(Level.FINEST, "Object Array " + classType);
        JClass arrayClass = nreadClass(classType);
        variablesIn.seek(currentReadPos);
        JObject objA[] = new JObject[length];
        currentReadPos = variablesIn.getStreamPosition();
        for (int counter = 0; counter < length; counter++) {
          long objReference = variablesIn.readLong();
          if (objReference == CJVMTI_NULL_OBJECT_ARRAY) {
            objA[counter] = (JObject) null;
            continue;
          }
          log.log(Level.FINEST, "Reading " + counter + " at "
              + Long.toHexString(objReference));
          currentReadPos = variablesIn.getStreamPosition();
          objA[counter] = (JObject) nreadReference(objReference);
          variablesIn.seek(currentReadPos);
        }
        obj = model
        .getObject(arrayClass.getID().getAddress(), position);
        obj.setObjArray(objA);
       
        return obj;
      case CJVMTI_BYTE_ARRAY:
        length = variablesIn.readInt();
View Full Code Here

    // generate system classloader

    selfGeneratedIDs++;
    bootJCL = (JClassLoader) model.getSystemClassLoader();
    JClass bootCLC = model.getClass(selfGeneratedIDs);
    bootCLC.classSig = "Ljava/lang/CJVMTISystemClassLoader;";
    JObject bootObj = model.getObject(selfGeneratedIDs, selfGeneratedIDs);
    bootJCL.obj = bootObj;
    // rootJCL.addClass(bootCLC);
    bootCLC.classloader = null;
View Full Code Here

    long methodID = variablesIn.readLong();
    String methodName = readUTFString(variablesIn);
    log.log(Level.FINEST, "Method name is: " + methodName);
    long declaringClass = variablesIn.readLong();
    long cPos = variablesIn.getStreamPosition(); // Save where we are before reading in the declaring class
    JClass clazz = (JClass) nreadReference(declaringClass);
    variablesIn.seek(cPos); // Return to our read position

    JStackFrame jsf = new JStackFrame();
    JLocation loc = new JLocation();
    JMethod jm = model.getMethod(methodID);
View Full Code Here

TOP

Related Classes of org.apache.kato.jvmti.javaruntime.model.JClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.