com.sun.billf.tass
Class TassChecker

java.lang.Object
  extended bycom.sun.billf.tass.TassChecker
All Implemented Interfaces:
com.sun.billf.tass.Visitee

public class TassChecker
extends java.lang.Object
implements com.sun.billf.tass.Visitee

This class is the entry point to the TASS checking module. TASS stands for "Test Application Signature Safety," and it brings you the news about an application's conformance to platform API signature rules.

This tool inspects appliation classes one at a time. For each class, it considers all external references to API elements: classes, methods, fields, etc. For each external reference, it checks if it's in one of the platform packages, that is, if it's in a package or a subpackage of one of the supplied platform package names.. If it isn't, it ignores it; this tool doesn't try to check applictions for appliction bugs like this.

If an external reference is to a platform class, this tool checks it. It checks the referred-to element against the platform class file stubs, provided. If the referred-to element is there, then checking proceeds. If, however, the element isn't present, an error message is (optionally) created, and an error is indicated.

Author:
Bill Foote bill.foote@sun.com

Constructor Summary
TassChecker()
          Create a new TassChecker.
 
Method Summary
 void checkFieldRef(java.lang.String className, java.lang.String fieldName)
          Internal Visitee implementation method
 void checkForClass(java.lang.String name)
          Internal Visitee implementation method
 void checkMethodRef(java.lang.String className, java.lang.String methodName, org.apache.bcel.generic.Type[] args)
          Internal Visitee implementation method
 void checkType(org.apache.bcel.generic.Type t)
          Internal Visitee implementation method
 boolean classIsOK(java.lang.String fileName)
          Check if the .class in the give file is OK.
 int getNumErrors()
          Return the total number of errors seen
 void init(java.lang.String stubsZipFile, java.lang.String[] platformPackages, java.lang.String maxClassFileVersion)
          Initialize a TassChecker
 void reportError(java.lang.String msg)
          Internal Visitee implementation method
 void setErrorOutput(java.io.PrintStream out)
          Supply a place to send error messages.
 boolean zipIsOK(java.lang.String fileName)
          Check if the .class files in the given archive are OK.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TassChecker

public TassChecker()
Create a new TassChecker. It must be initialized before use.

See Also:
init(java.lang.String, java.lang.String[], java.lang.String)
Method Detail

init

public void init(java.lang.String stubsZipFile,
                 java.lang.String[] platformPackages,
                 java.lang.String maxClassFileVersion)
          throws java.io.IOException
Initialize a TassChecker

Parameters:
stubsZipFile - The name of the .zip file olding the platform stubs
platformPackages - The string names of the platform packages
maxClassFileVersion - The maximum acceptable class file version for application classes, e.g. "47.0" for PBP 1.0.
Throws:
java.io.IOException - If on occurs reading the stubs
java.lang.IllegalArgumentException - if maxClassfileVersion can't be parsed

setErrorOutput

public void setErrorOutput(java.io.PrintStream out)
Supply a place to send error messages. If left unset, error messages will not be generated.

Parameters:
out - The output stream

classIsOK

public boolean classIsOK(java.lang.String fileName)
                  throws java.io.IOException
Check if the .class in the give file is OK. If an error is found, emits one or more messages to the error output stream, and returns false. Returns true if no errors found.

Parameters:
fileName - The name of the .class file
Throws:
java.io.IOException
See Also:
setErrorOutput(java.io.PrintStream)

zipIsOK

public boolean zipIsOK(java.lang.String fileName)
                throws java.io.IOException
Check if the .class files in the given archive are OK. If an error is found, emits one or more messages to the error output stream, and returns false. Returns true if no errors found.

Parameters:
fileName - The name of the zip archive containing .class files
Throws:
java.io.IOException
See Also:
setErrorOutput(java.io.PrintStream)

getNumErrors

public int getNumErrors()
Return the total number of errors seen

Returns:
the number of errors

reportError

public void reportError(java.lang.String msg)
Internal Visitee implementation method

Specified by:
reportError in interface com.sun.billf.tass.Visitee

checkForClass

public void checkForClass(java.lang.String name)
Internal Visitee implementation method

Specified by:
checkForClass in interface com.sun.billf.tass.Visitee

checkType

public void checkType(org.apache.bcel.generic.Type t)
Internal Visitee implementation method

Specified by:
checkType in interface com.sun.billf.tass.Visitee
See Also:
Visitee.checkForClass(String)

checkFieldRef

public void checkFieldRef(java.lang.String className,
                          java.lang.String fieldName)
Internal Visitee implementation method

Specified by:
checkFieldRef in interface com.sun.billf.tass.Visitee

checkMethodRef

public void checkMethodRef(java.lang.String className,
                           java.lang.String methodName,
                           org.apache.bcel.generic.Type[] args)
Internal Visitee implementation method

Specified by:
checkMethodRef in interface com.sun.billf.tass.Visitee