|
Quick Lists
|
|
Bug ID:
|
6199662
|
|
Votes
|
3
|
|
Synopsis
|
javac: compilation success depends on compilation order
|
|
Category
|
java:compiler
|
|
Reported Against
|
5.0
|
|
Release Fixed
|
mustang(b55)
|
|
State
|
10-Fix Delivered,
Verified,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
6280975
,
6325201
,
6726015
,
5011101
|
|
Submit Date
|
23-NOV-2004
|
|
Description
|
Below are three files: TreeInfo.java, TreeScanner.java and Tree.java.
If they are compiled with
javac p/Tree.java p/TreeScanner.java p/TreeInfo.java
the compilation succeeds.
If they are compiled with
javac p/TreeInfo.java p/TreeScanner.java p/Tree.java
you get the following error:
p/TreeScanner.java:9: unreported exception java.lang.Throwable; must be caught or declared to be thrown
if(tree!=null) tree.accept(this);
^
1 error
------Tree.java--------------
package p;
public abstract class Tree {
/** Visit this tree with a given visitor.
*/
public abstract <E extends Throwable> void accept(Visitor<E> v) throws E;
/** A generic visitor class for trees.
*/
public static abstract class Visitor<E extends Throwable> {
public void visitTree(Tree that) throws E { assert false; }
}
}
------TreeInfo.java----------
package p;
import p.Tree.*;
public class TreeInfo {
public static void declarationFor(final Tree tree) {
class DeclScanner extends TreeScanner<Error> {
public void scan(Tree tree) {
}
}
DeclScanner s = new DeclScanner();
tree.accept(s);
}
}
------TreeScanner.java-------
package p;
import p.Tree.*;
public class TreeScanner<E extends Throwable> extends Visitor<E> {
/** Visitor method: Scan a single node.
*/
public void scan(Tree tree) throws E {
if(tree!=null) tree.accept(this);
}
}
Posted Date : 2005-09-20 17:14:48.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
The problem is apparently that attribution and flow analysis is mixed with
erasure in main.JavaCompiler.compile in the while(todo.nonEmpty()) loop.
The work should be split into two: first a loop to do attribution and flow
analysis, then a loop to translate the types.
This analysis is confirmed by disabling the second part of the loop.
xxxxx@xxxxx 2004-11-24 08:24:54 GMT
A more correct solution would be to make erasure "non-destructive".
xxxxx@xxxxx 2005-05-18 02:16:13 GMT
Extracted "flow" phase out of "desugar"
xxxxx@xxxxx 2005-06-23 23:23:49 GMT
Posted Date : 2005-06-23 23:23:49.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |