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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:10:08+00:00 2026-06-18T14:10:08+00:00

I have a large body of Java code that uses a class XXX. Over

  • 0

I have a large body of Java code that uses a class XXX. Over time, the meaning of the class has changed, and the name is no longer appropriate. To make the code more readable, I would like to change the name of the class to YYY.

One option is to edit all the files in a single pass and change XXX to YYY, but the actual name of the class is not unique — there are other classes with the same name, different package — so I need to look at code. I would like to be able to make some changes, test that it is correct, and change some more, test some more, etc. During this transition time, I want to be able to use YYY and XXX interchangeably. Eventually I would eliminate the XXX.

What I need is an “alias” concept, where I could make YYY and alias of XXX, but Java does not have this.

I could make YYY a subclass of XXX with all the same constructors and methods. That will work fine where a variable is declared XXX, and I assign a value of type YYY. It will also work where a method parameter is XXX, and I pass a YYY. But it will not work the other way around when the parameter is declared YYY and I have an XXX value to send.

I could inject YYY into the inheritance, so that XXX extends YYY, but I have the same problem as above: in code that has mixed use of XXX declarations and YYY values there is trouble.

The transition time will take a couple of months. During this time, I don’t care about performance or efficiency, I just need it to compile and run correctly enough to test. Any suggestions for a best practice to allow for incremental change of a class name in a body of Java code?

UPDATE

The answer below is that while there is no way to do this in Java, there also should be no reason to either. I followed up by installing and refactoring the code, and wrote up the experience in this blog post: Don’t Suffer Poor Names

  • 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-18T14:10:09+00:00Added an answer on June 18, 2026 at 2:10 pm

    Use an IDE such as Eclipse and use its refactoring tools to rename the class. This will automatically change it everywhere it’s used, update imports, etc.

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

Sidebar

Related Questions

I have a large body of legacy code that I inherited. It has worked
I have a Java applet that uses the HTTPURLConnection class to upload very large
I have a large body of text which has several sentences wrapped in yada
I have a large body of code, compiled with /MT (i.e. expecting to statically
Background Info: I have a large body of text that I regularly encapsulate in
I have a data structure that represents C# code like this: class Namespace: string
i have large numbers of text files and i am in problem that i
I have large video files (~100GB) that are local on my machine. I have
I have large amounts of data in an ArrayList that holds about 2,600 classes
We have a large existing website (written in Java/Spring/Hibernate/JSP) and want to add a

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.