-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.2
-
x86
-
windows_nt
Name: rmT116609 Date: 08/28/2003
A DESCRIPTION OF THE REQUEST :
You cannot make an assertion on constructor parameters before you call this(...) or super(...). E.G.:
public Class(int value)
{
// Intended, but does not work
assert value < 100 : "value < 100";
super();
// Possible, but too late
assert value < 100 : "value < 100";
....
}
JUSTIFICATION :
It must be possible to check parameters before calling super() or this(). Otherwise false parameters would not be checked at the right time and debugging gets more complicated.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See above in the example
ACTUAL -
See above in the example
---------- BEGIN SOURCE ----------
class MyClass
{
public MyClass(int value)
{
// Intended, but not compilable
assert value < 100 : "value < 100";
super();
}
}
---------- END SOURCE ----------
(Incident Review ID: 200127)
======================================================================
A DESCRIPTION OF THE REQUEST :
You cannot make an assertion on constructor parameters before you call this(...) or super(...). E.G.:
public Class(int value)
{
// Intended, but does not work
assert value < 100 : "value < 100";
super();
// Possible, but too late
assert value < 100 : "value < 100";
....
}
JUSTIFICATION :
It must be possible to check parameters before calling super() or this(). Otherwise false parameters would not be checked at the right time and debugging gets more complicated.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See above in the example
ACTUAL -
See above in the example
---------- BEGIN SOURCE ----------
class MyClass
{
public MyClass(int value)
{
// Intended, but not compilable
assert value < 100 : "value < 100";
super();
}
}
---------- END SOURCE ----------
(Incident Review ID: 200127)
======================================================================
- relates to
-
JDK-4093999 Relax constraint on placement of super() call in constructors
- Closed