
Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
On Thu, 13 Apr 2006 09:30:24 +0100, Thomas Hawtin
<usenet@tackline.plus.com> wrote, quoted or indirectly quoted someone
who said :
>Interfaces have no variables. Therefore they cannot have an outer this.
They have instance implementing methods which might refer to this.
How did you interpret his question? You can't apply the word static
to an interface. Was he asking why all the members in an interface are
static finals?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
EJP - 14 Apr 2006 05:50 GMT
> How did you interpret his question? You can't apply the word static
> to an interface. Was he asking why all the members in an interface are
> static finals?
class MyClass
{
interface MyInterface1 {}
static interface MyInterface2 {}
}
The word 'static' is redundant; both interfaces are static.
v4vijayakumar - 16 Apr 2006 10:47 GMT
> You can't apply the word static to an interface.
agree, but wonder this works with java.
[root@cp_node1 (StkBarolo) java]#cat test.java
public class test {
static interface vijay {
}
public static void main(java.lang.String [] args) {
}
}
[root@cp_node1 (StkBarolo) java]#javap test$vijay
Compiled from test.java
public class test extends java.lang.Object {
public test();
public static void main(java.lang.String[]);
static interface test. vijay
/* ACC_SUPER bit NOT set */
{
}
}
Chris Uppal - 18 Apr 2006 09:18 GMT
> public class test {
> static interface vijay {
[quoted text clipped - 13 lines]
> }
> }
When I run this javap doesn't complain about the ACC_SUPER bit, but I wouldn't
worry if it did.
The ACC_SUPER bit is a flag that indicates to the JVM that it should use the
"modern" interpretation of the bytecodes corresponding to code like
super.doSomething()
(see the JVM spec if you are interested in the details). That flag is supposed
to be set in every class generated by recent compilers (in fact, since at least
1.0.4), so I presume that's why javap complains when it finds it missing.
However, there is no reason to bother one way of the other about interfaces,
since they don't have real methods, and so can't have code with super-sends.
It seems that the 1.4.2 and 1.5 javacs (at least) don't bother to set the
ACC_SUPER flag for interfaces, whether they are nested or not. (I can't
imagine why not -- seems pointless to treat them specially)
So it really doesn't matter.
-- chris