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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:56:36+00:00 2026-06-17T07:56:36+00:00

I have class A, and class B that inherits A in Eclipse workspace. The

  • 0

I have class A, and class B that inherits A in Eclipse workspace.

enter image description here
enter image description here

The issue that I have is that I got nothing when I tried to get the super types of type B using eclipse JDT API. This is the code (I got the code from – List all subclasses with fully qualified names):

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
java.io.File workspaceDirectory = root.getLocation().toFile();

// 1. The name of the project in the workspace
IProgressMonitor pm = new NullProgressMonitor();    
IProject orig = root.getProject(this.projectName);
orig.open(pm);
this.javaProject = JavaCore.create(orig);
orig.refreshLocal(IResource.DEPTH_INFINITE, pm);

// 2. Find the type                
IType type = this.javaProject.findType("p.B"); <-- returns correct type info
ITypeHierarchy hier = type.newSupertypeHierarchy(new NullProgressMonitor());
IType[] types = hier.getAllSuperclasses(type);
System.out.println(types); <-- Returns []

I also added the code to refresh/update the resources in package.

IPackageFragmentRoot[] packageFragmentRoots = this.javaProject.getPackageFragmentRoots();
for (IPackageFragmentRoot proot: packageFragmentRoots)
{
    proot.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
}

Everything works fine except getting the hierarchical type information.
What might be wrong? Did I miss any setup before executing the API?

Mine is a headless RCP application.

  • 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-17T07:56:37+00:00Added an answer on June 17, 2026 at 7:56 am

    This may be a temporary solution, but it worked for me.

    Short Answer

    Make a lib directory, and copy this rtstubs.jar into the directory.
    You may need to refresh(F5) the eclipse IDE to see the jar file is included in the project.

    enter image description here

    Then, in “Java Build Path”, you need to add this jar file.

    enter image description here

    After the inclusion of the jar file in package fragment, you’ll get the class hierarchy.

    enter image description here

    Long Answer (why does this solve the issue)

    CompilationUnitDeclaration (org.eclipse.jdt.internal.compiler.ast) and Hierarchy Resolver (org.eclipse.jdt.internal.core.hierarchy)

    It has a field ignoreFurtherInvestigation, and a method hasErrors() returns this field.

    org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver#resolve() method invokes hasError() to add type information to cache. However, without the inclusion of the jar file, the hasError() method always returns false to prevent any class hierarchical information is stored.

    enter image description here

    org.eclipse.jdt.internal.core.JavaProjectElementInfo

    This class has cache initialization methods such as initializePackageNames and getProjectCache. In getProjectCache() method, package fragment element roots are loaded and added to the cache.

    enter image description here

    With the rtstubs.jar in the package fragment, the cache now contains all the Java class hierarchy. Without this setup, in the course of cache build up, the ignoreFurtherInvestigation filed is on, and hasError() method returns true not to contain the class hierarchical information to return just nothing.

    enter image description here

    ADDED

    The other solution can be using IRegion.

    How can I set the region (=set of java Elements) parameter in JDT TypeHierarchy?

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

Sidebar

Related Questions

I've got a strange issue. I have a class that inherits from RelativeLayout .
I'm using protobuf-net v2 and have a class that inherits List that I wan't
I have a class that inherits from a base class (this contains a lot
I have a class that inherits from a generic dictionary as follows: Class myClass
I have a class that inherits QMainWindow and I just want it to have
I have a class that inherits from Page, called APage. public abstract class APage:
Example: I have an class that inherits from UIImageView. An object creates an instance
If we have a class that inherits from multiple interfaces, and the interfaces have
This is .NET 4.0/C#. I have a class that inherits from an interface: public
I have a class in Qt that inherits QDockWidget. And that class contains another

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.