Your generated Java program can call generated or non-generated
Java code.
To call one generated Java program from another, invoke the target Java™ class by using a
call statement.
However, be aware of package dependencies. One of the following statements
must be true:
- The target class and caller are in the same package; or
- The name of the target class is qualified with a package name.
If you want the generated Java program to invoke non-generated Java code, create an ExternalType
part that has the
JavaObject stereotype.
The part contains function prototypes for the Java methods of interest. In this case, invoke
a Java method in one of two
ways:
- If the method is marked static, invoke it by using dot syntax
that references the name of the ExternalType part; for example, MyExternalType.myMethod().
- Otherwise, create a variable based on the ExternalType and use
dot syntax to append the variable name to the name of the method;
for example, myVariable.myMethod().
When you invoke a non-generated class, it must provide a method
to instantiate itself. You cannot instantiate a Java class from within EGL.