1 Reply Latest reply: Jan 12, 2012 3:05 PM by 726642 RSS

    Bug: JVMTI's NativeMethodBind never called for Class.getSuperclass() method

    726642
      This issue is specific to the JRockit JVM only, since it doesnt occur in the HotSpotVM.
      The JRockit JVM version is:
      jrockit-jdk1.6.0_29-R28.2.0-4.1.0

      I am using the JVMTI's NativeMethodBind function to instrument the getSuperClass() method.
      However, it seems all the other native methods of java.lang.Class are indeed passed through the NativeMethodBind event, except for getSuperClass().

      Here is a bit of code:

      void JNICALL
      NativeMethodBind(jvmtiEnv *jvmti_env,
                          JNIEnv* jni_env,
                          jthread thread,
                          jmethodID method,
                          void* address,
                          void** new_address_ptr)
      {
           jvmtiPhase phase;
           jvmtiError status=jvmti_env->GetPhase(&phase);
           if((phase==JVMTI_PHASE_PRIMORDIAL) || (phase== JVMTI_PHASE_ONLOAD))
           {
      //store method info in vectors
                nativeMethodIdVector.push_back(method);
                nativeMethodAddressVector.push_back(address);
                return;
           }
           if(!nativeBound)
           {
                if(!checkedNativeList)
                {
                     checkedNativeList= true;
                     if(doCheckNativeList(jvmti_env))
                     {
                          nativeBound = true;
                          return;
                     }
                }

                char * name;
                char* sig;
                char* genericP;
                jvmtiError status= jvmti_env->GetMethodName(method,&name,&sig,&genericP);
                const char* a = name;
                printf("%s\n",a);
      }

      bool doCheckNativeList(jvmtiEnv *jvmti_env)
      {
           bool foundSuperClassMethod = false;
           for(std::vector<int>::size_type i = 0; i != nativeMethodIdVector.size(); i++)
           {
                jmethodID currentmethodid= nativeMethodIdVector;
                void* currentmethodAddress= nativeMethodAddressVector[i];
                char * name;
                char* sig;
                char* genericP;
                jvmti_env->GetMethodName(currentmethodid,&name,&sig,&genericP);
                const char* a = name;
                printf("%s\n",a);
           }

           return foundSuperClassMethod;

      }


      The output of this is the following. Note that even though methods like Class.forName0() are included, getSuperclass() is not

      debuggerEvent
      enterExceptionHandler
      generateVirtualCode
      generateFixedCode
      throwPendingType
      registerNatives
      initializeClass
      fillInStackTrace0
      registerNatives
      currentTimeMillis
      nanoTime
      registerNatives
      start0
      stop0
      isAlive
      suspend0
      resume0
      setPriority0
      yield
      sleep
      currentThread
      countStackFrames
      interrupt0
      isInterrupted
      holdsLock
      getThreads
      dumpThreads
      registerNatives
      getName0
      getInterfaces
      getSigners
      setSigners
      getModifiers
      getDeclaredFields0
      getDeclaredMethods0
      getDeclaredConstructors0
      getProtectionDomain0
      setProtectionDomain0
      getDeclaredClasses0
      getDeclaringClass
      getGenericSignature
      getRawAnnotations
      getConstantPool
      desiredAssertionStatus0
      getEnclosingMethod0
      getPrimitiveClass
      getStackAccessControlContext
      getCallerClass
      initProperties
      initialize
      getFileSystem
      initIDs
      initIDs
      registerNatives
      retrieveDirectives
      getPrimitiveHashCode0
      forName0
      intern0
      getFieldOffset
      getBooleanAttributes
      mapLibraryName
      canonicalize0
      registerFinalizer
      load
      initIDs
      initIDs
      set
      initIDs
      allocLargeObjectOrArray
      setIn0
      invokeMethod
      setOut0
      setErr0
      findSignal
      handle0
      setErrorMode
      open
      readBytesPinned
      available
      isJDK15OrBetter
      getNewTla
      initNative
      close0
      list
      canonicalizeWithPrefix0
      getFinalizeeArraySize
      waitForFinalizees
      waitForActivatedQueue
      findLoadedClass0
      isRetransformClassesSupported0
      availableProcessors
      delete0
      VMSupportsCS8
      checkIfThreadOwnsLock
      convertThinLockedToFatLocked
      waitForNotifySignal
      throwException
      clone0
      find
      getVersion0
      initOptionalSupportFields
      getStartupTime
      getVmArguments0
      maxMemory
      getSystemTimeZoneID
      getLength
      getClassContext
      initIDs
      open
      length
      seek
      writeBytesPinned
      initIDs
      initIDs
      initIDs
      initIDs
      read0
      read1
      pread0
      pread1
      readv0
      write0
      write1
      pwrite0
      pwrite1
      writev0
      preClose0
      close0
      force0
      close0
      checkAndTransferLazyLocked
      checkAndTransferLazyLocked
      finalize
      getUTF8At0
      getIntAt0
      defineClass0
      runClinit
      initIDs
      init
      deflateBytes
      defineClass0
      end
      init
      inflateFast
      latestUserDefinedLoader
      end
      park0
      park0
      park0
      park0
      setHasRetransformableTransformers
      getAllLoadedClasses0
      retransformClasses0
      unpark0
      yield
      sleep
      options
      init
      classID
      stackTraceID
      threadID
      rotate
      shutdown
      start
      stop
      onCloneRecording
      onStartRecording
      onStopRecording
      add
      remove
      buffer
      flush
      write
      setEnabled
      setThreshold
      setPeriod
      getPeriod
      descriptors
      addConstPool
      removeConstPool
      storeConstPool
      getSystemPackage0
      defineClass1
      hasStaticInitializer
      d2i
      open
      close0

      Edited by: user11362013 on Jan 11, 2012 4:56 PM

      Edited by: user11362013 on Jan 11, 2012 4:57 PM

      Edited by: user11362013 on Jan 11, 2012 4:58 PM