[3112] in java-interest
Re: Java Specification
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Tue Oct 31 14:44:35 1995
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: andcal@dcs.warwick.ac.uk (Andrew Callow)
Date: Tue, 31 Oct 1995 09:07:22 -0800 (PST)
Cc: java-interest@webrunner.neato.org (java)
In-Reply-To: <9052.199510311414@box.dcs.warwick.ac.uk> from "Andrew Callow" at Oct 31, 95 02:14:56 pm
Hi Andrew,
> Although I know the Language Specification is preliminary I would really
> appreciate some answers to the following questions.
>
> JLS = Java Language Specification alpha 1.3
>
> JLS 1
> Why is it that only one class/interface per compilation unit may be public?
The compiler needs to be able to find public classes on demand. If you have
more than one per file, then the compiler may not be able to find it because
the file name doesn't coresspond with the class name.
> JLS 4.1
> Discussion of narrowing class A to be used as an instance of class B.
> How are the possible 'extra' instance variables to be dealt with? Is class B's
> constructor called? The spec. says the programmer can write a type
> conversion - does a special casting routine have to be written?
Nothing special is done. Narrowing is an operation on the reference to
the object, not the object itself. A narrowing operation can therefore
only succeed if the object is already of the correct type. If it isn't,
then an exception is thrown.
> JLS4.4
> There is a table of costs for base type conversions. What is the scale used?
> How do these numbers relate to each other (apart from the obvious ordering)?
We've removed this table from the latest language spec. It sets of alarm
bells with a lot of people. We've now adopted a similar, but easier to
explain method matchin algorithm.
> JLS 4.7.2
> "When a class is loaded". Do I take this to mean when the first instance
> of the class is created? Is the code within the unnamed static method
> only executed once?
A class is loaded when it is first referenced. That can happen in many ways
and you shouldn't rely on the exact order in which it happens. The static
initializer is executed only once.
Have fun,
Arthur van Hoff
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com