In a bucket with versioning enabled or suspended, the storage class of each version of an object can be different. RestoreObject restores the current version of the target object by default. You can specify the versionId in the request to restore the specified version of the object.

You can run the following code to restore an object:
// This example uses the China East 1 (Hangzhou) endpoint. Specify the actual endpoint based on your requirements.
String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// It is highly risky to log on with the AccessKey of an Alibaba Cloud account because the account has permissions on all the APIs in OSS. We recommend that you log on as a RAM user to access APIs or perform routine operations and maintenance. To create a RAM user account, log on to https://ram.console.aliyun.com.
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";
String bucketName = "<yourBucketName>";
String objectName = "<yourObjectName>";
// Specifies the version ID of the Archive object.
String versionid = "<yourArchiveObjectVersionid>";

// Obtains a part of the metadata of the specified version of the object.
GenericRequest getObjectMetadataRequest = new GenericRequest(bucketName,objectName, versionid);
ObjectMetadata objectMetadata = ossClient.getObjectMetadata(getObjectMetadataRequest);

// Checks whether the specified version of the object is an Archive object.
StorageClass storageClass = objectMetadata.getObjectStorageClass();
System.out.println("object storage class:" + objectMetadata.getObjectStorageClass());
if (storageClass == StorageClass.Archive) {
    // Restores the object.
    GenericRequest genericRequest = new GenericRequest(bucketName, objectName, versionid);
    RestoreObjectResult restoreObjectResult = ossClient.restoreObject(genericRequest);
    System.out.println("restor versionid: " + restoreObjectResult.getVersionId());

    // Waits until the object is restored.
    do {
        Thread.sleep(1000);
        objectMetadata = ossClient.getObjectMetadata(getObjectMetadataRequest);
        System.out.println("is competed:" + objectMetadata.isRestoreCompleted());
    } while (!objectMetadata.isRestoreCompleted());
}

// Obtains the specified version of the restored object.
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, objectName);
getObjectRequest.setVersionId(versionid);
OSSObject ossObject = ossClient.getObject(getObjectRequest);
ossObject.getObjectContent().close();

For more information about restoring an object, see RestoreObject.