# Changing Method Names

## ObjectiveCName Annotation

You can annotate any Java method with
[@ObjectiveCName](https://developers.google.com/j2objc/reference/annotations/objectivecname) to change the translated name of
that method and any method that overrides it. For example:

    @ObjectiveCName("setTimeWithHours:minutes:seconds:")
    public void setTime(int hours, int minutes, int seconds) {
      ...
    }

is translated as:

    - (void)setTimeWithHours:(jint)hours
                     minutes:(jint)minutes
                     seconds:(jint)seconds;

> [!NOTE]
> **Note:** The string value in the annotation is the desired Objective-C selector. Parameter types and names are excluded.

## Mapping File

Method names can be changed using the **--mapping** flag, which takes a properties file with the
mappings to use. Each method mapping is defined with the full Java method signature for the key, and
an Objective-C selector value. For example, the line to map Object.equals() to NSObject.isEqual:
is:

    java.lang.Object.equals(Ljava/lang/Object;)Z = isEqual:

The left hand declaration is the full method signature, as [defined by the Java Virtual Machine
Specification](http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.4). The right
hand definition consists of the iOS selector (i.e. what you would pass to @selector()).
The method and its mapping must have the same number of parameters.

As another example, this line is equivalent to the example in the previous section:

    pkg.ClassName.setTime(III)V = setTimeWithHours:minutes:seconds:

Additional mapping files can be specified on the command-line, using the --mapping option.