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

Commit

Permalink
[GR-44518] Add possibility to convert object JavaConstant to jobject.
Browse files Browse the repository at this point in the history
PullRequest: labsjdk-ce-17/106
  • Loading branch information
tzezula committed Mar 17, 2023
2 parents 46e0fb3 + 35915eb commit 90f5597
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,26 @@ JavaType lookupTypeInternal(String name, HotSpotResolvedObjectType accessingType
}
}

/**
* Gets the {@code jobject} value wrapped by {@code peerObject}. The returned "naked" value is
* only valid as long as {@code peerObject} is valid. Note that the latter may be shorter than
* the lifetime of {@code peerObject}. As such, this method should only be used to pass an
* object parameter across a JNI call from the JVMCI shared library to HotSpot. This method must
* only be called from within the JVMCI shared library.
*
* @param peerObject a reference to an object in the peer runtime
* @return the {@code jobject} value wrapped by {@code peerObject}
* @throws IllegalArgumentException if the current runtime is not the JVMCI shared library or
* {@code peerObject} is not a peer object reference
*/
public long getJObjectValue(HotSpotObjectConstant peerObject) {
if (peerObject instanceof IndirectHotSpotObjectConstantImpl) {
IndirectHotSpotObjectConstantImpl remote = (IndirectHotSpotObjectConstantImpl) peerObject;
return remote.getHandle();
}
throw new IllegalArgumentException("Cannot get jobject value for " + peerObject + " (" + peerObject.getClass().getName() + ")");
}

@Override
public JVMCIBackend getHostJVMCIBackend() {
return hostBackend;
Expand Down

0 comments on commit 90f5597

Please sign in to comment.