Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicate:
Why is super.super.method(); not allowed in Java?Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is an actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is useful and needs to be called.

Possible Duplicate:
Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is an actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is useful and needs to be called.

Possible Duplicate:
Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is an actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is useful and needs to be called.

spelling in title
Link
Cœur
  • 39k
  • 25
  • 207
  • 282

Java: How to call super().super() in overridenoverridden method (grandparent method)

deleted 2 characters in body
Source Link
Caner
  • 59.7k
  • 37
  • 184
  • 185

Possible Duplicate:
Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is a nan actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is usefulluseful and needs to be called.

Possible Duplicate:
Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is a n actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is usefull and needs to be called.

Possible Duplicate:
Why is super.super.method(); not allowed in Java?

I have 3 classes they inherit from each other as follows:

A ↳ B ↳ C 

Inside each class I have the following method:

protected void foo() { ... } 

Inside class C I want to call foo from class A without calling foo in B:

protected void foo() { // This doesn't work, I get the following compile time error: // Constructor call must be the first statement in a constructor super().super().foo(); } 

EDIT
Some Context Info:
Class B is an actual class we use. Class C is a unit test class, it has some modifications. foo method inside B does some things we don't want so we override it inside C. However foo in class A is useful and needs to be called.

added 280 characters in body
Source Link
Caner
  • 59.7k
  • 37
  • 184
  • 185
Loading
insert duplicate link
Source Link
Loading
Post Closed as "exact duplicate" by Tomasz Nurkiewicz, Nathan Hughes, Pshemo, Romain, rsp
Source Link
Caner
  • 59.7k
  • 37
  • 184
  • 185
Loading