From 39ee8d45de6fad9472ad1a7da65d40f8476618f9 Mon Sep 17 00:00:00 2001 From: igerasim Date: Wed, 3 Apr 2019 03:33:25 +0100 Subject: [PATCH] 8218453: More dynamic RMI interactions Reviewed-by: aph --- .../sun/rmi/registry/RegistryImpl_Skel.java | 22 +++++++++++++++--- .../sun/rmi/server/UnicastServerRef.java | 23 ++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/share/classes/sun/rmi/registry/RegistryImpl_Skel.java b/src/share/classes/sun/rmi/registry/RegistryImpl_Skel.java index 842d47719..6807a328b 100644 --- a/src/share/classes/sun/rmi/registry/RegistryImpl_Skel.java +++ b/src/share/classes/sun/rmi/registry/RegistryImpl_Skel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,8 +58,24 @@ public final class RegistryImpl_Skel public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash) throws java.lang.Exception { - if (hash != interfaceHash) - throw new java.rmi.server.SkeletonMismatchException("interface hash mismatch"); + if (opnum < 0) { + if (hash == 7583982177005850366L) { + opnum = 0; + } else if (hash == 2571371476350237748L) { + opnum = 1; + } else if (hash == -7538657168040752697L) { + opnum = 2; + } else if (hash == -8381844669958460146L) { + opnum = 3; + } else if (hash == 7305022919901907578L) { + opnum = 4; + } else { + throw new java.rmi.UnmarshalException("invalid method hash"); + } + } else { + if (hash != interfaceHash) + throw new java.rmi.server.SkeletonMismatchException("interface hash mismatch"); + } sun.rmi.registry.RegistryImpl server = (sun.rmi.registry.RegistryImpl) obj; switch (opnum) { diff --git a/src/share/classes/sun/rmi/server/UnicastServerRef.java b/src/share/classes/sun/rmi/server/UnicastServerRef.java index d82746030..2d51e40e8 100644 --- a/src/share/classes/sun/rmi/server/UnicastServerRef.java +++ b/src/share/classes/sun/rmi/server/UnicastServerRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import java.rmi.ServerError; import java.rmi.ServerException; import java.rmi.UnmarshalException; import java.rmi.server.ExportException; +import java.rmi.server.Operation; import java.rmi.server.RemoteCall; import java.rmi.server.RemoteRef; import java.rmi.server.RemoteStub; @@ -295,15 +296,14 @@ public class UnicastServerRef extends UnicastRef throw new UnmarshalException("error unmarshalling call header", readEx); } - if (num >= 0) { - if (skel != null) { + if (skel != null) { + // If there is a skeleton, use it oldDispatch(obj, call, num); return; - } else { - throw new UnmarshalException( - "skeleton class not found but required " + - "for client version"); - } + + } else if (num >= 0){ + throw new UnmarshalException( + "skeleton class not found but required for client version"); } try { op = in.readLong(); @@ -429,8 +429,8 @@ public class UnicastServerRef extends UnicastRef /** * Handle server-side dispatch using the RMI 1.1 stub/skeleton - * protocol, given a non-negative operation number that has - * already been read from the call stream. + * protocol, given a non-negative operation number or negative method hash + * that has already been read from the call stream. * Exceptions are handled by the caller to be sent to the remote client. * * @param obj the target remote object for the call @@ -462,7 +462,8 @@ public class UnicastServerRef extends UnicastRef } // if calls are being logged, write out object id and operation - logCall(obj, skel.getOperations()[op]); + Operation[] operations = skel.getOperations(); + logCall(obj, op >= 0 && op < operations.length ? operations[op] : "op: " + op); unmarshalCustomCallData(in); // dispatch to skeleton for remote object skel.dispatch(obj, call, op, hash); -- GitLab