pascal-lab/Tai-e

SootField Failed to be converted to JField because of Signature Problem

Closed this issue · 2 comments

Overall Description

i was performing analysis on a project, and tai-e reports an Exception: Exception in thread "main" pascal.taie.ir.proginfo.FieldResolutionFailedException: Cannot resolve <org.apache.james.jmap.api.model.Size$: org.apache.james.jmap.api.model.Size$ MODULE$>
when resolving a Field. I went deep down and found that it's about Generic Signature convertion.

Current Behavior

Firstly, i want to post the code that was being analyzed.

public final class Size$ {
    public static final Size$ MODULE$ = new Size$();
    private static final Logger logger = LoggerFactory.getLogger(Refined.class);
    private static final long Zero;

    static {
        Zero = (Long)((Refined).MODULE$.refinedRefType().unsafeWrap(BoxesRunTime.boxToLong(0L))).value();
    }

    private Logger logger() {
        return logger;
    }

    public long Zero() {
        return Zero;
    }

    public long sanitizeSize(final long value) {
        Either size = eu.timepit.refined.package..MODULE$.refineV().apply(BoxesRunTime.boxToLong(value), eu.timepit.refined.boolean.Not..MODULE$.notValidate(eu.timepit.refined.numeric.Less..MODULE$.lessValidate(eu.timepit.refined.internal.WitnessAs..MODULE$.natWitnessAs(shapeless.Witness..MODULE$.witness0(), shapeless.ops.nat.ToInt..MODULE$.toInt0(), scala.math.Numeric.LongIsIntegral..MODULE$), scala.math.Numeric.LongIsIntegral..MODULE$)));
        return (Long)((Refined)size.fold((e) -> {
            return new Refined($anonfun$sanitizeSize$1(e));
        }, (refinedValue) -> {
            return new Refined($anonfun$sanitizeSize$2((Long)((Refined)refinedValue).value()));
        })).value();
    }

    private Size$() {
    }
}

Then, when converting field 'Zero' in convertGSignature
GSignatures.toTypeSig(signatureTag.getSignature()) will return a var that is instance of pascal.taie.language.generics.BaseType, thus trigger a CastExcption throwed to function build in JClass. and finally leads to the failure of JField convertion.

Expected Behavior

Although i am actually not quite familir with Generic Resolution, i speculate that the field Zero has nothing to do with Generic Type, thus should not get a BaseType of generic?
Anyway, looking forword to your feedback!

Tai-e Version

newest version of main branch

Tai-e Arguments

the error appears at phrase of world buiding, so i think the arguments is that important.

JDK Version

17

System Environment

Ubuntu 22.04

Additional Information

No response

Hello, @lollipop190

Thank you for bringing this issue to our attention. To help us address your concern more effectively, we would greatly appreciate additional details. Specifically, could you provide:

  • Steps to Reproduce: Please detail the specific steps that lead to the issue. If possible, include a minimal reproducible example.

If you're unsure about any of these details, feel free to ask for guidance. We're here to assist you. For your convenience, you can also use our issue templates and the example of how to write a reproducible case, which help in organizing and submitting the required information efficiently.

We appreciate your contribution to our project and look forward to your response. With the additional details, we aim to resolve this matter promptly and effectively.

Thank you for your cooperation and understanding.

The information you provided seems to be contradictory and unhelpful; Beause the field private static final long Zero; does not contain a generics signature in bytecode, it will not pass the following if statement to invoke GSignatures.toTypeSig(signatureTag.getSignature()).

private static ReferenceTypeGSignature convertGSignature(SootField sootField) {
Tag tag = sootField.getTag("SignatureTag");
if (tag instanceof SignatureTag signatureTag) {
return GSignatures.toTypeSig(signatureTag.getSignature());


A reproducible example would allow me to get to your question quickly, it's sometimes clearer than a description of the problem and more useful than a personal guess because it's not misleading. In the absence of a reproducible example (or even the program being analysed) I will not be able to proceed.

I am closing this issue.