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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:32:00+00:00 2026-06-16T16:32:00+00:00

I have about 55 Java interfaces and 5 abstract classes. Each declaration uses the

  • 0

I have about 55 Java interfaces and 5 abstract classes. Each declaration uses the same set of generic parameters: it lists the approximately 60 declarations so each implementation knows a specific type of each other implementation and substitute this type in method parameters and returns as appropriate. It appears that this (perhaps over)use of generics is causing the compiler to hang. The compiler throws an OutOfMemoryError, but does not appear to terminate.

Considering my circumstance, a code listing comprising even one of these declarations is a little difficult, but a part of a listing might be possible. The interface declarations commonly specify a collection of about five methods, but the use of generics in the declaration increases the size of a source module to about a thousand lines.

Could my case be a case of the compiler actually going into an infinite loop, or should I just give it more memory? It takes about 20 minutes for the OutOfMemoryError exception to be thrown, so I’m concerned that if I just increase the memory given to the compiler by a factor, it will just take that factor longer for the compiler to throw the exception.

I’m using NetBeans as my editor environment, but have been resorting to running the clean/build script as soon as I start NetBeans. I do this because NetBeans quickly becomes unresponsive when it begins to check the syntax of my code after start-up. I’m using Ubuntu 10.4 (I think – I’m writing this from Windows). I have resorted to opening a command line in the Ubuntu environment, running NetBeans as a background process, checking the output and correcting any source code mistakes using gedit, killing and then restarting NetBeans. This appeared to suffice until I found that no more syntax errors were being produced. I don’t know how to run the clean/build script from the command line.

Sorry if this question appears vague, but if others could help me then maybe I could be a little more specific.

Thanks for any considered advice.

  • 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-16T16:32:01+00:00Added an answer on June 16, 2026 at 4:32 pm

    It sounds to me like you’ve got some overly complicated use of generics, and this is causing the Java compiler to use an excessive amount of memory trying to represent the expansions of the generic types. The very long times before failure are probably due to a “garbage collection death spiral” … where the GC spends more and more time, reclaiming less and less memory each time, until it finally has to give up.

    If you can’t show us the code, the only possible suggestion is to run the compiler with a larger heap, and see if that cures the problem.

    I don’t know how to run the clean/build script from the command line.

    Well, I think you need to figure that out. It may help you solve the problem, and it is important to know these things anyway; e.g. so that you can use a CI system to build your code and run your tests. (And you will probably need to run the script from the command line to get the build to run in a separate JVM with a heap whose size you can control independently of your IDE.)


    It is also possible that your complicated use of generics includes something pathological (and probably nonsensical) that the Java compiler cannot cope with.

    A probable source of trouble about my generic declarations is that they’re self referential; one declaration refers to another which refers to the first.

    Yea … that’s the kind of thing that I’m talking about. If you are not careful, you can end up with something that is meaningless (from a Java perspective) that involves infinite type expansions.

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

Sidebar

Related Questions

I have several Java interfaces/ABCs/classes: public abstract class Target { public abstract void fire(Load
Suppose you have a Java class hierarchy of about 30 classes, with a base
I'm trying to work with C++ java/C# like interfaces by creating classes that have
I have a Java project that needs a addon interface. I was thinking about
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
I had a question about Java Class Path variables. If I have multiple jars
I am testing a java project but i don't know about java console. Have
I have a question about how GC works in Java. Consider the following code:
I have a question about best practices in Java. I'm writing a class, which
I Have a question about finding html tags using Java and Regex. I am

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.