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 8093053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:25:13+00:00 2026-06-05T20:25:13+00:00

As good as the Java API is, I need to change the code of

  • 0

As good as the Java API is, I need to change the code of some classes in the default API packages (for example java.util.Scanner) for a project I am working on.

Ideally, I would extend the classes I am interested and create my own sub-classes, but the classes I want to extend are declared ‘final’. How do you suggest I do this? Will I get into trouble with the compiler if I customize the source code of these packages?

  • 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-05T20:25:15+00:00Added an answer on June 5, 2026 at 8:25 pm

    If you can, you should rather wrap and delegate, as suggested in another answer. See the Adapter Pattern.

    But there are of course ways to do this if you really need it.

    A straightforward approach is to simply modify the code in downloaded sources and substitute your own version of a jar in the classpath.

    Another option is to use aspect-oriented programming techniques, likely with AspectJ to intercept and modify calls as needed.

    It might also be possible to hack together a solution using reflection and home-grown classloaders, but it will be painful to code.

    All of these are however quite risky if you don’t know what you’re doing. Frequently classes are made final for good reason.

    If you tell us more specifically what it is you’re hoping to change, we might be able to provide assistance in avoiding what you currently think you need.

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

Sidebar

Related Questions

I need a good OLEDate java implementation, and this one does not seem to
In Java classes is it considered good or bad practice to access member fields
Is there a good lightweight framework for java that provides the publish/subscribe pattern? Some
I'm not able to find any good web scraping Java based API. The site
I need to optimise a Java application. It makes some 3rd party calls. I
A good example is www.espacio asir.com, which gives this result: image-link: http://api.browsershots.org/png/original/50/509a78b11505752692d066f07fff6661.png I don't
I am currently working on a project where in which I need to package
I regularly observe obsolete classes and methods in Java API. I did not find
do i need Java Advanced Imaging API to learn image processing in Java? and
I am looking for a good visualization library in Java for my school project

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.