Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3318564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:43:14+00:00 2026-05-17T22:43:14+00:00

I have the following Java class structure. (JDK 1.6.0_21) Class C extends B` {

  • 0

I have the following Java class structure. (JDK 1.6.0_21)

Class C extends B` {
  //Nothing relevant
}

Class B extends A {
  public void clear() {
    // whatever
  }
}

Class A {
  public void clear() {
    // whatever
  }
}

I had an object c of type C. When I was calling c.clear(), it was calling the clear() method from class A, not class B. After more than a few clean and builds, it started using the clear method on class B, which is as expected.

Before anyone states “You musn’t have rebuilt after changing class A, B or C”. These classes haven’t changed in 3 years. I even added debug lines to prove it was calling A.clear(), which also proves that it had all been recompiled.

Does anyone know of any reason it would have been calling A.clear() instead of B.clear(), remembering that all three of these classes haven’t changed in years?

EDIT: Class A and B are part of a library that end up in a jar file. Class C is in a Java Application. Both these projects are checked out in Eclipse and were compiled multiple times with this issue – as I was adding debug in the library and debug in the Java app.

EDIT AGAIN: The clear() method in Class B does NOT use super.clear(), and neither is it supposed to.

FINAL EDIT: The answer has to be that there was some kind of compilation/environment issue – if Java’s JDK had some kind of flaw effecting the inheritance model there would be much more heard of it. Without exposing the entirety of the project, I don’t think there’s much more anyone can do. Thanks to those who answered!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:43:15+00:00Added an answer on May 17, 2026 at 10:43 pm

    I even added debug lines to prove it was calling A.clear(), which also proves that it had all been recompiled.

    No it doesn’t. The debugger can run with different code than the one deployed. You’ll just be seeing the wrong lines, and in the worst case – the same lines (if the code changes didn’t move anything around)

    Next time make sure the date of the files/jars is not in the past.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java file TestThis.java like the following: class A { public void
I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name=ClientData) public class
I have the following (Java) code: public class TestBlah { private static final String
I've got following java class. package com.org.data.dbresource; import org.springframework.orm.ibatis.SqlMapClientTemplate; public class DBConnectionManager { private
Using GWT I have a Java class: public class Pojo { private String name;
I have a weird problem using the Java Box class. I am using JDK
I have the following Java 6 code: Query q = em.createNativeQuery( select T.* +
I have the following issue using java 1.4 I try to display a very
I have the following problem in my Data Structures and Problem Solving using Java
I'm converting an application to use Java 1.5 and have found the following method:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.