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

  • SEARCH
  • Home
  • 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 8803847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:26:53+00:00 2026-06-14T01:26:53+00:00

Here is my problem actually I’m facing now. I have a class, let’s say

  • 0

Here is my problem actually I’m facing now.
I have a class, let’s say Foo and this class defines a method called getBar that returns a Bar instance. The class Bar is defined inside Foo and and is declared public static final. What I want to do is to define a class MyFoo that extends Foo but I also want to extend Bar with MyBar by adding my own functionalities (methods, properties,etc).
I also want getBar to return MyBar.

The problem is Bar is final. Here is an illustration of what I want to do :

public class Foo {

  Bar bar = new Bar();

  public Bar getBar(){
      return bar;
  } 

   ....

   public static final class Bar {

    } 
}

What I want to do is :

public class MyFoo extends Foo {


   public MyBar getBar(){ // here I want to return an instance of MyBar

   }

  public static final class MyBar extends Bar { // That's impossible since Bar is final

  } 
}

How can I achieve that?

[EDIT] I am adding more details to my question.
I am actually developing a plugin for Jenkins and after searching, I realize there is a plugin that offers the base functionalities that I want to do, Foo and Bar. I want to custom Foo and Bar, so it can fits my needs.
Foo is the main class of the plugin and extends a class called Builder. Foo defines a method called perform which contains all the operations for performing a build.
Bar contains operations for configurations purposes and Foo needs Bar to get those informations.

So what I want to do is to extend Foo with MyFoo and add some configurations with MyBar. And as you see, MyFoo will need to get those configuations by calling getBar();

The second thing is I have no control of the instanciation of MyFoo and MyBar

What blocks me, is that I cannot extend Bar. How can I achieve that?

  • 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-06-14T01:26:55+00:00Added an answer on June 14, 2026 at 1:26 am

    You can’t, basically. It looks like the developer who designed Bar intended for it not to be extended – so you can’t extend it. You’ll need to look for a different design – possibly one which doesn’t use inheritance so much… assuming you can’t change the existing code, of course.

    (It’s hard to give more concrete advice without knowing more about the real goal here – the design of the overall system.)

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

Sidebar

Related Questions

We have a very odd problem here with SVN. Let me first explain the
Alright, so this is probably a really beginner problem here, but I've never actually
Lets say I have a MovieClip called Box, and String is actually 'box' just
Aside from scalability issues, has anyone here actually stumbled upon a web-development problem where
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I have a problem here im trying to upload a file first time it
I have a problem here. My Zend_Forms do not render in view script. Via
I have a problem here I can't solve. I have a database of houses
Ok, I have a really stupid problem here, and I'm starting to get really
I have a problem here with cakePHP. I have 4 .ctp view pages that

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.