-
Notifications
You must be signed in to change notification settings - Fork 56
Class ExploreClass
Ori Roth edited this page Apr 2, 2017
·
3 revisions
public class ExploreClass {
/*
* Forge (1)
*/
ExploreClass();
/*
* Utilities (1)
*/
static void main(String[] args) throws ClassNotFoundException;
}
Exception types: ClassNotFoundException.
// SSDLPedia
package il.ac.technion.cs.cs236700.classfile;
import il.ac.technion.cs.ssdl.files.CLASSFILES;
import il.ac.technion.cs.ssdl.stereotypes.Application;
import java.io.IOException;
import java.io.InputStream;
/**
* A small application demonstrating the constants' pool can be printed.
*
* Author: Yossi Gil, the Technion.
*
* See: 06/08/2008
*/
@Application public class ExploreClass {
/**
* Search for classes in the usual Java search path (JRE, Java extensions,
* and then the classpath), and prints the constant pool onto
* System.out.
*
* args full names of Java classes to print
* ClassNotFoundException in case the corresponding Class
* object could not be found
*/
public static void main(final String[] args) throws ClassNotFoundException {
if (args.length == 0)
System.out.println("Usage: java ExploreClass className(s)");
for (int i = 0; i < args.length; i++)
explore(args[i]);
}
/**
* Print out information
*
* className full name of a class to explore
* ClassNotFoundException in case the corresponding Class
* object could not be found
*/
private static void explore(final String className) throws ClassNotFoundException {
InputStream is = null;
try {
is = CLASSFILES.find(className);
if (is == null)
throw new ClassNotFoundException(className);
printConstantPool(new Pool(is));
} catch (final IOException e) {
System.out.println(e);
} finally {
try {
if (is != null)
is.close();
} catch (final IOException _) {
// so, close failed, so what?
}
}
}
/**
* Print a constants pool
*
* p a constant pool to print
*/
private static void printConstantPool(final Pool p) {
for (int i = 1; i < p.pool.length; i++)
System.out.println(i + "/" + (p.pool.length - 1) + ": " + p.pool[i].typeName() + ": " + p.pool[i]);
}
}
Metric | Value | Acronym | Explanation |
---|---|---|---|
LOC | 70 | Lines Of Code | Total number of lines in the code |
SCC | 18 | SemiColons Count | Total number of semicolon tokens found in the code. |
NOT | 286 | Number Of Tokens | Comments, whitespace and text which cannot be made into a token not included. |
VCC | 1592 | Visible Characters Count | The total number of non-white (i.e., not space, tab, newline, carriage return, form feed) characters. |
CCC | 910 | Code Characters Count | Total number of non-white characters in tokens. White space characters in string and character literals are not counted. |
UIC | 37 | Unique Identifiers Count | The number of different identifiers found in the code |
WHC | 4 | Weighted Horizontal Complexity | A heuritistic on horizontal complexity |
Statistic | Value |
---|---|
Average token length | 3.2 |
Tokens/line | 4.1 |
Visible characters/line | 23 |
Code characters/line | 13 |
Semicolons/tokens | 6% |
Comment text percentage | 42% |
Token Kind | Occurrences |
---|---|
KEYWORD | 41 |
OPERATOR | 18 |
LITERAL | 8 |
ID | 95 |
PUNCTUATION | 124 |
COMMENT | 6 |
OTHER | 131 |