jeudi 7 septembre 2017

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?





Aucun commentaire:

Enregistrer un commentaire