-
Enhancement
-
Resolution: Rejected
-
P5
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
javac -version: javac 1.6.0-rc
javac -J-version: java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b97)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b97, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The following code snippet:
public class Test {
public static void main(String[] args) {
new Object(){
{
super();
//above errors: "call to super must be first statement in constructor"
}
};
}
}
generates an error on the 'super' call:
"call to super must be first statement in constructor"
The real bug is the text in the error message. It is misleading. The call to super was not in a constructor at all but in an initializer block.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A. copy/paste snippet listed in 'description' to a 'Test.java' textfile.
B. run "javac Test.java"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting it to compile just fine, or possibly tell me that super() calls are not allowed inside a 'constructor' of an anonymous class.
The error message received suggests a fix - to make it the first statement, but it already is.
Suggested fix: Make it possible to call super() as first statement in constructors for anonymous classes.
ACTUAL -
C:\>"c:\Program Files\Java\jdk1.6.0\bin\javac.exe" Test.java
Test.java:5: call to super must be first statement in constructor
super();
^
1 error
ERROR MESSAGES/STACK TRACES THAT OCCUR :
call to super must be first statement in constructor
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
new Object(){
{
super();
//above errors: "call to super must be first statement in constructor"
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround available.
javac -version: javac 1.6.0-rc
javac -J-version: java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b97)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b97, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The following code snippet:
public class Test {
public static void main(String[] args) {
new Object(){
{
super();
//above errors: "call to super must be first statement in constructor"
}
};
}
}
generates an error on the 'super' call:
"call to super must be first statement in constructor"
The real bug is the text in the error message. It is misleading. The call to super was not in a constructor at all but in an initializer block.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A. copy/paste snippet listed in 'description' to a 'Test.java' textfile.
B. run "javac Test.java"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting it to compile just fine, or possibly tell me that super() calls are not allowed inside a 'constructor' of an anonymous class.
The error message received suggests a fix - to make it the first statement, but it already is.
Suggested fix: Make it possible to call super() as first statement in constructors for anonymous classes.
ACTUAL -
C:\>"c:\Program Files\Java\jdk1.6.0\bin\javac.exe" Test.java
Test.java:5: call to super must be first statement in constructor
super();
^
1 error
ERROR MESSAGES/STACK TRACES THAT OCCUR :
call to super must be first statement in constructor
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
new Object(){
{
super();
//above errors: "call to super must be first statement in constructor"
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround available.