Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentPropagationMutator replaces with non-matching type #677

Open
Vampire opened this issue Sep 19, 2019 · 0 comments
Open

ArgumentPropagationMutator replaces with non-matching type #677

Vampire opened this issue Sep 19, 2019 · 0 comments

Comments

@Vampire
Copy link
Contributor

Vampire commented Sep 19, 2019

According to documentation, the ArgumentPropagationMutator should only replace with type-matching argument.
But it mutated this code:

private final Map<String, UsageContext> usageTreeCache = new ConcurrentHashMap<>();
//...
UsageContext usageTree = usageTreeCache.computeIfAbsent(usage, key -> null);

to (decompiled)

UsageContext usageTree = (UsageContext)usage;

which of course only checks coverage, as it will result in ClassCastException.

This is the original byte code:

    ALOAD 0
    GETFIELD net/kautler/command/api/ParameterParser.usageTreeCache : Ljava/util/Map;
    ALOAD 6
    ALOAD 6
    INVOKEDYNAMIC apply(Ljava/lang/String;)Ljava/util/function/Function; [
      // handle kind 0x6 : INVOKESTATIC
      java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
      // arguments:
      (Ljava/lang/Object;)Ljava/lang/Object;, 
      // handle kind 0x6 : INVOKESTATIC
      net/kautler/command/api/ParameterParser.lambda$getParsedParameters$0(Ljava/lang/String;Ljava/lang/String;)Lnet/kautler/command/usage/UsageParser$UsageContext;, 
      (Ljava/lang/String;)Lnet/kautler/command/usage/UsageParser$UsageContext;
    ]
    INVOKEINTERFACE java/util/Map.computeIfAbsent (Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object; (itf)
    CHECKCAST net/kautler/command/usage/UsageParser$UsageContext
    ASTORE 7

this the mutant:

    ALOAD 0
    GETFIELD net/kautler/command/api/ParameterParser.usageTreeCache : Ljava/util/Map;
    ALOAD 6
    ALOAD 6
    INVOKEDYNAMIC apply(Ljava/lang/String;)Ljava/util/function/Function; [
      // handle kind 0x6 : INVOKESTATIC
      java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
      // arguments:
      (Ljava/lang/Object;)Ljava/lang/Object;, 
      // handle kind 0x6 : INVOKESTATIC
      net/kautler/command/api/ParameterParser.lambda$getParsedParameters$0(Ljava/lang/String;Ljava/lang/String;)Lnet/kautler/command/usage/UsageParser$UsageContext;, 
      (Ljava/lang/String;)Lnet/kautler/command/usage/UsageParser$UsageContext;
    ]
    POP
    SWAP
    POP
    CHECKCAST net/kautler/command/usage/UsageParser$UsageContext
    ASTORE 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant