<< Previous <<         [Session1 Index]            >> Next >>

Java Abstraction Example

Question: Which Data object method grants an authority and needs to be encapsulated as a separate capability?

Answer: (c)


Remember detailed definition of a capability: a capability represents something you need to read or write "outside" to do. It is not a capability if you only need to do computations on info that the user of the object is supplying. With this in mind, looking at the choices in the question, (a), (b), and (d) are all simple computations. Only (c) requires going outside, in this case to the hardware clock.

Of course, Java makes no distinction between the functions that require capabilities and those which do not, except in the most gross fashion: in Java, there is no function for setting the current date! One of the first and simplest programs developed for windowed operating systems, the Clock program, cannot be written in Java! Just as Java's capabilities associated with ReadStreams in an earlier example were too powerful for security, Java's capabilities associated with Dates are too weak for general-purpose programming. We can, and must, do better. Fortunately, we can.