JDK-4483171 : Adding support for delegates and method references
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-07-23
  • Updated: 2006-11-14
  • Resolved: 2006-11-14
Related Reports
Duplicate :  
Description
Name: bsC130419			Date: 07/23/2001


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

I hope that you re-evaluate your event handling strategy. Use of delegates
improve on the interface approach by allowing the invocation of a method
without the need for inner-class adapters or extra code to handle multiple-
method invocations. IMHO it is much easier to write a one method to handle
event than make a inner class for it. Also it makes life for IDEs easier
because they can just generate a one method body from the event, than
searching for a suitable adapter and overloading a certain method on it.

there's a one paper about supporting delegates in Java:
http://www.javasoft.com/docs/white/delegates.html

The conclusions 'The Java Language Team' have against delegates in the paper
seem to be influenced by some anti Microsoft spirit. I hope re-evaluation
would be made open-minded and really considering the alternative.

Support method references via reflection seems no way to go, so are there
any other and especially faster way to support them?
(Review ID: 128614) 
======================================================================

Comments
EVALUATION I am marking this a duplicate of another request for method references. However, as the previous Evaluation said, the real answer is closures.
14-11-2006

WORK AROUND Name: bsC130419 Date: 07/23/2001 "Any use of a bound method reference to a private method can be transformed, in a simple and purely local way, into an equivalent program using a one-member private class." - The Java Language Team (http://www.javasoft.com/docs/white/delegates.html) ======================================================================
24-08-2004

EVALUATION Delegates are a pretty lame solution. A cleaner and more effective approach would use real closures. However, it is completely unrealistic to expect the APIs that already use nested classes for call backs to be reworked, even if a new language feature were introduced. ###@###.### 2001-10-11
11-10-2001