I'm working with a LARGE legacy C++ code base with numerous IDL files that have all the types and constants declared outside of any module.
For C++, this results in code being generated to the global namespace -- ugly, but acceptable.
Now I'm trying to add Java clients to connect via CORBA. For Java, however, the types that are generated from the IDL (using the Sun/Oracle IDL compiler for java: idlj) are in the java default package because they are not within an IDL module. This results in Java compilation errors, as it is illegal to import from the default package.
I'm looking for the easiest way to correct the problem.
I've considered the following:
I find it difficult to believe that there's no easy way to force the IDL to be in a Java package if there's not an existing module that contains all the types. I'm hoping that I'm just missing the obvious!
Edit:
Example:
Foo.idl
struct Foo
{
.
.
.
}
Foo.java: (note that no package is specified, meaning 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;
};
you can play with options pkgPrefix and pkgTranslate as indicated in a french site I guess you had that part right but I detail just in case.
example:
interface T1
{
};
interface T2
{
};
You out pkgPrefix configuration in file idl.config
PkgPrefix.T1=aaa
PkgPrefix.T2=bbb
Following command
idlj -td dir T.idl
creates the files in (existing) directory dir:
dir/
├── aaa
│ ├── T1Helper.java
│ ├── T1Holder.java
│ ├── T1.java
│ ├── T1Operations.java
│ └── _T1Stub.java
└── bbb
├── T2Helper.java
├── T2Holder.java
├── T2.java
├── T2Operations.java
└── _T2Stub.java
To create the configuration file, you can use a combination of grep / awk / sed / cut.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With