Java is begin as Oak at SUN. Designed for coding set-top device for TV. Project failed. But Internet happened after, people want secure language, unlike binaries in C. Every language needs a "killer app". For Java, it was Internet.
Java's influence: Modula-3 type, Eiffel, Object C, C++ objects and interface, Lisp dynamic flavor.
(ie. write as parent class, read as child class that has missing fields)
Java type checks at runtime, which is slow.
Exception object is not an ordinary object.
try, mark current location in stack
throw, throw away stack until first
tryand execute corresponding
It introduce some overhead during normal execution. But more complex techniques reduce overhead. (and by make exception slightly more expensive for trade off)
finalization: before Java garbage collect an object, it will call the object's finalization method to do some user specified cleanup work. (useful for closing file handler)
When there is exception in finalization method, should garbage collector throw exception and abort? No. The exception is dropped like nothing happen.
Since many programmer forget to handel exception, Java's compiler check for possible exception and always enforce programmer to handel them. (except for some common exceptions like integer overflow)
Interface: specify relationship between classes without inheritance. (must provide same signature, and one class can
implements multiple interfaces)
It is harder to implement interfaces than inheritance, since methods in interfaces need not be at fixed offset. (infinitely many combination fo possible interfaces since there exists no total ordering)
One inefficient approach: lookup table from method string name to method address.
cast type for you.
widening coercion: always succeed
narrowing coercion: downcast, may fail at runtime
boolis the only type that has no coercion defined
Thread: has own program counter, own stack
Synchronization: obtain a lock on object so only one thread at a time can access.
Java guarantees write of values are atomic except for
double (since it is two machine instruction, unless is marked as
Concurrency in language is still in research.
Java allows classes to be loaded at run-time.
This is troublesome: type checking happens at compile time. So bytecode verification is needed when the class is loaded at run-time. Policies handled by
Classes can be unloaded, but behavior is not well-specified.
Class initialization in java: class is initialized when it is first used, not when loaded. (this is to make error in initialization predictable)
Initialization: we are talking about THE class, not an instance of the class (used for introspection and reflection)
lesson: any system with N features, there is around N^2 feature interactions (assuming pairwise feature), subset feature will grow exponentially.
Java was successful by production language standard
introduced strong static typing
introduced garbage collection
many feature have problems (not fully realized)
but too many features
Table of Content