本文整理汇总了Java中org.objectweb.asm.signature.SignatureReader类的典型用法代码示例。如果您正苦于以下问题:Java SignatureReader类的具体用法?Java SignatureReader怎么用?Java SignatureReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SignatureReader类属于org.objectweb.asm.signature包,在下文中一共展示了SignatureReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitLocalVariable
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
@Override
public void visitLocalVariable(final String name, final String desc,
final String signature, final Label start, final Label end,
final int index) {
buf.setLength(0);
buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
appendDescriptor(FIELD_DESCRIPTOR, desc);
buf.append(' ');
appendLabel(start);
buf.append(' ');
appendLabel(end);
buf.append(' ').append(index).append('\n');
if (signature != null) {
buf.append(tab2);
appendDescriptor(FIELD_SIGNATURE, signature);
TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
SignatureReader r = new SignatureReader(signature);
r.acceptType(sv);
buf.append(tab2).append("// declaration: ")
.append(sv.getDeclaration()).append('\n');
}
text.add(buf.toString());
}
示例2: visit
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
Class<? extends ClassFileDescriptor> javaType = getJavaType(access);
String fullQualifiedName = SignatureHelper.getObjectType(name);
cachedType = visitorHelper.createType(fullQualifiedName, fileDescriptor, javaType);
dependentTypeSignatureVisitor = new DependentTypeSignatureVisitor(cachedType, visitorHelper);
ClassFileDescriptor classFileDescriptor = cachedType.getTypeDescriptor();
classFileDescriptor.setByteCodeVersion(version);
if (hasFlag(access, Opcodes.ACC_ABSTRACT) && !hasFlag(access, Opcodes.ACC_INTERFACE)) {
classFileDescriptor.setAbstract(Boolean.TRUE);
}
setModifiers(access, classFileDescriptor);
if (signature == null) {
if (superName != null) {
TypeDescriptor superClassType = visitorHelper.resolveType(SignatureHelper.getObjectType(superName), cachedType).getTypeDescriptor();
classFileDescriptor.setSuperClass(superClassType);
}
for (int i = 0; interfaces != null && i < interfaces.length; i++) {
TypeDescriptor interfaceType = visitorHelper.resolveType(SignatureHelper.getObjectType(interfaces[i]), cachedType).getTypeDescriptor();
classFileDescriptor.getInterfaces().add(interfaceType);
}
} else {
new SignatureReader(signature).accept(new ClassSignatureVisitor(cachedType, visitorHelper, dependentTypeSignatureVisitor));
}
}
示例3: parseSignature
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
FieldAnalyzeVisitor parseSignature() {
final EntryMessage m = log.traceEntry("fieldSignature={}", fieldSignature);
boolean isStatic = (Opcodes.ACC_STATIC & this.access) > 0;
SignatureReader signatureReader = new SignatureReader(this.fieldSignature);
FieldSignatureVisitor visitor;
if (isStatic) {
visitor = new FieldSignatureVisitor(this.name, new ArrayList<>(4));
} else {
visitor = new FieldSignatureVisitor(this.name, this.classAnalyzeVisitor.classTypeParameters);
}
if (this.typeMap != null) {
visitor.setTypeMap(this.typeMap);
}
this.fieldSignatureVisitor = visitor;
signatureReader.acceptType(fieldSignatureVisitor);
return log.traceExit(m, this);
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
}
}
示例8: 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;
}
示例9: resolve
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
/**
* Resolve the given type variable in the base class, as it is parameterized
* by the childClass
*/
public String resolve(ClassNode child, String baseClass, String typeVariable) {
ArrayList<String> parameterValues = new ArrayList<>();
while (true) {
// System.out.println(child.signature);
// new SignatureReader(child.signature)
// .accept(new PrintingSignatureVisitor(""));
SignatureVisitorImpl visitor = new SignatureVisitorImpl(parameterValues);
if (child.signature != null) {
new SignatureReader(child.signature).accept(visitor);
parameterValues = visitor.parameterValuesOut;
}
if (child.name.equals(baseClass)) {
return visitor.parameterMap.get(typeVariable);
}
if (child.superName == null)
break;
child = getNode(child.superName);
}
return null;
}
示例10: visitLocalVariable
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
/**
* @see org.objectweb.asm.MethodVisitor#visitLocalVariable(String, String, String, Label, Label, int)
*/
public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end,
int index)
{
Type type = Type.getType(descriptor);
if (type != null)
{
inspectType(type);
}
if (signature != null)
{
new SignatureReader(signature).acceptType(new SignatureInspector());
}
}
示例11: visitField
import org.objectweb.asm.signature.SignatureReader; //导入依赖的package包/类
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if (isSynthetic(access))
return null;
VariableJson f = new VariableJson();
f.setName(name);
f.setType(new TypeJson(Type.getType(desc).getClassName()));
f.setAccess(access);
if (signature != null) {
SignatureReader sr = new SignatureReader(signature);
TypeSignatureNode sn = new TypeSignatureNode();
sr.acceptType(sn);
TypeJson type = new TypeJson();
sn.accept(type);
f.setType(type);
}
addField(f);
return new FieldJsonVisitor(f);
}
示例12: 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());
}
}
示例13: 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;
}
}
示例14: 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();
}
示例15: 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;
}
}