Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8303678: [JVMCI] Add possibility to convert object JavaConstant to jo…
…bject.

Reviewed-by: never
  • Loading branch information
Tomas Zezula authored and Doug Simon committed Mar 13, 2023
1 parent d20bde2 commit 1148a65
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -858,6 +858,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

1 comment on commit 1148a65

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.