Is it possible to make some privileged instructions (eg sti, cli) available via some Java's API?
Why not? (Or if it's is, could you give me some outline/basic idea of how this would be implemented?)
Thanks
In a conventional Java implementation, your only option is to implement the code that executes the privileged instructions in a native method that you call using JNI or JNA. And it won't do you any good ... because the hardware / operating system will prevent the instructions from running. (You will get an illegal instruction trap ... and the program will be killed.)
Why not?
Basically, if a regular Java application (or any other user-space application) could execute privileged instructions, it could trivially crash the operating system. That is a really bad idea.
In a bare-metal implementation of Java, it may be possible to execute privileged instructions via native code, or possibly by other means. (For instance, in JNode the native code compiler will replace certain "magic" method calls with privileged instructions ... under carefully controlled circumstances.)