Skip to content

Corrupt generic signatures lead to incorrect class super types/interfaces, field types, and method parameter/variable types #409

@SpaceWalkerRS

Description

@SpaceWalkerRS

Vineflower version

1.10.1

Describe the bug

If generic signatures are present, Vineflower replaces the corresponding types with those in the signatures, without verifying that they are the same.

Additional information

For example, take the following class

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

abstract class Signatures implements List<String> {
	List<String> field = new ArrayList<>();

	void method(List<String> o) {
	}
}

The class Signatures has interface java/util/List and signature Ljava/lang/Object;Ljava/util/List<Ljava/lang/String;>;.
The field field has descriptor Ljava/util/List; and signature Ljava/util/List<Ljava/lang/String;>;.
The method method has descriptor (Ljava/util/List;)V and signature Ljava/util/List<Ljava/lang/String;>;.

Now if we corrupt the class file by changing only the signatures, as follows:
Change the class signature to Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;.
Change the field signature to Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;.
Change the method signature to (Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;)V.

This corrupted class file will decompile to

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

abstract class Signatures implements Map<String, String> {
	Map<String, String> field = new ArrayList();

	void method(Map<String, String> o) {
	}
}

Notice that the class interface, field descriptor, and method descriptor all changed, while those were not modified in the class file at all.

In situations like this Vineflower ought to ignore corrupted signatures rather than corrupting other code with it.

Here's the class files I tested with:
uncorrupted class file
corrupted class file

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: LowLow prioritySubsystem: GenericsAnything concerning how generics are decompiledType: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions