9.8. Native Methods

Be careful when using native methods. Native methods, by definition, are outside the Java security system. Neither the security manager nor any other Java security mechanism is designed to control the behavior of native code. Thus, errors or security breaches in native code can be a lot more deadly. You should examine native methods for the parameters they take and the values they return. In particular, if a native method does something that bypasses Java security checks, you must be very careful about the access mode of the method. If the mode is public, anyone can call the method. You must examine the consequences and decide whether that method should be made private.

Get Inside Java™ 2 Platform Security: Architecture, API Design, and Implementation, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.