本文整理汇总了Java中org.objectweb.asm.signature.SignatureReader.accept方法的典型用法代码示例。如果您正苦于以下问题:Java SignatureReader.accept方法的具体用法?Java SignatureReader.accept怎么用?Java SignatureReader.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.signature.SignatureReader
的用法示例。
在下文中一共展示了SignatureReader.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
MethodAnalyzeVisitor parseSignature() {
final EntryMessage entryMessage =
log.traceEntry("name={} methodSignature={}", this.name, this.methodSignature);
final boolean isStatic = (Opcodes.ACC_STATIC & this.access) > 0;
final SignatureReader signatureReader = new SignatureReader(this.methodSignature);
MethodSignatureVisitor visitor;
if (isStatic) {
visitor = new MethodSignatureVisitor(this.name, new ArrayList<>(4));
} else {
visitor = new MethodSignatureVisitor(this.name, this.classAnalyzeVisitor.classTypeParameters);
}
if (this.typeMap != null) {
visitor.setTypeMap(this.typeMap);
}
signatureReader.accept(visitor);
this.formalType = visitor.getFormalType();
this.parameterTypes = visitor.getParameterTypes();
this.typeParameters = visitor.getTypeParameters();
this.returnType = visitor.getReturnType();
log.traceExit(entryMessage);
return this;
}
示例2: visitMethod
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
@Override
public MethodVisitor visitMethod(
int access, String name, String desc, String signature, String[] exceptions) {
String target = signature;
if (target == null) {
target = desc;
}
SignatureReader signatureReader = new SignatureReader(target);
this.visitor = new MethodSignatureVisitor(name, new ArrayList<>());
signatureReader.accept(this.visitor);
System.out.println(name);
System.out.println(this.visitor.getFormalType());
System.out.println(this.visitor.getParameterTypes());
System.out.println(this.visitor.getTypeParameters());
System.out.println(this.visitor.getReturnType());
// result.put(name, this.visitor.getFormalType());
return super.visitMethod(access, name, desc, signature, exceptions);
}
示例3: visitField
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if ("$VALUES".equals(name) && classStack.peek().isEnum()) {
return null;
}
String signatureDesc = signature != null ? signature : desc;
SignatureReader r = new SignatureReader(signatureDesc);
CustomTraceSignatureVisitor sv = new CustomTraceSignatureVisitor(Opcodes.ACC_PUBLIC);
r.accept(sv);
FieldInfo field = FieldInfo.fieldInfo()
.name(name)
.modifiers(access)
.type(sv.getTypeOrSuperclass())
.value(value)
.build();
classStack.peek().addToFields(field);
return new FieldProcessor(field);
}
示例4: parseSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
private void parseSignature(MethodNode method) {
if (method.signature == null) {
return;
}
SignatureVisitor visitor = new SignatureVisitor(0, method.visibleParameterAnnotations, method.invisibleParameterAnnotations);
visitor.setLocalVariableNodes(method.localVariables);
visitor.setStatic(Util.containsFlag(method.access, Opcodes.ACC_STATIC));
SignatureReader signatureReader = new SignatureReader(method.signature);
signatureReader.accept(visitor);
mGenericExceptions = visitor.getExceptions();
mArguments.putAll(visitor.getArguments());
mGenericReturnType = visitor.getReturnType();
if (visitor.getDeclaration() != null) {
mGenericArgs = visitor.getDeclaration();
if (mGenericArgs.indexOf("<") == 0) {
int gtPosition = mGenericArgs.indexOf(">") + 1;
mGenericReturnType = mGenericArgs.substring(0, gtPosition) + " " + mGenericReturnType;
mGenericArgs = mGenericArgs.substring(gtPosition);
}
}
}
示例5: MethodInvocationExpression
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public MethodInvocationExpression(int opCode, String name, String desc, String owner, String callingMethod) {
super(opCode);
mName = name;
SignatureVisitor v = new SignatureVisitor(0, null, null);
SignatureReader r = new SignatureReader(desc);
r.accept(v);
mType = DataType.getTypeFromObject(v.getReturnType());
mArgTypes = new ArrayList<>();
for (Type argType: Type.getArgumentTypes(desc)) {
mArgTypes.add(DataType.getType(argType));
}
mArgumentCount = v.getArguments().size();
mArguments = new ArrayList<>();
mOwnerClass = DataType.getType(Type.getObjectType(owner));
mCallingMethod = callingMethod;
}
示例6: test
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void test() throws Exception {
if (line.length() > 2) {
String signature = line.substring(2);
SignatureWriter wrt = new SignatureWriter();
SignatureReader rdr = new SignatureReader(signature);
switch (line.charAt(0)) {
case 'C':
case 'M':
rdr.accept(wrt);
break;
case 'T':
rdr.acceptType(wrt);
break;
default:
return;
}
assertEquals(signature, wrt.toString());
}
}
示例7: testSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void testSignature() {
TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
SignatureReader r = new SignatureReader(data.signature);
switch (data.type) {
case 'C':
r.accept(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'F':
r.acceptType(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'M':
r.accept(d);
String fullMethodDeclaration = d.getReturnType()
+ d.getDeclaration()
+ (d.getExceptions() != null ? d.getExceptions() : "");
assertEquals(data.declaration, fullMethodDeclaration);
break;
}
}
示例8: translateSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
private String translateSignature(final String signature, boolean type) {
if (signature == null) {
return null;
}
SignatureReader r = new SignatureReader(signature);
SignatureWriter w = new SignatureWriter() {
public void visitClassType(final String name) {
String n = translator.getClassMirrorTranslation(name);
super.visitClassType(n);
}
};
if (type) {
r.acceptType(w);
} else {
r.accept(w);
}
return w.toString();
}
示例9: testSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void testSignature() {
TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
SignatureReader r = new SignatureReader(data.signature);
switch (data.type) {
case 'C':
r.accept(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'F':
r.acceptType(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'M':
r.accept(d);
String fullMethodDeclaration = d.getReturnType()
+ d.getDeclaration()
+ (d.getExceptions() != null ? d.getExceptions() : "");
assertEquals(data.declaration, fullMethodDeclaration);
break;
}
}
示例10: checkSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void checkSignature() {
SignatureWriter wrt = new SignatureWriter();
SignatureReader rdr = new SignatureReader(data.signature);
switch (data.type) {
case 'C':
rdr.accept(new CheckSignatureAdapter(
CheckSignatureAdapter.CLASS_SIGNATURE, wrt));
break;
case 'M':
rdr.accept(new CheckSignatureAdapter(
CheckSignatureAdapter.METHOD_SIGNATURE, wrt));
break;
case 'F':
rdr.acceptType(new CheckSignatureAdapter(
CheckSignatureAdapter.TYPE_SIGNATURE, wrt));
break;
default:
return;
}
assertEquals(data.signature, wrt.toString());
}
示例11: testSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void testSignature() {
TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
SignatureReader r = new SignatureReader(data.signature);
switch (data.type) {
case 'C':
r.accept(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'F':
r.acceptType(d);
assertEquals(data.declaration, d.getDeclaration());
break;
case 'M':
r.accept(d);
String fullMethodDeclaration = d.getReturnType()
+ d.getDeclaration()
+ (d.getExceptions() != null ? d.getExceptions() : "");
assertEquals(data.declaration, fullMethodDeclaration);
break;
}
}
示例12: checkSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
public void checkSignature() {
SignatureWriter wrt = new SignatureWriter();
SignatureReader rdr = new SignatureReader(data.signature);
switch (data.type) {
case 'C':
rdr.accept(new CheckSignatureAdapter(CheckSignatureAdapter.CLASS_SIGNATURE,
wrt));
break;
case 'M':
rdr.accept(new CheckSignatureAdapter(CheckSignatureAdapter.METHOD_SIGNATURE,
wrt));
break;
case 'F':
rdr.acceptType(new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE,
wrt));
break;
default:
return;
}
assertEquals(data.signature, wrt.toString());
}
示例13: mapSignature
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
/**
* @param signature
* signature for mapper
* @param typeSignature
* true if signature is a FieldTypeSignature, such as the
* signature parameter of the ClassVisitor.visitField or
* MethodVisitor.visitLocalVariable methods
* @return signature rewritten as a string
*/
public String mapSignature(String signature, boolean typeSignature) {
if (signature == null) {
return null;
}
SignatureReader r = new SignatureReader(signature);
SignatureWriter w = new SignatureWriter();
SignatureVisitor a = createSignatureRemapper(w);
if (typeSignature) {
r.acceptType(a);
} else {
r.accept(a);
}
return w.toString();
}
示例14: stripInterface
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
private void stripInterface(ClassNode classNode, String interfaceName, boolean stripRefs)
{
final String ifaceName = interfaceName.replace('.', '/');
boolean found = classNode.interfaces.remove(ifaceName);
if (found && classNode.signature != null)
{
SignatureReader sr = new SignatureReader(classNode.signature);
final RemovingSignatureWriter signatureWriter = new RemovingSignatureWriter(ifaceName);
sr.accept(signatureWriter);
classNode.signature = signatureWriter.toString();
if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed from type signature");
}
if (found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed", interfaceName);
if (!found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s NOT removed - not found", interfaceName);
if (found && stripRefs)
{
if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method signature references", interfaceName);
for (Iterator<MethodNode> iterator = classNode.methods.iterator(); iterator.hasNext();)
{
MethodNode node = iterator.next();
if (node.desc.contains(ifaceName))
{
if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method containing reference %s", interfaceName, node.name);
iterator.remove();
}
}
if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - all method signature references stripped", interfaceName);
}
else if (found)
{
if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - NOT stripping method signature references", interfaceName);
}
}
示例15: visit
import org.objectweb.asm.signature.SignatureReader; //导入方法依赖的package包/类
@Override
public void visit(
int api, int access, String name, String signature, String superClass, String[] interfaces) {
// log.debug("Name:{}", name);
// call class
this.access = access;
final boolean isInterface = (Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE;
// log.debug("name {} sig {} IF:{}", name, signature, isInterface);
if (signature != null) {
// generics
// log.debug("name {} sig {}", name, signature);
final SignatureReader signatureReader = new SignatureReader(signature);
ClassSignatureVisitor classSignatureVisitor =
new ClassSignatureVisitor(this.className, isInterface);
signatureReader.accept(classSignatureVisitor);
this.classTypeParameters = classSignatureVisitor.getTypeParameters();
this.classIndex = classSignatureVisitor.getClassIndex();
if (!this.classIndex.getSupers().contains(ClassNameUtils.OBJECT_CLASS)) {
this.classIndex.addSuper(ClassNameUtils.OBJECT_CLASS);
}
} else {
this.classTypeParameters = new ArrayList<>(4);
final List<String> supers = new ArrayList<>(4);
if (superClass != null) {
final String superClassFQCN = ClassNameUtils.replaceSlash(superClass);
supers.add(superClassFQCN);
}
Arrays.stream(interfaces)
.forEach(interfaceName -> supers.add(ClassNameUtils.replaceSlash(interfaceName)));
this.classIndex = new ClassIndex(this.className, new ArrayList<>(4), supers);
this.classIndex.setInterface(isInterface);
}
}