本文整理汇总了Java中javassist.bytecode.EnclosingMethodAttribute类的典型用法代码示例。如果您正苦于以下问题:Java EnclosingMethodAttribute类的具体用法?Java EnclosingMethodAttribute怎么用?Java EnclosingMethodAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnclosingMethodAttribute类属于javassist.bytecode包,在下文中一共展示了EnclosingMethodAttribute类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDeclaringClass
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
public CtClass getDeclaringClass() throws NotFoundException {
ClassFile cf = getClassFile2();
InnerClassesAttribute ica = (InnerClassesAttribute)cf.getAttribute(
InnerClassesAttribute.tag);
if (ica == null)
return null;
String name = getName();
int n = ica.tableLength();
for (int i = 0; i < n; ++i)
if (name.equals(ica.innerClass(i))) {
String outName = ica.outerClass(i);
if (outName != null)
return classPool.get(outName);
else {
// maybe anonymous or local class.
EnclosingMethodAttribute ema
= (EnclosingMethodAttribute)cf.getAttribute(
EnclosingMethodAttribute.tag);
if (ema != null)
return classPool.get(ema.className());
}
}
return null;
}
开发者ID:AndreJCL,项目名称:JCL,代码行数:27,代码来源:CtClassType.java
示例2: getEnclosingMethod
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
public CtMethod getEnclosingMethod() throws NotFoundException {
ClassFile cf = getClassFile2();
EnclosingMethodAttribute ema
= (EnclosingMethodAttribute)cf.getAttribute(
EnclosingMethodAttribute.tag);
if (ema != null) {
CtClass enc = classPool.get(ema.className());
return enc.getMethod(ema.methodName(), ema.methodDescriptor());
}
return null;
}
开发者ID:AndreJCL,项目名称:JCL,代码行数:13,代码来源:CtClassType.java
示例3: classContainer
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
@Override
public String classContainer() {
//taken from Javassist, method javassist.CtClassType.getDeclaringClass()
final InnerClassesAttribute ica =
(InnerClassesAttribute) this.cf.getAttribute(InnerClassesAttribute.tag);
if (ica == null) {
return null;
}
final String name = getClassName();
final int n = ica.tableLength();
for (int i = 0; i < n; ++i)
if (name.equals(ica.innerClass(i))) {
final String outName = ica.outerClass(i);
if (outName != null) {
return outName;
} else {
// maybe anonymous or local class.
final EnclosingMethodAttribute ema =
(EnclosingMethodAttribute)cf.getAttribute(EnclosingMethodAttribute.tag);
if (ema != null) {
return ema.className();
}
}
}
return null;
}
开发者ID:pietrobraione,项目名称:jbse,代码行数:29,代码来源:ClassFileJavassist.java
示例4: getEnclosingMethodOrConstructor
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
@Override
public Signature getEnclosingMethodOrConstructor() {
//taken from Javassist, method javassist.CtClassType.getEnclosingBehavior().
final EnclosingMethodAttribute ema =
(EnclosingMethodAttribute) this.cf.getAttribute(EnclosingMethodAttribute.tag);
if (ema == null) {
return null;
}
return new Signature(internalClassName(ema.className()), ema.methodDescriptor(), ema.methodName());
}
开发者ID:pietrobraione,项目名称:jbse,代码行数:11,代码来源:ClassFileJavassist.java
示例5: isAnonymousClass
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry) {
// is this class already marked anonymous?
EnclosingMethodAttribute enclosingMethodAttribute = (EnclosingMethodAttribute)c.getClassFile().getAttribute(EnclosingMethodAttribute.tag);
if (enclosingMethodAttribute != null) {
if (enclosingMethodAttribute.methodIndex() > 0) {
return EntryFactory.getBehaviorEntry(
Descriptor.toJvmName(enclosingMethodAttribute.className()),
enclosingMethodAttribute.methodName(),
enclosingMethodAttribute.methodDescriptor()
);
} else {
// an attribute but no method? assume not anonymous
return null;
}
}
// if there's an inner class attribute, but not an enclosing method attribute, then it's not anonymous
InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag);
if (innerClassesAttribute != null) {
return null;
}
ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(c.getName()));
// anonymous classes:
// can't be abstract
// have only one constructor
// it's called exactly once by the outer class
// the type the instance is assigned to can't be this type
// is abstract?
if (Modifier.isAbstract(c.getModifiers())) {
return null;
}
// is there exactly one constructor?
if (c.getDeclaredConstructors().length != 1) {
return null;
}
CtConstructor constructor = c.getDeclaredConstructors()[0];
// is this constructor called exactly once?
ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(constructor);
Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = getBehaviorReferences(constructorEntry);
if (references.size() != 1) {
return null;
}
// does the caller use this type?
BehaviorEntry caller = references.iterator().next().context;
for (FieldEntry fieldEntry : getReferencedFields(caller)) {
if (fieldEntry.getType().hasClass() && fieldEntry.getType().getClassEntry().equals(innerClassEntry)) {
// caller references this type, so it can't be anonymous
return null;
}
}
for (BehaviorEntry behaviorEntry : getReferencedBehaviors(caller)) {
if (behaviorEntry.getSignature().hasClass(innerClassEntry)) {
return null;
}
}
return caller;
}
开发者ID:cccssw,项目名称:enigma-vk,代码行数:66,代码来源:JarIndex.java
示例6: isAnonymousClass
import javassist.bytecode.EnclosingMethodAttribute; //导入依赖的package包/类
private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry)
{
// is this class already marked anonymous?
EnclosingMethodAttribute enclosingMethodAttribute =
(EnclosingMethodAttribute)c.getClassFile().getAttribute(
EnclosingMethodAttribute.tag);
if(enclosingMethodAttribute != null)
if(enclosingMethodAttribute.methodIndex() > 0)
return EntryFactory.getBehaviorEntry(
Descriptor.toJvmName(enclosingMethodAttribute.className()),
enclosingMethodAttribute.methodName(),
enclosingMethodAttribute.methodDescriptor());
else
// an attribute but no method? assume not anonymous
return null;
// if there's an inner class attribute, but not an enclosing method
// attribute, then it's not anonymous
InnerClassesAttribute innerClassesAttribute =
(InnerClassesAttribute)c.getClassFile().getAttribute(
InnerClassesAttribute.tag);
if(innerClassesAttribute != null)
return null;
ClassEntry innerClassEntry =
new ClassEntry(Descriptor.toJvmName(c.getName()));
// anonymous classes:
// can't be abstract
// have only one constructor
// it's called exactly once by the outer class
// the type the instance is assigned to can't be this type
// is abstract?
if(Modifier.isAbstract(c.getModifiers()))
return null;
// is there exactly one constructor?
if(c.getDeclaredConstructors().length != 1)
return null;
CtConstructor constructor = c.getDeclaredConstructors()[0];
// is this constructor called exactly once?
ConstructorEntry constructorEntry =
EntryFactory.getConstructorEntry(constructor);
Collection<EntryReference<BehaviorEntry, BehaviorEntry>> references =
getBehaviorReferences(constructorEntry);
if(references.size() != 1)
return null;
// does the caller use this type?
BehaviorEntry caller = references.iterator().next().context;
for(FieldEntry fieldEntry : getReferencedFields(caller))
if(fieldEntry.getType().hasClass()
&& fieldEntry.getType().getClassEntry().equals(innerClassEntry))
// caller references this type, so it can't be anonymous
return null;
for(BehaviorEntry behaviorEntry : getReferencedBehaviors(caller))
if(behaviorEntry.getSignature().hasClass(innerClassEntry))
return null;
return caller;
}
开发者ID:Wurst-Imperium,项目名称:Wurst-Enigma,代码行数:65,代码来源:JarIndex.java
注:本文中的javassist.bytecode.EnclosingMethodAttribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论