aspose file tools*
The moose likes Java in General and the fly likes Java type system Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java type system" Watch "Java type system" New topic
Author

Java type system

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Hi Jim,

What you have explained about "A Real Problem" in the The Type System chapter of the book?

And are you talking about any possible improvement for the language in the book?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Jim Waldo
author
Greenhorn

Joined: Jun 22, 2011
Posts: 29
I assume you are talking about the real problem of the difference between the runtime type (which includes the classloader) and the compile time type (which does not).

If so, I'm afraid I don't have any fixes at the language level. If I had a time machine, we could go back and stop the decision of making the classloader part of the type, so that the compile time type and the runtime type were the same. But making that change now would break too much existing code, to say nothing of all of the "clever" uses of classloaders that peoples have invented. Most of these are disgusting hacks (my technical term), but some are also useful.

As a craftsperson/programmer, you can avoid a lot of the problem cases by declaring all of your arguments and return values as interfaces rather than classes. Since interfaces are not scoped by classloader, you don't run into the same problem. This is yet another reason to have all of your declarations done with interfaces. I know that there are some people who think that I'm an interface bigot, but only because the use of interfaces lets you avoid to many problems.

At this point in Java's life, it is very hard to fix problems by changing the language, since almost everything is depended upon by a large number of running programs and systems. But we can find idioms that keep the problems from getting worse. Not as good as a real fix, but better than nothing.


Jim Waldo
Author of Java:The Good Parts
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

At this point in Java's life, it is very hard to fix problems by changing the language, since almost everything is depended upon by a large number of running programs and systems.

Agree.
But we can find idioms that keep the problems from getting worse. Not as good as a real fix, but better than nothing.

Or even new features to do things in a proper way than before without breaking the old code yet can be applied to new code...
 
 
subject: Java type system
 
Similar Threads
iPad Portable Genius
Need Help with beginner Java programming.
AXIS: Next Generation Java SOAP by Romin Irani, S. Jeelani Basha
OCJP 6 Passed with 86% - Thanks to Kathy Sierra and Bert Bates
Any chances of Head First Spring Framework getting released?