当前位置: 首页>>代码示例>>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;未经允许,请勿转载。