Package javax.tools.diagnostics.runtime.java

Examples of javax.tools.diagnostics.runtime.java.JavaMethod


    assertNotNull("Unable to find this class", thisClass);
   
    Iterator methods = thisClass.getDeclaredMethods().iterator();
    boolean found=false;
    while(methods.hasNext()) {
      JavaMethod method = (JavaMethod) methods.next();
     
      if (method.getName().equals(SetupJavaMethod_getName.methodName)) {
        found = true;
        break;
      }
    }
   
View Full Code Here


  private ImageSection _section = null;
 
  public  ImageSection defaultImageSection()
  {
    //for now we will just grab a compiled method section
    JavaMethod method = defaultJavaMethod();
    Iterator it = method.getCompiledSections().iterator();
    assertNotNull(it);
    assertTrue(it.hasNext());
    return (ImageSection) it.next();
  }
View Full Code Here

   
    JavaThread t1=getThread(allThreads,SetupJavaRuntimeThreads.DTFJ_TCK_T1);
    Iterator i=t1.getStackFrames().iterator();
    JavaStackFrame frame=(JavaStackFrame) i.next();
    JavaLocation location=frame.getLocation();
    JavaMethod  method=location.getMethod();
    String name=method.getName();
    assertEquals(name,"sleep");
   
   
   
  }
View Full Code Here

    while (compiledMethods.hasNext() && !found) {
      Object next = compiledMethods.next();
      if (!(next instanceof JavaMethod)) {
        continue;
      }
      JavaMethod method = (JavaMethod)next;
      try {
        String methodName = method.getName();
        // System.out.println("Current method is: "+ methodName);
        if ("jitMe".equals(methodName)) {
          return;
        }
      } catch (CorruptDataException cde) {
View Full Code Here

    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building method list..."); //$NON-NLS-1$
    while(jClasses.hasNext()){
      JavaClass jClass = jClasses.next();
      Iterator jMethods = jClass.getDeclaredMethods().iterator();
      while(jMethods.hasNext()){
        JavaMethod jMethod = (JavaMethod)jMethods.next();
        try{
          int index = intToMethod.size();
          intToMethod.put(index, jMethod);
          methodToInt.put(jMethod, index);
          //logr.log(JDILogger.LEVEL_VERBOSE, jClass.getName()+"."+jMethod.getName()+"#"+methodList.indexOf(jMethod));
View Full Code Here

              JavaThread thd = (JavaThread) tmpobj;
              Iterator frames = thd.getStackFrames().iterator();
              while(frames.hasNext()){
                JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                JavaLocation jLocation = jStackFrame.getLocation();
                JavaMethod jMethod = jLocation.getMethod();
                JavaClass jClass = jMethod.getDeclaringClass();


                if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
                  int line = -1;
                  try{
View Full Code Here

              JavaThread thd = (JavaThread) tmpobj;
              Iterator frames = thd.getStackFrames().iterator();
              while(frames.hasNext()){
                JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                JavaLocation jLocation = jStackFrame.getLocation();
                JavaMethod jMethod = jLocation.getMethod();
                JavaClass jClass = jMethod.getDeclaringClass();


                if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
                  int line = -1;
                  try{
View Full Code Here

        Iterator javaMethods = javaClass.getDeclaredMethods().iterator();
        logr.log(JDILogger.LEVEL_VERYVERBOSE, javaClass.getName() + ":"); //$NON-NLS-1$
        Vector<Byte> vctr = new Vector<Byte>();
        int count = 0;
        while (javaMethods.hasNext()){
          JavaMethod jMethod = (JavaMethod)javaMethods.next();
          long methodID = getMethodId(refType, jMethod);
          String name = jMethod.getName();
          String signature = jMethod.getSignature();
          int modBits = jMethod.getModifiers();
          addLongToVector(vctr, methodID);
          addStringToVector(vctr, name);
          addStringToVector(vctr, signature);
          addIntToVector(vctr, modBits);
          logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + name + " (" + signature + ", " + methodID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          count++;
        }
        addIntToVectorFront(vctr,count);
        logr.log(JDILogger.LEVEL_VERYVERBOSE, "Found " + count + " method(s)"); //$NON-NLS-1$ //$NON-NLS-2$
        ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
        rpckt.setData(vectorToByte(vctr));
        return rpckt;
      }


      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
      return rpckt;
    }else if (cpckt.getCommand() == REFERENCE_TYPE_GET_VALUES){
      byte [] inData = cpckt.getByteData();
      long refType = createLongFromBytes(inData, 0, 8);
      int fields = createIntFromBytes(inData, 8, 4);
      logr.log(JDILogger.LEVEL_VERBOSE, "ReferenceType.GetValues(" + refType + ", " + fields + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      Vector<Byte> vctr = new Vector<Byte>();

      addIntToVector(vctr, fields);

      for(int i = 0; i < fields; i++){
        long fieldID = createLongFromBytes(inData, 12 + (i * 8), 8);
        logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + i + " of " + fields + " {" + fieldID+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        if (!getFieldFromClass(vctr, refType, fieldID)){
          ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
          return rpckt;
        }
      }
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    }else if (cpckt.getCommand() == REFERENCE_TYPE_SOURCE_FILE){
      byte [] inData = cpckt.getByteData();
      long refType = createLongFromBytes(inData, 0, 8);
      logr.log(JDILogger.LEVEL_VERBOSE, "SourceFile(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
      Iterator asIt = image.getAddressSpaces( ).iterator();
      while ( asIt.hasNext( ) )
      {
        ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
        Iterator prIt = as.getProcesses( ).iterator();

        while ( prIt.hasNext( ) )
        {
          ImageProcess process = (ImageProcess) prIt.next( );
          Iterator runTimesIt = process.getRuntimes( ).iterator();
          while ( runTimesIt.hasNext( ) )
          {
            JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
            Iterator thds = javaRT.getThreads().iterator();
            while(thds.hasNext()){
              Object tmpobj = thds.next();
              if (tmpobj instanceof CorruptData){
                //ignore this thread
              }else{
                JavaThread thd = (JavaThread) tmpobj;
                Iterator frames = thd.getStackFrames().iterator();
                while(frames.hasNext()){
                  JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                  JavaLocation jLocation = jStackFrame.getLocation();
                  JavaMethod jMethod = jLocation.getMethod();
                  JavaClass jClass = jMethod.getDeclaringClass();


                  if (jClass.getID().getAddress() == refType){
                    Vector<Byte> vctr = new Vector<Byte>();
                    try{
View Full Code Here

                JavaThread thd = (JavaThread) tmpobj;
                Iterator frames = thd.getStackFrames().iterator();
                while(frames.hasNext()){
                  JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                  JavaLocation jLocation = jStackFrame.getLocation();
                  JavaMethod jMethod = jLocation.getMethod();
                  JavaClass jClass = jMethod.getDeclaringClass();

                  if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
                    int line = -1;
                    try{
                      line = jLocation.getLineNumber();
                    }
                    catch(CorruptDataException exxy){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "  CorruptData for:"); //$NON-NLS-1$
                    }
                    catch(DataUnavailable exxy){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "  DataUnavailable for:"); //$NON-NLS-1$
                    }


                    Vector<Byte> vctr = new Vector<Byte>();
                    if (line > 0){

                      int lowest = findLowestLineRef(refType, methodID) - 1;
                      int highest = findHighestLineRef(refType, methodID) + 1;
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "  (L)" + jClass.getName() + "." + jMethod.getName() + ":" + lowest + "<" + line + ">" + highest); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                     
//                      //Code index start
//                      addLongToVector(vctr, lowest);
//                      //Code index end
//                      addLongToVector(vctr, highest);
//                      //Number of lines
//                      addIntToVector(vctr, highest - lowest);
//                      for(int i = lowest; i <= highest; i++){
//                        addLongToVector(vctr, i);
//                        addIntToVector(vctr, i);
//                      }
                     
                      //Code index start
                      addLongToVector(vctr, 0);
                      //Code index end
                      addLongToVector(vctr, 99999999); // TODO go through local variable tables looking for highest reference?
                      //Number of lines
                      addIntToVector(vctr, 1);
                      //for(int i = lowest; i <= highest; i++){
                        addLongToVector(vctr, jLocation.getAddress().getAddress()-1);
                        addIntToVector(vctr, jLocation.getLineNumber());
                      //}
                     
                     
                    }else{
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "  (N)" + jClass.getName() + "." + jMethod.getName() + ":" + line); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                      //Code index start
                      addLongToVector(vctr, -1);
                      //Code index end
                      addLongToVector(vctr, -1);
                      //Number of lines
                      //We're native right now.
                      addIntToVector(vctr, 0);
                    }
                    ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
                    rpckt.setData(vectorToByte(vctr));
                    return rpckt;
                  }
                }
              }
            }
          }
        }
      }
     
      Vector<Byte> vctr = new Vector<Byte>();
      addLongToVector(vctr, -1);
      //Code index end
      addLongToVector(vctr, -1);
      //Number of lines
      //We're native right now.
      addIntToVector(vctr, 0);
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    }else if (cpckt.getCommand() == 2){
      byte [] inData = cpckt.getByteData();
      long refType = createLongFromBytes(inData, 0, 8);
      long methodID = createLongFromBytes(inData, 8, 8);
      logr.log(JDILogger.LEVEL_VERBOSE, "Method.VariableTable(" + refType + "," + methodID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      int slotsUsed = 0;
      Iterator asIt = image.getAddressSpaces( ).iterator();
      while ( asIt.hasNext( ) )
      {
        ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
        Iterator prIt = as.getProcesses( ).iterator();

        while ( prIt.hasNext( ) )
        {
          ImageProcess process = (ImageProcess) prIt.next( );
          Iterator runTimesIt = process.getRuntimes( ).iterator();
          while ( runTimesIt.hasNext( ) )
          {
            JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
            Iterator thds = javaRT.getThreads().iterator();
            while(thds.hasNext()){
              Object tmpobj = thds.next();
              if (tmpobj instanceof CorruptData){
                //ignore this thread
              }else{
                JavaThread thd = (JavaThread) tmpobj;
                Iterator frames = thd.getStackFrames().iterator();
                while(frames.hasNext()){
                  JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                  JavaLocation jLocation = jStackFrame.getLocation();
                  JavaMethod jMethod = jLocation.getMethod();
                  JavaClass jClass = jMethod.getDeclaringClass();
                 
                 
                  if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
                    Vector<Byte> vctr = new Vector<Byte>();

                    List vars = jMethod.getVariables();
                    String sig = jMethod.getSignature();
                   
                    addIntToVector(vctr, methodSignatureSize(sig));
                    addIntToVector(vctr, vars.size());

                    logr.log(JDILogger.LEVEL_VERYVERBOSE, " "+jLocation+
View Full Code Here

                        JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                        addLongToVector(vctr, jStackFrame.getBasePointer().getAddress());

                        JavaLocation jLoc = jStackFrame.getLocation();

                        JavaMethod jMethod = jLoc.getMethod();

                        JavaClass jClass = jMethod.getDeclaringClass();

                        if (jClass.isArray()){
                          vctr.add((byte)3);
                        }else if(isInterface(jClass.getID().getAddress())){
                          vctr.add((byte)2);
                        }else{
                          vctr.add((byte)1);
                        }

                        addLongToVector(vctr, jClass.getID().getAddress());
                        addLongToVector(vctr, getMethodId(jClass.getID().getAddress(), jMethod));

                        //This is the current memory address.
                        addLongToVector(vctr, jLoc.getAddress().getAddress());
                        try{
                          logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + jLoc.getFilename() + "@" + jLoc.getMethod().getDeclaringClass().getName() + "{"+jLoc.getMethod().getDeclaringClass().getID().getAddress()+"}." + jLoc.getMethod().getName() + "{"+getMethodId(jClass.getID().getAddress(), jLoc.getMethod())+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                          try{
                            logr.log(JDILogger.LEVEL_VERYVERBOSE, "    :" + jLoc.getLineNumber()); //$NON-NLS-1$
                          }catch(Exception exxy){
                          }

                        }catch (Exception exxy){}
                        count++;
                      }
                    }else{
                      if (currentFrame >= startFrame){
                        JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                        addLongToVector(vctr, jStackFrame.getBasePointer().getAddress());

                        JavaLocation jLoc = jStackFrame.getLocation();

                        JavaMethod jMethod = jLoc.getMethod();

                        JavaClass jClass = jMethod.getDeclaringClass();
                        if (jClass.isArray()){
                          vctr.add((byte)3);
                        }else if(isInterface(jClass.getID().getAddress())){
                          vctr.add((byte)2);
                        }else{
View Full Code Here

TOP

Related Classes of javax.tools.diagnostics.runtime.java.JavaMethod

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.