Jrpcgen - Distinct RPC/XDR IDL Compiler

Jrpcgen compiles RPC/XDR IDL ("*.x") files into Java client and server stubs.

Syntax

java Jrpcgen [ options ] filename.x

Description

The Jrpcgen command compiles RPC/XDR IDL ".x" files into Java client and server stubs. You then integrate these stubs with your RPC client or server application, compile the complete application with javac (or an equivalent Java compiler), and run it together with the Distinct ONC RPC/XDR for Java.package. The stubs are created as Java files in the current directory. Jrpcgen creates one main stub class file per ".x" file, which has the same name as the ".x" file but has a ".java" extension,  as well as one Java class per data structure defined in the ".x" file. The server stubs include an additional stub for the server.

The main stub class is always derived from the class JRPCClient. It defines a constructor that connects the client to the server and one method for each function defined in the RPC/XDR interface description. As with the C mapping, the interface version number is automatically appended after an underscore to the method names. All defined types in the interface description and the types of the methods input and output parameters are mapped to equivalent Java types.

XDR data structures are mapped to Java types as follows.
(unsigned) int int
(unsigned) long int
(unsigned) short short
(unsigned) char char
(unsigned) hyper long
float float
double double
bool boolean
string String
opaque byte array
fixed length array Java array
variable length array Java array
optional data (pointer-like *x) Reference to an object of class x. If x is a basic type, a special wrapper class XDRx which implements XDRType is used instead.
enum x Class x implements XDRType with member variable int value and one constant int per enum constant.
struct x Class x implements XDRType with member variables for each struct member.
union x Class x implements XDRType with member variables for each union member including discriminant. No overlaying of members is supported (neither for type conversion nor for saving space).
typedef x y Class x implements XDRType with member variable value of the redefined type y.
Each generated class implements the XDRType interface. This interface defines the methods for encoding and decoding the classes into and from an XDRStream. You can define your own types (or alter the Jrpcgen generated files) and use them in RPC calls as long as they define these RFC 1832 (XDR) compliant encoding and decoding methods.

Jrpcgen understands C-like comments (/* ... */) and it copies lines that are starting with a "%" symbol in front of all generated output files. By default, Jrpcgen runs a C/C++ preprocessor on the given ".x" file before translating it to Java. It defines two symbols for this preprocessor run. The symbol "JAVA" is always defined. In addition, a context symbol with the name of the top-level ".x" file (without extension) is defined (i.e. "java Jrpcgen demo.x" defines a symbol "demo"). This allows the writing of RPC/XDR specifications with special Java related parts (although this is not recommended, it might sometimes be necessary).

Options

-S
Use this option to generate the server side stubs.
-p package
Specifies the package name of the generated stub files. By default there is no package name.
-P package
Specifies the package name of the generated stub files, creates the according package subdirectories and places the generated files there.
-n
Do not run the C/C++ preprocessor before translating the ".x" file. This option is useful when you do not have a C compiler installed and you want to translate a file that does not contain preprocessor directives.
-o class
Names the generated class as specified by the class parameter.Without this option, the name of the generated class is based on the name of the .x file being processed. This option is useful to override the default behaviour if there is no relationship between the class name and the name of the .x file.
-m
Jrpcgen by default generates constructors for XDR data types. For backward compatability, this feature can be disabled by specifying this option.
-f
Names the generated class after the name given in the "program" statement. Without this option, the name of the generated class is based on the name of the .x file being processed. This option is useful to override the default behaviour if there is no relationship between the class name and the name of the .x file.
-c C-preprocessor
Specifies the name of the C/C++ preprocessor to be used. The default is "cl /C /EP /nologo" (in the current path). Specify the command line if you are using a different preprocessor (for example, "/usr/ccs/lib/cpp" on Solaris systems).