类org.objectweb.asm.signature.SignatureWriter源码实例Demo

下面列出了怎么用org.objectweb.asm.signature.SignatureWriter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: CodenameOne   文件: NameTranslatorClassVisitor.java
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();
}
 
源代码2 项目: Concurnas   文件: Remapper.java
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
源代码3 项目: JByteMod-Beta   文件: Remapper.java
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
源代码4 项目: JReFrameworker   文件: Remapper.java
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
源代码5 项目: JReFrameworker   文件: Remapper.java
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
源代码6 项目: bytecode-viewer   文件: Remapper.java
/**
 * @param typeSignature true if signature is a FieldTypeSignature, such as the
 *                      signature parameter of the ClassVisitor.visitField or
 *                      MethodVisitor.visitLocalVariable methods
 */
public String mapSignature(String signature, boolean typeSignature) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter();
    SignatureVisitor a = createRemappingSignatureAdapter(w);
    if (typeSignature) {
        r.acceptType(a);
    } else {
        r.accept(a);
    }
    return w.toString();
}
 
源代码7 项目: byte-buddy   文件: FieldDescription.java
/**
 * {@inheritDoc}
 */
public String getGenericSignature() {
    TypeDescription.Generic fieldType = getType();
    try {
        return fieldType.getSort().isNonGeneric()
                ? NON_GENERIC_SIGNATURE
                : fieldType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(new SignatureWriter())).toString();
    } catch (GenericSignatureFormatError ignored) {
        return NON_GENERIC_SIGNATURE;
    }
}
 
源代码8 项目: byte-buddy   文件: MethodDescription.java
/**
 * {@inheritDoc}
 */
public String getGenericSignature() {
    try {
        SignatureWriter signatureWriter = new SignatureWriter();
        boolean generic = false;
        for (TypeDescription.Generic typeVariable : getTypeVariables()) {
            signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol());
            boolean classBound = true;
            for (TypeDescription.Generic upperBound : typeVariable.getUpperBounds()) {
                upperBound.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(classBound
                        ? signatureWriter.visitClassBound()
                        : signatureWriter.visitInterfaceBound()));
                classBound = false;
            }
            generic = true;
        }
        for (TypeDescription.Generic parameterType : getParameters().asTypeList()) {
            parameterType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(signatureWriter.visitParameterType()));
            generic = generic || !parameterType.getSort().isNonGeneric();
        }
        TypeDescription.Generic returnType = getReturnType();
        returnType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(signatureWriter.visitReturnType()));
        generic = generic || !returnType.getSort().isNonGeneric();
        TypeList.Generic exceptionTypes = getExceptionTypes();
        if (!exceptionTypes.filter(not(ofSort(TypeDefinition.Sort.NON_GENERIC))).isEmpty()) {
            for (TypeDescription.Generic exceptionType : exceptionTypes) {
                exceptionType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(signatureWriter.visitExceptionType()));
                generic = generic || !exceptionType.getSort().isNonGeneric();
            }
        }
        return generic
                ? signatureWriter.toString()
                : NON_GENERIC_SIGNATURE;
    } catch (GenericSignatureFormatError ignored) {
        return NON_GENERIC_SIGNATURE;
    }
}
 
源代码9 项目: byte-buddy   文件: RecordComponentDescription.java
/**
 * {@inheritDoc}
 */
public String getGenericSignature() {
    TypeDescription.Generic recordComponentType = getType();
    try {
        return recordComponentType.getSort().isNonGeneric()
                ? NON_GENERIC_SIGNATURE
                : recordComponentType.accept(new TypeDescription.Generic.Visitor.ForSignatureVisitor(new SignatureWriter())).toString();
    } catch (GenericSignatureFormatError ignored) {
        return NON_GENERIC_SIGNATURE;
    }
}
 
源代码10 项目: buck   文件: SourceAbiCompatibleVisitor.java
private String fixupSignature(@PropagatesNullable String signature) {
  if (signature == null || compatibilityMode.usesDependencies()) {
    return signature;
  }

  SignatureReader reader = new SignatureReader(signature);
  SignatureWriter writer = new SignatureWriter();

  reader.accept(new SourceAbiCompatibleSignatureVisitor(writer));

  return writer.toString();
}
 
源代码11 项目: buck   文件: SignatureFactory.java
/**
 * Returns the type signature of the given element. If none is required by the VM spec, returns
 * null.
 */
@Nullable
public String getSignature(Element element) {
  SignatureWriter writer = new SignatureWriter();
  element.accept(elementVisitorAdapter, writer);
  String result = writer.toString();
  return result.isEmpty() ? null : result;
}
 
源代码12 项目: buck   文件: SignatureFactory.java
@Nullable
public String getSignature(TypeMirror type) {
  SignatureWriter writer = new SignatureWriter();
  type.accept(typeVisitorAdapter, writer);
  String result = writer.toString();
  return result.isEmpty() ? null : result;
}
 
源代码13 项目: buck   文件: SignatureFactoryTest.java
/**
 * We can't tell whether an inferred class is a class, interface, annotation, or enum. This is
 * problematic for expressing generic type bounds, because the bytecode is different depending on
 * whether it is a class or an interface. As it happens, it's safe (from the compiler's
 * perspective) to treat everything as an interface. This method is used to rework the "expected"
 * signature so that we can use the same test data for testing with and without deps.
 */
private String treatDependencyBoundsAsInterfaces(String signature) {
  if (signature == null) {
    return null;
  }

  if (isTestingWithDependencies() || !signature.contains(":Lcom/facebook/foo/Dep")) {
    return signature;
  }

  SignatureWriter writer = new SignatureWriter();
  new SignatureReader(signature).accept(new SourceAbiCompatibleSignatureVisitor(writer));
  return writer.toString();
}
 
 类所在包
 类方法
 同包方法