Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:35:34+00:00 2026-06-18T12:35:34+00:00

I have a question involving RMI, Serialization and runtime polymorphism. I have an RMI

  • 0

I have a question involving RMI, Serialization and runtime polymorphism.

I have an RMI server with below:

public interface Shape extends Remote, Serializable { 
    public double getArea() throws RemoteException;
}

public class Circle implements Shape {
  double radius;
  public Circle( double r) { radius = r; }
  public double getArea() { return Math.PI * radius * radius; }
}

An object cObj of Circle class is registered in the RMI Registry:

Circle cObj = new Circle (10);
registry.bind("cObj", cObj);

Now, on the client side, I have the Shape.class file on the CLASSPATH, but it does not have Circle.class file on CLASSPATH.
Is it possible for the RMI client to perform below?

Shape obj = (Shape) registry.lookup("cObj");
obj.getArea();

Note that Circle.class is not in the CLASSPATH of the RMI client and the code on the client is not directly referencing the Circle class anyway. It is only referencing Shape interface type.

How I would look at this, may be the client performs a lookup and finds the object with cObj name, and Circle type. The server knows that Circle is a subtype of Shape, and serializes the object and sends it to the client. Now, I am not sure if the client can cast it into the superclass (Shape) type without having access to the Circle class definition.

Help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:35:36+00:00Added an answer on June 18, 2026 at 12:35 pm

    If you don’t want to deploy the Circle class to the client you have two choices:

    1. Use the RMI codebase feature. You need to look this up as it is far too large a topic to discuss here, but basically it makes classloading possible from an additional location dictated by the RMI server.

    2. Make it an exported remote object, so that calls to it are also RMI calls. You’re halfway there already by making Shape extended Remote, but you also need to export Circle, either by making it extend UnicastRemoteObject or by calling UnicastRemoteObject.exportObject() with it on construction.

    It seems to me that by extending Remote you really meant to do (2) all along. If you do this you don’t need to make Shape extend Serializable. If you don’t do (2) there is no point in having Shape extend Remote. You should remove one or the other: they are kind of mutually exclusive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question involving the Replace Method. I saw a question similar to
Avoiding Fat Controller So I'm using Zend Framework and I have a question involving
I have an esoteric question involving Python metaclasses. I am creating a Python package
This is a conceptual question involving Hadoop/HDFS. Lets say you have a file containing
I have a question about Objective-C today involving NSMutableArray. Coming from a .net/c# background
I have a linq query involving the following 3 entities: public class LandPoint {
Just a quick question involving upgrading Magento. I currently have version 1.4.1 and would
Hi coders I have yet another question involving data binding in winforms. I set
I have a quick little question involving the read() command. I am really rusty
I have a question involving PHP arrays and adding up the values. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.