本文整理汇总了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;
}
示例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);
}
}
}
}
示例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;
}
示例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));
}