-
Bug
-
Resolution: Fixed
-
P4
-
1.0, 1.0.2, 1.1, 1.1.4, 1.2.0
-
1.2beta3
-
generic, x86, sparc
-
generic, solaris_2.4, solaris_2.5, windows_95
-
Verified
Java language specification says (13.6, p.216):
"A statement labeled by an identifier must not appear anywhere within
another statement labelled by the same identifier, or a compile-time
error will occur. Two statements can be labeled by the same identifier
if neither statement contains the other."
Java compiler doesn't diagnose the case when two labels
with the same name are used in nested blocks.
See an example below:
> cat stmt127.java
class stmt127 {
public static void main(String argv[])
{
int j = 0;
L0: {
L0: if ( j == 0 )
break L0;
System.out.println(" j = " + j);
}
}
}
> /usr/local/java/1.0/bin/javac stmt127.java
> /usr/local/java/1.0/bin/java stmt127
j = 0
"A statement labeled by an identifier must not appear anywhere within
another statement labelled by the same identifier, or a compile-time
error will occur. Two statements can be labeled by the same identifier
if neither statement contains the other."
Java compiler doesn't diagnose the case when two labels
with the same name are used in nested blocks.
See an example below:
> cat stmt127.java
class stmt127 {
public static void main(String argv[])
{
int j = 0;
L0: {
L0: if ( j == 0 )
break L0;
System.out.println(" j = " + j);
}
}
}
> /usr/local/java/1.0/bin/javac stmt127.java
> /usr/local/java/1.0/bin/java stmt127
j = 0
- duplicates
-
JDK-4035334 Incorrect scoping for statement labels
- Closed
-
JDK-4018155 multiple labels with the same name must be flagged as an error
- Closed