Scrivio Interview library
ConceptPrincipal6 min read · updated 12 November 2026

Array covariance is now widely considered a mistake in Java's design, yet it cannot be removed. How should a large organization deal with language features that are known to be flawed but permanent?

Because Java's compatibility promise means flawed features such as covariant arrays, raw types or finalize stay for a very long time, or leave only after years of deprecation, we cannot remove them; we can only stop them spreading. So an organisation writes standards that steer new code away from them, enforces those standards with static analysis so they do not depend on reviewers remembering, teaches the reason behind each rule through the failure it prevents, and watches shared libraries most closely, because a flawed choice there spreads to every caller.

Why this question is asked

Every large Java codebase contains features the language designers themselves would not add today. Some are merely awkward; others cause real incidents, such as an ArrayStoreException in production or a resource leak from a finalizer that never ran. Interviewers ask this question at a principal or architect level because it tests how we turn technical judgment into organisational practice: guidance that thousands of engineers follow without arguing about it on every pull request. In this answer, we will recap why Java keeps flawed features, look at how to decide which ones need a rule, write standards that are easy to follow, enforce them automatically, teach the reasoning, and focus attention on shared libraries.

1Why Java Keeps Flawed Features

Java's strongest promise is backward compatibility: code compiled twenty years ago should still run on a new JVM, and source that compiled should usually still compile. That promise is a large part of why companies trust Java for systems that live for decades.

The cost is that design mistakes are almost permanent. Covariant arrays cannot be removed without breaking every program that assigns a String[] to an Object[]. Raw types, such as a plain List with no type argument, still compile so that pre-generics code keeps working. When the JDK does remove something, it takes years: finalize() was deprecated in Java 9 and marked for removal in Java 18 (JEP 421), yet it still exists in Java 25. Thread.stop() was deprecated for decades and only in recent versions throws UnsupportedOperationException. So we should plan as if every flawed feature will be with us for the life of our systems.

2Deciding Which Features Need a Rule

Not every quirk deserves a standard; too many rules make all of them easy to ignore. A good filter is to ask, for each feature, how often it causes real failures, how hard those failures are to diagnose, and whether there is a clear better alternative. Covariant arrays in public APIs score high on all three: the failure is a run-time exception far from the mistake, and collections are a clear replacement. Raw types score high too, because they disable generic checks silently. finalize() is clear-cut: it is unpredictable, slow, and replaced by try-with-resources and java.lang.ref.Cleaner.

Examples of permanent flaws and what we steer towards
FeatureFailure it causesWhat new code uses
Covariant arrays in APIsArrayStoreException at run timeList<T> and other collections
Raw typesClassCastException far from the causeParameterised types, List<String>
finalize()resources freed late or nevertry-with-resources, Cleaner
Mutable public static arraysglobal state changed by any callerList.of or private arrays
java.util.Date and Calendarmutable, confusing time zonesjava.time types

3Writing Standards That Steer New Code

The standard should be short and specific, and say what to do instead, not only what to avoid. For example: public methods return collections, not reference arrays; no raw types; no finalize(); new code uses java.time. Each rule links to a one-paragraph reason and an example of the failure.

Just as important is what the standard does not demand. It applies to new and changed code, not to a rewrite of existing systems. Legacy code that works is left alone until someone touches it for another reason. Demanding a big clean-up costs a lot and breaks things, and teams will push back on the whole standard if it comes with that bill.

4Enforcing With Static Analysis

A rule that depends on reviewers remembering it will be applied unevenly, and it turns every review into a debate. Rules that machines can check should be checked by machines. javac itself helps: -Xlint:rawtypes,unchecked,deprecation with -Werror in new modules turns raw types and unchecked operations into build failures. Tools such as Error Prone, SpotBugs, PMD or Sonar have rules for mutable static arrays, finalizers and returning internal arrays, and ArchUnit lets us write project-specific checks, such as no public method in an api package returning an array type.

Java
// An ArchUnit rule run as a normal unit test in every service build
@ArchTest
static final ArchRule noArraysInPublicApi =
methods().that().arePublic()
.and().areDeclaredInClassesThat().resideInAPackage("..api..")
.should().notHaveRawReturnType(Object[].class) // extend with other array types as needed
.because("public APIs return collections; see standards/arrays.md");

For existing code, we introduce rules in a ratchet mode: the tool records the current number of violations as a baseline and fails the build only when the number grows. New code is clean from day one, and the count of old violations can only go down. The exact API for baselines differs by tool, so we check the version we use.

5Teaching the Reason, Not Only the Rule

Engineers follow rules they understand and work around rules they do not. So each rule comes with the story of the failure it prevents, ideally a real incident from our own systems: the service that crashed with ArrayStoreException after someone passed a String[] where an Object[] was filled with mixed values, or the file handle leak traced to a finalizer that ran minutes late under memory pressure.

This also helps with legacy code. An engineer who knows why covariant arrays are dangerous recognises the pattern when they meet it in a ten-year-old module and knows to be careful there, even though no rule forces them to change it. Short internal talks, onboarding material and code review comments that link to the reasoning all reinforce this.

6Watching Shared Libraries Most Closely

A flawed choice inside one service affects that service. The same choice in a shared library's public API affects every service that uses it, and fixing it later requires a deprecation cycle across many teams. So shared libraries get stricter rules and more attention: API reviews for new public methods, compatibility checks in the build with a tool that compares the new API with the last release, and periodic scans across the organisation's code to track how often flawed features are used and where. That tracking gives us numbers, such as raw type usages falling from 4,000 to 900 in a year, which tell us whether the standards are working.

7Follow-up questions

How do you handle a team that pushes back on a rule?

First, we listen, because sometimes the rule is wrong for their case, such as primitive arrays in a performance-critical module. We give the standard an explicit exception process: a team can suppress a rule locally with a comment explaining why. If many teams ask for the same exception, the rule should change.

Should we ever rewrite legacy code just to remove a flawed feature?

Only when the feature is causing real problems or blocks something we need, such as an upgrade. finalize() is a good example where clean-up can be worth it, because its removal is planned. Otherwise we fix it when we touch the code for another reason.

How do you keep the standards current as Java evolves?

We review them at each LTS release. New features can make old advice obsolete, for example records replacing hand-written value classes, and deprecations announce which features are on their way out. Each review adds, updates or removes rules, so the standard reflects the current language.

8Conclusion

In this answer, we saw that Java's compatibility promise keeps flawed features such as covariant arrays, raw types and finalize for a very long time, so the practical goal is to stop them spreading rather than remove them. An organisation chooses the few features that cause real failures, writes short standards that say what to use instead, enforces them with javac warnings, static analysis and ArchUnit with a ratchet for old code, teaches each rule through the failure it prevents, and watches shared libraries most closely, tracking usage to see whether the standards work.

What to say in the interviewAbout 80 seconds aloud

Open with

I start from the fact that Java's compatibility promise is a feature, and the price is that mistakes like covariant arrays, raw types or finalize either stay forever or leave very slowly. finalize, for example, was deprecated years ago, marked for removal in Java 18, and is still there in Java 25.

Then, if they want more

So the realistic goal is to stop these features spreading in new code, not to remove them. I would pick a small number of rules, only for features that cause real, hard-to-diagnose failures and have a clear replacement: collections instead of arrays in public APIs, no raw types, no finalizers, java.time instead of Date.

Each rule says what to do instead and links to a short explanation. Then I'd make machines enforce them, with javac lint flags, Error Prone or Sonar rules, and ArchUnit tests, using a baseline so old violations don't fail the build but new ones do. Reviewers shouldn't have to remember them.

I'd also teach the why, using real failures, so engineers recognise these patterns in legacy code where no rule applies. And I'd focus most on shared libraries, because a flawed API there spreads to every caller, so they get API review, compatibility checks, and usage tracking over time.

About this answer

Last updated
12 November 2026
Versions it names
Java 18, Java 25, Java 9
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Array covariance is now widely considered a mistake in Java's design, yet it cannot be...": https://scrivio-interview-library.netlify.app/java/arrays/f994fe8e52/