Q:

java.lang.reflect.Method#getModifiers returns flag outside valid range?

The following code:
Class.forName("java.lang.String")
     .getDeclaredMethods
     .find(_.getName == "join")
     .get
     .getModifiers & ~(java.lang.reflect.Modifier.methodModifiers())

Evaluates to 128. It seems to me that it should evaluate to 0, because every modifier that's attached to the java.lang.String#join method should be within the set of java.lang.reflect.Modifier.methodModifiers().
Looking at the constants in java.lang.reflect.Modifier, it seems that 128 corresponds to the modifier bit java.lang.reflect.Modifier.TRANSIENT. How can a method end up being flagged as transient?

A:

Brief Explanation
There are two flags with the value 0x80 (128), VARARGS and TRANSIENT, as per the answer here, so the method is actually a varargs method.
The JavaDoc confirm that this method is varargs, so the flag makes sense
Worked example
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

class TestClass {
  public static void main(final String... args) throws Throwable{
    int methodModifiers = Class.forName("java.lang.String")
        .getDeclaredMethod("join", CharSequence.class, CharSequence[].class)
        .getModifiers();

    Field varargsField = Class.forName("java.lang.reflect.Modifier")
        .getDeclaredField("VARARGS");
    varargsField.setAccessible(true);

    int varargsF = varargsField.getInt(null);
    int staticF = Modifier.STATIC;
    int publicF = Modifier.PUBLIC;

    if (methodModifiers == publicF + staticF + varargsF) {
      System.out.println("Correct");
    } else {
      System.out.println("Wrong");
    }
  }
}

