Example usage for org.objectweb.asm TypeReference CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT

List of usage examples for org.objectweb.asm TypeReference CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT

Introduction

In this page you can find the example usage for org.objectweb.asm TypeReference CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT.

Prototype

int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT

To view the source code for org.objectweb.asm TypeReference CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT.

Click Source Link

Document

The sort of type references that target a type parameter of a generic constructor in a constructor call.

Usage

From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java

License:Open Source License

private boolean applyOperationAnnotation(@Nonnull final A a, final int typeRef,
        @Nullable final TypePath typePath, final boolean logError) {
    final Op op = this.ops.get(this.ops.size() - 1);
    final TypeReference typeReference = new TypeReference(typeRef);
    switch (typeReference.getSort()) {
    case TypeReference.CAST: {
        if (op instanceof CAST) {
            ((CAST) op).setToT(annotateT(((CAST) op).getToT(), a, typePath));
            return true;
        }//from w  w  w.  jav a  2 s  .  co  m
        if (logError) {
            log.warn(getM() + ": Wrong operation '" + op + "' for type annotation ref sort 'CAST' : " + typeRef
                    + " : " + typePath + " : " + a);
        }
        return false;
    }
    case TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
    case TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT: {
        if (op instanceof INVOKE) {
            log.warn(getM()
                    + ": Missing bytecode info, cannot really apply type annotation ref sort 'CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT' or 'METHOD_INVOCATION_TYPE_ARGUMENT' : "
                    + typeRef + " : " + typePath + " : " + a);
            return true;
        }
        if (logError) {
            log.warn(getM() + ": Wrong operation '" + op
                    + "' for type annotation ref sort 'CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT' or 'METHOD_INVOCATION_TYPE_ARGUMENT' : "
                    + typeRef + " : " + typePath + " : " + a);
        }
        return false;
    }
    case TypeReference.CONSTRUCTOR_REFERENCE:
    case TypeReference.METHOD_REFERENCE: {
        if (op instanceof INVOKE) {
            final Object[] bsArgs = ((INVOKE) op).getBsArgs();
            if (bsArgs != null && bsArgs.length > 1) {
                final Object bsArg = bsArgs[1];
                if (bsArg instanceof M) {
                    bsArgs[1] = annotateM((M) bsArg, a, typePath);
                    return true;
                }
            }
        }
        if (logError) {
            log.warn(getM() + ": Wrong operation '" + op
                    + "' for type annotation ref sort 'CONSTRUCTOR_REFERENCE' or 'METHOD_REFERENCE' : "
                    + typeRef + " : " + typePath + " : " + a);
        }
        return false;
    }
    case TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
    case TypeReference.METHOD_REFERENCE_TYPE_ARGUMENT: {
        if (op instanceof INVOKE) {
            final Object[] bsArgs = ((INVOKE) op).getBsArgs();
            if (bsArgs != null && bsArgs.length > 1 && bsArgs[1] instanceof M) {
                log.warn(getM()
                        + ": Missing bytecode info, cannot really apply type annotation ref sort 'CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT' or 'METHOD_REFERENCE_TYPE_ARGUMENT' : "
                        + typeRef + " : " + typePath + " : " + a);
                return true;
            }
        }
        if (logError) {
            log.warn(getM() + ": Wrong operation '" + op
                    + "' for type annotation ref sort 'CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT' or 'METHOD_REFERENCE_TYPE_ARGUMENT' : "
                    + typeRef + " : " + typePath + " : " + a);
        }
        return false;
    }
    case TypeReference.NEW: {
        if (op instanceof NEW || op instanceof NEWARRAY) {
            ((TypedOp) op).setT(annotateT(((TypedOp) op).getT(), a, typePath));
            return true;
        }
        if (logError) {
            log.warn(getM() + ": Wrong operation '" + op + "' for type annotation ref sort 'NEW' : " + typeRef
                    + " : " + typePath + " : " + a);
        }
        return false;
    }
    default:
        log.warn(
                getM() + ": Unknown type annotation ref sort '0x" + Integer.toHexString(typeReference.getSort())
                        + "' : " + typeRef + " : " + typePath + " : " + a);
    }
    return false;
}