Is a Java package the equivalent of a .Net assembly?

后端 未结 5 1005
一个人的身影
一个人的身影 2020-12-04 20:01

I am a .Net developer starting Java development for Android and would like to know if it\'s correct to think of Java packages like .Net assemblies.

5条回答
  •  一个人的身影
    2020-12-04 20:20

    Bear in mind that I'm far from a Java expert, but anyway, there it goes my take on this:

    As pointed out by other answers, a package is not the equivalent to an Assembly. However, I don't fully agree with the idea of a .jar being the equivalent to an Assembly. To me, a Java class (contained in a .class file) is closer to an Assembly than a .jar is. I'm saying this cause while the load unit for the CLR is the Assembly (which means all classes contained in that Assembly get loaded), the load unit for the JVM is a class (when the JVM needs a class, the ClassLoader does not load all the classes in the container jar, it just loads that specific needed class).

    You can read more about java class loading here: When does the JVM load classes?

    and here: http://www.lansa.com/support/notes/p0294.htm

提交回复
热议问题