• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Access to inherited static members of inner classes

 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a different thread I opened, the following conclusion has
been reached (through experimentation of a number of people):
The inherited static members of inner classes may or may not be accessed depending on the particular compiler used.
javac 1.2.2 causes a compile-time error, whereas javac 1.3 and the compiler that comes with VisualAge 3.5 do not. JLS nowhere says that this should cause a compile-time error, but javac 1.2.2 causes one. Should we assume that a java compiler *must* catch all compile-time errors specified in the JLS, but may catch more if it so wishes?
Any ideas?
Panagiotis.
<pre>
===================
class HasStatic {
public static void foo() {
System.out.println("I am static");
}
}
class Outer {
class Inner extends HasStatic {
}
}
class Test {
public static void main(String[] args) {
Outer.Inner.foo();
}
}
===================
</pre>
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the compiler probably is giving an error because it is incorrect to make a static reference to an inner class which is not STATIC or a TOP LEVEL NESTED class.
i tried
new Outer().new Inner().foo();
and got the o/p as : I am static
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic