With JDK 6 released, we are considering features for inclusion in JDK 7. Here is a list of things I would like to see (in no particular order):
String s1 = Collections.max(Collections.emptySet()); String s2 = Collections.max((Set<String>)Collections.emptySet());Most developers are not familiar with implicit type arguments but you have to use them when inference fails:
String s = Collections.max(Collections.<String>emptySet());The original GJ compiler (which was the foundation for adding generics) did better. However, the specification was found to lead to an unsound type system and we did not find an alternative specification we had confidence in. I would like to investigate if we can do better now that we have more experience.
var) for this purpose. I would prefer not adding
a new keyword as this can break a lot of existing programs. I
discussed this with
Christian Plesner Hansen
on his last visit to Mountain View. He had a very simple
solution that I really like:
final strings = new ArrayList<String>();Christian's solution implies that you cannot assign the variable more than once. However, the more I think about this, the more I like it. We do not need to add a new keyword and if you don't want to specify the type of a variable, you should probably not assign to it later.
final property String name = "Name"; property String address;becomes
final private String name = "Name"; public String getName() { return name; } private String address; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; }Notice that
property need not be a keyword.
import java.util.List<String> as StringList;Notice that
as need not be a keyword.
final map = new HashMap<String, Integer>(); map["one"] = 1;
ArrayList<String> strings = ArrayList.of("a", "b", "c");
String s = 1;This gives this error message:
Test.java:3: incompatible types
found : int
required: java.lang.String
String s = 1;
^
1 error
This would be better:
Test.java:3: attempt to assign an expression of type int
to a variable with an incompatible type (java.lang.String)
String s = 1;
^^^^^^^^^^^^
foo and a method getFoo()?) and be
confusing. (is it field access or a method call with potential
unknown side-effects?) On the other hand, it has to be '.'
(dot). Anything else would look silly. I think this is
unsolvable.
Posted by Taras Tielkes on December 15, 2006 at 12:44 PM PST #
Posted by Peter von der Ahé on December 15, 2006 at 12:57 PM PST #
String switch statements would just encourage more use of strings which we do not need. XML literals are insane.
Consider this entry shared.
Maybe I'm an old stick in the mud or something but one of the things that has made me keep coming back to Java is that the code is nice and readable. Compare any Java program to Perl or C or almost any other language and I think most people would agree that the Java one is easier to follow. Why? A nice straightforward syntax. Not a lot of keywords. No pointers. In short, it's because of all the things that Java didn't do that made the language so readable. So it concerns me that we adding all these new shiny baubles to the language without considering what it will do to the long-term maintainability of the code, the readability that makes it so nice to work with etc.
I would far rather that you focused on the usability of the existing Java APIs, on adding new APIs like NIO2 that keeps getting delayed, improved memory usage and performance.
Please remember that every time you add a feature to the language that (unless you're very careful) you're reducing the readability of the code that will be eventually written.
I think the original designers of the language did a very good job of balancing features vs. readability etc... It concerns me that the people that are now in charge of the language aren't considering this so much. All the closure proposals I've seen seem to involve ugly syntax to the language. Shorthand syntax for local variable assignment? A new assignment operator (:=) ... Ugh. IMHO, it's not worth it. Please. Don't clutter up the language. Don't turn it into Perl where there are at least 49 ways to express the same thing.
Thanks,
Corey
Posted by Corey Puffalt on December 15, 2006 at 06:28 PM PST #
Corey, somehow your comment got flagged as spam. Sorry about that.
This is my personal wish list. I do not decide what actually happens. But since everybody else are public about what they want, I felt I had to make my preferences known as well.
I'm a compiler engineer and I implement language features and the purpose is to make existing API easier to use. But that has nothing to do with NIO2. But speaking of it, I'm convinced that the new NIO2 guy will get something done.
BTW: I find your comment about ':=' very funny given that it was suggested by James Gosling.
Posted by Peter von der Ahé on December 15, 2006 at 08:10 PM PST #
Posted by Peter von der Ahé on December 16, 2006 at 07:44 AM PST #
Posted by Igor Katrayev on December 17, 2006 at 03:25 PM PST #
Posted by Rory Winston on December 18, 2006 at 02:17 AM PST #
Hi everybody, i've patched javac to provide a prototype that allows the syntaxes decribed by James Gosling and Christian Plesner Hansen for declaring local variables.
The prototype is downlodable on my blog.
Let me know what you thinking.
RĂ©miPosted by Rémi Forax on December 18, 2006 at 03:01 AM PST #
Posted by Peter von der Ahé on December 18, 2006 at 03:12 AM PST #
I am in broad agreement with you about additions that would be beneficial to Java and a while back blogged about Clear, Consistent, and Concise Syntax . The blog suggests syntax like:
withLock lock, method{out.println "Hello"}; // Note no brackets and method{} for a closure
declare sum = 0; // Integer, for int use: int sum = 0 or declare int sum = 0
final strings = ArrayList< String >.new.add "A"; // Note Type.new instead of new Type for backward compatibility
method toString { "Hello" } // Overridden method declaration with return inferred
new( i ) { default } // Constructor uses new and infer argument type from field of same name and default means copy of argument into field - ML like but more flexible
method getName { default } // Read access to a variable of name Name - similarly setName
The point of this syntax is, as the name suggests, to be Clear, Consistent, and Concise (in that order). In particular the syntax uses
keyword( ... ) { ... } to be consistent with other Java constructs like if, etc.
The C3S syntax presented in the blog referenced above comes from earlier attempts, notably RFE 6389769 and a previous blog. In both these cases I consistently got feedback that the essence of Java is clear and consistent syntax that uses keywords. Hence the C3S proposal.
What do people in this forum think?
PS Sorry about the blocks - it was the only way I could get a code like font on the blog!
Posted by Howard Lovatt on December 18, 2006 at 05:51 PM PST #
Closure - not really. Feels like too much overlapping with other features in the language, even though it could make other things possible. IMO a language should stay concise, i.e. minimising the number of ways to accomplish any given task.
Type Literal - quite cool from completeness point of view.
Super packages - will need to see how it gets on with existing visibility mechanism. One can't erase history in the Java Language ;-)
Improved Type Inference - yeah, why not? I like the challenge from an academic point of view as well.
Shorthand syntax for declaring local variables - "final" is definitely an elegant solution. Especially that means the keyword would get used more often, hence could save me a lot of trouble when debugging / fixing others' code!
Shorthand syntax for declaring properties - I think Tools is the answer to this, not the language itself.
Type aliasing - could potentially becomes as confusing as #define. And it's probably just me but I really quite like the verbosity - just get yourself a bigger / wider screen :-D
Array syntax for collections - nice, but not very Java-ish to me and would make the language less "concise".
More factory methods for collection classes - or constructors? Can be decided through a popularity vote I suppose.
Self-types - hmmm... I don't have any compelling use cases off the top of my head. So I shall kindly skip this one :-P
Improved compiler diagnostics - always a nice & ongoing work.
Strings in switch statements - ugh, go away! *takes deep breathe* I mean, what are the gains beside introducing another possibility to do the same thing?
XML literals - indeed embedding these stuff outside the Java source code, e.g. through property files with IDEs' aid seem to be the better way.
Shorthand syntax for accessing properties - can't really see what we can gain from this. Really.
Posted by Alex Lam on December 21, 2006 at 12:04 AM PST #
marked as spam?!
Posted by Alex Lam on December 21, 2006 at 12:05 AM PST #
Closure - not really. Feels like too much overlapping with other features in the language, even though it could make other things possible. IMO a language should stay concise, i.e. minimising the number of ways to accomplish any given task.
Type Literal - quite cool from completeness point of view.
Super packages - will need to see how it gets on with existing visibility mechanism. One can't erase history in the Java Language ;-)
Improved Type Inference - yeah, why not? I like the challenge from an academic point of view as well.
Shorthand syntax for declaring local variables - "final" is definitely an elegant solution. Especially that means the keyword would get used more often, hence could save me a lot of trouble when debugging / fixing others' code!
Shorthand syntax for declaring properties - I think Tools is the answer to this, not the language itself.
Type aliasing - could potentially becomes as confusing as #define. And it's probably just me but I really quite like the verbosity - just get yourself a bigger / wider screen :-D
Array syntax for collections - nice, but not very Java-ish to me and would make the language less "concise".
More factory methods for collection classes - or constructors? Can be decided through a popularity vote I suppose.
Self-types - hmmm... I don't have any compelling use cases off the top of my head. So I shall kindly skip this one :-P
Improved compiler diagnostics - always a nice & ongoing work.
Strings in switch statements - ugh, go away! *takes deep breathe* I mean, what are the gains beside introducing another possibility to do the same thing?
XML literals - indeed embedding these stuff outside the Java source code, e.g. through property files with IDEs' aid seem to be the better way.
Shorthand syntax for accessing properties - can't really see what we can gain from this. Really.
Posted by Alex Lam on December 21, 2006 at 12:06 AM PST #
Alright, alright - spam I am then.
Closure - not really. Feels like too much overlapping with other features in the language, even though it could make other things possible. IMO a language should stay concise, i.e. minimising the number of ways to accomplish any given task.
Type Literal - quite cool from completeness point of view.
Posted by Alex Lam on December 21, 2006 at 12:13 AM PST #
Super packages - will need to see how it gets on with existing visibility mechanism. One can't erase history in the Java Language ;-)
Improved Type Inference - yeah, why not? I like the challenge from an academic point of view as well.
Posted by Alex Lam on December 21, 2006 at 12:14 AM PST #
Improved Type Inference - yeah, why not? I like the challenge from an academic point of view as well.
Shorthand syntax for declaring local variables - "final" is definitely an elegant solution. Especially that means the keyword would get used more often, hence could save me a lot of trouble when debugging / fixing others' code!
Posted by Alex Lam on December 21, 2006 at 12:14 AM PST #
(Comments on super packages marked as spam. Oh well...)
Shorthand syntax for declaring properties - I think Tools is the answer to this, not the language itself.
Type aliasing - could potentially becomes as confusing as #define. And it's probably just me but I really quite like the verbosity - just get yourself a bigger / wider screen :-D
Posted by Alex Lam on December 21, 2006 at 12:15 AM PST #
Array syntax for collections - nice, but not very Java-ish to me and would make the language less "concise".
More factory methods for collection classes - or constructors? Can be decided through a popularity vote I suppose.
Posted by Alex Lam on December 21, 2006 at 12:16 AM PST #
Self-types - hmmm... I don't have any compelling use cases off the top of my head. So I shall kindly skip this one :-P
Improved compiler diagnostics - always a nice & ongoing work.
Strings in switch statements - ugh, go away! *takes deep breathe* I mean, what are the gains beside introducing another possibility to do the same thing?
XML literals - indeed embedding these stuff outside the Java source code, e.g. through property files with IDEs' aid seem to be the better way.
Shorthand syntax for accessing properties - can't really see what we can gain from this. Really.
Posted by Alex Lam on December 21, 2006 at 12:16 AM PST #
Posted by Scott Richmond on December 21, 2006 at 01:00 AM PST #
Posted by tcmaster on December 21, 2006 at 05:46 AM PST #
Posted by Christopher Brown on December 22, 2006 at 05:40 AM PST #
About the "Shorthand syntax for declaring properties"...
I don't see the point of that syntax. The whole point of "get" and "set" is to allow for encapsulation of extra processing around property access. For example, a "setter" can validate input, persist data or whatever. A "getter" can provide access to a computed property (suppose "width" and "height" are real properties, there's no point in defining a third "area" property when you can define "getArea" as a value based on width and height). All your example buys is more long-winded way to type "get" and "set"...
It's preferable to do something like:
private String f;
public String property foo {
get {
return f;
}
set throws IllegalArgumentException {
check(value);
f = value;
}
}
... where "value" is the unique value of the property's type passed to the setter. The declaration of indexed properties could be as follows:
private List<String> values;
public String property foo[i] {
get {
if (i < 0 || i > values.size()) throw new IndexOutOfBoundsException(...);
return f[i];
}
set throws IllegalArgumentException, {
if (i < 0 || i > values.size()) throw new IndexOutOfBoundsException(...);
check(value);
values.set(i,value);
}
}
As for "array syntax for collections", maybe this is better:
@ArrayAccess
public V get(K key) {
// implemented here
}
...so that it can be generalized beyond the Map interface.
- Chris
Posted by Christopher Brown on December 22, 2006 at 05:43 AM PST #
Posted by Christopher Stura on December 22, 2006 at 06:21 AM PST #
Posted by Christopher Stura on December 22, 2006 at 06:26 AM PST #
Posted by 65.220.16.193 on December 22, 2006 at 06:29 AM PST #
>> I would rather see a general solution for embedding foreign languages than hacks like multi-line strings or narrowly scoped features such as XML literals.
I'd started the lexicalj project about a year ago, wherein I used a preprocessor to embed a language within java that would allow closures in 1.5. Obviously, Neal's proposals take all of the wind out of the sails of that idea, but I wonder if something like the proposed syntax would meet your definition.
Posted by David Hall on December 22, 2006 at 06:41 AM PST #
Posted by SWP on December 22, 2006 at 06:43 AM PST #
Posted by Ben Loud on December 22, 2006 at 08:17 AM PST #
Posted by SWP on December 22, 2006 at 08:38 AM PST #
Posted by Tom Palmer on December 22, 2006 at 11:32 AM PST #
Posted by WillGayther on December 22, 2006 at 02:04 PM PST #
Posted by rami on December 22, 2006 at 02:57 PM PST #
Posted by Mike Reid on December 22, 2006 at 05:56 PM PST #
import util:java.util.List;
import awt:java.awt.List;
class WidgetFactory {
awt:List createLabel(util:List<String> labels) {
awt:List widget = new awt:List(4, false);
for (String label : labels) {
widget.add(label);
}
return widget;
}
}
Posted by Emmanuel Rodriguez on December 22, 2006 at 11:31 PM PST #
Posted by Neil Swingler on December 22, 2006 at 11:38 PM PST #
Posted by Michael McCutcheon on December 22, 2006 at 11:45 PM PST #
Posted by Michael McCutcheon on December 23, 2006 at 12:06 AM PST #
Posted by dog on December 23, 2006 at 09:31 AM PST #
Posted by Jeroen Wenting on December 24, 2006 at 12:37 AM PST #
Let's take short hand notations: As nobody types all this declaration code anyway, it's no big win. IDEs do all that for me.
The point is: is it better to read? I don't think so. Code has to explain itself, as documentation is outdated anyway it most cases. So, making it unnecessary to define types, write certain keywords, ... makes it harder, as one has to know all those conventions.
Closures: I don't see the advantage in cluttering Java with a new syntax. I agree, that anonymous inner classes are ugly. But it's a good thing, as they are only used when it's really needed ;-)
Closures don't make code more readable. They don't offer enough advantages to justify the hassle.
Instead of making Java easier, let's make it more powerful and let the IDE do the hard work of defining all that stuff (as it's done with the current features).
For Java 7, I'd prefer to see modularization of the class library, clean-up of old deprecated methods, continued retrofitting of Generics in the 'old' APIs (especially those int constants usd all over Swing&Co.
Just my 0.02$,
Claus
Posted by claus on December 24, 2006 at 01:22 AM PST #
Posted by Andy L on December 24, 2006 at 04:08 AM PST #
Posted by Chris Dennett on December 24, 2006 at 09:15 AM PST #
I'd also like to suggest an additional item for your consideration, type-level interface methods.
Posted by Nathan D. Ryan on December 24, 2006 at 10:25 PM PST #
Posted by wangzx on December 25, 2006 at 06:41 PM PST #
switch (value)
{
case (1)
{
// a single int (same as the current behavior,
// but without the need of a break statement.)
}
case (2, 3, 4)
{
// an array of int containing { 2, 3, 4 }.
}
default
{
// ...
}
}
switch (value)
case ("one")
{
// same thing with a String.
}
case ("two", "three", "four")
{
// similar, with an array of Strings.
}
default
{
// ...
}
}
Posted by Jerome on December 27, 2006 at 05:42 AM PST #
Posted by Lucas Jordan on December 27, 2006 at 06:38 AM PST #
Posted by Pratik Parikh on December 27, 2006 at 08:10 AM PST #
Posted by Herb Poppe on December 27, 2006 at 03:16 PM PST #
Posted by Laird Nelson on December 27, 2006 at 04:08 PM PST #
Posted by A. Reader on December 27, 2006 at 08:25 PM PST #
I disagree with: The power of the language lies in its simplicity. Don't kill it. and Instead of making Java easier, let's make it more powerful and let the IDE do the hard work of defining all that stuff.
I, for one, like to write my code. Shorthand syntax for declaring properties helps. A lot.
Posted by A. Reader on December 27, 2006 at 08:36 PM PST #
Posted by asd on December 28, 2006 at 05:00 AM PST #
Posted by asd on December 28, 2006 at 05:09 AM PST #
I like the property suggestion. While this particular idea may need to be refined, I definitely think it is an idea worth developing.
My primary motivation for a feature such as this is to increase the level of documentation because I am frustrated by requiring to javadoc the field, the getter, and the setter. When writing classes, I generally start with defining the private fields, then will use Eclipse to generate the public getters and setters. I like to Javadoc each field, but that Javadoc then needs to be repeated two more times (get and set), so I end up with needing to maintain 3 copies of the documentation. Trying to keep documentation up to date is hard enough -- let alone maintaining multiple copies.
I do agree that sometimes there is value to defining an explicit getter or setter, so that ability needs to be preserved (also for backwards compatibility), but 90% of the time a standard shell is sufficient.
I have posted some ideas about this already:
Parameter validation is a valid concern for setters. Personally, I like the Hibernate Validator annotations approach. Maybe that idea also needs to be built into the language. (The JPA includes some validation rules like nullability, and length, but this is not as sophisticated to validate regular expression matching, minimum and maximum numeric ranges, or anything more sophisticated.)
Posted by Anthony Whitford on December 28, 2006 at 07:16 AM PST #
Your "Array syntax for collections" (map["one"] = 1;) is a limited form of operator overloading.
I'm all in favour of operator overloading, because the arguments in favour are powerful (e.g. doing things like Complex arithmetic is absurdly clunky using method calls); and the arguments against always seem specious to me (e.g. "C++ operator overloading lets you shoot yourself in the foot"), because they usually assume that Java's implementation would have to be like other languages.
As it happens, I'm not in favour of using [] for maps, because I think a[n] should be shorthand for a.get(n), and a[n] = b should be shorthand for a.set(n,b). Basically I think there should be some interfaces in java.lang whose methods are aliases for specific operators. For instance, java.lang.Storage could define E get(int index) and E set(int index,E element). Any class that implements it can use [] syntax instead of these methods; so java.util.List would extend java.lang.Storage. Storage would have a written contract, like any other interface: it would say that get(n) returns the same object previously stored via set(n). Bye bye C++ operator abuse nightmares.
Similar interfaces could be defined to allow, but control, the overloading of +, - etc. For instance it might be required that (a+b-b).equals(a).
Posted by Jonathan on December 28, 2006 at 11:22 AM PST #
Posted by Seyyed Jamaleddin Pishvayi on December 28, 2006 at 10:19 PM PST #
Posted by Ben Tels on December 29, 2006 at 05:43 AM PST #
Posted by M on December 30, 2006 at 11:43 AM PST #
Posted by M on December 30, 2006 at 11:46 AM PST #
Posted by Eugene Vigdorchik on December 30, 2006 at 12:07 PM PST #
M:<em>One more thing, Annotation is not supposed to chnage the Language, It is not code generator or someone else that allow u to create getter/setter.</em>
No, annotations are not supposed to change the language -- they're supposed to add metadata to a program, which may then mean something to language processors like the compiler.
At the same time, the JavaBeans Specification (JavaBeans Spec) defines a property as a named attribute that will always be accessed through accessor methods (see chapter 7). Which means that if something in a class is a property, that class will publish a getter or a setter for that thing.
Given that, I see absolutely no problem in introducing an annotation that defines a property and therefore implicitly introduces a getter and setter into a class definition. Obviously it won't do much for you if you want a derived property, but most properties people define are just the boilerplate case. And you can certainly save typing in that case.
For example, one might consider the following annotations:
@Property private Color color; /* A regular, "boilerplate" property */ @Property(read-only="true") private PersonnelNumber number; /* Only exposes a getter */ @Property(write-only="true") private int somethingElse; /* Only exposes a setter */
One might also consider listener associations, but I'd have more reservations about that. Something like this:
@Property(vetoableChangeListeners="my.package.Listener0,my.package.Listener1") private String blah; @Property(propertyChangeListeners="my.package.Listener2,my.package.Listener3") private String boo;
Posted by Ben Tels on December 31, 2006 at 06:47 AM PST #
Posted by Jonathan on January 01, 2007 at 11:46 AM PST #
Posted by Jonathan on January 01, 2007 at 11:54 AM PST #
Posted by Juan Carlos Flores Beltran on January 01, 2007 at 12:24 PM PST #
Posted by Mm on January 01, 2007 at 01:18 PM PST #
Jonathan, I have to manually correct the spam filter :-(
Unfortunately, I seem to have deleted your comment starting with "'Array syntax for collections' is a form of operator overloading" so please post it again.
Posted by Peter von der Ahé on January 01, 2007 at 03:41 PM PST #
Why should it be necessary to change the code at source level? Annotating a field with @Property would simply mean that the class in question defines a property of that name and type and would therefore imply the presence of a getter and/or setter -- an annotation is only as much as how the tools interpret it to be, after all. It seems to me that code generation in the source would defeat the point of using an annotation.
And perhaps the JCP would decide that such an annotation is not worth the effort. Still I'd be opposed to the property shorthand as an alternative.
Posted by Ben Tels on January 02, 2007 at 01:19 AM PST #
No need to worry about IDE integration, the compiler team is very focused on that aspect.
Cheers,Posted by Peter von der Ahé on January 02, 2007 at 06:42 AM PST #
Posted by 195.177.121.231 on January 02, 2007 at 07:51 AM PST #
'Array syntax for collections' is a form of operator overloading. This kind of notation is clearly good for collections, and would be even more useful if generalized. It seems to me that the argument always given against adding operator overloading to Java is 'operators in C++ are widely abused' - but that's because C++ leaves them open to abuse. Java needn't implement them in the same way.
IMHO a simple and safe operator overloading system would be to allow certain operators to be aliases for methods: a[b] would be converted to a.get(b), a[b] = c converted to a.set(b,c), etc. But to protect them from abuse, the conversions only work for classes which implement a corresponding special interface: for instance, if a class implements java.lang.Storage (containing get and set) then it's allowed to use the two forms of the [] operator. The protection from abuse is given by the contracts for these methods. They could specify, say, that get(n) must retrieve the value v previously passed to set(n,v).
This is how arithmetic operators like +, -, * and / can be restricted to behave in 'number-like' fashion for classes like Point and Complex. Their contracts would be based on algebraic rings and fields, which are the usual generalizations of arithmetic used in mathematics. Ironically, this would leave the built-in + operator for String as the only one that abuses the system! (Since I expect the contract for addition would require that (a + b - b).equals(a).)
A system like this seems very simple but powerful, and could easily be retrofitted to existing classes in the JDK.
Posted by Jonathan on January 03, 2007 at 05:13 AM PST #
Posted by Cay Horstmann on January 07, 2007 at 03:38 PM PST #
public (double, double, double) getGpsCoordinates() {
...
return (x, y, z);
}
main() {
double x, y, z;
(x, y, z) = getRoots(1.0, 1.0);
}
And maybe even treating the "tuple" syntax as a quick way of creating a new kind of anonymous classe quickly:
public (double a, double b, long c) getGpsCoordinates() {
...
return (x, y, z);
}
main() {
// here we treat the tuple as a type
(double p, double q, long r) myCoordinates;
myCoordinates = getRoots(1.0, 1.0);
System.out.println("Your coordinates: ");
System.out.println(" 1: " + myCoordinates.p);
System.out.println(" 2: " + myCoordinates.q);
System.out.println(" 3: " + myCoordinates.r);
}
Haven't thought much more about it, though, so this may in fact be a very bad idea. :-)
Posted by CR on January 10, 2007 at 07:00 AM PST #
Posted by X on January 20, 2007 at 12:42 PM PST #
Posted by Marius on January 25, 2007 at 06:25 AM PST #
(double, double) complex[][] = fourierMatrix.transpose().toArray();instead of
ComplexNumber complex[][] = ...
double real[][] = ... double imaginary[][] = ...which is the common workaround, splitting the values and messing up code.
java.awt.Polygon(int[] xpoints, int[] ypoints, int npoints) double width = dimension.getWidth(), height = dimension.getHeight(); int temp=a; a=b; b=temp;could be replaced by
java.awt.Polygon((int,int)[] points) (double width, double height) = dimension.get(); (a,b) = (b,a);
Posted by Scott Cotton on April 08, 2007 at 08:20 AM PDT #
class Controler{
View Model getModel(){}
Controler void setParent(Controler controler){}
}
getModel() can access only instances of View and subclasses. It allows only for correct framework use.
Posted by TW on April 11, 2007 at 05:23 AM PDT #
There is one feature for the Java language/compiler I'd really like to see: something like a "nullable" / "notnull" reasoning.
Generics help us to avoid the annoying runtime ClassCastExceptions by having the compiler find code that isn't type-safe before runtime. Similar, the "notnull" reasoning would have the compiler check for potential NullPointerExceptions.
I'm not sure how much of this reasoning can be automated - maybe it doesn't need the help from any new keywords. And there are compatibility questions - what about code that really wants to get NullPointerExceptions?
Posted by Ralf Kleberhoff on May 04, 2007 at 01:46 AM PDT #