本文整理匯總了Java中org.apache.bcel.classfile.JavaClass.getClassName方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaClass.getClassName方法的具體用法?Java JavaClass.getClassName怎麽用?Java JavaClass.getClassName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.bcel.classfile.JavaClass
的用法示例。
在下文中一共展示了JavaClass.getClassName方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void visit(JavaClass obj) {
String name = obj.getClassName();
String[] parts = name.split("[$+.]");
baseClassName = parts[parts.length - 1];
classIsPublicOrProtected = obj.isPublic() || obj.isProtected();
if (baseClassName.length() == 1) return;
if(Character.isLetter(baseClassName.charAt(0))
&& !Character.isUpperCase(baseClassName.charAt(0))
&& baseClassName.indexOf("_") ==-1
)
bugReporter.reportBug(new BugInstance(this,
"NM_CLASS_NAMING_CONVENTION",
classIsPublicOrProtected
? NORMAL_PRIORITY
: LOW_PRIORITY
)
.addClass(this));
super.visit(obj);
}
示例2: visit
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void visit(JavaClass obj) {
try {
methodMap.clear();
badOverrideMap.clear();
JavaClass superClass = obj.getSuperClass();
if (superClass == null) return;
String packageName = superClass.getPackageName();
String className = superClass.getClassName();
isAdapter = ((className.endsWith("Adapter")) && (packageName.equals("java.awt.event") || packageName.equals("javax.swing.event")));
if (isAdapter) {
Method[] methods = superClass.getMethods();
for (int i = 0; i < methods.length; i++) {
methodMap.put(methods[i].getName(), methods[i].getSignature());
}
}
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
}
}
示例3: leaveSet
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void leaveSet(Set aJavaClasses)
{
final Iterator it = aJavaClasses.iterator();
while (it.hasNext()) {
final JavaClass javaClass = (JavaClass) it.next();
final String className = javaClass.getClassName();
final JavaClassDefinition classDef = findJavaClassDef(javaClass);
final FieldDefinition[] fieldDefs = classDef.getFieldDefs();
for (int i = 0; i < fieldDefs.length; i++) {
if (fieldDefs[i].getReadReferenceCount() == 0) {
final Field field = fieldDefs[i].getField();
if (!field.isFinal()
&& (!ignore(className, field))
)
{
log(
javaClass,
0,
"unread.field",
new Object[] {fieldDefs[i]});
}
}
}
}
}
示例4: leaveSet
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void leaveSet(Set aJavaClasses)
{
final Iterator it = aJavaClasses.iterator();
while (it.hasNext()) {
final JavaClass javaClass = (JavaClass) it.next();
final String className = javaClass.getClassName();
final JavaClassDefinition classDef = findJavaClassDef(javaClass);
final MethodDefinition[] methodDefs = classDef.getMethodDefs();
for (int i = 0; i < methodDefs.length; i++) {
if (!classDef.hasReference(methodDefs[i], getReferenceDAO())) {
final Method method = methodDefs[i].getMethod();
if (!ignore(className, method)) {
log(
javaClass,
0,
"unused.method",
new Object[] {methodDefs[i]});
}
}
}
}
}
示例5: visitJavaClass
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void visitJavaClass(JavaClass obj) {
if (obj.isInterface()) return;
String name = obj.getClassName();
if (!visited.add(name)) return;
try {
JavaClass supers[] = Repository.getSuperClasses(obj);
for (int i = 0; i < supers.length; i++) {
visitJavaClass(supers[i]);
}
} catch (ClassNotFoundException e) {
// ignore it
}
super.visitJavaClass(obj);
}
示例6: scanFields
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
private void scanFields(JavaClass jclass, Set<XField> assignableFieldSet) {
JavaClass myClass = classContext.getJavaClass();
String myClassName = myClass.getClassName();
String myPackageName = myClass.getPackageName();
String superClassName = jclass.getClassName();
String superPackageName = jclass.getPackageName();
Field[] fieldList = jclass.getFields();
for (int i = 0; i < fieldList.length; ++i) {
Field field = fieldList[i];
if (field.isStatic())
continue;
boolean assignable = false;
if (field.isPublic() || field.isProtected())
assignable = true;
else if (field.isPrivate())
assignable = myClassName.equals(superClassName);
else // package protected
assignable = myPackageName.equals(superPackageName);
if (assignable) {
assignableFieldSet.add(new InstanceField(superClassName, field.getName(), field.getSignature(),
field.getAccessFlags()));
}
}
}
示例7: findXField
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
* Look up a field with given name and signature in given class,
* returning it as an {@link XField XField} object.
* If a field can't be found in the immediate class,
* its superclass is search, and so forth.
*
* @param className name of the class through which the field
* is referenced
* @param fieldName name of the field
* @param fieldSig signature of the field
* @return an XField object representing the field, or null if no such field could be found
*/
public static XField findXField(String className, String fieldName, String fieldSig)
throws ClassNotFoundException {
JavaClass classDefiningField = Repository.lookupClass(className);
Field field = null;
loop:
while (classDefiningField != null) {
Field[] fieldList = classDefiningField.getFields();
for (int i = 0; i < fieldList.length; ++i) {
field = fieldList[i];
if (field.getName().equals(fieldName) && field.getSignature().equals(fieldSig)) {
break loop;
}
}
classDefiningField = classDefiningField.getSuperClass();
}
if (classDefiningField == null)
return null;
else {
String realClassName = classDefiningField.getClassName();
int accessFlags = field.getAccessFlags();
return field.isStatic()
? (XField) new StaticField(realClassName, fieldName, fieldSig, accessFlags)
: (XField) new InstanceField(realClassName, fieldName, fieldSig, accessFlags);
}
}
示例8: main
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
* Test driver.
*/
public static void main(String[] argv) throws Exception {
if (argv.length != 1) {
System.err.println("Usage: " + BetterCFGBuilder2.class.getName() + " <class file>");
System.exit(1);
}
String methodName = System.getProperty("cfgbuilder.method");
JavaClass jclass = new ClassParser(argv[0]).parse();
ClassGen classGen = new ClassGen(jclass);
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
if (method.isAbstract() || method.isNative())
continue;
if (methodName != null && !method.getName().equals(methodName))
continue;
MethodGen methodGen = new MethodGen(method, jclass.getClassName(), classGen.getConstantPool());
CFGBuilder cfgBuilder = new BetterCFGBuilder2(methodGen);
cfgBuilder.build();
CFG cfg = cfgBuilder.getCFG();
CFGPrinter cfgPrinter = new CFGPrinter(cfg);
System.out.println("---------------------------------------------------------------------");
System.out.println("Method: " + SignatureConverter.convertMethodSignature(methodGen));
System.out.println("---------------------------------------------------------------------");
cfgPrinter.print(System.out);
}
}
示例9: findSuperImplementor
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public static String
findSuperImplementor(String clazz, String name, String signature, BugReporter bugReporter) {
try {
JavaClass c =
findImplementor(Repository.getSuperClasses(clazz),
name, signature);
return (c != null) ? c.getClassName() : clazz;
} catch (ClassNotFoundException e) {
bugReporter.reportMissingClass(e);
return clazz;
}
}
示例10: visitObject
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitObject(Object aJavaClass)
{
final JavaClass javaClass = (JavaClass) aJavaClass;
final String className = javaClass.getClassName();
final JavaClass[] superClasses = javaClass.getSuperClasses();
final Field[] fields = javaClass.getFields();
// Check all fields
for (int i = 0; i < fields.length; i++) {
final Field field = fields[i];
// Go through all superclasses
for (int j = 0; j < superClasses.length; j++) {
final JavaClass superClass = superClasses[j];
final String superClassName = superClass.getClassName();
final Field[] superClassFields = superClass.getFields();
// Go through the filds of the superclasses
for (int k = 0; k < superClassFields.length; k++) {
final Field superClassField = superClassFields[k];
if (!superClassField.isPrivate() &&
superClassField.getName().equals(field.getName()) &&
!ignore(className, field)) {
log(
javaClass,
0,
"hidden.inherited.field",
new Object[] {fields[i], superClassName});
}
}
}
}
}
示例11: visitObject
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitObject(Object aJavaClass)
{
final JavaClass javaClass = (JavaClass) aJavaClass;
final String className = javaClass.getClassName();
final JavaClass[] superClasses = javaClass.getSuperClasses();
final Method[] methods = javaClass.getMethods();
// Check all methods
for (int i = 0; i < methods.length; i++) {
final Method method = methods[i];
// Check that the method is a possible match
if (!method.isPrivate() && method.isStatic()) {
// Go through all their superclasses
for (int j = 0; j < superClasses.length; j++) {
final JavaClass superClass = superClasses[j];
final String superClassName = superClass.getClassName();
final Method[] superClassMethods = superClass.getMethods();
// Go through the methods of the superclasses
for (int k = 0; k < superClassMethods.length; k++) {
final Method superClassMethod = superClassMethods[k];
if (superClassMethod.getName().equals(method.getName()) &&
!ignore(className, method)) {
Type[] methodTypes = method.getArgumentTypes();
Type[] superTypes = superClassMethod.
getArgumentTypes();
if (methodTypes.length == superTypes.length) {
boolean match = true;
for (int arg = 0; arg < methodTypes.length; arg++) {
if (!methodTypes[arg].equals(superTypes[arg])) {
match = false;
}
}
// Same method parameters
if (match) {
log(
javaClass,
0,
"hidden.static.method",
new Object[] {method, superClassName});
}
}
}
}
}
}
}
}