Skip to content

JavaKit: Passing objects between threads #157

Open
@lhoward

Description

@lhoward

javaMethodLookup() uses the environment attached to the object, probably it should use the ambient (thread-specific) environment or the one that is passed in?

java_vm_ext.cc:599] JNI DETECTED ERROR IN APPLICATION: thread Thread[23,tid=1783,Native,Thread*=0xb40000718be7eb40,peer=0x1449d000,"Thread-4"] using JNIEnv* from thread Thread[1,tid=1631,Native,Thread*=0xb40000718be307b0,peer=0x72c1eb68,"main"]
                                                                                                    java_vm_ext.cc:599]     in call to GetObjectClass

From the JNI specs:

The JNI interface pointer is only valid in the current thread. A native method, therefore, must not pass the interface pointer from one thread to another. A VM implementing the JNI may allocate and store thread-local data in the area pointed to by the JNI interface pointer.

So, I think this is a bug. Is the fix as simple as adding an environment argument to javaMethodLookup()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions