本文整理汇总了Java中com.sun.tools.classfile.ClassFile.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFile.getName方法的具体用法?Java ClassFile.getName怎么用?Java ClassFile.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.classfile.ClassFile
的用法示例。
在下文中一共展示了ClassFile.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMethod
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
static int checkMethod(ClassFile cf, String mthd) throws Exception {
if (cf.major_version < 52) {
throw new RuntimeException("unexpected class file version, in "
+ cf.getName() + "expected 52, got " + cf.major_version);
}
int count = 0;
for (Method m : cf.methods) {
String mname = m.getName(cf.constant_pool);
if (mname.equals(mthd)) {
for (Attribute a : m.attributes) {
if ("Code".equals(a.getName(cf.constant_pool))) {
count++;
checkMethod(cf.getName(), mname, cf.constant_pool,
(Code_attribute) a);
}
}
}
}
return count;
}
示例2: readClass
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void readClass(ClassFile c) throws IOException,
ConstantPoolException,
InvalidDescriptor {
klass = new Element("Class");
cfile.add(klass);
String thisk = c.getName();
klass.setAttr("name", thisk);
AccessFlags af = new AccessFlags(c.access_flags.flags);
klass.setAttr("flags", flagString(af, klass));
if (!"java/lang/Object".equals(thisk)) {
klass.setAttr("super", c.getSuperclassName());
}
for (int i : c.interfaces) {
klass.add(new Element("Interface", "name", getCpString(i)));
}
readFields(c, klass);
readMethods(c, klass);
readAttributesFor(c, c.attributes, klass);
klass.trimToSize();
}
示例3: checkDebugAttributes
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
ClassFile classFile = ClassFile.read(new ByteArrayInputStream(strippedClassFile));
String[] debugAttributes = new String[]{
Attribute.LineNumberTable,
Attribute.LocalVariableTable,
Attribute.LocalVariableTypeTable
};
for (Method method : classFile.methods) {
String methodName = method.getName(classFile.constant_pool);
Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
for (String attr : debugAttributes) {
if (code.attributes.get(attr) != null) {
throw new AssertionError("Debug attribute was not removed: " + attr +
" from method " + classFile.getName() + "#" + methodName);
}
}
}
}
示例4: readClass
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void readClass(ClassFile c) throws IOException,
ConstantPoolException,
InvalidDescriptor {
klass = new Element("Class");
cfile.add(klass);
String thisk = c.getName();
klass.setAttr("name", thisk);
AccessFlags af = new AccessFlags(c.access_flags.flags);
klass.setAttr("flags", flagString(af, klass));
if (!"java/lang/Object".equals(thisk)) {
if (c.super_class != 0) {
klass.setAttr("super", c.getSuperclassName());
}
}
for (int i : c.interfaces) {
klass.add(new Element("Interface", "name", getCpString(i)));
}
readFields(c, klass);
readMethods(c, klass);
readAttributesFor(c, c.attributes, klass);
klass.trimToSize();
}
示例5: scan
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
protected Set<String> scan() {
try {
ClassFile cf = ClassFile.read(path);
String name = cf.access_flags.is(AccessFlags.ACC_MODULE)
? "module-info" : cf.getName();
return Collections.singleton(name);
} catch (ConstantPoolException|IOException e) {
throw new ClassFileError(e);
}
}
示例6: parse
import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private Optional<FutureTask<Set<Location>>> parse(Archive archive, Finder finder) {
if (parsedArchives.get(finder).contains(archive))
return Optional.empty();
parsedArchives.get(finder).add(archive);
trace("parsing %s %s%n", archive.getName(), archive.path());
FutureTask<Set<Location>> task = new FutureTask<>(() -> {
Set<Location> targets = new HashSet<>();
for (ClassFile cf : archive.reader().getClassFiles()) {
if (cf.access_flags.is(AccessFlags.ACC_MODULE))
continue;
String classFileName;
try {
classFileName = cf.getName();
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
// filter source class/archive
String cn = classFileName.replace('/', '.');
if (!finder.accept(archive, cn, cf.access_flags))
continue;
// tests if this class matches the -include
if (!filter.matches(cn))
continue;
for (Dependency d : finder.findDependencies(cf)) {
if (filter.accepts(d)) {
archive.addClass(d.getOrigin(), d.getTarget());
targets.add(d.getTarget());
} else {
// ensure that the parsed class is added the archive
archive.addClass(d.getOrigin());
}
parsedClasses.putIfAbsent(d.getOrigin(), archive);
}
}
return targets;
});
tasks.add(task);
pool.submit(task);
return Optional.of(task);
}