Determine class dependencies

Hi,
I was curious if anyone has or knows of a way to determine the dependencies for a given class. For example...
Example
package people;
import java.util.List;
import pet.*;
public class Bob {
     Pet[] pets;
     List todoList;
    // ...other code here
package pets;
import cool.stuff.*;
public class Pet {
     private String name;
     // ....other code here
}Ok, so in this case if I want to know what dependencies the "Bob" class has I can easily look at the import statements and see Bob needs java.util.List and all classes in the "pets" package.
What i am interested in is gathering a list of classes needed by "Bob" inclusive. So in this case it would be something like...
Bob needs...
pets.*
Pet needs...
cool.stuff.*
so the list would include, people\Bob.java, pets\Pet.java (because the pets package in my case only contains one class, and all classes in cool\stuff.
So how can I get this list? I saw a class in the Ant API called DependencyAnalyzer which may work for this...but I have no clue how to use it ( i am still looking for an example of where / how it is used).
Thanks.

Hi,
I was curious if anyone has or knows of a way to
to determine the dependencies for a given class.You would obviously need some tool to do that. I guess you have done some research as you've found the Ant task mentioned, but I don't know that you really have researched.
http://www.google.com/search?hl=en&q=Java+dependency+analyze
Seems there are some tools out there. The only thing I would add is that you really can't be 100% sure that any tool will be totally accurate. They would pretty much have to run your code and have 100% code coverage executed to tell what all the dependencies are. Most code is never totally covered, as there are exception conditions which may never be met, for example.

Similar Messages

  • Determine class type of Generic Parameter (not via getGenericSuperclass()!)

    I need to know the class type of a generic Parameter. Please imagine this class:
    class MyGenericClass<T>
    }In cases where other classes derived from MyClass and defined the generic parameter (like MyDerivedClass extends MyGenericClass<String>),
    this snippets works just fine:
    (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];But now I have no inheritance but the definition of the type parameter via instantiation:
    MyGenericClass<String> entity = new MyGenericClass<String>();The method "getGenericSuperclass()" does not suit my needs because it does not target the actual class. Nor can "getTypeParameters() " help me...
    After countless trying to retrieved the type information, I still have no clue how to determine for that case that (in my example) the type parameter
    is a 'String'.
    Does anyone know the solution?

    Serethos_0 wrote:
    Sure I could pass the class type itself as parameter to be stored in 'exportClassType'. But I only tried to adapt the idea used e.g. in Generic DAOs
    as descibed here: [http://community.jboss.org/wiki/GenericDataAccessObjects]. The big difference is, that in the Generic DAO example the typed
    information is available within the class definition ..
    Besides that I am open for any other suggestion!I would recommend passing around the Class object as you say.
    Some might suggest that you make MyGenericClass abstract, forcing any instantiation to be like this:
    MyGenericClass<String> entity = new MyGenericClass<String>() {};That would indeed cause the String type parameter to be available at runtime, since you're creating an anonymous inner class. But it leads to a convoluted and extremely statically expensive instantiation pattern. Using the class object is a better solution IMO.

  • Tracking down rogue class dependencies

    Hi,
    This is a bit of a wierd one, and it could well be that it's late at night and I'll suddenly realise I'm being terribly stupid tomorrow morning.
    I have an issue that I have a base class in that when I load it, it also loads all of its child classes and as it's a fairly big project makes everything horrendously slow. I've done the right click on dependencies and selected 'Why in dependencies?' for clues and it points to 2 VI's that are called from child classes, but it still doesn't explain why all of these child classes should be loaded.
    Does anyone have any advice or strategies for trying to figure out why this is happenning - is it something VI Analyzer might find?
    Any advice greatly received,
    Thanks,
    Dave
    David Clark
    CLA | CTA
    CLA Design Ltd
    Hampshire, England

    Two thoughts:
    Are the classes all in a library together? I think that a library does load all the classes that it owns when it's loaded.
    Is it possible that you have controls/indicators/constants somewhere with default data which includes the child classes? That would cause them to be loaded.
    Also, if the class points to a VI in the class, check to see where that VI is called.
    Try to take over the world!

  • Automatic Batch Determination - Class  and  Classification - SD only

    Hi
    What Is use of Class  and  Classification in Automatic Batch Determination ?
    Regards.,
    Lakshmanan.S
    E-Mail id : [email protected]

    Hi Lakshmanan.S
    please refer to the steps below to implement this functionality:
    1. create characteristics to reflect the attributes of your product.
    2. create new class(with class type batch) to group those characteris.
    3. assign the class to your material master.
    4. in IMG, make sure batch determination procedure is properly assigned to sales area and order type.
    5. activate the auto. determination for item categoty.
      (IMG->LO->batch management..->..in SD->..)
    6. as it uses conditon tech. also, make sure your strategy record is maintain.
    I just delivered the workshop of this topic in my office today Hope u find this useful.
    Best regards,
    David Wang

  • Class dependencies with Ant?

    The "Show Dependencies" functionality for Java classes doesn't work because I use Ant as the build system:
    Message
    showDeps.ShowDepsNoDepBuildSystem: Cannot show dependencies as the projects build system does not support this.
    Cause
    The build system for the project (e.g. Ant) you are using does not support generation of dependencies that this feature requires.
    Action
    Switch to a build system that does support generation of dependency information. The standard JDeveloper build system supports this.
    Now is there a way that I can configure Ant to create this dependency information (maybe by using the Oracle compiler in JDeveloper)?

    At this time there is no way to configure this feature to work when using the Ant build system. It is possible to use the Oracle Java Compiler from within your Ant buildfile. However, due to the arbitrary content of an Ant buildfile, JDeveloper still has no way of knowing if the resulting compilation will produce all the information needed for an accurate dependency analysis. Therefore, this feature is disabled when using the Ant build system. A possible solution might be to configure your project to use the normal JDeveloper build system to enable this feature, and run Ant manually by right clicking on the buildfile in the System Navigator and selecting the target you want to bulid.
    -Matt Hawkins, JDeveloper Team

  • Class dependencies

    Hi, I have created an Applet using forte. I can run it in forte but when I put it in the broswer it complains about not finding some classes. I can try to find where all those classes are but most are in big jar files.
    I was wondering is there a way or maybe a tool that can look for dependencies and put only those classes into one jar file. so the size of the applet is small. and would make sure that it would run on any browser?
    or do I have to do something else?

    look at sourceforge, i think there is a project being developed that will work out dependencies.

  • J2EE debugger cannot determine class type

    Hi,
    when i try to remote debug servlets, jsps or enterprisebeans, i always get the source code finder window popup writing:
    "the source of the type 'ocm.sap.internal.jcmsystool.SystoolProcessor' could not be shown as the type was not found."
    I tried to pack the web project into a jar and add it explicitely to the source code searchlist, but even that did not help.
    i use nwds 2.0.15
    thanks in advance, joerg.

    Joerg,
    In this window check what jar/zip/dirs are used for source lookup.
    With remote debugging it is common to setup debug configuration for project A, then use it for debugging project B. And debugger is unable to find sources of B in A (that is defined via configuration)
    VS

  • Invoice No. 4902 dtd 23.07.09 u201C(error in account determination)u201D

    Hello SAP GURUS,
    The billing document no. 90175064 had been generated but the document has not been posted in respective G/L.
    what I understood i would like to share with you that-
    The accounting document was not generated, because system did not found respective  GL for condition type ZDIC (Customer discount). The condition type ZDIC is only applicable in case of selling of  Molten Metals.But due to same batch no.(B17746) for both the Pig Iron & Molten Metal, system wrongly picked the condition type ZDIC in this case as well.
            While in the subject, i also wish to inform you that this is the case of last year (23.07.2009) when logic for selecting customer discount was Batch specific.
    Now i required to reconcile the account,for that We have change the Billing date to 24.08.2010 so that posting can be taking place in current year. But error message is coming u201C(error in account determination)u201D
    I request you to help me on this.
    Regards
    Rajiv

    Please follow the Follwoing Process :
    1.SD Account Determination Process :
    IMG - SD - Basic Functions - Account Assignment/Costing - Revenue Account Determination - Define Dependencies Of Revenue Account Determination
    2.MM Account Determination Process :
    IMG - Material Management  -> Purchasing -> Material Master -> Entry aids for items without a Material Master
    G/L Accounts in MM Account Determination
    3. For Asset Account Determination process :
    IMG u2013 Financial Accounting u2013 Asset Accounting u2013 Organizational Structure u2013 Asset Class u2013
    Specify Account Determination
    Please can your try this process
    Thanks and Regards
    N.Soma Sundaram
    SAP - FICO Consaltant

  • Question about view/controller/nib class design

    Assume you need to make an application with, let's say, 15 different views in total. There are two extreme design choices you can use to implement the app:
    1) Every single view has its own view controller and a nib file. Thus you end up with 15 controller classes and 15 nib files (and possibly a bunch of view classes if any of your views needs to be somehow specialized).
    2) You have only one controller which manages all the views, and one nib file from which they are loaded.
    AFAIK Apple and many books recommend going purely with option #1. However, going with this often results in needless complexity, large amounts of classes (and nib files) to be managed and complicated class dependencies, especially if some of the views (and thus their controllers) interact with each other or share something (something which would be greatly simplified if all these related views were handled by one single controller class).
    Option #2 also usually ends up being very complex. The major problem is that the single controller will often end up being enormous, handling tons of different (and usually unrelated) things (which is just outright bad design). This is seldom a good design, unless your application consists of only a few views which are closely related to each other (and thus it makes sense for one single controller class to handle them).
    (Option #2 also breaks the strictest interpretation of the MVC pattern, but that's not really something I'm concerned about. I'm concerned about simple design, not about following a programming pattern to the letter.)
    A design somewhere in between the two extremes often seems to be the best approach. However, since I don't have decades of Cocoa programming experience, I would like to hear some opinions about this subject matter from people with more experience on that subject. (I do have object-oriented programming experience, but I have only relatively recently started programming for the iPhone and thus Cocoa and its design patterns are relatively new to me, so I'm still learning.)

    Somehow I get the feeling that my question was slightly misunderstood.
    I was not asking "which one of these two designs do you think is better, option #1 or option #2?" I already said in my original post that option #2 is bad design (unless your application consists of just one or two views). That's not the issue.
    The issue is that from my own experience trying to adhere very strictly to the "every single view must have its own view controller and nib file" often results in needless complexity. Of course this is not always the case, but sometimes you end up having controller classes which perform very similar, if not even the exact same actions, resulting in code repetition. (An OO'ish solution to this problem would be to have a common base class for these view controllers where the common functionality has been grouped, but this often just adds to the overall complexity of the class hierarchy rather than alleviating it.)
    As an example, let's assume that you have a set of help screens (for example one help screen for each major feature of the app) and a view where you can select which help view to show. Every one of these views has, for example, a button to immediately exit the help system. If you had one single controller class managing these views, this becomes simpler: The controller can switch between any of the views and the buttons of each view (most of them doing the same things) can call back actions on this controller (eg. to return to the help selection or to exit the help screen completely). These help screens don't necessarily have any functionality of their own, so it's questionable what do they would need view controllers of their own. These view controllers would basically be empty because there's nothing special for them to do.
    View controllers might make it easy to use the navigation controller class, but the navigation controller is suitable mainly for utility apps but often not for things like games. (And if you need animated transitions between views, that can be implemented using the UIView animation features.)
    I also have hard time seeing the advantages of adhering strictly to the MVC pattern. The MVC pattern is useful in things like web servers, where MVC adds flexibility. The controller acts as a mediator between the database and the user interface, and it does so in such an abstract way that either one can be easily changed (eg. the "view", which normally outputs HTML, could be easily changed to a different "view" which outputs a PDF or even plain text, all this without having to touch the controller or the model at all). However, I'm not seeing the advantages of the MVC pattern in an iPhone app. It provides a type of class design, but why is it better than some other class design? It's not like the input and output formats of the app need to be changed on the fly (which is one advantage of a well-designed program using the MVC pattern).

  • Condition table for account determination

    Hi,
    I would like to know if there is any generic transaction to create condition tables.
    Specifically, I would like to create a condition table for revenue account determination.
    Any help would be appreciated.
    Thanks,
    Aroop

    Aroop,
    Yes you can create IMG --> SD --> BF --> Revenue Account determination --> Define dependencies of revenue account determination --> Account determination create Tables OR Tcode V/12.
    Try to create Table above 500 number.
    Regards
    Sathya

  • Adding Java Fact Classes not erroring, but not adding the facts/classes

    I'm attempting to build Rule dictionaries modeled after maven modules of the project I'm working on. First I created a dictionary "common" with common classes added as Java facts. Second I created a dictionary "domain". In the "domain" dictionary I linked the "common" dictionary and added some domain specific classes as java facts. Finally I created a "product" dictionary. The product dictionary links the "domain" dictionary. When I look at the facts in the "product" dictionary I see all the facts from "common" and "domain" linked in. When I attempt to add more facts to the "product" dictionary I can find the classes in the classpath without a problem. However when I select the classes I wanted added as java facts and click "OK" in JDevelopers 'Create Java Fact' Dialog none of the facts are added. I cannot find any error or explanation for why they were not added. I believe I have all class dependencies of these java facts already added in the "common" and "domain" dictionaries I have linked in. Any help in how to resolve this would be appreciated - or even some general guidelines on how to build and maintain dictionaries.
    Thanks,
    Mike

    Hello, I seem to have the same problem as you. Have you found a solution to this?
    See my thread here: Oracle Rules: Adding Java Facts - not showing up in list.

  • Can we conditionally rename the "Submit" as "Next" in web determinations?

    Hi,
    We are using web determinations for data entry and we have multiple screens for multiple entities. Is it possible to rename the submit buttons in the first and intermediate screens as "Next" and only have the last "Submit" button named/displayed as "Submit".
    Thanks!
    Antara

    The first question here is "what is the +last+ screen".
    Generally, the last screen will change depending on what answers have been provided. This is because Web Determinations is clever, and stops asking questions when it knows the answers to all the goals on the summary screen (or it runs out of questions).
    You can force a particular last screen to always be displayed if you either:
    (a) Define a flow with a mandatory screen at the end of the interview, and use that flow as the goal, or
    (b) Have a summary screen goal that depends on a specific piece of data collected on a screen that is last in your screen order.
    If you have done one of these, then you can achieve what you want by:
    (1) Making the change Jasmine suggests to change the default Submit button text to "Next" AND
    (2) Edit the Web Determinations classes/templates/controls/ButtonControl.vm template to conditionally render the "submit" buttonClass with the value of "Submit", when it is being rendered in the context of the final question screen. You could do this for example by checking for #if ( {screen.getId().equals("<screenidgoeshere>"} ).
    Davin Fifield

  • Error compiling a Class using generics in 11g Database

    I am using loadjava to load my java souce into the database (11g) and I get an error.
    Error while determining classes contained in utc/ehsrs/notification/EmailNotificationCfg.java
    Exception oracle.aurora.sqljdecl.ParseException: Encountered "<" at line 27, column 19.
    line 27 column 19 is the one in bold (uses Generics).
    public class EmailNotificationCfg {
    private String id;
    private String reportName;
    private String title;
    private String tablename;
    private String criteria;
    private String dynamicUser;
    private String message;
    private Vector<String> actions;
    private boolean includeLink = true;
    public EmailNotificationCfg() {
    The database says the JVM is version 1.5 I have compiled this outside the database with Java 1.5 (5.0).
    this is the first time I have tried to load a class with generics into the database. It also didn't like the annotations, but I have removed them.

    Good suggestion, but we need to keep the source in the database.
    However I upgraded my database client to 11g and loadjava loaded the source without errors.
    I can only guess that loadjava is parsing the file before loading the class and is not the lightweight application that I had assumed it was.

  • Asset class doesn't appear in T.code AS01

    Hi
    I created Asset Class, and Screen layout with that asset class. But when I creat asset in T.code AS01, I click field "Asset Class", but that asset class doesn't appear. It notice following:
    "Asset class 213200 cannot be used in company code HDQC
    Message no. AA130
    Diagnosis
    When you create an asset, the system determines the chart of depreciation from the company code definition. In order for a chart of depreciation to be available for an asset class during asset maintenance, the chart of depreciation has to be entered for that asset class (Determine class valuation). Chart of depreciation HDQC that was determined is not entered for asset class 213200.
    System Response
    You cannot create any assets in your company code for this class.
    Procedure
    You can do one of the following:
    Use another asset class, for which chart of depreciation HDQC is defined.
    Maintain the asset class valuations for asset class 213200 in chart of depreciation HDQC. Chart of depreciation HDQC has to be specified in order for you to be able to maintain the valuation parameters of asset class 213200 for chart of depreciation HDQC"
    Please explain me as detailed as possible
    Thanks
    Ngocpt

    Thank you
    I understood my problem. When I determine depreciation area in Asset Class. It notice error:
    Contact your system administrator (table error)
    Message no. AA826
    Diagnosis
    Depreciation area 41 has not been defined in the chart of depreciation HDQC.
    Procedure
    Define the depreciation area using in FI-AA Customizing.
    Before I created depreciation area 41.After that I deleted depreciation area 41. So I can't determine depreciation area in Asset Class 213200
    You can help me to fix that error.
    Thanks
    Ngocpt

  • Instantiation of similar object over a super class deciding the sub class

    Hello all
    First, sorry if I'm duplicating an already answered question. I didn't searched very deep.
    Initial position:
    I have 2 Object (A1 and A2) which share the most (about 90%) of their instance variables an the associated methods. The values of the instance variables are retrieved in the real implementation from a stream. Depending of the data of the stream, I have to instantiate either a A1 or A2 object.
    A test implementation (using an int in case of the stream):
    The super class A:
    package aaa;
    public class A
      protected int version = -1;
      protected String name = null;
      protected AE ae = null;
      protected A()
      protected A(int v)
        // Pseudo code
        if (v > 7)
          return;
        if (v % 2 == 1)
          this.version = 1;
        else
          this.version = 2;
      public final int getVersion()
        return this.version;
      public final String getName()
        return this.name;
      public final AE getAE()
        return this.ae;
    }The first sub class A1:
    package aaa;
    public final class A1 extends A
      protected A1(int v)
        this.version = v;
        this.name = "A" + v;
        this.ae = new AE(v);
    }The second subclass A2:
    package aaa;
    import java.util.Date;
    public final class A2 extends A
      private long time = -1;
      protected A2(int v)
        this.version = v;
        this.name = "A" + v;
        this.time = new Date().getTime();
        this.ae = new AE(v);
      public final long getTime()
        return this.time;
    }Another class AE:
    package aaa;
    public class AE
      protected int type = -1;
      protected AE(int v)
        // Pseudo code
        if (v % 2 == 1)
          this.type = 0;
        else
          this.type = 3;
      public final int getType()
        return this.type;
    }To get a specific object, I use this class:
    package aaa;
    public final class AFactory
      public AFactory()
      public final Object createA(int p)
        A a = new A(p);
        int v = a.getVersion();
        switch (v)
        case 1:
          return new A1(v);
        case 2:
          return new A2(v);
        default:
          return null;
    }And at least, a class using this objects:
    import aaa.*;
    public final class R
      public static void main(String[] args)
        AFactory f = new AFactory();
        Object o = null;
        for (int i = 0; i < 10; i++)
          System.out.println("===== Current Number is " + i + " =====");
          o = f.createA(i);
          if (o instanceof aaa.A)
            A a = (A) o;
            System.out.println("Class   : " + a.getClass().getName());
            System.out.println("Version : " + a.getVersion());
            System.out.println("Name    : " + a.getName());
            System.out.println("AE-Type : " + a.getAE().getType());
          if (o instanceof aaa.A2)
            A2 a = (A2) o;
            System.out.println("Time    : " + a.getTime());
          System.out.println();
    Questions:
    What would be a better way to encapsulate the logic into their respective objects ? Is there a way to let the super class A itself identify the type of the object and then extend from A to either A1 or A2 ?
    Thanks in advance
    Andreas

    Hello jduprez
    First, I would thank you very much for taking the time reviewing my problem.
    Just for the record: have you considered regular serialization? If you control the software at both ends of the stream, you could rely on standard serialization mechanism to marshall the objects and unmarshall them automatically.In my case, I can't control the other site of the stream. At the end, the data comes from a FileInputStream and there aren't objects on the other site, only pur binary data.
    - It seems you have one such factory class. Then you already have encapsulated the "determine class" logic, you don't need to add such logic in superclass A.I thought from an OO view, that the super class A is responsible of doing that, but that's where the problem starts. So at the end, it's better doing it in the factory class.
    - A itself encapsulates the logic to load its own values from the stream.
    - A1 and A2 can encapsulate the logic to load their own specific value from a stream (after the superclass' code has loaded the superclass' attributes values).
    My advise would be along the lines of:
    public class A {
    .... // member variables
    public void load(InputStream is) {
    ... // assign values to A's member variables
    // from what is read from the stream.
    public class A1 extends A {
    ... // A1-specific member variables
    public void load(InputStream is) {
    super.load(is);
    // now read A1-specific values
    public class AFactory {
    public A createA(InputStream is) {
    A instance;
    switch (is.readFirstByte()) {
    case A1_ID:
    a = new A1();
    break;
    case A2_ID:
    a = new A2();
    break;
    a.load(is);
    }The example above assumes you have control over the layout of the data in the stream (here for a given A instance, the attributes defined in A are read first, then come the subclass-specific attributes.
    The outcome is: you don't have to create a new A( ) to later create another instance, of a subclass.I like the idea. In the AFactory, is the "A instance;" read as "A a;" ?
    Is there a way to let the super class A itself identify the type of the object and then extend from A to either A1 or A2 ?Note I initially read this question as "can an instance of a class mutate into another class", to which the answer is no (an object has one single, immutable class; it is an instance of this class, and of any superclass and superinterface, but won't change its class at runtime).Yes, I have been thinking about a way for mutating into a subclass to keep the already initialized values from the A class without copying or parsing again. But preventing an instance of an A class will be my way. So, in this aspect, Java didn't changed in the last 10 years... It's a long time ago I've used Java for some real projects.
    You can, however, create an instance of another class, that copies the values off a priori A instance. Your example code was one way, another way could be to have a "copy constructor":
    public class A {
    public A(A model) {
    this.att1 = model.att1;
    this.att2 = model.att2;
    public class A1 {
    public A1(A model) {
    super(model);
    ... // do whatever A1-specific business
    )Still, I prefer my former solution less disturbing: I find the temporary A instance redundant and awkward.Nice to know. I prefer the first solution too.
    Thank you again for the help and advices. My mind is searching sometimes for strange solutions, where the real is so close ;-)
    Andreas

Maybe you are looking for