I work with LARGE's old C ++ code base with numerous IDL files that have all types and constants declared outside of any module.
For C ++, this leads to code generation in the global namespace - ugly but acceptable.
Now I'm trying to add Java clients to connect through CORBA. However, for Java, types created from IDL (using the Sun / Oracle IDL compiler for java: idlj ) are in the java package by default because they are not part of the IDL module. This leads to Java compilation errors, since importing from a package is prohibited by default.
I am looking for the easiest way to fix the problem.
I reviewed the following:
- Place the module declaration in all types . I am currently working on this solution, but it is VERY painful, based on the number of types affected and the impact on the large C ++ base code base.
- Use the -pkgPrefix or -pkgTranslate options . Until now, I canβt understand how to do this in general, since you must specify a module for translation or specify a type for adding a prefix. -pkgPrefix can be used for a specific type, but we have hundreds of types, and I would prefer not to list the -pkgPrefix option specifically for each compiled file ...
- Use the pragma directive ? I do not know which one to use, but hoping that the guru can point the way?
- ????
I find it hard to believe that there is no easy way to force the IDL to be in the Java package if there is no existing module that contains all types. I hope that I just miss the obvious!
Edit
- IDL-to-Java idlj compiler.
- Added example below.
- Updated item # 2 (see above) to clarify that using -pkgPrefix for each type is not possible (if it cannot be written enough by the script?)
Example:
Foo.idl
struct Foo { . . . }
Foo.java: ( note that the package is not specified, which means the default package ):
public final class Foo implements org.omg.CORBA.portable.IDLEntity { . . . }
ClassUsesFoo.java:
package com.sigh; import Foo; // <-- this is an error public class ClassUsesFoo { private Foo f; };
Kerry
source share