Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit 90f5597

Browse files
committed
[GR-44518] Add possibility to convert object JavaConstant to jobject.
PullRequest: labsjdk-ce-17/106
2 parents 46e0fb3 + 35915eb commit 90f5597

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,26 @@ JavaType lookupTypeInternal(String name, HotSpotResolvedObjectType accessingType
878878
}
879879
}
880880

881+
/**
882+
* Gets the {@code jobject} value wrapped by {@code peerObject}. The returned "naked" value is
883+
* only valid as long as {@code peerObject} is valid. Note that the latter may be shorter than
884+
* the lifetime of {@code peerObject}. As such, this method should only be used to pass an
885+
* object parameter across a JNI call from the JVMCI shared library to HotSpot. This method must
886+
* only be called from within the JVMCI shared library.
887+
*
888+
* @param peerObject a reference to an object in the peer runtime
889+
* @return the {@code jobject} value wrapped by {@code peerObject}
890+
* @throws IllegalArgumentException if the current runtime is not the JVMCI shared library or
891+
* {@code peerObject} is not a peer object reference
892+
*/
893+
public long getJObjectValue(HotSpotObjectConstant peerObject) {
894+
if (peerObject instanceof IndirectHotSpotObjectConstantImpl) {
895+
IndirectHotSpotObjectConstantImpl remote = (IndirectHotSpotObjectConstantImpl) peerObject;
896+
return remote.getHandle();
897+
}
898+
throw new IllegalArgumentException("Cannot get jobject value for " + peerObject + " (" + peerObject.getClass().getName() + ")");
899+
}
900+
881901
@Override
882902
public JVMCIBackend getHostJVMCIBackend() {
883903
return hostBackend;

0 commit comments

Comments
 (0)