Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in getPackage () method of the class ClassNode #7

Open
tacianosilva opened this issue Apr 16, 2014 · 1 comment
Open

Bug in getPackage () method of the class ClassNode #7

tacianosilva opened this issue Apr 16, 2014 · 1 comment
Labels

Comments

@tacianosilva
Copy link
Collaborator

Bug in getPackage () method of the class ClassNode. In creating the PackageNode when the name attribute of ClassNode does not contain the point that separates the name of the class and its package (line 525).

When I used a file https://code.google.com/p/on-the-nature-dataset/ in my experiment the getPackage () method throws an exception of the String class:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(Unknown Source)
    at org.designwizard.design.ClassNode.getPackage(ClassNode.java:525)
    at org.designwizard.design.ClassNode.getCalleePackages(ClassNode.java:842)
    at BugDW1.main(BugDW1.java:27)

The error occurs when calling for getCalleePackages() for the org.apache.lucene.index.Payload.clone class. The clone method there is a class called [B (Bracket B) that calls [B.clone(). The B class name does not have point, ie, no package.

I made a workaround in fork project, which generated changes in getCalleeClasses() method of the class MethodNode (line 468) and in getPackage () method of the class ClassNode (line 525).

Follow my test class that generates the error:

public class BugDW1 {

    public static void main(String[] args) {
        try {
            DesignWizard dw = new DesignWizard(
                    "./libs/lucene_week_001_rev_978784_date_2010-06-20.jar");

            // Pode ser feito com classes e métodos?
            Set<ClassNode> classes = dw.getAllClasses();

            for (ClassNode entityNode : classes) {

                PackageNode pacote = entityNode.getPackage();

                // Pacotes acessados pela classe
                Set<PackageNode> callees = entityNode.getCalleePackages();

                // Pacotes que chama essa classe
                Set<PackageNode> callers = entityNode.getCallerPackages();

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
@jeandersonbc
Copy link
Contributor

Thank you @tacianosilva.
@joaoarthurbm, we could use this to set a Test Case. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants