package test.of.directpart; class Bar { public static void staticCall() { int a = 0; return; } } class Foo { Foo f ; public Foo(Foo f) { this.f=f; } public Foo() { super(); } void test() { return; } Foo getF() { return f; } public void run() { //legeal call: direct part object f.test(); //legal test(); //legal getF(); //illegal getF().getF().test(); //illegal f.f.test(); //legal Bar.staticCall(); } public static void main(String[] args) { System.out.println("***** A correct implementation should report the following violations:\n"+ "********* Foo.java:39\n"+ "********* Foo.java:41"); Foo aFoo = new Foo(); aFoo.f=new Foo(); aFoo.f.f=new Foo(); aFoo.run(); aFoo=new Foo(new Foo(new Foo())); aFoo.run(); } }