Why are Java primitive types' modifiers `public`, `abstract`, & `final`?
- by oconnor0
In the process of doing some reflection on Java types, I came across an oddity that I do not understand.
Inspecting int for its modifiers returns public, abstract, and final. I understand public and final, but the presence of abstract on a primitive type is non-obvious to me. Why is this the case?
Edit: I am not reflecting on Integer but on int:
import java.lang.reflect.Modifier;
public class IntegerReflection {
public static void main(final String[] args) {
System.out.println(String.format("int.class == Integer.class -> %b", int.class == Integer.class));
System.out.println(String.format("int.class modifiers: %s", Modifier.toString(int.class.getModifiers())));
System.out.println(String.format("Integer.class modifiers: %s", Modifier.toString(Integer.class.getModifiers())));
}
}
The output when run:
int.class == Integer.class -> false
int.class modifiers: public abstract final
Integer.class modifiers: public final