Removes ElementUtil.toModifierSet() and ignores DEFAULT modifier in fromModifierSet() conversion. Previously we used the JDT bitmask for DEFAULT but JDT references are being removed.
Change on 2017/09/01 by kstanger
@@ -511,59 +511,7 @@ public final class ElementUtil {
return Sets.intersection(e.getModifiers(), VISIBILITY_MODIFIERS);
}
- public static Set<Modifier> toModifierSet(int modifiers) {
- Set<Modifier> set = modifierSets.get(modifiers);
- if (set == null) {
- set = EnumSet.noneOf(Modifier.class);
- if ((modifiers & java.lang.reflect.Modifier.PUBLIC) > 0) {
- set.add(Modifier.PUBLIC);
- }
- if ((modifiers & java.lang.reflect.Modifier.PRIVATE) > 0) {
- set.add(Modifier.PRIVATE);
- }
- if ((modifiers & java.lang.reflect.Modifier.PROTECTED) > 0) {
- set.add(Modifier.PROTECTED);
- }
- if ((modifiers & java.lang.reflect.Modifier.STATIC) > 0) {
- set.add(Modifier.STATIC);
- }
- if ((modifiers & java.lang.reflect.Modifier.FINAL) > 0) {
- set.add(Modifier.FINAL);
- }
- if ((modifiers & java.lang.reflect.Modifier.SYNCHRONIZED) > 0) {
- set.add(Modifier.SYNCHRONIZED);
- }
- if ((modifiers & java.lang.reflect.Modifier.VOLATILE) > 0) {
- set.add(Modifier.VOLATILE);
- }
- if ((modifiers & java.lang.reflect.Modifier.TRANSIENT) > 0) {
- set.add(Modifier.TRANSIENT);
- }
- if ((modifiers & java.lang.reflect.Modifier.NATIVE) > 0) {
- set.add(Modifier.NATIVE);
- }
- if ((modifiers & java.lang.reflect.Modifier.ABSTRACT) > 0) {
- set.add(Modifier.ABSTRACT);
- }
- if ((modifiers & java.lang.reflect.Modifier.STRICT) > 0) {
- set.add(Modifier.STRICTFP);
- }
- // Indirectly check whether Modifier.DEFAULT exists, since it was
- // added in Java 8.
- if ((modifiers & org.eclipse.jdt.core.dom.Modifier.DEFAULT) > 0) {
- try {
- Modifier m = Modifier.valueOf("DEFAULT");
- set.add(m);
- } catch (IllegalArgumentException e) {
- // Can only add DEFAULT modifier in Java 8.
- }
- }
-
- modifierSets.put(modifiers, set);
- }
- return set;
- }
-
+ // This conversion is lossy because there is no bit for "default" the JVM spec.
public static int fromModifierSet(Set<Modifier> set) {
int modifiers = 0;
if (set.contains(Modifier.PUBLIC)) {
@@ -599,16 +547,6 @@ public final class ElementUtil {
if (set.contains(Modifier.STRICTFP)) {
modifiers |= java.lang.reflect.Modifier.STRICT;
}
- // Indirectly check whether Modifier.DEFAULT exists, since it was
- // added in Java 8.
- try {
- Modifier m = Modifier.valueOf("DEFAULT");
- if (set.contains(m)) {
- modifiers |= org.eclipse.jdt.core.dom.Modifier.DEFAULT;
- }
- } catch (IllegalArgumentException e) {
- // Can only add DEFAULT modifier in Java 8.
- }
return modifiers;
}
