本文整理汇总了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();
}
}
示例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()]);
}
示例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);
}
}
}
}
}
}
示例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;
}
示例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()]);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例11: JType
import javassist.bytecode.ClassFile; //导入方法依赖的package包/类
protected JType(ClassFile classFile, ClasspathResolver resolver) {
super(classFile.getName(), resolver);
this.classFile = classFile;
}
示例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());
}
}