Git Product home page Git Product logo

java-source-metrics's Introduction

Java Source Metrics Build Status

An application to calculate metrics from java bytecode.

Compilation

Maven is used to handle our dependencies.

  • Install Maven 3
  • Check out this repo and run: mvn

java-source-metrics's People

Contributors

kiskae avatar

Stargazers

Parahat Melayev avatar

Watchers

James Cloos avatar  avatar

Forkers

zengyang

java-source-metrics's Issues

Coupling between classes in java bcel

Hi, i need a simple code for this algorithm:

Input: Any class file
Output: Total coupling in the class file
/Eff is set for efferent coupling(set is java collection which holds only unique
values), i is the index used, Interface contains the number of interfaces, Field contains
the number of fields, Method contains the number of methods, filename is the name of
input file, argumentstype is the type of argument, exceptiontype is the type of
exception. Here class is being iterated using an API bcel.jar
/

  1. Select a java class file and parse it using bcel API. //bcel parses it and creates
    objects of class
  2. Set: filename = inputfilename;
  3. Traverse the class.
  4. foreach Interface ? class do
    registerCoupling (Interface);
    endfor
  5. foreach Field ? class do
    registerCoupling (Field.returntype);
    endfor
  6. foreach Method ? class do //Identify different classes based on arguments,
    returntypes
    registerCoupling (Method.returntype);
    registerCoupling (Method.argumentstype);
    registerCoupling (Method.exceptiontype);
    registerCoupling (Method.localargumentstype);
    foreach MethodInstruction
    /* if conditions can be determined by using api bcel.jar and calling its api_/
    if (instruction instanceof LocalVariableInstruction)
    registerCoupling (LocalVariableInstruction type);
    endif
    if (instruction instanceof ArrayInstruction)
    registerCoupling (ArrayInstruction type);
    endif
    if (instruction instanceof FieldInstruction)
    registerCoupling (FieldInstruction type);
    endif
    if (instruction instanceof InvokeInstruction)
    registerCoupling (InvokeInstruction type);
    endif
    if (instruction instanceof INSTANCEOF)
    registerCoupling (INSTANCEOF type);
    endif
    if (instruction instanceof CHECKCAST)
    registerCoupling (CHECKCASTtype);
    endif
    endfor
    endfor
  7. Return Eff.size();
    Methods definition:
    registerCoupling (Type t){
    registerCoupling (className(t))
    }
    className(Type t){
    if (t is premetive)
    return;
    endif
    if (t is array type)
    return;
    endif
    return name of type t ;
    /in java it can be t.tostring()/
    }
    registerCoupling (String classname){
    if (classname is javaclass or classname is filename)
    return;
    endif
    /_Add to set*/
    Eff.add (classname)

Code for this algorithm in bcel java

Hi, i need a source code for this algorithm because i dont know how programming bcel java ....I try more times but I couldn't write a correct code ...
The algorithm is:
Input: Any class file
Output: Total coupling in the class file
/Eff is set for efferent coupling(set is java collection which holds only unique
values), i is the index used, Interface contains the number of interfaces, Field contains
the number of fields, Method contains the number of methods, filename is the name of
input file, argumentstype is the type of argument, exceptiontype is the type of
exception. Here class is being iterated using an API bcel.jar
/

  1. Select a java class file and parse it using bcel API. //bcel parses it and creates
    objects of class
  2. Set: filename = inputfilename;
  3. Traverse the class.
  4. foreach Interface ? class do
    registerCoupling (Interface);
    endfor
  5. foreach Field ? class do
    registerCoupling (Field.returntype);
    endfor
  6. foreach Method ? class do //Identify different classes based on arguments,
    returntypes
    registerCoupling (Method.returntype);
    registerCoupling (Method.argumentstype);
    registerCoupling (Method.exceptiontype);
    registerCoupling (Method.localargumentstype);
    foreach MethodInstruction
    /* if conditions can be determined by using api bcel.jar and calling its api_/
    if (instruction instanceof LocalVariableInstruction)
    registerCoupling (LocalVariableInstruction type);
    endif
    if (instruction instanceof ArrayInstruction)
    registerCoupling (ArrayInstruction type);
    endif
    if (instruction instanceof FieldInstruction)
    registerCoupling (FieldInstruction type);
    endif
    if (instruction instanceof InvokeInstruction)
    registerCoupling (InvokeInstruction type);
    endif
    if (instruction instanceof INSTANCEOF)
    registerCoupling (INSTANCEOF type);
    endif
    if (instruction instanceof CHECKCAST)
    registerCoupling (CHECKCASTtype);
    endif
    endfor
    endfor
  7. Return Eff.size();
    Methods definition:
    registerCoupling (Type t){
    registerCoupling (className(t))
    }
    className(Type t){
    if (t is premetive)
    return;
    endif
    if (t is array type)
    return;
    endif
    return name of type t ;
    /in java it can be t.tostring()/
    }
    registerCoupling (String classname){
    if (classname is javaclass or classname is filename)
    return;
    endif
    /_Add to set*/
    Eff.add (classname)
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.