• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / jmockit1 / 877

24 May 2026 05:57PM UTC coverage: 75.471% (-0.03%) from 75.496%
877

push

github

web-flow
Merge pull request #512 from hazendaz/copilot/modernize-list-usage

Modernize flagged collection/reflection API usages in `main` module (Java 21 build path)

6026 of 8488 branches covered (70.99%)

Branch coverage included in aggregate %.

25 of 34 new or added lines in 15 files covered. (73.53%)

5 existing lines in 1 file now uncovered.

12659 of 16270 relevant lines covered (77.81%)

0.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/main/src/main/java/mockit/coverage/dataItems/InstanceFieldData.java
1
/*
2
 * MIT License
3
 * Copyright (c) 2006-2025 JMockit developers
4
 * See LICENSE file for full license text.
5
 */
6
package mockit.coverage.dataItems;
7

8
import edu.umd.cs.findbugs.annotations.NonNull;
9

10
import java.util.Collection;
11
import java.util.HashMap;
12
import java.util.LinkedList;
13
import java.util.List;
14
import java.util.Map;
15

16
import mockit.internal.state.TestRun;
17

18
public final class InstanceFieldData extends FieldData {
×
19
    private static final long serialVersionUID = 6991762113575259754L;
20

21
    @NonNull
×
22
    private final transient Map<Integer, List<Integer>> testIdsToAssignments = new HashMap<>();
23

24
    void registerAssignment(@NonNull Object instance) {
25
        List<Integer> dataForRunningTest = getDataForRunningTest();
×
26
        Integer instanceId = System.identityHashCode(instance);
×
27

28
        if (!dataForRunningTest.contains(instanceId)) {
×
29
            dataForRunningTest.add(instanceId);
×
30
        }
31

32
        writeCount++;
×
33
    }
×
34

35
    void registerRead(@NonNull Object instance) {
36
        List<Integer> dataForRunningTest = getDataForRunningTest();
×
37
        Integer instanceId = System.identityHashCode(instance);
×
38

39
        dataForRunningTest.remove(instanceId);
×
40
        readCount++;
×
41
    }
×
42

43
    @NonNull
44
    private List<Integer> getDataForRunningTest() {
45
        int testId = TestRun.getTestId();
×
46
        return testIdsToAssignments.computeIfAbsent(testId, k -> new LinkedList<>());
×
47
    }
48

49
    @Override
50
    void markAsCoveredIfNoUnreadValuesAreLeft() {
51
        for (List<Integer> unreadInstances : testIdsToAssignments.values()) {
×
52
            if (unreadInstances.isEmpty()) {
×
53
                covered = true;
×
54
                break;
×
55
            }
56
        }
×
57
    }
×
58

59
    @NonNull
60
    public List<Integer> getOwnerInstancesWithUnreadAssignments() {
61
        if (isCovered()) {
×
NEW
62
            return List.of();
×
63
        }
64

65
        Collection<List<Integer>> assignments = testIdsToAssignments.values();
×
66
        return assignments.iterator().next();
×
67
    }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc