Why does Java generate Multiple .class files on compilation?

后端 未结 3 1577
逝去的感伤
逝去的感伤 2021-01-12 06:57

In Java, on compilation we get a .class file for each class( including nested classes and interfaces) defined in the source file.

What is the reason for this multiple

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 07:47

    That's is a design decision regarding a compilation unit, made by the developers. Compiled classes are usually combined in a jar file.

    Extract from Java Language Spec

    7.3 Compilation Units CompilationUnit is the goal symbol (§2.1) for the syntactic grammar (§2.3) of Java programs.

    Types declared in different compilation units can depend on each other, circularly. A Java compiler must arrange to compile all such types at the same time.

提交回复
热议问题