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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:34:46+00:00 2026-05-25T03:34:46+00:00

We have a JUnit test based on JDepend 2.9.1 in order to find illegal

  • 0

We have a JUnit test based on JDepend 2.9.1 in order to find illegal dependencies and cycles.

Today we found that JDepend is missing dependencies. It doesn’t seem to consider A depending on B in the following piece of code:

public class A {
    @SomeAnotation(value = B.class)
    public String someMethod() {
        ...
    }
}

Our test looks like this:

private JDepend setupJDepend() {
    JDepend jdepend = null;
    try {
        jdepend = new JDepend();
        jdepend.addDirectory("target/classes");
        jdepend.addDirectory("target/test-classes");
    } catch (final IOException ioException) {
        fail("An IOException occured: " + ioException.getMessage());
    }
    jdepend.analyzeInnerClasses(true);
    return jdepend;
}

@Test
public final void testNoCyclesOnPackageLevel() {
    final JDepend jdepend = setupJDepend();
    final Collection<?> packages = analyzeDependencies();

    assertTrue(packages.size() > 0);

    assertFalse("The code contains dependency cycles on package level!",
            jdepend.containsCycles());

    if (ignorePackageCycle) {
        return;
    }

    java.util.List<String> packagesWithCycle = new ArrayList<String>();
    for (Object pObject : packages) {
        JavaPackage javaPackage = (JavaPackage) pObject;
        if (javaPackage.containsCycle()) {
            packagesWithCycle.add(javaPackage.getName());
        }
    }
    assertTrue(packagesWithCycle.toString(), packagesWithCycle.isEmpty());
}

The JDepend4Eclipse plugin sees the dependency and reports the resulting cycle.

Is this a Bug? Is there a Workaround? Are we doing something wrong?

On a related note: jdepend.containsCycles() always returns false.

  • 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-05-25T03:34:46+00:00Added an answer on May 25, 2026 at 3:34 am

    This is a missing feature!

    For a @Retention(SOURCE) declared @SomeAnotation, no tool can find B in the compiled class file.

    For other policies, the annotations is included in the class file but the ClassFileParser of JDepend does not support annotations of any kind, this is a missing feature so far.

    EDIT: The source code checked in, support java 5 annotations and is used in the eclipse plugin. Maybe the 2.9.1 is not based on this. Not found the release notes of JDepend and its release date. The Code has been checked in 2010-05-19. The “latest” release seems to be from 2008.

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

Sidebar

Related Questions

I have a JUnit test that tests adding Strings to a Dictionary custom type.
I have a JUnit test that fails because the milliseconds are different. In this
I have this JUnit test that I need help developing a Interface and Class
Normally I would have one junit test that shows up in my integration server
I have a little JUnit-Test that export an Object to the FileSystem. In the
I have an ant build file that contains JUnit test suite that I would
I have a JUnit test that is checking to make sure that a customized
I have parametrized junit test that reads from several XML input files. In the
I have a JUnit 4 test that loops through an array of test data:
I have a junit test method that takes a CommonsMultipartFile object as a parameter.

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.