本文整理汇总了Java中org.objectweb.asm.tree.InnerClassNode类的典型用法代码示例。如果您正苦于以下问题:Java InnerClassNode类的具体用法?Java InnerClassNode怎么用?Java InnerClassNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InnerClassNode类属于org.objectweb.asm.tree包,在下文中一共展示了InnerClassNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectOuterClass
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
private static void detectOuterClass(ClassInstance cls, ClassNode cn) {
if (cn.outerClass != null) {
addOuterClass(cls, cn.outerClass, true);
} else if (cn.outerMethod != null) {
throw new UnsupportedOperationException();
} else { // determine outer class by outer$inner name pattern
for (InnerClassNode icn : cn.innerClasses) {
if (icn.name.equals(cn.name)) {
addOuterClass(cls, icn.outerName, true);
return;
}
}
int pos;
if ((pos = cn.name.lastIndexOf('$')) > 0 && pos < cn.name.length() - 1) {
addOuterClass(cls, cn.name.substring(0, pos), false);
}
}
}
示例2: getMeta
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
@Override
public RequestMeta getMeta(RequestRegistry registry, Item rawItem) {
if (!(rawItem instanceof AsmItem))
throw new UnsupportedOperationException(getClass().getName() + " only supports AsmItem");
AsmItem item = (AsmItem) rawItem;
ClassNode node = item.getResult();
noPkgPrivate(node);
Collection<Reference<AsmItem>> sgrefs = new HashSet<>();
for (InnerClassNode icn : node.innerClasses) {
addNullableRef(sgrefs, new AsmInnerClassReference(item, icn, AsmInnerClassReference.RT_INNER_NAME, false));
addNullableRef(sgrefs, new AsmInnerClassReference(item, icn, AsmInnerClassReference.RT_OUTER_NAME, false));
}
addNullableRef(sgrefs, new AsmOuterClassReference(item, node, false));
return new RequestMeta(rawItem, null, null, sgrefs,
Collections.emptyList(), Collections.emptyList());
}
示例3: modifyClass
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
/**
* Modifies a {@link ClassNode} to clear final flags and rewrite byte code.
*/
@SuppressWarnings("unchecked")
private void modifyClass(ClassNode classNode) {
// Make the class not final.
classNode.access &= ~Opcodes.ACC_FINAL;
List<MethodNode> methodNodes = classNode.methods;
for (MethodNode methodNode : methodNodes) {
methodNode.access &= ~Opcodes.ACC_FINAL;
fixMethodBody(methodNode, classNode);
}
List<FieldNode> fieldNodes = classNode.fields;
for (FieldNode fieldNode : fieldNodes) {
// Make public instance fields non-final. This is needed e.g. to "mock" SyncResult.stats.
if ((fieldNode.access & Opcodes.ACC_PUBLIC) != 0 &&
(fieldNode.access & Opcodes.ACC_STATIC) == 0) {
fieldNode.access &= ~Opcodes.ACC_FINAL;
}
}
List<InnerClassNode> innerClasses = classNode.innerClasses;
for (InnerClassNode innerClassNode : innerClasses) {
innerClassNode.access &= ~Opcodes.ACC_FINAL;
}
}
示例4: modifyClass
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
/**
* Modifies a {@link ClassNode} to clear final flags and rewrite byte code.
*/
@SuppressWarnings("unchecked")
private void modifyClass(ClassNode classNode) {
// Make the class not final.
classNode.access &= ~Opcodes.ACC_FINAL;
List<MethodNode> methodNodes = classNode.methods;
for (MethodNode methodNode : methodNodes) {
methodNode.access &= ~Opcodes.ACC_FINAL;
fixMethodBody(methodNode, classNode);
}
List<FieldNode> fieldNodes = classNode.fields;
for (FieldNode fieldNode : fieldNodes) {
// Make public instance fields non-final. This is needed e.g. to "mock" SyncResult.stats.
if ((fieldNode.access & Opcodes.ACC_PUBLIC) != 0 &&
(fieldNode.access & Opcodes.ACC_STATIC) == 0) {
fieldNode.access &= ~Opcodes.ACC_FINAL;
}
}
List<InnerClassNode> innerClasses = classNode.innerClasses;
for (InnerClassNode innerClassNode : innerClasses) {
innerClassNode.access &= ~Opcodes.ACC_FINAL;
}
}
示例5: shouldAddInnerClass
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
private boolean shouldAddInnerClass(InnerClassNode innerClass) {
if (innerClass.innerName != null && innerClass.outerName != null) {
return innerClass.name.equals(mClassNode.name + "$" + innerClass.innerName);
} else if (innerClass.outerName == null) {
int lastDollarLocation = innerClass.name.lastIndexOf("$");
String classNameWithoutInnerClass = innerClass.name.substring(0, lastDollarLocation);
String innerClassName = innerClass.name.substring(lastDollarLocation + 1);
if (innerClass.innerName == null) {
return classNameWithoutInnerClass.equals(mClassNode.name) && innerClassName.matches("[0-9]+$");
} else {
return classNameWithoutInnerClass.equals(mClassNode.name) && innerClassName.matches("[0-9]+.+$");
}
}
return false;
}
示例6: transform
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
public ClassNode transform(Type superClassType) {
log.info("Transforming blocking method: " + classNode.name + "." + originalAsyncMethod.name
+ originalAsyncMethod.desc);
//removeAsyncAnnotation(originalAsyncMethod);
// Create InnerClassNode for anoymous class
String asyncTaskClassName = createInnerClassName(classNode);
innerClassesOf(classNode).add(new InnerClassNode(asyncTaskClassName, null, null, 0));
// Create accessor methods
createAccessMethodsForAsyncMethod();
// Create ClassNode for anonymous class
ClassNode asyncTaskClassNode = createAnonymousClass(asyncTaskClassName, superClassType);
// Replace original method
MethodNode replacementAsyncMethodNode = createReplacementAsyncMethod(asyncTaskClassName);
List<MethodNode> methods = methodsOf(classNode);
methods.set(methods.indexOf(originalAsyncMethod), replacementAsyncMethodNode);
//System.out.println(BytecodeTraceUtil.toString(classNode));
return asyncTaskClassNode;
}
示例7: process
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
void process(final ClassNode cn) {
final JsonStruct json = this.ops.getJson(cn.name);
if (json == null)
return;
final JsonStruct.EnclosingMethod enc = json.enclosingMethod;
if (cn.outerClass == null && enc != null) {
cn.outerClass = enc.owner;
cn.outerMethod = enc.name;
cn.outerMethodDesc = enc.desc;
}
final List<String> icns = new ArrayList<String>();
for (final InnerClassNode icn : cn.innerClasses)
icns.add(icn.name);
if (json.innerClasses != null)
for (final JsonStruct.InnerClass i : json.innerClasses) {
if (icns.contains(i.inner_class))
continue;
int acc = i.getAccess();
final int accm = this.ops.getAccessClass(i.inner_class);
if (accm > -1)
acc = AccessTransformer.getAccessFlags(acc, accm);
cn.innerClasses.add(new InnerClassNode(i.inner_class, i.outer_class, i.inner_name, acc));
}
}
示例8: visitEnd
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
@Override
public void visitEnd() {
innerClasses.sort(
(o1, o2) -> {
// Enclosing classes and member classes should come first, with their order preserved
boolean o1IsEnclosingOrMember = isEnclosingOrMember(o1);
boolean o2IsEnclosingOrMember = isEnclosingOrMember(o2);
if (o1IsEnclosingOrMember && o2IsEnclosingOrMember) {
// Preserve order among these
return 0;
} else if (o1IsEnclosingOrMember) {
return -1;
} else if (o2IsEnclosingOrMember) {
return 1;
}
// References to other classes get sorted.
return o1.name.compareTo(o2.name);
});
for (InnerClassNode innerClass : innerClasses) {
innerClass.accept(cv);
}
super.visitEnd();
}
示例9: analyzeMethodForLocalDeadCode
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void analyzeMethodForLocalDeadCode(String dir, String className, ClassNode classNode,
MethodNode methodNode) throws IOException, XMLStreamException {
final LocalVariablesAnalyzer localVariablesAnalyzer = Factory
.createLocalVariablesAnalyzer(methodNode);
final Set<LocalVariableNode> localVariables = localVariablesAnalyzer.analyzeMethod();
if (localVariables.isEmpty()) {
return;
}
// on exclue éventuellement les variables avec les mêmes filtres que les méthodes
for (final Iterator<LocalVariableNode> it = localVariables.iterator(); it.hasNext();) {
final LocalVariableNode localVariable = it.next();
if (parameters.isMethodExcluded(localVariable.name)) {
it.remove();
}
}
// s'il reste des variables on regarde s'il y a des classes internes à la méthode
for (final InnerClassNode innerClassNode : (List<InnerClassNode>) classNode.innerClasses) {
if (innerClassNode.outerName != null
&& !innerClassNode.outerName.equals(classNode.name)) {
// des classes internes n'ont parfois pas la même classe externe ???
// (on ignore car la classe interne n'est alors pas forcément dans le même répertoire)
continue;
}
final ClassNode innerClass = new ClassNode();
final ClassReader innerClassReader = createClassReader(dir, innerClassNode.name);
innerClassReader.accept(innerClass, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
localVariablesAnalyzer.analyzeInnerClass(innerClass);
if (localVariables.isEmpty()) {
// si toutes les variables ont été utilisées, inutile de continuer à lire les classes internes
break;
}
}
if (!localVariables.isEmpty()) {
report.reportDeadLocalVariables(className, methodNode, localVariables);
suspectCount += localVariables.size();
}
}
示例10: sortAttributes
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
/** Apply a standard sort order to attributes. */
private static void sortAttributes(ClassNode n) {
n.innerClasses.sort(
Comparator.comparing((InnerClassNode x) -> x.name)
.thenComparing(x -> x.outerName)
.thenComparing(x -> x.innerName)
.thenComparing(x -> x.access));
sortAnnotations(n.visibleAnnotations);
sortAnnotations(n.invisibleAnnotations);
sortTypeAnnotations(n.visibleTypeAnnotations);
sortTypeAnnotations(n.invisibleTypeAnnotations);
for (MethodNode m : n.methods) {
sortParameterAnnotations(m.visibleParameterAnnotations);
sortParameterAnnotations(m.invisibleParameterAnnotations);
sortAnnotations(m.visibleAnnotations);
sortAnnotations(m.invisibleAnnotations);
sortTypeAnnotations(m.visibleTypeAnnotations);
sortTypeAnnotations(m.invisibleTypeAnnotations);
}
for (FieldNode f : n.fields) {
sortAnnotations(f.visibleAnnotations);
sortAnnotations(f.invisibleAnnotations);
sortAnnotations(f.visibleAnnotations);
sortAnnotations(f.invisibleAnnotations);
sortTypeAnnotations(f.visibleTypeAnnotations);
sortTypeAnnotations(f.invisibleTypeAnnotations);
}
}
示例11: addInnerChain
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
/**
* For each preserved InnerClass attribute, keep any information about transitive enclosing
* classes of the inner class.
*/
private static void addInnerChain(
Map<String, InnerClassNode> infos, List<InnerClassNode> used, String i) {
while (infos.containsKey(i)) {
InnerClassNode info = infos.get(i);
used.add(info);
i = info.outerName;
}
}
示例12: dump
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
public byte[] dump(ClassNode node, boolean autoAdd) {
if (node.innerClasses != null)
((List<InnerClassNode>) node.innerClasses).parallelStream().filter(in -> in.innerName != null).forEach(in -> {
if (in.innerName.indexOf('/') != -1)
in.innerName = in.innerName.substring(in.innerName.lastIndexOf('/') + 1); // Stringer
});
ClassWriter writer = new CustomClassWriter(ClassWriter.COMPUTE_FRAMES);
try {
try {
node.accept(writer);
} catch(RuntimeException e) {
if (e instanceof NoClassInPathException) {
NoClassInPathException ex = (NoClassInPathException) e;
System.out.println("Error: " + ex.getMessage()
+ " could not be found while writing " + node.name
+ ". Using COMPUTE_MAXS");
writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS);
node.accept(writer);
} else
if (e.getMessage() != null) {
if (e.getMessage().contains("JSR/RET")) {
System.out.println("ClassNode contained JSR/RET so COMPUTE_MAXS instead");
writer = new CustomClassWriter(ClassWriter.COMPUTE_MAXS);
node.accept(writer);
} else
throw e;
} else
throw e;
}
byte[] classBytes = writer.toByteArray();
if (autoAdd)
files.add(new ClassFile(node.name.replaceAll("\\.", "/") + ".class", classBytes));
return classBytes;
} catch(Throwable t) {
System.out.println("Error occurred while writing " + node.name + ". This class will not be written. Exception: " + t.getMessage());
}
return null;
}
示例13: appendInnerClasses
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
/**
* Decompiles inner classes
* @param innerClasses list of {@link InnerClassNode}
*/
private void appendInnerClasses(List innerClasses) {
for (Object object : innerClasses) {
InnerClassNode innerClass = (InnerClassNode) object;
if (shouldAddInnerClass(innerClass)) {
try {
String innerClassName = mPackage.isEmpty() ? innerClass.name : innerClass.name.replace(mPackage, "");
children.add(Disassembler.getInstance().decompileInnerClass(innerClassName, this));
} catch (DecompilerException e) {
children.add(new Statement(new PrimaryExpression(wrapInComment("Classfile of inner class " + innerClass.name + " was not found"),DataType.UNKNOWN), 0, this));
}
}
}
}
示例14: getInnerClass
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
private static InnerClassNode getInnerClass(ClassNode classNode, String innerClassName) {
for (InnerClassNode icn : innerClassesOf(classNode)) {
if (innerClassName.equals(icn.name)) {
return icn;
}
}
return null;
}
示例15: updateMap
import org.objectweb.asm.tree.InnerClassNode; //导入依赖的package包/类
void updateMap(ClassNode cls) {
log.debug("processing {}", cls.name);
if (cls.outerClass != null) {
outerClassNames.put(cls.name, cls.outerClass);
}
if (cls.innerClasses != null) {
for (Object obj : cls.innerClasses) {
InnerClassNode node = (InnerClassNode) obj;
if (node.outerName != null) {
outerClassNames.put(node.name, node.outerName);
}
}
}
if (cls.visibleAnnotations == null) {
return;
}
String reloadableDesc = Type.getDescriptor(Reloadable.class);
String nonReloadeableDesc = Type.getDescriptor(NonReloadable.class);
for (Object o : cls.visibleAnnotations) {
AnnotationNode a = (AnnotationNode) o;
if (reloadableDesc.equals(a.desc)) {
log.debug("class {} is reloadable", cls.name);
isReloadableMap.put(cls.name, true);
} else {
if (nonReloadeableDesc.equals(a.desc)) {
log.debug("class {} is NOT reloadable", cls.name);
isReloadableMap.put(cls.name, false);
}
}
}
}