package test.cf.directpart; class Foo { Bar b ; public Foo(Bar b) { this.b=b; } public Foo() { super(); } void test() { return; } public void run() { //legeal call: on Bar type object b.test(); //legal call: on Foo type object b.f.test(); //illegal call: on BarPrime type object b.bp.test(); } public static void main(String[] args) { System.out.println("***** A correct implementation should report the following violations:\n"+ "********* Foo.java:26\n"); Foo aFoo=new Foo(new Bar(new Foo())); aFoo.run(); } } class Bar { Foo f ; BarPrime bp = new BarPrime(); public Bar(Foo f) { this.f=f; } public void test() { return; } } class BarPrime { public void test() { return; } }