This section describes both the basics around importing existing Java code, and at a language level, the compatibility between StrataCode code and Java code.
Importing Compiled Java Libraries
StrataCode is designed to make it easy to work with large Java code bases. As a first step, you can simply import pre-compiled Java libraries and use them from StrataCode. You cannot modify these types using the modify operator, inject data binding, or use other features with them that require that StrataCode generate the code for these types.
A layer definition file can append to the class path as needed to add compiled libraries to the system. These types are automatically treated as JavaBeans by StrataCode using the get/set pattern. You can attach metadata to individual classes using "annotation layers". This metadata can affect the compiled code which uses that type, e.g. turning any use of a class into a component automatically. You can mark properties as constant to eliminate data binding warnings and overhead listening for events on properties that do not change. You can add code templates to a type used for defining object instances or component definitions.
To automate installs and updates, StrataCode has a simple repository package management system. There are RepositoryManagers for git, http, and maven but it will be easy to add others or it's easy to run commands from the command line. During the runtime, these package managers can ensure all dependencies are met before loading the Java code and do any installation or updates necessary.
Compilation of Java and StrataCode
To use more StrataCode language features, you can also copy your source files into layers and have StrataCode pre-process them.
Each layer can contain a mix of Java and StrataCode files. For Java files, you can use either the '.java" extension or ".scj'. You should .scj when you'd like to use the StrataCode IntelliJ plugin. StrataCode will translate all files to vanilla Java files before compiling. If your layer has Java files and you don't use any extensions, these files are passed through unmodified to the compilation phase. By default both .java and .scj files are processed as source files but it would be easy to configure it so .java files are copied without processing.
The only changes made to Java files are cosmetic - add a missing "package" tag from the layer's package, add a missing public or private modifier when you mark your layer as public or private. When dealing with pure Java files, StrataCode will still maintain class dependencies, compiling only files required to ensure your .class files are always up to date. This makes it easy to incrementally add StrataCode to an existing Java project a file at a time, replacing Java's ant build tool.
Compatibility with Java
You can simply rename a .java file with a .sc suffix and it should continue to compile and most likely will work without any changes. StrataCode classes use and produce standard Java types. A few changes made in the conversion from StrataCode to Java though could change the behavior in some edge cases. The biggest change is that fields and references in StrataCode may be automatically converted to getX and setX methods using the JavaBean naming convention.. So if you rename a .java file to a .sc file, when it gets compiled the resulting .java file may be different. If you don't happen to use any of the modified features though, the generated .java file will be the same. Get/Set conversion is performed when you use data binding, or annotate a property with an annotation. When changes are made to a source file, they are incremental because of the parselets framework.
Another difference between StrataCode and Java is that in Java a non-static field is treated the same as if you added the static keyword. But in StrataCode an interface with non-static fields will treat those as "instance fields" for all implementing classes. In other words, StrataCode uses a multiple inheritance pattern. It will copy those fields into each implementing class add add getX and setX methods to retrieve the field. All references to those fields are converted to call getX and setX instead so they work in the same way as interfaces.
If you do not want this behavior for a given interface, do not rename it to have the .sc suffix or add static/final modifiers.
There are a few other minor compatibility problems where Java code might not compile as StrataCode. With the object operator classes and instances are defined in the same name space. Java allows types and variables to have the same names - you always know whether you are looking up a type or a variable and so can determine which to use based on the context. StrataCode will treat types and variables of the same name as an error unless the variable is of that type. So in StrataCode, if you have two classes named "foo" and "bar", this code compiles: "foo; bar bar;" but this code gives errors: "bar foo; foo bar;"