Top Description Fields Constructors Methods
org.apache.tools.ant

public final Class Diagnostics

extends Object
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, .OutputStream, .PrintStream, java.lang.reflect.InvocationTargetException, .Method, java.net.URL, java.nio.file.Files, java.util.Calendar, .Properties, .TimeZone, javax.xml.parsers.SAXParser, .SAXParserFactory, javax.xml.transform.Transformer, .TransformerFactory, org.apache.tools.ant.launch.Launcher, org.apache.tools.ant.util.FileUtils, .JAXPUtils, .JavaEnvUtils, .ProxySetup, org.apache.tools.ant.util.java15.ProxyDiagnostics, org.xml.sax.XMLReader

A little diagnostic helper that output some information that may help in support. It should quickly give correct information about the jar existing in ant.home/lib and the jar versions...
Since
Ant 1.5

Field Summary

Modifier and TypeField and Description
private static final int
BIG_DRIFT_LIMIT

value for which a difference between clock and temp file time triggers a warning.

protected static final String
ERROR_PROPERTY_ACCESS_BLOCKED

The error text when a security manager blocks access to a property.

private static final int
private static final int
private static final int
private static final int
private static final int
TEST_FILE_SIZE

How big a test file to write.

Constructor Summary

AccessConstructor and Description
private
Diagnostics()

utility class

Method Summary

Modifier and TypeMethod and Description
public static void
doReport(PrintStream
the stream to print the report to.
out
)

Print a report to the given stream.

public static void
doReport(PrintStream
the stream to print the report to.
out
,
int
denotes the level of detail requested as one of Project's MSG_* constants.
logLevel
)

Print a report to the given stream.

private static void
doReportAntHomeLibraries(PrintStream
the stream to print the content to
out
)

Report the content of ANT_HOME/lib directory

private static void
doReportAntProperties(PrintStream
the stream to print the content to
out
)

Report the content of ANT_HOME/lib directory

private static void
doReportLocale(PrintStream
stream to print to
out
)

Report locale information

private static void
doReportParserInfo(PrintStream
a PrintStream
out
)

tell the user about the XML parser

private static void
doReportProxy(PrintStream
stream to print to
out
)

Report proxy information

private static void
doReportSystemProperties(PrintStream
the stream to print the properties to.
out
)

Report a listing of system properties existing in the current vm.

private static void
doReportTasksAvailability(PrintStream
the stream to print the tasks report to null for a missing stream (ie mapping).
out
)

Create a report about non-available tasks that are defined in the mapping but could not be found via lookup.

private static void
doReportTempDir(PrintStream
a PrintStream
out
)

try and create a temp file in our temp dir; this checks that it has space and access.

private static void
doReportUserHomeLibraries(PrintStream
the stream to print the content to
out
)

Report the content of ~/.ant/lib directory

private static void
doReportWhich(PrintStream
the stream to print the content to.
out
)

Call org.apache.env.Which if available

private static void
doReportXSLTProcessorInfo(PrintStream
a PrintStream
out
)

tell the user about the XSLT processor

private static URL
getClassLocation(Class<?>
the class to get the information from.
clazz
)

Helper method to get the location.

private static String

Returns:

null if there is no package or implementation version. '?.?' for JDK 1.0 or 1.1.
getImplementationVersion
(Class<?>
the class to get the information from.
clazz
)

Helper method to get the implementation version.

private static String
private static String
private static String

Returns:

the system property's value or error text
getProperty
(String
a property key
key
)

Get the value of a system property.

private static SAXParser

Returns:

parser or null for trouble
getSAXParser
()

Create a JAXP SAXParser

private static String

Returns:

path or null for trouble in tracking it down
getXMLParserLocation
()

get the location of the parser

private static String

Returns:

the classname of the parser
getXMLParserName
()

what parser are we using.

private static Transformer

Returns:

parser or null for trouble
getXSLTProcessor
()

Create a JAXP XSLT Transformer

private static String

Returns:

path or null for trouble in tracking it down
getXSLTProcessorLocation
()

get the location of the parser

private static String

Returns:

the classname of the parser
getXSLTProcessorName
()

what parser are we using.

private static void
header(PrintStream out, String section)

private static void
ignoreThrowable(Throwable
a Throwable to ignore
thrown
)

ignore exceptions.

public static boolean

Returns:

true
isOptionalAvailable
()

Deprecated Obsolete since Ant 1.8.2
Doesn't do anything.
private static File[]

Returns:

array of files (or null for no such directory)
listJarFiles
(File
directory
libDir
)

get a list of all JAR files in a directory

public static File[]

Returns:

the list of jar files existing in ant.home/lib or null if an error occurs.
listLibraries
()

return the list of jar files existing in ANT_HOME/lib and that must have been picked up by Ant script.

public static void
main(String[]
command line arguments.
args
)

main entry point for command line

private static void
printLibraries(File[]
array of libraries (can be null)
libs
,
PrintStream
output stream
out
)

list the libraries

private static void
printParserInfo(PrintStream out, String parserType, String parserName, String parserLocation)

private static void
printProperty(PrintStream
stream to print on
out
,
String
property name
key
)

print a property name="value" pair if the property is set; print nothing if it is null

public static void
validateVersion()

Deprecated Obsolete since Ant 1.8.2
Doesn't do anything.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIG_DRIFT_LIMITback to summary
private static final int BIG_DRIFT_LIMIT

value for which a difference between clock and temp file time triggers a warning. 10000

ERROR_PROPERTY_ACCESS_BLOCKEDback to summary
protected static final String ERROR_PROPERTY_ACCESS_BLOCKED

The error text when a security manager blocks access to a property. Access to this property blocked by a security manager

KILOBYTEback to summary
private static final int KILOBYTE
MINUTES_PER_HOURback to summary
private static final int MINUTES_PER_HOUR
SECONDS_PER_MILLISECONDback to summary
private static final int SECONDS_PER_MILLISECOND
SECONDS_PER_MINUTEback to summary
private static final int SECONDS_PER_MINUTE
TEST_FILE_SIZEback to summary
private static final int TEST_FILE_SIZE

How big a test file to write. 32

Constructor Detail

Diagnosticsback to summary
private Diagnostics()

utility class

Method Detail

doReportback to summary
public static void doReport(PrintStream out)

Print a report to the given stream.

Parameters
out:PrintStream

the stream to print the report to.

doReportback to summary
public static void doReport(PrintStream out, int logLevel)

Print a report to the given stream.

Parameters
out:PrintStream

the stream to print the report to.

logLevel:int

denotes the level of detail requested as one of Project's MSG_* constants.

doReportAntHomeLibrariesback to summary
private static void doReportAntHomeLibraries(PrintStream out)

Report the content of ANT_HOME/lib directory

Parameters
out:PrintStream

the stream to print the content to

doReportAntPropertiesback to summary
private static void doReportAntProperties(PrintStream out)

Report the content of ANT_HOME/lib directory

Parameters
out:PrintStream

the stream to print the content to

doReportLocaleback to summary
private static void doReportLocale(PrintStream out)

Report locale information

Parameters
out:PrintStream

stream to print to

doReportParserInfoback to summary
private static void doReportParserInfo(PrintStream out)

tell the user about the XML parser

Parameters
out:PrintStream

a PrintStream

doReportProxyback to summary
private static void doReportProxy(PrintStream out)

Report proxy information

Parameters
out:PrintStream

stream to print to

Since
Ant1.7
doReportSystemPropertiesback to summary
private static void doReportSystemProperties(PrintStream out)

Report a listing of system properties existing in the current vm.

Parameters
out:PrintStream

the stream to print the properties to.

doReportTasksAvailabilityback to summary
private static void doReportTasksAvailability(PrintStream out)

Create a report about non-available tasks that are defined in the mapping but could not be found via lookup. It might generally happen because Ant requires multiple libraries to compile and one of them was missing when compiling Ant.

Parameters
out:PrintStream

the stream to print the tasks report to null for a missing stream (ie mapping).

doReportTempDirback to summary
private static void doReportTempDir(PrintStream out)

try and create a temp file in our temp dir; this checks that it has space and access. We also do some clock reporting.

Parameters
out:PrintStream

a PrintStream

doReportUserHomeLibrariesback to summary
private static void doReportUserHomeLibraries(PrintStream out)

Report the content of ~/.ant/lib directory

Parameters
out:PrintStream

the stream to print the content to

doReportWhichback to summary
private static void doReportWhich(PrintStream out)

Call org.apache.env.Which if available

Parameters
out:PrintStream

the stream to print the content to.

doReportXSLTProcessorInfoback to summary
private static void doReportXSLTProcessorInfo(PrintStream out)

tell the user about the XSLT processor

Parameters
out:PrintStream

a PrintStream

getClassLocationback to summary
private static URL getClassLocation(Class<?> clazz)

Helper method to get the location.

Parameters
clazz:Class<?>

the class to get the information from.

Since
Ant 1.8.0
getImplementationVersionback to summary
private static String getImplementationVersion(Class<?> clazz)

Helper method to get the implementation version.

Parameters
clazz:Class<?>

the class to get the information from.

Returns:String

null if there is no package or implementation version. '?.?' for JDK 1.0 or 1.1.

getNamespaceParserLocationback to summary
private static String getNamespaceParserLocation()
getNamespaceParserNameback to summary
private static String getNamespaceParserName()
getPropertyback to summary
private static String getProperty(String key)

Get the value of a system property. If a security manager blocks access to a property it fills the result in with an error

Parameters
key:String

a property key

Returns:String

the system property's value or error text

See Also
ERROR_PROPERTY_ACCESS_BLOCKED
getSAXParserback to summary
private static SAXParser getSAXParser()

Create a JAXP SAXParser

Returns:SAXParser

parser or null for trouble

getXMLParserLocationback to summary
private static String getXMLParserLocation()

get the location of the parser

Returns:String

path or null for trouble in tracking it down

getXMLParserNameback to summary
private static String getXMLParserName()

what parser are we using.

Returns:String

the classname of the parser

getXSLTProcessorback to summary
private static Transformer getXSLTProcessor()

Create a JAXP XSLT Transformer

Returns:Transformer

parser or null for trouble

getXSLTProcessorLocationback to summary
private static String getXSLTProcessorLocation()

get the location of the parser

Returns:String

path or null for trouble in tracking it down

getXSLTProcessorNameback to summary
private static String getXSLTProcessorName()

what parser are we using.

Returns:String

the classname of the parser

headerback to summary
private static void header(PrintStream out, String section)
ignoreThrowableback to summary
private static void ignoreThrowable(Throwable thrown)

ignore exceptions. This is to allow future implementations to log at a verbose level

Parameters
thrown:Throwable

a Throwable to ignore

isOptionalAvailableback to summary
public static boolean isOptionalAvailable()

Deprecated

Obsolete since Ant 1.8.2

Doesn't do anything.

Returns:boolean

true

Annotations
@Deprecated
listJarFilesback to summary
private static File[] listJarFiles(File libDir)

get a list of all JAR files in a directory

Parameters
libDir:File

directory

Returns:File[]

array of files (or null for no such directory)

listLibrariesback to summary
public static File[] listLibraries()

return the list of jar files existing in ANT_HOME/lib and that must have been picked up by Ant script.

Returns:File[]

the list of jar files existing in ant.home/lib or null if an error occurs.

mainback to summary
public static void main(String[] args)

main entry point for command line

Parameters
args:String[]

command line arguments.

printLibrariesback to summary
private static void printLibraries(File[] libs, PrintStream out)

list the libraries

Parameters
libs:File[]

array of libraries (can be null)

out:PrintStream

output stream

printParserInfoback to summary
private static void printParserInfo(PrintStream out, String parserType, String parserName, String parserLocation)
printPropertyback to summary
private static void printProperty(PrintStream out, String key)

print a property name="value" pair if the property is set; print nothing if it is null

Parameters
out:PrintStream

stream to print on

key:String

property name

validateVersionback to summary
public static void validateVersion() throws BuildException

Deprecated

Obsolete since Ant 1.8.2

Doesn't do anything.

Annotations
@Deprecated