Пример #1
0
        private JvmtiEnvironment(JavaVM virtualMachine, jvmtiEnvHandle handle)
        {
            Contract.Requires<ArgumentNullException>(virtualMachine != null, "virtualMachine");

            _virtualMachine = virtualMachine;
            _handle = handle;
            _rawInterface = (jvmtiInterface)Marshal.PtrToStructure(Marshal.ReadIntPtr(handle.Handle), typeof(jvmtiInterface));

            jvmtiCapabilities previousCapabilities;
            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetCapabilities(this, out previousCapabilities));

            jvmtiCapabilities potentialCapabilities;
            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetPotentialCapabilities(this, out potentialCapabilities));

            var capabilities =
                new jvmtiCapabilities(
                    jvmtiCapabilities.CapabilityFlags1.CanTagObjects
                    | jvmtiCapabilities.CapabilityFlags1.CanGetSourceFileName
                    | jvmtiCapabilities.CapabilityFlags1.CanGetLineNumbers
                    | jvmtiCapabilities.CapabilityFlags1.CanGetSourceDebugExtension
                    | jvmtiCapabilities.CapabilityFlags1.CanAccessLocalVariables
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateSingleStepEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateExceptionEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateBreakpointEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateFramePopEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateAllClassHookEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGetBytecodes
                    | jvmtiCapabilities.CapabilityFlags1.CanSuspend,
                    jvmtiCapabilities.CapabilityFlags2.CanGetConstantPool
                    );
            JvmtiErrorHandler.ThrowOnFailure(RawInterface.AddCapabilities(this, ref capabilities));

            jvmtiCapabilities newCapabilities;
            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetCapabilities(this, out newCapabilities));
        }
Пример #2
0
        private JvmtiEnvironment(JavaVM virtualMachine, jvmtiEnvHandle handle)
        {
            Contract.Requires <ArgumentNullException>(virtualMachine != null, "virtualMachine");

            _virtualMachine = virtualMachine;
            _handle         = handle;
            _rawInterface   = (jvmtiInterface)Marshal.PtrToStructure(Marshal.ReadIntPtr(handle.Handle), typeof(jvmtiInterface));

            jvmtiCapabilities previousCapabilities;

            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetCapabilities(this, out previousCapabilities));

            jvmtiCapabilities potentialCapabilities;

            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetPotentialCapabilities(this, out potentialCapabilities));

            var capabilities =
                new jvmtiCapabilities(
                    jvmtiCapabilities.CapabilityFlags1.CanTagObjects
                    | jvmtiCapabilities.CapabilityFlags1.CanGetSourceFileName
                    | jvmtiCapabilities.CapabilityFlags1.CanGetLineNumbers
                    | jvmtiCapabilities.CapabilityFlags1.CanGetSourceDebugExtension
                    | jvmtiCapabilities.CapabilityFlags1.CanAccessLocalVariables
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateSingleStepEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateExceptionEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateBreakpointEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateFramePopEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGenerateAllClassHookEvents
                    | jvmtiCapabilities.CapabilityFlags1.CanGetBytecodes
                    | jvmtiCapabilities.CapabilityFlags1.CanSuspend,
                    jvmtiCapabilities.CapabilityFlags2.CanGetConstantPool
                    );

            JvmtiErrorHandler.ThrowOnFailure(RawInterface.AddCapabilities(this, ref capabilities));

            jvmtiCapabilities newCapabilities;

            JvmtiErrorHandler.ThrowOnFailure(RawInterface.GetCapabilities(this, out newCapabilities));
        }