Obviously, if Object refers to java.lang.Object (as defined by the loader loader), this is not possible, since each class of the process must be omitted from java.lang.Object
However, you can define something else called Object in the inner scope by hiding java.lang.Object .
Here's an example where the name Object refers to java.lang.Object at the beginning of the method and local class later:
public static void main(String[] args) { Object value = "42"; class Object {} System.out.println(value instanceof Object); }
This is a small cheat because the value declaration is not a single statement, but an operator followed by a local class definition.
I tested this in Eclipse 3.5.0, but I wonβt be surprised if other compilers behave differently with a pathological example like this.
finnw source share