-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
7
-
x86
-
windows_7
FULL PRODUCT VERSION :
1.7.0
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows Version 6.1.7601
A DESCRIPTION OF THE PROBLEM :
I have the following two files
G.java
------------------------
package foo.bar;
import foo.bar.H.HH;
import foo.bar.H.HH.HHH;
class G extends HH{
static class GG extends HHH {}
}
------------------------
H.java
------------------------
package foo.bar;
import foo.bar.G.GG;
class H extends G{
static class HH extends GG{
static class HHH{}
}
}
------------------------
Clearly, there is no hierarchy circle, the hierarchy is H -> G -> H.HH -> G.GG -> H.HH.HHH. I checked the language specification and could not find out why this code should be erroneous. It is neither a hierarchy circle, nor a depends circle, because no class is explicitly used as qualifier in the extends clause.
when trying to compile these classes, I get the following error
H.java:8: error: cannot find symbol
static class HH extends GG{
^
symbol: class GG
location: class H
H.java:5: error: cyclic inheritance involving H
class H extends G{
^
2 errors
The first error is strange but could be a result of the second. GG is in scope, since HH is in H which extends G and thus brings GG into scope. The second error is strange as well, as there is no cycle.
Note that the Ecplise JDT java compiler does not raise any errors here.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.) Write the following java files
G.java
------------------------
package foo.bar;
import foo.bar.H.HH;
import foo.bar.H.HH.HHH;
class G extends HH{
static class GG extends HHH {}
}
------------------------
H.java
------------------------
package foo.bar;
import foo.bar.G.GG;
class H extends G{
static class HH extends GG{
static class HHH{}
}
}
------------------------
2. run javac H.java G.java in the appropriate directory
3. Receive the error output
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No compile errors
ACTUAL -
Following compile errors:
H.java:8: error: cannot find symbol
static class HH extends GG{
^
symbol: class GG
location: class H
H.java:5: error: cyclic inheritance involving H
class H extends G{
^
2 errors
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
not necessary, this is a constructed case. Its only use is to detect a discrepancy between the specification and the compiler. In my opinion, it would be even better to forbid one class extending a member class of its subclasses.
1.7.0
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows Version 6.1.7601
A DESCRIPTION OF THE PROBLEM :
I have the following two files
G.java
------------------------
package foo.bar;
import foo.bar.H.HH;
import foo.bar.H.HH.HHH;
class G extends HH{
static class GG extends HHH {}
}
------------------------
H.java
------------------------
package foo.bar;
import foo.bar.G.GG;
class H extends G{
static class HH extends GG{
static class HHH{}
}
}
------------------------
Clearly, there is no hierarchy circle, the hierarchy is H -> G -> H.HH -> G.GG -> H.HH.HHH. I checked the language specification and could not find out why this code should be erroneous. It is neither a hierarchy circle, nor a depends circle, because no class is explicitly used as qualifier in the extends clause.
when trying to compile these classes, I get the following error
H.java:8: error: cannot find symbol
static class HH extends GG{
^
symbol: class GG
location: class H
H.java:5: error: cyclic inheritance involving H
class H extends G{
^
2 errors
The first error is strange but could be a result of the second. GG is in scope, since HH is in H which extends G and thus brings GG into scope. The second error is strange as well, as there is no cycle.
Note that the Ecplise JDT java compiler does not raise any errors here.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.) Write the following java files
G.java
------------------------
package foo.bar;
import foo.bar.H.HH;
import foo.bar.H.HH.HHH;
class G extends HH{
static class GG extends HHH {}
}
------------------------
H.java
------------------------
package foo.bar;
import foo.bar.G.GG;
class H extends G{
static class HH extends GG{
static class HHH{}
}
}
------------------------
2. run javac H.java G.java in the appropriate directory
3. Receive the error output
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No compile errors
ACTUAL -
Following compile errors:
H.java:8: error: cannot find symbol
static class HH extends GG{
^
symbol: class GG
location: class H
H.java:5: error: cyclic inheritance involving H
class H extends G{
^
2 errors
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
not necessary, this is a constructed case. Its only use is to detect a discrepancy between the specification and the compiler. In my opinion, it would be even better to forbid one class extending a member class of its subclasses.
- relates to
-
JDK-6863462 Unclear specification: circular class hierarchy dependency via static imports
- Open
-
JDK-6863465 javac doesn't detect circular subclass dependencies via qualified names
- Closed