Java Developer Tools

Audit - Rules - Portability

Description
This group contains audit rules that check your code for constructs that might hinder cross-platform portability.

Rules:

Details

Command Execution

Summary
External commands should not be executed because not all platforms have the same syntax for executing them.

Description
The method Runtime.exec() should not be used to execute commands because the format of command execution is platform dependent.

Example
The following invocation of the exec() method would be flagged as a violation:

    Runtime.exec("c:\\bin\\myApp.exe", new String[0]);

Disallow Native Methods

Summary
Native methods should be avoided because they are often platform dependent.

Description
Native methods should be avoided because they are often platform dependent.

Security Implications
When native methods are executed, the execution path leaves the Java API, leaving behind all Java security features, including any setup security managers.

Example
The following method declaration would be flagged as a violation because it is implemented as a native method:

    public int native getUID();

Disallow Use of AWT Peer Classes

Summary
AWT peer classes should not be referenced because they are platform dependent.

Description
The AWT peer classes provide a platform-specific implementation of the AWT widgets. Referencing any of these classes directly will result in platform dependent code.

Example
The following reference to the class sun.awt.windows.WButtonPeer would be flagged as a violation because it is specific to the Windows platform:

    if (peer instanceof sun.awt.windows.WButtonPeer)

Environment Variable Access

Summary
Environment variables should not be accessed because not all platforms have support for environment variables.

Description
The method System.getenv() should not be used to access environment variables because not all platforms have support for environment variables. Properties should be used instead.

Example
The following invocation of the getenv() method would be flagged as a violation:

    System.getenv("PATH");

Platform Specific Line Separator

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.