Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nested interfaces implemented by outer class...

0 views
Skip to first unread message

Mark McDowell

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
I was looking on the javaworld site
(http://www.javaworld.com/javaworld/javatips/f_jw-javatip50.html) and
began to try and implement the ideas in the article. Here is the simple
code I attempted:

public class Loader implements LoadParam, SortParam {

public interface LoadParam {
public static final LoadType FROM_MEMORY = new LoadType(1);
public static final LoadType FROM_FLATFILE = new LoadType(2);
public static final LoadType FROM_DB = new LoadType(4);
final class LoadType {
private final int m_loadtype;
private LoadType(int aType) {
m_loadtype = aType;
}
}
}

public interface SortParam {
public static final SortType BY_CITY = new SortType(1);
public static final SortType BY_NAME = new SortType(2);
public static final SortType BY_NUMBER = new SortType(4);
final class SortType {
private final int m_sorttype;
private SortType(int aType) {
m_sorttype = aType;
}
}
}

/** Creates new Loader */
public Loader() {
}
}

However, when I compile it, I get this error:
TestParameterConstants/SiteLoader.java [17:12] cyclic inheritance
involving TestParameterConstants.SiteLoader
public interface LoadParameters {
TestParameterConstants/SiteLoader.java [29:12] cyclic inheritance
involving TestParameterConstants.SiteLoader
public interface SortParameters {
2 errors

Does anyone have ideas about why? I'm using Java SDK 1.3 with Forte.

Mark McDowell

Amit Kulkarni

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
I think you have not posted complete code ,but when I compile it
after I place all *public* classes/interfaces into separate files ,they
compile nicely with jikes but javac gives me

D:\java>javac *.java
sun.tools.java.CompilerError: illegal class modifiers
at
sun.tools.javac.SourceClass.assertModifiers(SourceClass.java:2059)
at sun.tools.javac.SourceClass.compileClass(SourceClass.java:2577)
at sun.tools.javac.SourceClass.compile(SourceClass.java:2039)
at sun.tools.javac.Main.compile(Main.java:567)
at sun.tools.javac.Main.main(Main.java:733)
error: An error has occurred in the compiler; please file a bug report
(http://java.sun.com/cgi-bin/bugreport.cgi).
1 error


"Mark McDowell" <m.mcd...@bigfoot.com> wrote in message
news:MPG.140603cee...@news.ic.ncs.com...

Margalit Gur-Arie_elidan1

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
This does not compile on my JSDK 1.3 either.

On JDK 1.2 it does compile after you fix the error in the first line,

public class Loader implements Loader.LoadParam, Loader.SortParam {

So maybe Sun has a new policy on the subject. I'm going to check the
what's new for 1.3 docs.

Margalit Gur-Arie_elidan1

unread,
Aug 17, 2000, 3:00:00 AM8/17/00
to
> This does not compile on my JSDK 1.3 either.

> On JDK 1.2 it does compile after you fix the error in the first line,

> public class Loader implements Loader.LoadParam, Loader.SortParam {

> So maybe Sun has a new policy on the subject. I'm going to check the
> what's new for 1.3 docs.


Sure enough ! This behavior has been submitted as bug
http://developer.java.sun.com/developer/bugParade/bugs/4326631.html

But they insist it is not a bug, and refer you to the JLS 2nd Ed., saying
that:
"...the rule against cyclic inheritance has been extended to prohibit
a class or interface from "depending" on itself, directly or
indirectly........."

Mark McDowell

unread,
Aug 18, 2000, 3:00:00 AM8/18/00
to
In article <966550043.960673@sj-nntpcache-3>, amku...@cisco.com says...

> I think you have not posted complete code ,but when I compile it
> after I place all *public* classes/interfaces into separate files ,they
> compile nicely with jikes but javac gives me
I did provide the entire .java file. The article was apparently written
before 1.3 and Sun made a change to disallow the "cyclic dependency"
where the interface was an inner interface to the class when the class
implements it. Oh, well. Thanks for your help.

Mark

Mark McDowell

unread,
Aug 18, 2000, 3:00:00 AM8/18/00
to
In article <20000817...@elidan.icon-stl.net>, m...@elidan.icon-
stl.net says...

> Sure enough ! This behavior has been submitted as bug
> http://developer.java.sun.com/developer/bugParade/bugs/4326631.html=20

>
> But they insist it is not a bug, and refer you to the JLS 2nd Ed.,
> saying=20 that:

> "...the rule against cyclic inheritance has been extended to prohibit
> a class or interface from "depending" on itself, directly or=20
> indirectly........."
Thanks so much for the help. I was only trying to implement it exactly,
as it seemed to answer a problem I was working on and seemed to
encapsulate the information and provide type safety at the same time...

Sigh... :)

Mark

0 new messages