Currently, the JRuby AOT compiler does not output any kind of version information in the produced class files. This makes it difficult to debug, if a ruby.rb file, compiled by an earlier AOT compiler to ruby.class, is loaded by a later and incompatible version of the JRuby runtime.
A specific use case from my project: I have some ruby files that are library dependencies (such as optparse.rb or Active Support), and I pre-compile them to be loaded as a lib.jar. Without version information and compatibility check, it will be difficult to determine any runtime error, if I upgrade to a later and incompatible JRuby runtime, while still using the lib.jar compiled by an earlier version.
This may also be useful for generic pre-compilation of popular Ruby libraries, such as active_support.jar or rails.jar, which can then be deployed or released without each user having to pre-compile their own copies (more work will be needed, but compiler version information will be a necessary feature to ensure safe usage of older released compiled JRuby class files).
My suggestion is for the compiler to output its version information in the produced class files. At runtime, the JRuby runtime will consult the version information and check to make sure that the loaded code is compatible with its' own version. If the loaded file is not compatible, an appropriate exception can be thrown (rather then the current way of various Java linkage error with no indication that they are due to JRuby version compatibility).
Peter, would having the logic that loads script classes catch a LinkageError and report a better error message for it be acceptable? Do you have an example of the error you saw?
I will keep looking at how I can embed some data into the class file without adding a lot of overhead.