Java type definitions
You will generally not be required to manipulate Java class definitions except in a few cases where it is impossible for the Java repository to calculate the correct information. These situations and the format of the definitions detailed below.
The following is an example of a Java type definition as the Smalltalk repository would store it in an application method.
sun_rmi_registry_RegistryImpl
^#((#class 'sun.rmi.registry.RegistryImpl' 'java.rmi.server.RemoteServer'
#SstRmiRegistry 4666870661827494597 4905912898345647071
('java.rmi.registry.Registry' 'java.rmi.Remote'))
(('bindings' 'Ljava.util.Hashtable;' #bindings #bindings:))
(#bind:to: 'bind(Ljava.lang.String;Ljava.rmi.Remote;)V'
('java.rmi.RemoteException' ...) 7583982177005850366)
...)
The example illustrates the following:
1. The method selector is derived by replacing all '.' in the Java class name with '_'. Make sure that the Java class is contained in a package.
2. (#class <class><superclass><Smalltalk class><serialization UID><interface hash>(<interface><interface>...))
3. ((<field name><field type>)(<Smalltalk getter><Smalltalk setter>)...)
4. (<Smalltalk method selector><Java method signature> (<exception>...)<method hash>)
Tip icon
For Java 1.2, if you don't use the method hash entry, the hash value is generated dynamically. Therefore, if you don't use the method hash entry, there could be performance considerations. For Java 1.2, the method hash entry is optional. For Java 1.1, the method hash entry is not necessary.
5. More method definitions as required
The Java repository is able to output all information but that in the <Smalltalk*> fields, which include the implementation class, method selectors, and field accessors. By default the <Smalltalk*> elements of the definition are given as ##nil. In the case of the implementation class and method selector, these values must be replaced by you. This is done by editing the relevant files or methods.
If a field accessor entry is ##nil, the default accessors derived from the field name (for example, name and name:) are used. You can redefine these to be the selector of your choice.
Note that merging a new file from the Java repository into an existing repository or application will preserve the Smalltalk information previously specified.
The method entries are only required if the class is not serializable (that is, remote). Serializable objects are copied and, once instantiated in Smalltalk, are normal Smalltalk objects.
Tip icon
Do not reorganize the information in the Java class definitions. Java RMI depends on a specific ordering of class members (fields and methods) and the Smalltalk repository maintains the declaration order.
The builder can also take minimal Java class and interface descriptions and generate both the SST specifications described above and Java files containing the corresponding Java source. This is done using the generate* builder protocols. For example:
SstRmiTypeBuilder new
generateClassesAndJavaFor: 'java.class.name'
interfaces: #('interface.1' 'interface.2' ...)
methods: #(
('method1(Ljava.lang.String;J)Z'('java.exception.1'
'java.exception.2' ...))
...)
Note that there are several other related builder API methods. In addition, the output of the builder is controlled by setting the application, buildDirectoryStructure, stubVersion, and directory attributes. Detailed explanations are provided in the setter method comments.
Last modified date: 05/12/2020