當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassFile.getName方法代碼示例

本文整理匯總了Java中javassist.bytecode.ClassFile.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassFile.getName方法的具體用法?Java ClassFile.getName怎麽用?Java ClassFile.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javassist.bytecode.ClassFile的用法示例。


在下文中一共展示了ClassFile.getName方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeFile0

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
private static void writeFile0(ClassFile cf, String directoryName)
        throws CannotCompileException, IOException {
    String classname = cf.getName();
    String filename = directoryName + File.separatorChar
            + classname.replace('.', File.separatorChar) + ".class";
    int pos = filename.lastIndexOf(File.separatorChar);
    if (pos > 0) {
        String dir = filename.substring(0, pos);
        if (!dir.equals("."))
            new File(dir).mkdirs();
    }

    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
            new FileOutputStream(filename)));
    try {
        cf.write(out);
    }
    catch (IOException e) {
        throw e;
    }
    finally {
        out.close();
    }
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:25,代碼來源:FactoryHelper.java

示例2: getNestedClasses

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
public CtClass[] getNestedClasses() throws NotFoundException {
    ClassFile cf = getClassFile2();
    InnerClassesAttribute ica
        = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
    if (ica == null)
        return new CtClass[0];

    String thisName = cf.getName() + "$";
    int n = ica.tableLength();
    ArrayList<CtClass> list = new ArrayList<CtClass>(n);
    for (int i = 0; i < n; i++) {
        String name = ica.innerClass(i);
        if (name != null)
            if (name.startsWith(thisName)) {
                // if it is an immediate nested class
                if (name.lastIndexOf('$') < thisName.length())
                    list.add(classPool.get(name));
            }
    }

    return (CtClass[])list.toArray(new CtClass[list.size()]);
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:23,代碼來源:CtClassType.java

示例3: removeFinalModifierFromClass

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
private void removeFinalModifierFromClass(final CtClass clazz) {
    if (strategy != INST_REDEFINE) {
        if (Modifier.isFinal(clazz.getModifiers())) {
            clazz.setModifiers(clazz.getModifiers() ^ Modifier.FINAL);
        }

        ClassFile classFile = clazz.getClassFile2();
        AttributeInfo attribute = classFile.getAttribute(InnerClassesAttribute.tag);
        if (attribute != null && attribute instanceof InnerClassesAttribute) {
            InnerClassesAttribute ica = (InnerClassesAttribute) attribute;
            String name = classFile.getName();
            int n = ica.tableLength();
            for (int i = 0; i < n; ++i) {
                if (name.equals(ica.innerClass(i))) {
                    int accessFlags = ica.accessFlags(i);
                    if (Modifier.isFinal(accessFlags)) {
                        ica.setAccessFlags(i, accessFlags ^ Modifier.FINAL);
                    }
                }
            }
        }
    }
}
 
開發者ID:awenblue,項目名稱:powermock,代碼行數:24,代碼來源:MainMockTransformer.java

示例4: getClassName

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
public String getClassName(String name, InputStream stream) throws IOException {
	// NOTE package-info.class should be excluded
	if (!name.endsWith(".class") || name.contains("-"))
		return null;
	DataInputStream dstream = new DataInputStream(stream);
	try {
		ClassFile cf = new ClassFile(dstream);
		if (!cf.isInterface() && !isAnnotationPresent(cf)) {
			// behaviour that implements a concept
			for (String fname : cf.getInterfaces()) {
				String cn = fname.replace('.', '/') + ".class";
				InputStream in = cl.getResource(cn).openStream();
				try {
					if (super.getClassName(cn, in) != null)
						return cf.getName();
				} finally {
					in.close();
				}
			}
		}
	} finally {
		dstream.close();
		stream.close();
	}
	return null;
}
 
開發者ID:anno4j,項目名稱:anno4j,代碼行數:27,代碼來源:CheckForBehaviour.java

示例5: getNestedClasses

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
public CtClass[] getNestedClasses() throws NotFoundException {
    ClassFile cf = getClassFile2();
    InnerClassesAttribute ica
        = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
    if (ica == null)
        return new CtClass[0];

    String thisName = cf.getName() + "$";
    int n = ica.tableLength();
    ArrayList list = new ArrayList(n);
    for (int i = 0; i < n; i++) {
        String name = ica.innerClass(i);
        if (name != null)
            if (name.startsWith(thisName)) {
                // if it is an immediate nested class
                if (name.lastIndexOf('$') < thisName.length())
                    list.add(classPool.get(name));
            }
    }

    return (CtClass[])list.toArray(new CtClass[list.size()]);
}
 
開發者ID:MeRPG2,項目名稱:EndHQ-Libraries,代碼行數:23,代碼來源:CtClassType.java

示例6: scanClass

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
/**
 * Scans passed {@link ClassFile} instance for specific annotations
 * 
 * @param cf
 * @param url
 */
protected void scanClass(ClassFile cf, URL url) {

    String className = cf.getName();

    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
    AnnotationsAttribute invisible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.invisibleTag);

    if (ObjectUtils.notNull(visible)) {
        populate(visible.getAnnotations(), className, url);
    }

    if (ObjectUtils.notNull(invisible)) {
        populate(invisible.getAnnotations(), className, url);
    }
}
 
開發者ID:levants,項目名稱:lightmare,代碼行數:22,代碼來源:AnnotationFinder.java

示例7: scan

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
@Override
public void scan(final Object cls) {
  final ClassFile classFile = (ClassFile)cls;
  String className = classFile.getName();
  String superclass = classFile.getSuperclass();
  boolean isAbstract = (classFile.getAccessFlags() & (AccessFlag.INTERFACE | AccessFlag.ABSTRACT)) != 0;
  ChildClassDescriptor scannedClass = new ChildClassDescriptor(className, isAbstract);
  if (!superclass.equals(Object.class.getName())) {
    children.put(superclass, scannedClass);
  }
  for (String anInterface : classFile.getInterfaces()) {
    children.put(anInterface, scannedClass);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:15,代碼來源:ClassPathScanner.java

示例8: getClassName

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
public String getClassName(String name, InputStream stream) throws IOException {
	DataInputStream dstream = new DataInputStream(stream);
	try {
		ClassFile cf = new ClassFile(dstream);
		if (checkAccessFlags(cf.getAccessFlags())) {
			if (isAnnotationPresent(cf))
				return cf.getName();
		}
	} finally {
		dstream.close();
	}
	return null;
}
 
開發者ID:anno4j,項目名稱:anno4j,代碼行數:14,代碼來源:CheckForConcept.java

示例9: scanClass

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
protected void scanClass(ClassFile cf) {
    String className = cf.getName();
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
    AnnotationsAttribute invisible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.invisibleTag);
    if (visible != null)
        populate(visible.getAnnotations(), className);
    if (invisible != null)
        populate(invisible.getAnnotations(), className);
}
 
開發者ID:audit4j,項目名稱:audit4j-core,代碼行數:10,代碼來源:AnnotationDB.java

示例10: CtClassType

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
CtClassType(InputStream ins, ClassPool cp) throws IOException {
    this((String)null, cp);
    classfile = new ClassFile(new DataInputStream(ins));
    qualifiedName = classfile.getName();
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:6,代碼來源:CtClassType.java

示例11: JType

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
protected JType(ClassFile classFile, ClasspathResolver resolver) {
    super(classFile.getName(), resolver);
    this.classFile = classFile;
}
 
開發者ID:JadiraOrg,項目名稱:jadira,代碼行數:5,代碼來源:JType.java

示例12: JInterface

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
protected JInterface(ClassFile classFile, ClasspathResolver resolver) {
    super(classFile, resolver);
    if (!classFile.isInterface() || (classFile.getSuperclass().equals("java.lang.annotation.Annotation"))) {
        throw new IllegalArgumentException("Argument was not interface: " + classFile.getName());
    }
}
 
開發者ID:JadiraOrg,項目名稱:jadira,代碼行數:7,代碼來源:JInterface.java


注:本文中的javassist.bytecode.ClassFile.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。