001: /*
002: * @(#)IMethodCode.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.codecoverage.v2;
028:
029: import org.apache.bcel.classfile.LineNumberTable;
030: import org.apache.bcel.classfile.Method;
031: import org.apache.bcel.generic.Instruction;
032:
033: /**
034: * Contains the BCEL bytecode for a method, and provides helper methods for
035: * generating the marks for certain bytecode instructions.
036: *
037: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
038: * @version $Date: 2004/04/15 05:48:25 $
039: * @since December 15, 2002
040: */
041: public interface IMethodCode {
042: /**
043: * Returns the original BCEL Method object.
044: *
045: * @return the original BCEL Method object
046: */
047: public Method getOriginalMethod();
048:
049: /**
050: * Returns the line number table for the original BCEL method object.
051: *
052: * @return the LineNumberTable, or <tt>null</tt> if there isn't one
053: * for this method.
054: */
055: public LineNumberTable getLineNumberTable();
056:
057: /**
058: * A helper to get the method name.
059: *
060: * @return the method name
061: */
062: public String getMethodName();
063:
064: /**
065: * A helper to get the class name.
066: *
067: * @return the class name
068: */
069: public String getClassName();
070:
071: /**
072: * Returns the number of bytecode instructions in the method.
073: *
074: * @return the number of bytecode instructions
075: */
076: public int getInstructionCount();
077:
078: /**
079: * Returns the bytecode instruction at the given index. If the index
080: * is out of range (< 0 or >= <tt>getInstructionCount()</tt>),
081: * then a <tt>IndexOutOfBoundsException</tt> is thrown.
082: *
083: * @param index the 0-based index of the method's instruction list
084: * @return the instruction at <tt>index</tt>
085: */
086: public Instruction getInstructionAt(int index);
087:
088: /**
089: * Marks an instruction for coverage analysis. If the index
090: * is out of range (< 0 or >= <tt>getInstructionCount()</tt>),
091: * then a <tt>IndexOutOfBoundsException</tt> is thrown.
092: *
093: * @param index the 0-based index of the method's instruction list
094: * @param meta meta-data the analysis module records in association with
095: * the mark. This cannot be <tt>null</tt>.
096: * @exception IllegalArgumentException if <tt>meta</tt> is <tt>null</tt>.
097: * @exception IndexOutOfBoundsException if <tt>index</tt> is not within
098: * the valid range.
099: */
100: public void markInstruction(int index, IAnalysisMetaData meta);
101: }
|