org.objectweb.asm.signature.SignatureWriter Java Examples
The following examples show how to use
org.objectweb.asm.signature.SignatureWriter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NameTranslatorClassVisitor.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
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(); }
Example #2
Source File: Remapper.java From Concurnas with MIT License | 5 votes |
/** * 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(); }
Example #3
Source File: Remapper.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
/** * 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(); }
Example #4
Source File: Remapper.java From JReFrameworker with MIT License | 5 votes |
/** * 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(); }
Example #5
Source File: Remapper.java From JReFrameworker with MIT License | 5 votes |
/** * 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(); }
Example #6
Source File: Remapper.java From bytecode-viewer with GNU General Public License v3.0 | 5 votes |
/** * @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(); }
Example #7
Source File: FieldDescription.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@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; } }
Example #8
Source File: MethodDescription.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@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; } }
Example #9
Source File: RecordComponentDescription.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@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; } }
Example #10
Source File: SourceAbiCompatibleVisitor.java From buck with Apache License 2.0 | 5 votes |
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(); }
Example #11
Source File: SignatureFactory.java From buck with Apache License 2.0 | 5 votes |
/** * 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; }
Example #12
Source File: SignatureFactory.java From buck with Apache License 2.0 | 5 votes |
@Nullable public String getSignature(TypeMirror type) { SignatureWriter writer = new SignatureWriter(); type.accept(typeVisitorAdapter, writer); String result = writer.toString(); return result.isEmpty() ? null : result; }
Example #13
Source File: SignatureFactoryTest.java From buck with Apache License 2.0 | 5 votes |
/** * 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(); }