Would it be possible to "emulate" the dynamic code generation that is done via Spring AOP, Dependency Injection and other Spring mechanisms when we recompile a java application to a native one? How about Hibernate and pure java reflection? Some of the tools that are capable of translating Java to native code include the GCC and the Excelsior compilers, but do they provide reliable native code that will work in the same way as does the Java application?
The whole story
Currently, we are facing a weird scenario at work. We have a server-side java web application that uses Spring with its dependency injection, messaging, MVC and AOP. The application is quite a large one, with complex structure and dependencies, involving lots of third parties and has a huge code base.
The problem is that we have to target a Windows system (Windows 7 embedded; Core2 Duo; 4GB RAM) that should host the above application. We have certain limitations (hardware, software and legal) which disallow us to use pure java code on the target hardware. The hardware operates a Windows operating system, and the only allowed option for us is a native executable (EXE).
So, we have to convert (a soft word for it) the java server application (or a minimal subset of it) to native one for the device. According to certain resources on the internet, this might be possible trough certain compilers that produce native (non-JAVA) binaries. However, due to severe difference between a dynamic platform (as Java is) and the static nature of the native one, some of the JVM features will not be available - for instance dynamic compilation and proxies (according to this page). So it seems a nearly impossible task for an application that is relying on dynamic fundamental technologies like Spring's DI, AOP and transaction management. Not to mention that we are using Hibernate as an ORM.
I must say that the whole application will be trimmed as much as possible and only the desired functionality will be left (as it is quite standalone - in terms of not relying on third party services to work), but still we cannot say goodbye to core concepts like Spring, Hibernate and AOP. Therefore, my question is: is it somehow possible successfully convert such an application to a native code (having the above properties and effective limitations)? Would it be possible to "emulate" the dynamic code generation that is done via the AOP (like writing our proxies as static instead if relying on the AOP) and other Spring mechanisms? Some of the tools that are mentioned to do this include the GCC and the Excelsior compilers. Do they provide reliable result with the dynamic technologies I mentioned? Is there any alternative besides rewriting the application on a more-static language like C/C++ (which is unacceptable for our time frame)? I'd also appreciate any arguments in support for not doing so, as we are currently just evaluating the opportunity. Any well-argumented rejection is acceptable for me, as myself personally have never done such native code conversion and am not aware of the full impacts of it over the software.
Your only real target option are things like IKVM and JNBridgePro -- however, i'm guessing a .net application is not really reasonable either given the way you described your constraints, and depending on the technical details of the application IKVM
In that case, you're pretty much asking for the impossible. There is no sane strategy for compiling java down to win32 native code that supports any significant subset of the average enterprise application tool chain.
It will be cheaper to re-write the application from scratch for the target platform then it will be to create the infrastructure and do the testing required to hack/port it from it's target runtime to a wholly unrelated foreign runtime.
UPDATE: Some things have changed: There is now graalvm which will generate native images for your java code. It's free and fancy and does largely what OP wanted.