United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4093687 : Extension of 'Interface' definition to include class (static) methods.

Details
Type:
Enhancement
Submit Date:
1997-11-18
Status:
Closed
Updated Date:
2011-10-31
Project Name:
JDK
Resolved Date:
2011-10-31
Component:
specification
OS:
linux,generic,windows_98,windows_xp,windows_95,windows_2000
Sub-Component:
language
CPU:
x86,generic
Priority:
P4
Resolution:
Won't Fix
Affected Versions:
1.1.4,1.1.5,1.2.2,1.3.0,1.4.0,1.4.1,1.4.2,6,7
Fixed Versions:
7

Related Reports
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:

Sub Tasks

Description
Name: rm29839			Date: 11/18/97


Please extend the definition of an 'Interface'
to include class (static) methods.

Currently, attempting to expose class methods 
via an interface generates a compiler error, e.g.

MyInterface.java:2: Interface methods can't be 
native, static, synchronized, final, private, 
or protected : void classMethod()
    public static void classMethod ();

This limitation forces one to create two classes
and two interfaces (which in turn creates other
difficulties), instead of one of each, in order
to publish class methods e.g. 'Orders' and 'Order'
classes and interfaces.  Visual Basic's lack of 
class methods forces one to do the same thing.

Noting the other exclusions above, I would also
question why interfaces cannot have final or
synchronized methods.
(Review ID: 19893)
======================================================================

                                    

Comments
EVALUATION

Proposals for new features in the Java programming language are no longer being accepted or maintained in the bug database at http://bugs.sun.com/. This also applies to proposals for new features in the Java Virtual Machine (that is, in the abstract JVM, as opposed to a JVM implementation like HotSpot).

All proposals for new features should be made through the "JDK Enhancement - Proposal & Roadmap Process" described at http://openjdk.java.net/jeps/1.

This specific request to change the Java programming language is related to the work of OpenJDK Project Lambda. It will be considered further by that project, not here.

The bug database continues to accept and maintain submissions about technical errors in the design and specification of the Java programming language and the Java Virtual Machine.
                                     
2011-10-31
EVALUATION

This request is being considered for Dolphin.  However, we may well decide
not to include this in Dolphin.  If so, this RFE will be closed.
                                     
2006-02-27
WORK AROUND

Name: rm29839			Date: 11/18/97



======================================================================
                                     
2004-09-23
EVALUATION

The fact that interfaces cannot impose constraints on class methods is a problem. I don't know if a language change to address this will ever be realistic, but I believe it's a good idea. 

The other comments (i.e., why an interface method cannot be synchronized or final) show a misunderstanding. These properties are not part of the type of a method, but of its implementation, and interfaces have no business dictating such details.

gilad.bracha@eng 1997-11-18
                                     
1997-11-18



Hardware and Software, Engineered to Work Together