User Tools

Site Tools


inner_classfiles_naming

This is an old revision of the document!


From the beginning of the introduction of inner classes in Java, developers knew that it would be a mess… and it has been proven again and again. Here is a recent example. Take the following (academic) piece of code:

public class Anonymous {
	public void foo() {
		class B {}
		new B();
	}
}

Compile it with your standard Java compiler javac. On both MacOS and Windows, there are two files generated… BUT, these two files have different names (!), thus throwing on the ground some of the dedicated PADL tests (in particular in project PADL Creator ClassFile Tests)

  • On MacOS
    • Anonymous.class
    • Anonymous$1B.class
  • On Windows
    • Anonymous.class
    • Anonymous$1$B.class

Did you notice the difference? on MacOS, the file describing the inner class is named Anonymous$1B.class with only one $ sign, while on Windows, its name is Anonymous$1$B.class with two $ signs. Sigh…

inner_classfiles_naming.1384328466.txt.gz · Last modified: 2018/03/04 02:53 (external edit)