-
Enhancement
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.2
-
sparc
-
solaris_9
Name: rmT116609 Date: 05/12/2004
A DESCRIPTION OF THE REQUEST :
Extend the interface declaration syntax, by allowing to specify implementors.
Example:
--------------------------------------
package org.mystuff
import java.sql.*;
public interface SQLWarningSource
implementedby java.sql.Connection, java.sql.Statement, java.sql.ResultSet, MyClass
{
void clearWarnings();
SQLWarning getWarnings();
}
--------------------------------------
When the interface implementation is defined with this new syntax at the interface level, instead as as usually at the implementor level, then this interface implementation is dynamic, effective as soon the class loader loads the interface.
This implies that instanceof expression always "see" dynamically implemented types, because the dynamic interface is explicitly referenced and therefore loaded by the classloader.
On the other hand, Class.getInterfaces() would not necessarily "see" the dynamically implemented interfaces. This method would return only the interfaces known at the invocation time.
JUSTIFICATION :
It is often necessary to create interfaces for external code where we cannot update the sources.
When you write a class, you do not know in advance all the interfaces that will be required by all the situations where other developers will use your class.
Usually, in this kind of situation, we write adapters (such as the famous GoF design pattern or using dynamic proxies).
This can sometimes be a heavy task, sometimes even impossible.
Today, more and more OO languages allow dynamic implementation, implicit interfaces, latent typing, etc. This additional flexibility comes sometimes at the cost of type weakening, making the code more difficult to understand and to reverse engineer (for example with UML tools).
In contrast, the proposed solution introduces dynamic implementation by still keeping Java strong typing, by still explicitly naming each interface.
It is logical to allow API clients as well to specify interface implementations, because the clients finally use them. The proposed syntax could be the simplest way.
(Incident Review ID: 246274)
======================================================================
A DESCRIPTION OF THE REQUEST :
Extend the interface declaration syntax, by allowing to specify implementors.
Example:
--------------------------------------
package org.mystuff
import java.sql.*;
public interface SQLWarningSource
implementedby java.sql.Connection, java.sql.Statement, java.sql.ResultSet, MyClass
{
void clearWarnings();
SQLWarning getWarnings();
}
--------------------------------------
When the interface implementation is defined with this new syntax at the interface level, instead as as usually at the implementor level, then this interface implementation is dynamic, effective as soon the class loader loads the interface.
This implies that instanceof expression always "see" dynamically implemented types, because the dynamic interface is explicitly referenced and therefore loaded by the classloader.
On the other hand, Class.getInterfaces() would not necessarily "see" the dynamically implemented interfaces. This method would return only the interfaces known at the invocation time.
JUSTIFICATION :
It is often necessary to create interfaces for external code where we cannot update the sources.
When you write a class, you do not know in advance all the interfaces that will be required by all the situations where other developers will use your class.
Usually, in this kind of situation, we write adapters (such as the famous GoF design pattern or using dynamic proxies).
This can sometimes be a heavy task, sometimes even impossible.
Today, more and more OO languages allow dynamic implementation, implicit interfaces, latent typing, etc. This additional flexibility comes sometimes at the cost of type weakening, making the code more difficult to understand and to reverse engineer (for example with UML tools).
In contrast, the proposed solution introduces dynamic implementation by still keeping Java strong typing, by still explicitly naming each interface.
It is logical to allow API clients as well to specify interface implementations, because the clients finally use them. The proposed syntax could be the simplest way.
(Incident Review ID: 246274)
======================================================================
- relates to
-
JDK-4430717 Pseudo-compiler interface exposure...
-
- Closed
-