JDK-4069541 : Need a 'const' qualifier
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.1.3,1.1.5
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1997-08-04
  • Updated: 1997-08-06
  • Resolved: 1997-08-06
Related Reports
Relates :  
Description

Name: rlT66838			Date: 08/04/97


Having developed a major (>100kloc) client/server application
in Java over the past year, we have found that the lack of a
'const'-like qualifier is one of Java's biggest shortcomings
as far as the language is concerned.

The only way to protect an object, currently, is to clone it
before passing it; however, for obvious reasons, this is unacceptable
in many cases for performance reasons.

The reason this is a serious problem is that it significantly
diminishes our ability to write bulletproof code with Java, since
rogue code can do bad things much more easily.

On the positive side, such a change could be implemented without
affecting existing code.

Anyway, thanks for listening...

======================================================================

Comments
WORK AROUND Name: rlT66838 Date: 08/04/97 ======================================================================
11-06-2004

EVALUATION I think that by 'const', the reporter means 'immutable.' The sort of immutability that he's talking about is difficult to enforce programmatically, and it's not clear that it's feasible to put it into the language. Furthermore, there are better solutions than "defensive copyikng" (which the reporter seems to think is the only workaround). It is perfectly possible to define immutable types (e.g., String, BigInteger). The 1.2 Collection package will likely contain facilities to provide immutable views of any Collection (or Table). joshua.bloch@Eng 1997-08-06
06-08-1997