A while back, I wanted to demonstrate to somebody on a mailing-list that the restrictions of the Java programming language and those of the Java Virtual Machine were not the same thing. Namely, that reserved keywords in the Java language are not reserved by the JVM.
Hence: class.class is a Java class called, well, 'class'. It has a main method, so if you put it in a directory and run 'java class', it'll instantiate an instance of itself and print out that instance's getClass().getName().
I could have used a fancy Java assembler, but an existing class and a hex-editor was quicker. :)
Epiphany:~ cmiller$ java class
this object's class is: class
Epiphany:~ cmiller$ javap -c class
Compiled from Class.java
public class class extends java.lang.Object {
public class();
public static void main(java.lang.String[]);
}
Method class()
0 aload_0
1 invokespecial #9 <Method java.lang.Object()>
4 return
Method void main(java.lang.String[])
0 new #2 <Class class>
3 dup
4 invokespecial #16 <Method class()>
7 astore_1
8 getstatic #22 <Field java.io.PrintStream out>
11 new #24 <Class java.lang.StringBuffer>
14 dup
15 ldc #26 <String "this object's class is: ">
17 invokespecial #29 <Method
java.lang.StringBuffer(java.lang.String)>
20 aload_1
21 invokevirtual #33 <Method java.lang.Class getClass()>
24 invokevirtual #39 <Method java.lang.String getName()>
27 invokevirtual #43 <Method
java.lang.StringBuffer append(java.lang.String)>
30 invokevirtual #46 <Method java.lang.String toString()>
33 invokevirtual #51 <Method void println(java.lang.String)>
36 return