<p>Core calculi for Java typically take the classes-as-types approach.  Two well-known examples are <a href="http://dl.acm.org/citation.cfm?id=320395">Featherweight Java</a> and <a href="http://dl.acm.org/citation.cfm?id=268961">Classic Java</a>.</p>

CC BY-SA 3.0
2012-08-31T15:49:59.530Z
Given OO researchers' actual practice, this is clearly the right answer. As a personal prejudice, I've never liked the FJ style of fixing the class table up-front and not letting it vary during program execution. It feels like a trick, sort of like interpreting functional languages by defunctionalizing them. I don't do objects often enough to do anything about it, though!
Neel Krishnaswami
CC BY-SA 3.0
2012-09-01T13:16:16.780Z
@NeelKrishnaswami, if you wanted to model Pascal, wouldn't you start with a table of procedures, as in the *IMP* language in Winskel's book? In Java, the set of classes *is* fixed up front (unless you're modeling class-loaders, or something like that).
Sam Tobin-Hochstadt
CC BY-SA 3.0
2012-09-01T14:18:46.397Z
Thanks Sam.  Featherweight Java is a very useful data point.  I had forgotten about that.  On the other hand, FJ seems to be used mainly for defining type systems and type checking, and there seems to be very little on its semantics.  So, what a class means as a type is still an open question.
Uday Reddy
CC BY-SA 3.0
2012-09-01T14:23:05.380Z
@NeelKrishnaswami I wonder why the assumption is made that the class table is fixed.  If it is merely to define the operational semantics, then the assumption would be quite reasonable because the entire class table would be available before a program is run.  Is it restrictive for other reasons?
Uday Reddy
CC BY-SA 3.0
2012-09-01T18:31:24.437Z
@UdayReddy, I'm not sure what more you're looking for.  FJ (and Classic Java) both provide operational semantics for the languages.
Sam Tobin-Hochstadt
CC BY-SA 3.0
2012-09-02T12:47:14.100Z
@SamTobin-Hochstadt: Class loaders are the clearest example, but all libraries in OO languages are intended to be used in programs which have extended the class hierarchy. So it feels morally wrong to me not to represent that in the semantics.
Neel Krishnaswami
CC BY-SA 3.0
2012-09-03T03:05:08.100Z
@SamTobin-Hochstadt: I could say that I am looking for denotational semantics, but my search at the moment is for something more basic.  What does a class *mean* when used as a type?  You can see some discussion I have included in [Objects and Classes in Algol-like Languages](http://www.cs.bham.ac.uk/~udr/papers/objects-and-classes.pdf), under two headings "types versus classes" and "types and classes".  (There are also interesting citations there which I had forgotten about.)  I am trying to see whether there any other answers by now.
Uday Reddy
CC BY-SA 3.0
2012-09-03T22:51:21.533Z
@NeelKrishnaswami, but *Java* doesn't represent that in the semantics -- a Java library isn't runnable by itself. Are you unhappy (like Uday) that these formalisms aren't giving a compositional account of the meaning of classes?
Sam Tobin-Hochstadt
CC BY-SA 3.0
2012-08-31T14:48:04.710Z
2012-08-31T14:48:04.710Z
Sam Tobin-Hochstadt
<p>In typical object-oriented programming languages like Java, <em>classes</em> are used as types.  On the other hand, type-theoretic approaches to object-oriented languages treat <em>interfaces</em> as types.</p>

<p>Are there any theoretical frameworks that formalize the use of classes as types?</p>

<pl.programming-languages><type-systems><object-oriented>
Classes and types in object-oriented languages
Uday Reddy
# Classes and types in object-oriented languages

(Asked by: username_0 on 2012-08-31)

In typical object-oriented programming languages like Java, *classes* are used as types. On the other hand, type-theoretic approaches to object-oriented languages treat *interfaces* as types.

Are there any theoretical frameworks that formalize the use of classes as types?

**Tags:** pl.programming-languages, type-systems, object-oriented

---

## 1 answers

### Answer by username_1 on 2012-08-31. Score: 6 | Accepted answer

Core calculi for Java typically take the classes-as-types approach. Two well-known examples are [Featherweight Java](http://dl.acm.org/citation.cfm?id=320395) and [Classic Java](http://dl.acm.org/citation.cfm?id=268961).

> **Comments:**
> **username_2**: Given OO researchers' actual practice, this is clearly the right answer. As a personal prejudice, I've never liked the FJ style of fixing the class table up-front and not letting it vary during program execution. It feels like a trick, sort of like interpreting functional languages by defunctionalizing them. I don't do objects often enough to do anything about it, though!  
> **username_1**: @NeelKrishnaswami, if you wanted to model Pascal, wouldn't you start with a table of procedures, as in the *IMP* language in Winskel's book? In Java, the set of classes *is* fixed up front (unless you're modeling class-loaders, or something like that).  
> **username_0**: Thanks Sam.  Featherweight Java is a very useful data point.  I had forgotten about that.  On the other hand, FJ seems to be used mainly for defining type systems and type checking, and there seems to be very little on its semantics.  So, what a class means as a type is still an open question.  
> **username_0**: @NeelKrishnaswami I wonder why the assumption is made that the class table is fixed.  If it is merely to define the operational semantics, then the assumption would be quite reasonable because the entire class table would be available before a program is run.  Is it restrictive for other reasons?  
> **username_1**: @UdayReddy, I'm not sure what more you're looking for.  FJ (and Classic Java) both provide operational semantics for the languages.  
> **username_2**: @SamTobin-Hochstadt: Class loaders are the clearest example, but all libraries in OO languages are intended to be used in programs which have extended the class hierarchy. So it feels morally wrong to me not to represent that in the semantics.  
> **username_0**: @SamTobin-Hochstadt: I could say that I am looking for denotational semantics, but my search at the moment is for something more basic.  What does a class *mean* when used as a type?  You can see some discussion I have included in [Objects and Classes in Algol-like Languages](http://www.cs.bham.ac.uk/~udr/papers/objects-and-classes.pdf), under two headings "types versus classes" and "types and classes".  (There are also interesting citations there which I had forgotten about.)  I am trying to see whether there any other answers by now.  
> **username_1**: @NeelKrishnaswami, but *Java* doesn't represent that in the semantics -- a Java library isn't runnable by itself. Are you unhappy (like Uday) that these formalisms aren't giving a compositional account of the meaning of classes?  

---

