Skip to content

Missing some tests for identifiers obfuscating #22

@Fanyhsiao

Description

@Fanyhsiao

In Java 8 or better, see jls. We can construct a lambda based instance for interfaces.

package tech.skidonion.identifiersobfuscating;

import java.util.ArrayList;
import java.util.List;

public class LambdaTest {

    interface SAMInterfaceA {
        Object sam();
    }

    interface SAMInterfaceB {
        List<?> sam();
    }

    interface SAMInterfaceC {
        List<String> sam();
    }

    interface SAMInterfaceD {
        ArrayList<String> sam();
    }


    public static void main(String[] args) {
        System.out.println(((SAMInterfaceC & SAMInterfaceD & SAMInterfaceB & SAMInterfaceA) () -> new ArrayList<String>() {{
            add("hello");
        }}).sam());
    }

}

In this case, SAMInterfaceA SAMInterfaceB SAMInterfaceC SAMInterfaceD don't point to the same single abstract method statically but dynamically.

When obfuscating, we should statically parse the generated invokedynamic bytecode to generate the correct mapping for all interfaces.

Therefore, it is necessary to add a test to test if that the mapping is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions