Reputation: 241
I will do my best to explain the exact situation we ran into. Let me know if you guys have additional questions. I do not know if this is a java linking issue or a java loading issue.
I have compiled the code using a external jar file which has changed during the execution. I am referencing a class file called "Contract" in my code. The library which I am using at compile time has a "Contract" class which extends from the "BaseContract" class. But the library which I am using at execution time does not have a super class ("BaseContract"). At runtime, I get a a error saying BaseContract class is not found. The class referencing the "Contract" class, lets say, is called "AppClass".
At compile time, does java store the class hierarchy of all its referenced classes in the class file which is being compiled. In my specific example, does java store the class hierarchy of the "Contract" class in the AppClass.class file? If so, why does java have to store the class hierarchy here. Is it not more efficient to store the class "Contract" hierarchy in the Contract.class file rather than in the AppClass.class file?
Any help or pointers are greatly appreciated.
Upvotes: 0
Views: 370
Reputation: 41178
No, it doesn't. Each class knows only it's own class hierarchy. However it also knows when it goes to make a method call, create an object, etc the expected signature of that method, type of that object, etc.
If nothing is available matching that expectation then you will get the class not found error (or other similar errors depending on exactly what the miss-match is).
Upvotes: 1