Server Smalltalk Guide

Using JDK 1.2

In JDK 1.1, stub classes are assigned a hash value based on characteristics of the remote class, such as its name and the interfaces that it implements. In JDK 1.2, every stub class is assigned a hash value of 2.

In JDK 1.2, each method is also assigned a hash value based on the signature of that method. Remote calls pass this hash value to identify the correct method to call. Because the stub protocol has changed, the stub generation has also changed.

The new RMIC stub generation program shipped with JDK 1.2 generates three different types of stubs:

JDK 1.1 compliant stubs
JDK 1.1 stubs do not contain the method hash values.

JDK 1.2 compliant stubs
JDK 1.2 stubs contain the method hash values. Also, JDK 1.2 has obsoleted some RMI API and the JDK 1.2 stubs do not reference the obsoleted RMI API.

Hybrid stubs that can support both versions
The hybrid stubs can act as either JDK 1.1 stubs or JDK 1.2 stubs. The hybrid stubs determine the correct stub protocol based on which version of Java the local VM is running.

In order to use JDK 1.2, you must change the stub protocol version. To use JDK 1.2 with RMI, you must change the security. It is also recommended that you migrate your existing mappings in order to add the method hash value. Smalltalk can generate this method hash value dynamically. However, if it is generated dynamically, there are performance considerations.

Changing the stub protocol version for JDK 1.2

The SstRmiMarshalingConfiguration now has a new attribute, stubProtocolVersion. The stubProtocolVersion attribute is used when marshalling a request or unmarshalling a request. Set this attribute to either SstRmiConstants::SstRmiStubVersion1, if you are using JDK 1.1, or SstRmiConstants::SstRmiStubVersion2, if you are using JDK 1.2. The default is SstRmiVersion1.

In order to use the same mappings for JDK 1.1 and JDK 1.2, set the stub mappings to the JDK 1.1 hash value. When marshalling a request, this hash value is used when the stubProtocolVersion of the marshaling configuration is SstRmiStubVersion1. When the stubProtocolVersion of the marshaling configuration is SstRmiVersion2, the stub mapping hash value for JDK 1.1 is ignored and the hash value of 2 is used.

Changing the security for JDK 1.2

For Java 1.2, the Java security manager must grant access to the ports that RMI uses. Otherwise, when you try to bind a remote object to the RMI Registry, an error is returned. An example java.policy file is as follows:

grant {
	     permission java.net.SocketPermission "*:1024-65535",
		       "connect,accept";
	     permission java.net.SocketPermission "*:80",
		       "connect";
	     permission java.lang.RuntimePermission "accessDeclaredMembers";
	     };
 

Start Java with the --D option as follows:

java -Djava.security.policy=java.policy <my.class.with.Main()>

For more information, see http://java.sun.com/docs/books/tutorial/rmi/running.html

Migrating method mappings to JDK 1.2

In order for Smalltalk to use RMI with JDK 1.2, Smalltalk must know the method hash information. If you are using JDK 1.1, the method hash value is ignored.

The mapping migration utility searches the image for existing JDK 1.1 mappings and gives the user an option to update these to the new JDK 1.2 mapping. Run the migration utility by loading the SstRmiMigration application and executing the following code:

SstRmiMigration runMigration


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]