United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4083890 : Empty statements are not marked as unreachable

Details
Type:
Bug
Submit Date:
1997-10-03
Status:
Closed
Updated Date:
2001-10-11
Project Name:
JDK
Resolved Date:
2001-02-16
Component:
tools
OS:
solaris_2.6,solaris_2.5.1,generic
Sub-Component:
javac
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.1.3,1.2.0
Fixed Versions:
1.4.0 (merlin)

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
Just a semicolon in a method body is a null statement.  It has the full status
of a statement except that it is a noop.

Hence, the following method should not compile:

void f() {
  return;;
}

The second semicolon is a different statement and is unreachable.  There
should be an error reported that the second semicolon is unreachable.

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
merlin

FIXED IN:
merlin

INTEGRATED IN:
merlin

VERIFIED IN:
merlin-beta3


                                     
2004-06-14
EVALUATION

This is a bug.  The ; is being picked out in the parser, but there
should be a special EmptyStatement node that undergoes reachability
like other statements.

david.stoutamire@Eng 1997-10-06

This bug exists in the jdk1.3 compiler.

iris.garcia@eng 1999-10-28

Well, I fixed it (the tree is called Skip), and discovered how often 
people write things like

	return 0;/* exit success */;

and

	{
	    return f();
	} catch (Whatever e) {
	    throw new Whatever2();
	};

Note the extra semicolon in both cases. I fixed a number of problems
in JDK sources and reported a number of JCK test cases that are broken.
And I'll bet we get lots of problem reports from users once this bug
fix makes it public. My plan is to dup those bug reports to this one, 
so people see WHY it isn't a compiler bug but rather was a bug in their
sources that the compiler simply wasn't catching before.

neal.gafter@Eng 2001-02-05
                                     
2001-02-05
PUBLIC COMMENTS

<p>The compiler now detects unreachable empty statements as required by the
language specification.

<p>While people don't
normally write unreachable statements intentionally, they can easily arise 
accidentally. Here are two of the most common types of cases we've seen 
since the compiler started catching them:

<pre>
	return 0;/* exit success */;
</pre>
and
<pre>
	{
	    return f();
	} catch (Whatever e) {
	    throw new Whatever2();
	};
</pre>

<p>Note the extra semicolon in both cases. In addition, some automatically
generated source code may generate unreachable empty statements.

neal.gafter@Eng 2001-02-05
                                     
2001-02-05



Hardware and Software, Engineered to Work Together