Java Code Examples for java.lang.reflect.GenericSignatureFormatError

The following examples show how to use java.lang.reflect.GenericSignatureFormatError. These examples are extracted from open source projects. 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 Project: j2objc   Source File: GenericSignatureParser.java    License: Apache License 2.0 6 votes vote down vote up
Type parseFieldTypeSignature() {
    // FieldTypeSignature ::= ClassTypeSignature | ArrayTypeSignature
    //         | TypeVariableSignature.

    switch (symbol) {
    case 'L':
        return parseClassTypeSignature();
    case '[':
        // ArrayTypeSignature ::= "[" TypSignature.
        scanSymbol();
        return new GenericArrayTypeImpl(parseTypeSignature());
    case 'T':
        return parseTypeVariableSignature();
    default:
        throw new GenericSignatureFormatError();
    }
}
 
Example 2
Source Project: yGuard   Source File: TestGenerics.java    License: MIT License 5 votes vote down vote up
public void run(){
    new GenericSignatureFormatError();
    ParameterizedType<MyStringType> pt = new ParameterizedType<MyStringType>();
    pt.add(new MyStringType());
    pt.add(new MyStringType(){});
    for (MyType myType : pt.getList()){
      System.out.println();
      System.out.println("myType " + myType);
      System.out.println("Enclosed by " + myType.getClass().getEnclosingMethod());
      System.out.println("Enclosed by " + myType.getClass().getEnclosingClass().getName());
    }
    
//    Field[] fields = this.getClass().getDeclaredFields();
    for (Field field : this.getClass().getDeclaredFields()){
      System.out.println();
      for (Annotation a : field.getAnnotations()){
        System.out.println(a);
      }
      System.out.println(field);
      System.out.println("generic type " + field.getGenericType());
    }
    
    for (TypeVariable tv : pt.getClass().getTypeParameters()){
      System.out.println();
      System.out.println(tv);
      for (Type t : tv.getBounds()){
        System.out.println("bounds " + t);
      }
    }
  }
 
Example 3
Source Project: j2objc   Source File: GenericSignatureParser.java    License: Apache License 2.0 5 votes vote down vote up
void scanSymbol() {
    if (!eof) {
        if (pos < buffer.length) {
            symbol = buffer[pos];
            pos++;
        } else {
            symbol = 0;
            eof = true;
        }
    } else {
        throw new GenericSignatureFormatError();
    }
}
 
Example 4
Source Project: j2objc   Source File: GenericSignatureParser.java    License: Apache License 2.0 5 votes vote down vote up
void expect(char c) {
    if (symbol == c) {
        scanSymbol();
    } else {
        throw new GenericSignatureFormatError();
    }
}
 
Example 5
Source Project: j2objc   Source File: GenericSignatureParser.java    License: Apache License 2.0 5 votes vote down vote up
void scanIdentifier() {
    if (!eof) {
        StringBuilder identBuf = new StringBuilder(32);
        if (!isStopSymbol(symbol)) {
            identBuf.append(symbol);
            do {
                char ch = buffer[pos];
                if ((ch >= 'a') && (ch <= 'z') || (ch >= 'A') && (ch <= 'Z')
                        || !isStopSymbol(ch)) {
                    identBuf.append(ch);
                    pos++;
                } else {
                    identifier = identBuf.toString();
                    scanSymbol();
                    return;
                }
            } while (pos != buffer.length);
            identifier = identBuf.toString();
            symbol = 0;
            eof = true;
        } else {
            // Ident starts with incorrect char.
            symbol = 0;
            eof = true;
            throw new GenericSignatureFormatError();
        }
    } else {
        throw new GenericSignatureFormatError();
    }
}
 
Example 6
Source Project: byte-buddy   Source File: FieldDescription.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@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 7
Source Project: byte-buddy   Source File: MethodDescription.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@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 8
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 9
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 10
Source Project: jdk8u60   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 11
Source Project: java-n-IDE-for-Android   Source File: SignatureParser.java    License: Apache License 2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    if (DEBUG) System.out.println("Parse error:" + errorMsg);
    return new GenericSignatureFormatError();
}
 
Example 12
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 13
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 14
Source Project: javaide   Source File: SignatureParser.java    License: GNU General Public License v3.0 4 votes vote down vote up
private Error error(String errorMsg) {
    if (DEBUG) System.out.println("Parse error:" + errorMsg);
    return new GenericSignatureFormatError();
}
 
Example 15
Source Project: Bytecoder   Source File: SignatureParser.java    License: Apache License 2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 16
Source Project: openjdk-jdk9   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 17
Source Project: jdk8u-jdk   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 18
Source Project: hottub   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 19
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 20
Source Project: openjdk-8   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 21
Source Project: jdk8u_jdk   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 22
Source Project: jdk8u-jdk   Source File: SignatureParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 23
private Error error(String errorMsg) {
    return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
                                           "\n\tRemaining input: " + remainder());
}
 
Example 24
Source Project: byte-buddy   Source File: AbstractTypeDescriptionTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = GenericSignatureFormatError.class)
public void testMalformedTypeSignature() throws Exception {
    TypeDescription typeDescription = describe(SignatureMalformer.malform(MalformedBase.class));
    assertThat(typeDescription.getInterfaces().size(), is(1));
    typeDescription.getInterfaces().getOnly().getSort();
}
 
Example 25
Source Project: byte-buddy   Source File: AbstractTypeDescriptionTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = GenericSignatureFormatError.class)
public void testMalformedFieldSignature() throws Exception {
    TypeDescription typeDescription = describe(SignatureMalformer.malform(MalformedBase.class));
    assertThat(typeDescription.getDeclaredFields().size(), is(1));
    typeDescription.getDeclaredFields().getOnly().getType().getSort();
}
 
Example 26
Source Project: byte-buddy   Source File: AbstractTypeDescriptionTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = GenericSignatureFormatError.class)
public void testMalformedMethodSignature() throws Exception {
    TypeDescription typeDescription = describe(SignatureMalformer.malform(MalformedBase.class));
    assertThat(typeDescription.getDeclaredMethods().filter(isMethod()).size(), is(1));
    typeDescription.getDeclaredMethods().filter(isMethod()).getOnly().getReturnType().getSort();
}