A system and method is provided for reducing the complexity and improving
the performance of enforcing security restrictions on the execution of
program code in a runtime environment. In a preferred embodiment, units
of executable code, such as methods or functions, are classified by
"security level." Code units belonging to a "trusted" security level may
call any other code unit in the runtime environment, but other security
levels are restricted in the code units they can call. In a preferred
embodiment, the security levels are represented by corresponding
permission objects. Each permission object that is associated with a
particular security level includes a numerical value that denotes that
security level. Security policies can be enforced with respect to caller
and callee code units by comparing numerical values of corresponding
permission objects. This security level scheme also improves runtime
performance by making it unnecessary to check individually-defined
permissions in many cases.