- assigned_to: nobody --> bokowski
A bug report from Christian Stork:
> > - Why are some statements, say Throw and Return, not targetable stmts?
> > Quickly skimming thru the JLS2 didn't reveal any reason why they
> > shouldn't...
>
> I don't have the JLS at hand right now, but I think that only compound
> statements can be targets of a break, and only loop statements can be
> targets of a continue.
It seems that labels for arbitrary statements are legal but (probably)
useless in the sense you describe.
The JLS2 is somewhat unspecific on this subject (in 14.14 it says "the
break target need *not* be a while, do, for, or switch statement.").
Essentially it puts it in the following terms:
1) The scope of labels are only the immediately enclosed statement.
2) Labels are allowed for arbitrary statements.
3) breaks can jump to all visible labels
4) continue labels can only refer to enclosing iteration statements
Therefore labeled statements like
...
xxx: i = 3;
yyy: break yyy;
...
are legal (and are accepted by javac & jikes). Barat throws a
ClassCastException on these since it tries to cast, for example, the
break statement to an ATargetStatement, I assume.
Well, I don't know if it's better to be JLS conforming (did you ever
attempt to pass this 100% pure Java test suite?) or to exclude these
senseless constructions right from the beginning. You definitely don't
have to "fix" this as far as I am concerned.
Log in to post a comment.