当前位置: 首页>>代码示例>>Java>>正文


Java ClassReader.getClassName方法代码示例

本文整理汇总了Java中org.objectweb.asm.ClassReader.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassReader.getClassName方法的具体用法?Java ClassReader.getClassName怎么用?Java ClassReader.getClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.ClassReader的用法示例。


在下文中一共展示了ClassReader.getClassName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCommonInterface

import org.objectweb.asm.ClassReader; //导入方法依赖的package包/类
private String getCommonInterface(final ClassReader classReader1, final ClassReader classReader2) {
    final Set<String> interfaceHierarchy = new HashSet<String>();
    traversalInterfaceHierarchy(interfaceHierarchy, classReader1);

    if (isInterface(classReader2)) {
        if (interfaceHierarchy.contains(classReader2.getClassName())) {
            return classReader2.getClassName();
        }
    }

    final String interfaceInternalName = getImplementedInterface(interfaceHierarchy, classReader2);
    if (interfaceInternalName != null) {
        return interfaceInternalName;
    }
    return OBJECT_CLASS_INTERNAL_NAME;
}
 
开发者ID:willfleury,项目名称:prometheus-metrics-agent,代码行数:17,代码来源:ASMClassWriter.java

示例2: registerHierarchyOfClass

import org.objectweb.asm.ClassReader; //导入方法依赖的package包/类
private void registerHierarchyOfClass(ClassReader classReader) {
	final String asmClassName = classReader.getClassName();
	final String asmSuperClassName = classReader.getSuperName();
	if (isPublicIndexationStep() || !DcdHelper.isJavaClass(asmSuperClassName)) {
		// les classes java et javax ne sont pas auditées
		result.registerSuperClass(asmSuperClassName, asmClassName);
		result.registerSubClass(asmSuperClassName, asmClassName);
		if (isPublicIndexationStep()) {
			for (final String asmInterfaceName : classReader.getInterfaces()) {
				result.registerSubClass(asmInterfaceName, asmClassName);
			}
		}
	}
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:15,代码来源:DeadCodeDetector.java

示例3: readClasses

import org.objectweb.asm.ClassReader; //导入方法依赖的package包/类
/**
 * Reads the classes of the given jar into a map.
 *
 * @param jarPath
 *            Path to jarfile to read classes from.
 * @return Map of classes from the given jarfile.
 * @throws IOException
 *             If an exception was encountered while reading the jarfile.
 */
public static Map<String, ClassNode> readClasses(String jarPath) throws IOException {
	Map<String, ClassNode> map = new HashMap<>();
	try (ZipFile file = new ZipFile(jarPath)) {
		Enumeration<? extends ZipEntry> entries = file.entries();
		while (entries.hasMoreElements()) {
			ZipEntry entry = entries.nextElement();
			if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
				continue;
			}
			String name = null;
			Recaf.INSTANCE.logging.fine("Reading jar class: " + entry.getName(), 1);
			try (InputStream is = file.getInputStream(entry)) {
				ClassReader cr = new ClassReader(is);
				name = cr.getClassName();
				map.put(cr.getClassName(), getNode(cr));
			} catch (IndexOutOfBoundsException ioobe) {
				if (name == null) {
					Recaf.INSTANCE.logging.error(new RuntimeException("Failed reading class from: " + entry.getName(),
							ioobe));
				} else {
					Recaf.INSTANCE.logging.error(new RuntimeException("Failed reading into node structure: " + name, ioobe));
				}
			}
		}
	}
	return map;
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:37,代码来源:Asm.java

示例4: shouldExtractApiClassFrom

import org.objectweb.asm.ClassReader; //导入方法依赖的package包/类
/**
 * Indicates whether the class held by the given reader is a candidate for extraction to
 * an API class. Checks whether the class's package is in the list of packages
 * explicitly exported by the library (if any), and whether the class should be
 * included in the public API based on its visibility. If the list of exported
 * packages is empty (e.g. the library has not declared an explicit {@code api {...}}
 * specification, then package-private classes are included in the public API. If the
 * list of exported packages is non-empty (i.e. the library has declared an
 * {@code api {...}} specification, then package-private classes are excluded.
 *
 * <p>For these reasons, this method should be called as a test on every original
 * .class file prior to invoking processed through
 * {@link #extractApiClassFrom(ClassReader)}.</p>
 *
 * @param originalClassReader the reader containing the original class to evaluate
 * @return whether the given class is a candidate for API extraction
 */
public boolean shouldExtractApiClassFrom(ClassReader originalClassReader) {
    if (!isCandidateApiMember(originalClassReader.getAccess(), apiIncludesPackagePrivateMembers)) {
        return false;
    }
    String originalClassName = originalClassReader.getClassName();
    if (isLocalClass(originalClassName)) {
        return false;
    }
    return exportedPackages == null
        || exportedPackages.contains(packageNameOf(originalClassName));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:29,代码来源:ApiClassExtractor.java


注:本文中的org.objectweb.asm.ClassReader.getClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。