当前位置: 首页>>代码示例>>Java>>正文


Java SignatureWriter类代码示例

本文整理汇总了Java中org.objectweb.asm.signature.SignatureWriter的典型用法代码示例。如果您正苦于以下问题:Java SignatureWriter类的具体用法?Java SignatureWriter怎么用?Java SignatureWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SignatureWriter类属于org.objectweb.asm.signature包,在下文中一共展示了SignatureWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的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());
    }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:20,代码来源:SignatureTest.java

示例2: translateSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的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();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:NameTranslatorClassVisitor.java

示例3: checkSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的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());
}
 
开发者ID:lrytz,项目名称:asm-legacy-svn-clone,代码行数:22,代码来源:CheckSignatureAdapterUnitTest.java

示例4: checkSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的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());
}
 
开发者ID:nxmatic,项目名称:objectweb-asm-4.0,代码行数:22,代码来源:CheckSignatureAdapterUnitTest.java

示例5: valueSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
/**
 * This method assumes that return type of the method is
 * <code>com.google.code.jconts.Computation&lt;T&gt;</code>. It extracts the type
 * argument <code>T</code> and returns it signature.
 */
private String valueSignature() {
	final SignatureWriter sign = new SignatureWriter();
	SignatureAdapter adaptor = new SignatureAdapter() {
		public SignatureVisitor visitReturnType() {
			return new SignatureAdapter() {
				@Override
				public SignatureVisitor visitTypeArgument(char wildcard) {
					return sign;
				}

				// FIXME: All other are error!
			};
		};
	};
	new SignatureReader(signature).accept(adaptor);
	return sign.toString();
}
 
开发者ID:idubrov,项目名称:jconts,代码行数:23,代码来源:MethodContext.java

示例6: ContinuationClassGenerator

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
public ContinuationClassGenerator(MethodContext info) {
	this.info = info;
	this.stateDesc = info.stateType.getDescriptor();

	SignatureWriter sign = new SignatureWriter();

	// Name<T> implements Continuation<T>
	sign.visitFormalTypeParameter("T");
	SignatureVisitor v = sign.visitClassBound();
	v.visitClassType(OBJECT_NAME);
	v.visitEnd();
	v = sign.visitSuperclass();
	v.visitClassType(OBJECT_NAME);
	v.visitEnd();
	v = sign.visitInterface();
	v.visitClassType(CONTINUATION_NAME);
	v.visitTypeArgument('=').visitTypeVariable("T");
	v.visitEnd();
	this.signature = sign.toString();
}
 
开发者ID:idubrov,项目名称:jconts,代码行数:21,代码来源:ContinuationClassGenerator.java

示例7: mapSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的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();
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:24,代码来源:Remapper.java

示例8: mapSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
public String mapSignature(String signature, boolean isType, int api) {
    if (signature != null) {
        SignatureReader reader = new SignatureReader(signature);
        final SignatureWriter writer = new SignatureWriter();
        SignatureVisitor visitor = new BookSignatureVisitor(api, writer, this);
        if (isType) {
            reader.acceptType(visitor);
        } else {
            reader.accept(visitor);
        }
        return writer.toString();
    }
    return null;
}
 
开发者ID:PaperModLoader,项目名称:Book,代码行数:15,代码来源:Mappings.java

示例9: mapSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
/**
 * 
 * @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();
}
 
开发者ID:8BitPlus,项目名称:BitPlus,代码行数:22,代码来源:Remapper.java

示例10: getGenericSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
@Override
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;
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:12,代码来源:FieldDescription.java

示例11: getGenericSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
@Override
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;
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:38,代码来源:MethodDescription.java

示例12: getGenericSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
@Override
public String getGenericSignature() {
    try {
        SignatureWriter signatureWriter = new SignatureWriter();
        boolean generic = false;
        for (Generic typeVariable : getTypeVariables()) {
            signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol());
            for (Generic upperBound : typeVariable.getUpperBounds()) {
                upperBound.accept(new Generic.Visitor.ForSignatureVisitor(upperBound.asErasure().isInterface()
                        ? signatureWriter.visitInterfaceBound()
                        : signatureWriter.visitClassBound()));
            }
            generic = true;
        }
        Generic superClass = getSuperClass();
        // The object type itself is non generic and implicitly returns a non-generic signature
        if (superClass == null) {
            superClass = TypeDescription.Generic.OBJECT;
        }
        superClass.accept(new Generic.Visitor.ForSignatureVisitor(signatureWriter.visitSuperclass()));
        generic = generic || !superClass.getSort().isNonGeneric();
        for (Generic interfaceType : getInterfaces()) {
            interfaceType.accept(new Generic.Visitor.ForSignatureVisitor(signatureWriter.visitInterface()));
            generic = generic || !interfaceType.getSort().isNonGeneric();
        }
        return generic
                ? signatureWriter.toString()
                : NON_GENERIC_SIGNATURE;
    } catch (GenericSignatureFormatError ignored) {
        return NON_GENERIC_SIGNATURE;
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:33,代码来源:TypeDescription.java

示例13: fixupSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
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();
}
 
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:SourceAbiCompatibleVisitor.java

示例14: getSignature

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:SignatureFactory.java

示例15: treatDependencyBoundsAsInterfaces

import org.objectweb.asm.signature.SignatureWriter; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:facebook,项目名称:buck,代码行数:21,代码来源:SignatureFactoryTest.java


注:本文中的org.objectweb.asm.signature.SignatureWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。