Skip to content

Commit

Permalink
Add documentation for class loader
Browse files Browse the repository at this point in the history
M	jnigi.go
  • Loading branch information
timob committed Apr 11, 2024
1 parent 7cefc64 commit 83c00e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jnigi.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,18 @@ func UseJVM(pvm unsafe.Pointer, penv unsafe.Pointer, thiz unsafe.Pointer) (*JVM,
return jvm, env
}

// A reference to a class loader object
type ClassLoaderRef struct {
ref unsafe.Pointer
}

// Get a class loader object from an existing object obj
func (r *Env) GetClassLoader(obj *ObjectRef) *ClassLoaderRef {
classLoader := getClassLoader(r.jniEnv, (unsafe.Pointer)(obj.jobject))
return &ClassLoaderRef{classLoader}
}

// Set the env to look up classes using classloader, (it still fall back to JNI findClass function)
func (r *Env) SetClassLoader(classLoader *ClassLoaderRef) {
r.addtlClassLoader = classLoader.ref
}
Expand Down

0 comments on commit 83c00e3

Please sign in to comment.